/* Lapp Driver — LappOne's palette: charcoal with Lapp yellow (#f1d50a,
   from LappOne ui/theme.slint). Dark is the brand look; a light variant
   follows the phone's setting for reading in full sun. Phone first: big
   targets, one column. No inline styles anywhere — the CSP forbids them. */

:root {
  /* LappOne dark, verbatim. */
  --bg: #1e1e1e;
  --surface: #262626;
  --input: #2d2d2d;
  --raised: #313131;
  --line: #3a3a3a;
  --line-bright: #555555;
  --ink: #ececec;
  --ink-soft: #c6c6c6;
  --muted: #a0a0a0;
  --accent: #f1d50a;      /* Lapp yellow — RGB 241/213/10 */
  --on-accent: #171717;
  --success: #25c138;
  --info: #2e86d7;
  --danger: #de5454;
  --danger-soft: #3a2222;
  --success-soft: #1e3322;
  --bar: #141414;          /* LappOne's rail colour: the top bar, always */
  --radius: 6px;
  --tap: 56px;
  --gutter: 16px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f2f0;
    --surface: #ffffff;
    --input: #ffffff;
    --raised: #f7f7f5;
    --line: #d4d4d0;
    --line-bright: #9a9a96;
    --ink: #171717;
    --ink-soft: #333333;
    --muted: #5c5c5c;
    --success: #1b8a2a;
    --info: #1f6fb8;
    --danger: #b83232;
    --danger-soft: #fbe9e7;
    --success-soft: #e4f4e6;
    color-scheme: light;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--ink); }
h1 { font-size: 1.55rem; line-height: 1.2; margin: 8px 0 12px; }
h2 { font-size: .95rem; margin: 28px 0 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 8px 0; }
.muted { color: var(--muted); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- chrome ---- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) var(--gutter) 10px;
  background: var(--bar); color: #ececec;
  border-bottom: 3px solid var(--accent);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark { display: block; }
.brand-name { font-weight: 800; font-size: 1.2rem; letter-spacing: .01em; }
.brand-lapp { color: var(--accent); }
.brand-app { color: #c6c6c6; font-weight: 600; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; font-size: .95rem; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #c6c6c6; }
.topbar .link { color: #ececec; }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px var(--gutter);
  background: var(--success-soft); color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.banner.is-stale { background: var(--danger-soft); }
.banner-text { color: inherit; text-decoration: none; flex: 1 1 200px; }
.banner-text strong { color: var(--success); }
.banner.is-stale .banner-text strong { color: var(--danger); }
.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }

main { max-width: 640px; margin: 0 auto; }
.screen { padding: 12px var(--gutter) 40px; }
.screen.center { text-align: center; padding-top: 48px; }
.loading { padding: 40px var(--gutter); color: var(--muted); text-align: center; }
.empty { color: var(--muted); padding: 12px 0; }

.signin-mark { width: 88px; height: 88px; margin: 8px auto 16px; display: block; }

/* ---- buttons ---- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  min-height: var(--tap); padding: 0 20px;
  border: 2px solid var(--accent); border-radius: var(--radius);
  background: var(--accent); color: var(--on-accent);
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  touch-action: manipulation;
}
.btn.big { display: flex; width: 100%; min-height: 60px; font-size: 1.15rem; margin: 12px 0; }
.btn.small { min-height: 52px; padding: 0 16px; font-size: 1rem; }
.btn.icon { width: var(--tap); padding: 0; font-size: 1.6rem; }
.btn.secondary { background: transparent; color: var(--ink); border-color: var(--line-bright); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn:disabled, .btn.is-busy { opacity: .55; cursor: progress; }
.link {
  background: none; border: 0; padding: 8px 0; color: var(--ink);
  font: inherit; text-decoration: underline; text-decoration-color: var(--accent);
  text-underline-offset: 3px; cursor: pointer;
}
.link.block { display: block; padding: 12px 0; }
.back { display: inline-block; padding: 8px 0; text-decoration: none; font-weight: 600; color: var(--muted); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions .btn.big { margin: 4px 0; }
.footer-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---- today ---- */

.daynav { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.daynav-day { flex: 1; text-align: center; display: flex; flex-direction: column; }
.daynav-day .link { padding: 2px 0; font-size: .9rem; }

.tabs { display: flex; border-bottom: 2px solid var(--line); margin-bottom: 8px; }
.tabs a {
  flex: 1; text-align: center; padding: 12px 0; min-height: var(--tap);
  color: var(--muted); text-decoration: none; font-weight: 700;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tabs a[aria-selected="true"] { color: var(--ink); border-color: var(--accent); }

.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 12px; }
.total { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; text-align: center; }
.total-value { display: block; font-size: 1.2rem; font-weight: 800; }
.total-label { display: block; font-size: .85rem; color: var(--muted); }

/* ---- cards ---- */

.cards { display: grid; gap: 10px; margin: 8px 0; }
.card {
  display: block; padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none;
}
.card.is-open { border-left: 5px solid var(--success); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.card-line { font-size: .95rem; }
.card-body { white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .82rem; font-weight: 700; background: var(--raised); color: var(--ink-soft);
  border: 1px solid var(--line); white-space: nowrap;
}
.chip.live { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.chip.family { background: var(--raised); color: var(--info); border-color: var(--info); margin-right: 6px; }
.family-note { color: var(--info); font-weight: 700; margin: 0 0 8px; }
.chip.cat-vehicle_maintenance { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.chip.cat-on_duty_issue { color: var(--info); border-color: var(--info); }

/* ---- trip ---- */

.title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.title-row h1 { overflow-wrap: anywhere; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 16px 0; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.fact dt { font-size: .82rem; color: var(--muted); }
.fact dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.stop {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--line-bright);
}
.stop.is-here { border-left-color: var(--success); }
.stop.kind-delivery, .stop.kind-pickup { border-left-color: var(--accent); }
.stop.is-here.kind-delivery, .stop.is-here.kind-pickup { border-left-color: var(--success); }
.stop-main { flex: 1; min-width: 0; color: var(--ink); text-decoration: none; }
.stop-top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .9rem; }
.stop-place { font-weight: 700; margin-top: 4px; overflow-wrap: anywhere; }
.stop-notes { font-size: .92rem; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- forms ---- */

.field { display: flex; flex-direction: column; gap: 6px; margin: 16px 0; }
.field-label { font-weight: 700; }
.field-hint { font-size: .9rem; color: var(--muted); }
.field-error { color: var(--danger); font-weight: 700; font-size: .95rem; }
.field[aria-invalid="true"] input, .field[aria-invalid="true"] select, .field[aria-invalid="true"] textarea { border-color: var(--danger); }

input:not([type="checkbox"]), select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  font: inherit; font-size: 1.05rem; /* 16px+ stops iOS zooming on focus */
  color: var(--ink); background: var(--input);
  border: 2px solid var(--line); border-radius: var(--radius);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }

.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-weight: 600; cursor: pointer; }
.check input { width: 26px; height: 26px; accent-color: var(--accent); flex: none; }

.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.choice {
  min-height: 64px; padding: 8px 10px; border-radius: var(--radius);
  border: 2px solid var(--line-bright); background: var(--raised); color: var(--ink);
  font: inherit; font-weight: 800; font-size: 1.05rem; cursor: pointer; touch-action: manipulation;
}
.choice[aria-checked="true"] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.field[aria-invalid="true"] .choice { border-color: var(--danger); }

.computed { font-size: 1.3rem; font-weight: 800; margin: 0 0 8px; min-height: 1.4em; }

/* ---- the time picker: big squares, tap one, nudge, done ---- */

.tp { padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: grid; gap: 10px; }
.tp-value { display: flex; align-items: baseline; gap: 10px; padding: 2px 4px; }
.tp-time { font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.tp-day { color: var(--muted); font-weight: 700; font-size: 1.05rem; }
.tp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tp-grid.four { grid-template-columns: repeat(4, 1fr); }
.tp-btn {
  min-height: 64px; padding: 6px 4px; border-radius: var(--radius);
  border: 2px solid var(--line-bright); background: var(--raised); color: var(--ink);
  font: inherit; font-weight: 800; font-size: 1.05rem; line-height: 1.2;
  cursor: pointer; touch-action: manipulation;
}
.tp-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.tp-big { font-size: 1.2rem; font-weight: 800; white-space: nowrap; }
.tp-small { font-size: .85rem; font-weight: 600; opacity: .8; }
.tp-btn.wide { grid-column: 1 / -1; }
.tp-btn.nudge { font-variant-numeric: tabular-nums; }
.tp-btn.quiet { color: var(--muted); font-weight: 700; }
.tp-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.tp-btn:active { transform: scale(.97); }

/* ---- logging a whole trip ---- */

.stop-rows { display: grid; gap: 12px; }
.stop-row { padding: 12px; border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: var(--radius); background: var(--raised); }
.stop-row-top { display: flex; justify-content: space-between; align-items: center; }

.message {
  margin: 12px 0; padding: 12px 14px; border-radius: var(--radius);
  background: var(--danger-soft); color: var(--danger); font-weight: 700;
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center;
  border: 1px solid var(--danger);
}
.message .link { color: var(--danger); padding: 0; }
.notice { margin: 12px 0; padding: 12px 14px; border-radius: var(--radius); background: var(--raised); border: 1px solid var(--line); }
.dev-note { background: var(--accent); color: var(--on-accent); padding: 8px 12px; border-radius: var(--radius); font-size: .92rem; font-weight: 600; }

@media (min-width: 700px) {
  .screen { padding-top: 20px; }
}
