:root {
  --ground: #F2F3EF;
  --card: #FFFFFF;
  --ink: #15181B;
  --muted: #5A6168;
  --muted-2: #3F454B;
  --line: #D9DCD5;
  --line-2: #E6E8E2;
  --field: #B9BEB4;
  --primary: #1E5E3A;
  --primary-dark: #15452A;
  --primary-soft: #DDEFE3;
  --diesel: #2B2F33;
  --elektro: #1D4ED8;
  --warn-bg: #FFF1D6;
  --warn-ink: #6B4000;
  --info-bg: #DCEBFF;
  --info-ink: #123E8C;
  --danger: #A8261B;
  --danger-bg: #FBE3E0;
  --radius: 12px;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-num: 'Barlow Condensed', 'Barlow', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  background: var(--ground);
  color: var(--ink);
}
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 18px; font-weight: 700; }
p { margin: 0; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #E8A317; outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.num { font-family: var(--font-num); font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.label {
  font-size: 13px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.right { text-align: right; }
.sep { height: 1px; background: var(--line-2); }

/* Buttons */
.btn {
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--primary); background: var(--card); color: var(--primary);
  font-weight: 600; font-size: 15px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #F4F8F5; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-dark { background: var(--card); color: var(--ink); border-color: var(--ink); }
.btn-dark:hover { background: #F1F2EE; }
.btn-danger { background: var(--card); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink); }
.btn-big { min-height: 64px; font-size: 20px; font-weight: 700; border-radius: 14px; width: 100%; white-space: normal; text-align: center; padding: 8px 16px; line-height: 1.2; }
.btn-mid { min-height: 52px; font-size: 18px; border-radius: 14px; width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-icon { width: 44px; padding: 0; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px 20px;
}
.card.tight { padding: 12px 16px; }
.card-dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.card-dark .label, .card-dark .muted { color: #C9CDC4; }

/* Badges */
.badge {
  display: inline-block; font-size: 13px; font-weight: 600;
  padding: 2px 8px; border-radius: 6px; color: #fff; white-space: nowrap;
}
.b-diesel { background: var(--diesel); }
.b-elektro { background: var(--elektro); }
.b-none { background: #8A9088; }
.pill {
  display: inline-block; font-size: 13px; font-weight: 600;
  padding: 4px 10px; border-radius: 12px; white-space: nowrap;
}
.s-geplant { background: var(--line-2); color: var(--muted-2); }
.s-unterwegs { background: var(--info-bg); color: var(--info-ink); }
.s-beendet, .s-abweichung { background: var(--warn-bg); color: var(--warn-ink); }
.s-freigegeben { background: var(--primary-soft); color: var(--primary); }
.s-abgerechnet { background: #E3E0F5; color: #3D2F86; }

.note { border-radius: 10px; padding: 10px 14px; font-size: 14px; font-weight: 500; }
.note-warn { background: var(--warn-bg); color: var(--warn-ink); }
.note-info { background: var(--info-bg); color: var(--info-ink); }
.note-err { background: var(--danger-bg); color: var(--danger); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .flabel { font-size: 14px; font-weight: 600; color: var(--muted-2); }
.input, select.input, textarea.input {
  min-height: 48px; width: 100%; border-radius: 10px; border: 1px solid var(--field);
  padding: 0 12px; background: #fff; font-size: 16px;
}
textarea.input { padding: 10px 12px; min-height: 80px; }
.input.big { min-height: 64px; font-family: var(--font-num); font-size: 34px; font-weight: 700; border: 2px solid var(--primary); }
.input.sm { min-height: 40px; font-size: 15px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--field);
  background: #fff; font-weight: 600; font-size: 15px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Tables */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 15px; }
table.t th {
  text-align: left; color: var(--muted); font-size: 13px; text-transform: uppercase;
  letter-spacing: .05em; font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: #FAFBF8;
}
table.t td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr:last-child td { border-bottom: none; }
table.t tr.warn td { background: #FFFAF0; }
table.t tr.clickable { cursor: pointer; }
table.t tr.clickable:hover td { background: #F7F8F5; }
table.t tfoot td { font-weight: 700; border-top: 2px solid var(--line); }

/* Desktop shell */
.topbar {
  background: var(--ink); color: #fff; display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px 24px; padding: 10px 24px; position: sticky; top: 0; z-index: 10;
}
.topbar .brand { font-family: var(--font-num); font-size: 24px; font-weight: 700; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px; }
.topbar nav button, .topbar nav a {
  min-height: 44px; display: inline-flex; align-items: center; gap: 8px; padding: 0 14px;
  border-radius: 8px; color: #D7DBD3; font-weight: 600; text-decoration: none;
  background: transparent; border: none; cursor: pointer; font-size: 15px;
}
.topbar nav [aria-current="page"] { background: #2F3A33; color: #fff; }
.topbar .user { margin-left: auto; display: flex; align-items: center; gap: 12px; color: #D7DBD3; font-size: 14px; }
.topbar .user button { background: transparent; border: 1px solid #5A6168; color: #fff; border-radius: 8px; min-height: 36px; padding: 0 12px; cursor: pointer; }
.count { background: #E8A317; color: var(--ink); border-radius: 10px; padding: 0 8px; font-size: 13px; }
.page { padding: 20px 24px 40px; max-width: 1440px; margin: 0 auto; }
.layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.layout > .main { flex: 999 1 640px; min-width: 0; }
.layout > .side { flex: 1 1 280px; min-width: 0; }
.layout > .list { flex: 1 1 320px; min-width: 0; max-width: 460px; }

/* Mobile shell */
.mobile { max-width: 520px; margin: 0 auto; min-height: 100vh; padding: 20px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.mobile .bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
.back { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: none; background: transparent; cursor: pointer; color: var(--ink); }
.vehicle-num {
  width: 64px; height: 64px; border-radius: 12px; background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center; font-family: var(--font-num);
  font-size: 40px; font-weight: 700; flex: none;
}
.timer { font-family: var(--font-num); font-size: 56px; font-weight: 700; line-height: 1; }
.steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.step { min-height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 600; background: var(--line-2); color: var(--muted); }
.step.on { background: var(--primary); color: #fff; font-weight: 700; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile {
  min-height: 120px; border-radius: 14px; padding: 12px 14px; background: #fff;
  border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px;
  text-align: left; cursor: pointer;
}
.tile.sel { border: 3px solid var(--primary); }
.tile:disabled { background: var(--line-2); color: var(--muted); cursor: not-allowed; }
.tile .num { font-size: 44px; line-height: 1; }
.photo-drop {
  min-height: 180px; border-radius: 16px; background: #DDE0D8; border: 2px dashed #8A9088;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--muted-2); cursor: pointer; overflow: hidden; text-align: center; padding: 12px;
}
.photo-drop img { max-width: 100%; max-height: 320px; border-radius: 10px; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button { width: 56px; height: 56px; border-radius: 12px; border: 1px solid var(--ink); background: #fff; font-size: 28px; font-weight: 600; cursor: pointer; }
.stepper .val { flex: 1; text-align: center; font-family: var(--font-num); font-size: 36px; font-weight: 700; }

/* Login */
.login { max-width: 400px; margin: 0 auto; min-height: 100vh; padding: 48px 20px; display: flex; flex-direction: column; justify-content: center; gap: 20px; }

/* Toast, Spinner, Dialog */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-weight: 600; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.toast.err { background: var(--danger); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.spin { width: 18px; height: 18px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
dialog { border: none; border-radius: 16px; padding: 0; max-width: min(640px, calc(100% - 24px)); width: 100%; }
dialog::backdrop { background: rgba(21, 24, 27, .55); }
dialog .dlg { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
dialog .dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.photo-full { max-width: 100%; border-radius: 10px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

@media print {
  .no-print, .topbar, .toast { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .page { padding: 0; max-width: none; }
  .card, .table-wrap { border: none; padding: 0; }
  table.t th { background: #fff; }
  .print-only { display: block !important; }
  a { color: inherit; text-decoration: none; }
}
.print-only { display: none; }
