:root {
  --red: #c8102e; --red-d: #9f0c24; --ink: #1f2328; --muted: #656d76; --line: #d8dee4;
  --bg: #f4f5f7; --card: #fff; --ok: #1a7f37; --warn: #9a6700; --warn-bg: #fff8c5;
  --crit: #bc4c00; --crit-bg: #fff1e5; --over: #cf222e; --over-bg: #ffebe9; --ok-bg: #dafbe1;
  --radius: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
       color: var(--ink); background: var(--bg); }
a { color: #0b57d0; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
small, .muted { color: var(--muted); }

/* Kopfzeile */
.top { background: var(--red); color: #fff; position: sticky; top: 0; z-index: 10;
       box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.top-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 1rem;
             padding: 0 1rem; min-height: 52px; }
.brand { color: #fff; font-weight: 700; white-space: nowrap; display: flex; align-items: center; gap: .5rem; }
.brand:hover { text-decoration: none; }
.brand svg { width: 22px; height: 22px; }
.nav { display: flex; gap: .15rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #fff; padding: .45rem .7rem; border-radius: 6px; white-space: nowrap; opacity: .92; }
.nav a:hover { background: rgba(255,255,255,.15); text-decoration: none; }
.nav a.active { background: rgba(0,0,0,.22); opacity: 1; }
.user { display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
.user a, .user button { color: #fff; background: none; border: 0; font: inherit; cursor: pointer; padding: .3rem .4rem; }
@media (max-width: 760px) {
  .top-inner { flex-wrap: wrap; gap: .3rem; padding: .4rem .6rem 0; }
  .nav { order: 3; flex-basis: 100%; padding-bottom: .3rem; }
  .user .uname { display: none; }
  .brand { flex: 1; }
}

main { max-width: 1200px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
        flex-wrap: wrap; margin-bottom: 1rem; }
.head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }

/* Karten & Raster */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 1rem; margin-bottom: 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.kpis { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 1rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
       padding: .8rem 1rem; display: block; color: var(--ink); }
.kpi:hover { text-decoration: none; border-color: #aaa; }
.kpi b { display: block; font-size: 1.8rem; line-height: 1.1; }
.kpi.over { border-left: 5px solid var(--over); }
.kpi.crit { border-left: 5px solid var(--crit); }
.kpi.warn { border-left: 5px solid #d4a72c; }
.kpi.neutral { border-left: 5px solid #8c959f; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600;
     background: #f6f8fa; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
.card table { margin: -.25rem 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2, .card.flush > h3 { padding: .8rem 1rem 0; }
tr.group td { background: #fafbfc; font-weight: 600; }
.indent-1 { padding-left: 1.6rem !important; } .indent-2 { padding-left: 3rem !important; }
.indent-3 { padding-left: 4.4rem !important; } .indent-4 { padding-left: 5.8rem !important; }

/* Status */
.chip { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem;
        font-weight: 600; white-space: nowrap; }
.st-over { background: var(--over-bg); color: var(--over); }
.st-crit { background: var(--crit-bg); color: var(--crit); }
.st-warn { background: var(--warn-bg); color: var(--warn); }
.st-ok   { background: var(--ok-bg); color: var(--ok); }
.tag { display: inline-block; padding: .05rem .45rem; border-radius: 4px; font-size: .75rem;
       background: #eaeef2; color: #424a53; white-space: nowrap; }
.tag.lager { background: #ddf4ff; color: #0550ae; }
.tag.fahrzeug { background: #ffebe9; color: #a40e26; }
.tag.behaelter { background: #fbefff; color: #6639ba; }
.short { color: var(--crit); font-weight: 600; }

/* Formulare */
form.stack { display: grid; gap: .8rem; max-width: 640px; }
.row { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .2rem; }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; font-size: .95rem; }
.hint { font-size: .82rem; color: var(--muted); font-weight: 400; margin-top: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
  width: 100%; padding: .55rem .6rem; border: 1px solid #c3cad2; border-radius: 6px;
  font: inherit; background: #fff; min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #0b57d0; outline-offset: -1px; border-color: transparent; }
textarea { min-height: 70px; }
input[type=checkbox] { width: 18px; height: 18px; }
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .5rem .9rem; border-radius: 6px;
       border: 1px solid #c3cad2; background: #f6f8fa; color: var(--ink); font: inherit; font-weight: 600;
       cursor: pointer; min-height: 38px; white-space: nowrap; }
.btn:hover { background: #eef1f4; text-decoration: none; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-d); }
.btn.danger { color: var(--over); border-color: #f0b4b4; background: #fff; }
.btn.danger:hover { background: var(--over-bg); }
.btn.small { padding: .25rem .55rem; min-height: 30px; font-size: .85rem; }
.inline { display: inline-flex; gap: .35rem; align-items: center; flex-wrap: wrap; margin: 0; }
.inline input[type=number] { width: 80px; min-height: 32px; padding: .3rem .4rem; }
.inline select { width: auto; min-height: 32px; padding: .3rem .4rem; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters > div { min-width: 150px; }
.lines .line { display: grid; grid-template-columns: 90px 1fr 1fr 36px; gap: .5rem; margin-bottom: .5rem; }
@media (max-width: 520px) { .lines .line { grid-template-columns: 70px 1fr 36px; } .lines .line .lot { display: none; } }

/* Meldungen */
.flash { padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid; }
.flash.ok { background: var(--ok-bg); border-color: #aceebb; color: #116329; }
.flash.err { background: var(--over-bg); border-color: #ffcecb; color: #a40e26; }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); }
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: .6rem; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login { width: 100%; max-width: 380px; }
.login .logo { text-align: center; color: var(--red); margin-bottom: 1rem; }
.login .logo svg { width: 48px; height: 48px; }

@media print {
  .top, .actions, .no-print, form.inline, .btn { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .card { border: 0; padding: 0; }
  main { padding: 0; max-width: none; }
}

/* Bestandstabelle auf dem Handy: Aktionen unter die Zeile */
@media (max-width: 640px) {
  table.stock, table.stock tbody, table.stock tr, table.stock td { display: block; }
  table.stock tr.hd, table.stock td.ec, table.stock td:empty { display: none; }
  table.stock tr.group { display: flex; justify-content: space-between; gap: .5rem;
                         background: #fafbfc; border-bottom: 1px solid var(--line); }
  table.stock tr.group td { border: 0; }
  table.stock tr.batch { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem;
                         padding: .55rem .6rem .55rem 1.4rem; border-bottom: 1px solid var(--line); }
  table.stock tr.batch td { border: 0; padding: 0 !important; }
  table.stock td.act { flex-basis: 100%; text-align: left; }
}
.lines .line.load-line { grid-template-columns: 90px 1fr 36px; }
@media (max-width: 520px) { .lines .line.load-line { grid-template-columns: 70px 1fr 36px; } }
@media (max-width: 640px) {
  table.loadtbl, table.loadtbl tbody, table.loadtbl tr, table.loadtbl td { display: block; }
  table.loadtbl tr.hd { display: none; }
  table.loadtbl tr { padding: .6rem 1rem; border-bottom: 1px solid var(--line); display: grid;
                     grid-template-columns: 1fr 1fr; gap: .35rem .8rem; }
  table.loadtbl td { border: 0; padding: 0; text-align: left; }
  table.loadtbl td:empty { display: none; }
  table.loadtbl td[data-label]::before { content: attr(data-label); display: block; font-size: .78rem;
                                         font-weight: 600; color: var(--muted); }
  table.loadtbl td input { width: 100% !important; max-width: none !important; }
}

/* Fahrzeug-Kacheln */
.vgrid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); margin-bottom: 1rem; }
.vtile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
         color: var(--ink); display: flex; flex-direction: column; transition: box-shadow .15s, border-color .15s; }
.vtile:hover { text-decoration: none; border-color: #aaa; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.vtile .pic { aspect-ratio: 16 / 10; background: #eef1f4; display: grid; place-items: center; overflow: hidden; }
.vtile .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vtile .pic svg { width: 72px; color: #9aa4ae; }
.vtile .body { padding: .6rem .8rem .75rem; }
.vtile .body b { display: block; font-size: 1.02rem; }
.vtile .chips { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .4rem; }
@media (max-width: 520px) { .vgrid { grid-template-columns: repeat(2, 1fr); gap: .5rem; } .vtile .chips .chip { font-size: .72rem; } }
@media (max-width: 640px) {
  table.dltbl, table.dltbl tbody, table.dltbl tr, table.dltbl td { display: block; }
  table.dltbl tr.hd { display: none; }
  table.dltbl tr { padding: .6rem 1rem; border-bottom: 1px solid var(--line); }
  table.dltbl td { border: 0; padding: .1rem 0; text-align: left; }
  table.dltbl td:empty { display: none; }
  table.dltbl td.act { padding-top: .4rem; }
}
