/* FahrPilot – eigenes Design: warm, rund, grün. Mobile-first für Fahrer. */

:root {
  --go: #0f8a6d;
  --go-dark: #0b6b54;
  --go-soft: #e3f3ee;
  --sun: #f0b429;
  --sun-soft: #fdf3d7;
  --rose: #d64550;
  --rose-soft: #fbe9ea;
  --violet: #7c5cff;
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #22302b;
  --muted: #7d8a84;
  --line: #e8e6df;
  --r: 18px;
  --shadow: 0 2px 10px rgba(34, 48, 43, .07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.view { min-height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
#loginView { align-items: center; justify-content: center; padding: 24px; }
.login-box { width: min(440px, 100%); text-align: center; }
.logo-big { font-size: 46px; }
.login-title { font-size: 32px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; }
.login-sub { color: var(--muted); margin: 4px 0 26px; }
.driver-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.driver-tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 18px 12px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  font-family: inherit; font-size: 15px; font-weight: 600; color: var(--ink);
  transition: transform .08s ease;
}
.driver-tile:active { transform: scale(.97); }
.driver-tile.admin-tile { grid-column: 1 / -1; flex-direction: row; justify-content: center; padding: 14px; }
.howto {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 18px;
  text-align: left;
}
.howto-title { font-weight: 800; font-size: 15px; margin-bottom: 8px; }
.howto-steps {
  padding-left: 20px;
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13.5px; line-height: 1.5;
}
.howto-note { margin-top: 10px; font-size: 12px; color: var(--muted); }
.pin-hint { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }

.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 17px;
  background: var(--go);
  flex: none;
}
.avatar-admin { background: var(--ink); }

/* ---------- App-Rahmen ---------- */
.app-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.head-user { display: flex; align-items: center; gap: 12px; }
.head-name { font-weight: 700; }
.head-sub { font-size: 12.5px; color: var(--muted); }
.app-main {
  flex: 1;
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 18px 16px 96px;
  display: flex; flex-direction: column; gap: 16px;
}
.app-main.wide { width: min(1020px, 100%); padding-bottom: 40px; }

/* ---------- Bottom-Nav (Fahrer) ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
}
.nav-btn {
  border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 600;
  color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; border-radius: 12px;
}
.nav-btn span { font-size: 21px; }
.nav-btn.active { color: var(--go); background: var(--go-soft); }

/* ---------- Tabs (Admin) ---------- */
.tab-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
  width: min(1020px, 100%);
  margin: 0 auto;
  padding: 14px 16px 0;
}
.tab {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
}
.tab.active { background: var(--go); border-color: var(--go); color: #fff; }

/* ---------- Karten ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.card.warn { background: var(--sun-soft); border-color: #f0d894; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: 14px;
  font-family: inherit; font-size: 15px; font-weight: 700;
  padding: 12px 18px;
  cursor: pointer;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-go { background: var(--go); color: #fff; }
.btn-go:hover:not(:disabled) { background: var(--go-dark); }
.btn-plain { background: var(--bg); border: 1px solid var(--line); color: var(--ink); }
.btn-danger { background: var(--rose); color: #fff; }
.btn-sun { background: var(--sun); color: #22302b; }
.btn-big { width: 100%; padding: 16px; font-size: 16px; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }

/* ---------- Fahrt / Numpad ---------- */
.price-display {
  text-align: center;
  font-size: 44px; font-weight: 800; letter-spacing: -.02em;
  padding: 8px 0 2px;
}
.price-display small { font-size: 20px; color: var(--muted); font-weight: 600; }
.numpad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin: 12px 0;
}
.numpad button {
  font-family: inherit; font-size: 22px; font-weight: 700;
  padding: 14px 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}
.numpad button:active { background: var(--go-soft); }
.numpad .np-alt { font-size: 16px; color: var(--muted); }

.seg-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.seg {
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  padding: 12px 6px;
  font-family: inherit; font-size: 14px; font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.seg small { font-weight: 500; font-size: 10.5px; color: var(--muted); }
.seg.active { border-color: var(--go); background: var(--go-soft); }
.dt-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.dt-row label { font-size: 13px; font-weight: 600; color: var(--muted); }
.dt-row input {
  flex: 1;
  font-family: inherit; font-size: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
}

/* ---------- Schicht ---------- */
.shift-clock { text-align: center; padding: 10px 0; }
.shift-elapsed { font-size: 42px; font-weight: 800; letter-spacing: -.02em; }
.shift-since { color: var(--muted); font-size: 13px; margin-top: 2px; }
.pause-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--sun-soft); color: #6b4f04;
  border-radius: 12px; padding: 8px 14px; margin-top: 12px;
  font-size: 13px; font-weight: 700;
}
.shift-btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-row-3 { grid-template-columns: repeat(3, 1fr); }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 14px;
}
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 22px; font-weight: 800; margin-top: 2px; }

/* ---------- Listen ---------- */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 700; font-size: 14.5px; }
.list-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.list-amount { font-weight: 800; font-size: 15px; white-space: nowrap; }
.list-empty { color: var(--muted); text-align: center; padding: 22px 0; font-size: 14px; }

.chip {
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
  white-space: nowrap;
}
.chip.go { background: var(--go-soft); color: var(--go-dark); }
.chip.sun { background: var(--sun-soft); color: #8a6414; }
.chip.rose { background: var(--rose-soft); color: var(--rose); }
.chip.plain { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

/* ---------- Formulare ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.form-grid label { font-size: 12.5px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 4px; }
.form-grid input, .form-grid select {
  width: 100%;
  font-family: inherit; font-size: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
}
.form-note { grid-column: 1 / -1; }

/* ---------- Tabellen (Admin) ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; padding: 10px 12px;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted);
  border-bottom: 1.5px solid var(--line);
  white-space: nowrap;
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; }
.tbl .row-off td { opacity: .55; }

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

/* ---------- PIN ---------- */
.modal-pin { width: min(320px, 92vw); text-align: center; }
.pin-who { font-weight: 700; margin-bottom: 10px; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin-bottom: 16px; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.pin-dot.on { background: var(--go); }
.modal-pin .numpad { margin-bottom: 10px; }
.pin-shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(34, 48, 43, .45);
  display: grid; place-items: center;
  padding: 16px;
}
.modal {
  background: var(--card);
  border-radius: 20px;
  padding: 20px;
  width: min(420px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,.18);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Beleg ---------- */
.modal-receipt { width: min(380px, 100%); }
.receipt {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 12.5px;
  background: #fffef8;
  color: #1c1c1c;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 14px;
  white-space: pre-wrap;
}
.receipt .r-center { text-align: center; }
.receipt .r-title { font-size: 15px; font-weight: 700; }
.receipt .r-big { font-size: 22px; font-weight: 800; }
.receipt hr { border: none; border-top: 1px dashed #bbb; margin: 8px 0; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt td { padding: 1.5px 0; vertical-align: top; }
.receipt td.num { text-align: right; white-space: nowrap; }
.receipt .r-small { font-size: 11px; color: #555; }
.receipt .r-qr { display: grid; place-items: center; margin-top: 8px; }
.receipt .r-storno { color: var(--rose); font-weight: 700; }
.receipt .r-belegart { text-align: center; font-weight: 800; letter-spacing: .1em; margin: 4px 0; }

/* ---------- Icon-Buttons (Zeilen-Aktionen, z. B. schnell drucken) ---------- */
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: middle;
  width: 32px; height: 32px; flex: none;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; cursor: pointer;
}
.btn-icon:hover { background: var(--go-soft); }

/* ---------- Diagramm: tägliche Auswertung ---------- */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-col-head {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 4px;
}
.chart-col-head strong { font-size: 17px; color: var(--ink); font-weight: 800; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-baseline { stroke: var(--line); stroke-width: 1px; }
.chart-bar-fill { transition: filter .1s ease; }
.chart-hit { fill: transparent; cursor: pointer; }
.chart-band:hover .chart-bar-fill,
.chart-band:focus .chart-bar-fill { filter: brightness(1.12); }
.chart-band:focus { outline: none; }
.chart-band:focus-visible .chart-hit { stroke: var(--go); stroke-width: 2px; fill: none; }
.chart-axis-label { font-size: 9.5px; fill: var(--muted); font-family: inherit; }
.chart-value-label { font-size: 10.5px; font-weight: 800; fill: var(--ink); font-family: inherit; }

.chart-tooltip {
  position: fixed;
  transform: translate(-50%, calc(-100% - 10px));
  background: var(--ink); color: #fff;
  padding: 6px 11px; border-radius: 9px;
  font-size: 12px; white-space: nowrap;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  pointer-events: none; z-index: 60;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.chart-tooltip.hidden { display: none; }
.ctt-value { font-weight: 800; font-size: 13px; }
.ctt-label { color: rgba(255,255,255,.75); font-size: 11px; }

@media (max-width: 640px) {
  .chart-row { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  .stat-row-3 { grid-template-columns: 1fr 1fr; }
  .stat-row-3 .stat:nth-child(3) { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .tab-bar { padding-top: 10px; }
  .tab { font-size: 13px; padding: 8px 14px; }
}

@media print {
  body > *:not(#receiptModal) { display: none !important; }
  .modal-backdrop { position: static; background: none; display: block; padding: 0; }
  .modal { width: auto; box-shadow: none; padding: 0; }
  .modal-actions { display: none; }
  .receipt { border: none; }
}
