/* Gaadi Log — paper & ink. One accent (ink), green = done, red = alert, amber = warn.
   Tokens follow the shadcn naming so a future React port is a copy-paste. */
:root {
  --background: #F7F5EF;
  --card: #FFFFFF;
  --foreground: #16150F;
  --muted: #6B6A62;
  --muted-bg: #EEECE4;
  --border: #DDDAD0;
  --primary: #16150F;
  --primary-fg: #FFFFFF;
  --success: #15803D;
  --success-bg: #DCFCE7;
  --danger: #B91C1C;
  --danger-bg: #FEE2E2;
  --warn: #92400E;
  --warn-bg: #FEF3C7;
  --ring: #16150F;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: #121210;
    --card: #1C1B18;
    --foreground: #F2F0E9;
    --muted: #A3A197;
    --muted-bg: #262521;
    --border: #33322D;
    --primary: #F2F0E9;
    --primary-fg: #121210;
    --success: #4ADE80;
    --success-bg: #14532D;
    --danger: #FCA5A5;
    --danger-bg: #7F1D1D;
    --warn: #FCD34D;
    --warn-bg: #78350F;
    --ring: #F2F0E9;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--background);
  color: var(--foreground);
  line-height: 1.5;
  padding-bottom: var(--safe-b);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.wrap { max-width: 520px; margin: 0 auto; padding: 16px; }
.wide { max-width: 960px; }
header.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  max-width: 960px; margin: 0 auto;
}
header.top .brand { display: flex; align-items: center; gap: 10px; }
header.top .brand svg { width: 22px; height: 22px; }

/* cards */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 560px) { .grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid3 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* buttons — 48px min, pressed state via opacity+scale (no layout shift) */
.btn {
  white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card); color: var(--foreground);
  font: inherit; font-weight: 600; font-size: 16px; cursor: pointer;
  transition: opacity .15s ease, transform .15s ease, background .15s ease;
  text-decoration: none; width: 100%;
}
.btn:active { transform: scale(.98); opacity: .85; }
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.btn.primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.btn.big { min-height: 64px; font-size: 18px; border-radius: var(--radius); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--danger); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn.icon { width: 44px; min-height: 44px; padding: 0; border-radius: 999px; }

/* inputs */
label.field { display: block; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px; font: inherit; font-size: 17px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--foreground);
}
.input:focus { outline: 2px solid var(--ring); outline-offset: 1px; border-color: transparent; }
.input.reading { font-size: 34px; font-weight: 600; letter-spacing: .04em; text-align: center; min-height: 68px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.err { font-size: 14px; color: var(--danger); margin-top: 8px; font-weight: 500; }

/* status pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap;
}
.pill.ok { background: var(--success-bg); color: var(--success); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.neutral { background: var(--muted-bg); color: var(--muted); }
.pill svg { width: 13px; height: 13px; }

/* metric tiles */
.tile { background: var(--muted-bg); border-radius: var(--radius-sm); padding: 12px 14px; }
.tile .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 22px; white-space: nowrap; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; }
.tile .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.bad { background: var(--danger-bg); } .tile.bad .k, .tile.bad .v, .tile.bad .s { color: var(--danger); }
.tile.ok { background: var(--success-bg); } .tile.ok .k, .tile.ok .v, .tile.ok .s { color: var(--success); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: var(--primary); color: var(--primary-fg); padding: 12px 18px; border-radius: 999px;
  font-weight: 600; font-size: 15px; opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 50;
  display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast svg { width: 18px; height: 18px; }

/* camera */
.cam {
  position: fixed; inset: 0; background: #000; z-index: 40; display: flex; flex-direction: column;
}
.cam video { flex: 1; width: 100%; object-fit: cover; }
.cam .guide {
  position: absolute; left: 8%; right: 8%; top: 32%; height: 22%;
  border: 2px solid rgba(255,255,255,.9); border-radius: 12px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.45);
}
.cam .guide span {
  position: absolute; left: 0; right: 0; top: -34px; text-align: center; color: #fff; font-weight: 600; font-size: 15px;
}
.cam .bar {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 20px calc(24px + var(--safe-b));
  display: flex; align-items: center; justify-content: space-between;
}
.shutter {
  width: 76px; height: 76px; border-radius: 50%; background: #fff; border: 5px solid rgba(255,255,255,.4);
  background-clip: padding-box; cursor: pointer;
}
.shutter:active { transform: scale(.94); }
.cam .btn.ghost { color: #fff; width: auto; }

/* driver strip of last 7 nights */
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.strip .d { text-align: center; font-size: 11px; color: var(--muted); }
.strip .b { height: 44px; border-radius: 8px; background: var(--muted-bg); display: flex; align-items: flex-end; justify-content: center; overflow: hidden; }
.strip .b i { display: block; width: 100%; background: var(--primary); opacity: .75; border-radius: 6px 6px 0 0; }
.strip .v { font-size: 12px; font-weight: 600; text-align: center; margin-top: 4px; }

/* ledger */
.ledger { display: flex; flex-direction: column; gap: 8px; }
.day {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px;
  display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; cursor: pointer;
}
.day > .mid { min-width: 0; }
.day.missing { border-style: dashed; background: transparent; }
.day .dt { line-height: 1.3; min-width: 0; } .day .dt b { display: block; font-size: 15px; } .day .dt span { font-size: 12px; color: var(--muted); display: block; }
.day .km { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.day .km small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.day .meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.day .flags { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.day .flags:empty { display: none; }
.day .thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); display: block; }
.day .detail { grid-column: 1 / -1; border-top: 1px solid var(--border); padding-top: 10px; display: none; }
.day.open .detail { display: block; }
.day .fuelrow { font-size: 13px; color: var(--muted); margin-top: 2px; }
.day .fuelrow svg { vertical-align: -2px; margin-right: 4px; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--foreground); text-decoration: underline; cursor: pointer; }

/* overlay sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; display: none; }
.sheet-bg.show { display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 520px; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + var(--safe-b)); max-height: 92vh; overflow: auto; }
@media (min-width: 720px) { .sheet-bg.show { align-items: center; } .sheet { border-radius: 20px; } }
.lightbox { position: fixed; inset: 0; background: #000; z-index: 60; display: none; align-items: center; justify-content: center; }
.lightbox.show { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; }

/* car switcher (owner) */
.switch { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 12px; scrollbar-width: none; }
.switch::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--foreground);
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; transition: background .15s, border-color .15s;
}
.chip.on { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.chip.on .muted { color: inherit; opacity: .7; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: none; }
.dot.ok { background: var(--success); }
/* car picker (driver) */
.pick { display: grid; gap: 10px; }
.pick .btn { justify-content: space-between; min-height: 60px; }
.pick .btn small { font-weight: 500; color: var(--muted); }
select.input { appearance: auto; }

.hidden { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
