/* One dark theme in a premium-automotive style: black, hairlines, serif
   headings, one blue for actions. The status colours of the buttons carry
   meaning and stay strong enough to read at a glance while driving. */

:root {
  color-scheme: dark;
  --bg: #000;
  --surface: #121212;
  --surface-2: #1c1c1c;
  --line: #2b2b2b;
  --line-strong: #4d4d4d;
  --text: #fff;
  --muted: #9a9a9a;
  --accent: #0078d6;
  --accent-ink: #4aa8ff;
  --ok: #21a330;       --ok-ink: #5fd36f;
  --warn: #facc00;     --warn-ink: #ffd84d;
  --severe: #d92121;   --severe-ink: #ff6b6b;
  --radius: 4px;
  --gap: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  /* iOS blurs a band below the status bar over the page, so content starts a
     little lower than the inset; devices without an inset get nothing extra. */
  --top-pad: calc(var(--safe-top) + min(var(--safe-top), 14px));
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  /* No rubber band and no browser pull-to-refresh: the app has its own. */
  overscroll-behavior-y: none;
  overflow-x: hidden;
}

#app {
  min-height: var(--app-height, 100dvh);
  padding: var(--top-pad) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  border-radius: var(--radius);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}
button:disabled { opacity: .35; cursor: default; }

/* 17px+ inputs: smaller ones make iOS zoom the page on focus. */
input, textarea {
  font: inherit;
  font-size: 18px;
  width: 100%;
  padding: 12px 14px;
  margin-top: 6px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: var(--radius);
  text-transform: none;
  letter-spacing: normal;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
input[type=checkbox] { width: 24px; height: 24px; margin: 0; flex: none; accent-color: var(--accent); box-shadow: none; }

label {
  display: block;
  margin: 18px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.opt { color: #6b6b6b; font-weight: 500; letter-spacing: .04em; text-transform: none; font-size: 13px; margin-left: 4px; }

/* --- bars ----------------------------------------------------------------- */

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  min-height: 60px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.bar h1 { flex: 1; margin: 0; font: 400 22px/1.2 var(--serif); letter-spacing: .01em; }
.bar .back { min-width: 44px; font-size: 26px; line-height: 1; padding: 6px 10px 9px; }

.brand { min-height: 72px; }
.wordmark { flex: 1; display: flex; flex-direction: column; line-height: 1.1; }
.wordmark .name { font: 400 26px/1.1 var(--serif); letter-spacing: .01em; }
.wordmark .sub {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
}

/* --- generic blocks ------------------------------------------------------- */

.pad { padding: 6px 16px 40px; max-width: 760px; margin: 0 auto; }

.section-title {
  margin: 30px 0 4px;
  padding-bottom: 10px;
  font: 400 22px/1.2 var(--serif);
  border-bottom: 1px solid var(--line);
}

.big {
  display: block;
  width: 100%;
  min-height: 56px;
  margin: 14px 0;
  padding: 12px 16px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .01em;
}
.primary { background: var(--accent); color: #fff; }
.primary:active { background: #0063b2; }
.secondary { background: transparent; border: 1px solid var(--line-strong); }
.secondary:active { background: var(--surface-2); }
.danger { color: var(--severe-ink); }
.big.danger { background: transparent; border: 1px solid var(--severe); }

.ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  padding: 9px 14px;
  min-height: 44px;
  font-size: 15px;
  font-weight: 600;
}
.ghost:active { background: var(--surface-2); }

.row { display: flex; gap: var(--gap); }
.row > * { flex: 1; }
.row .ghost { margin: 6px 0; }

.notice {
  margin: 16px 0;
  padding: 12px 14px;
  background: var(--surface);
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 15px;
  color: #d6d6d6;
}
.notice strong { display: block; margin-bottom: 3px; color: var(--text); }
.notice.warn { border-left-color: var(--warn); color: var(--text); font-weight: 600; }

.muted { color: var(--muted); font-size: 15px; }
.err { color: var(--severe-ink); font-weight: 600; min-height: 1.4em; margin: 8px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 8px; }
.chip {
  padding: 8px 14px;
  min-height: 40px;
  background: transparent;
  border: 1px solid var(--line-strong);
  font-size: 15px;
  font-weight: 600;
}
.chip:active { background: var(--surface-2); }

.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 2px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  border: 1px solid var(--line-strong);
  color: var(--muted);
}
.tag.open { color: var(--warn-ink); border-color: var(--warn); }
.tag.done { color: var(--ok-ink); border-color: var(--ok); }

.tone-ok { --tone: var(--ok); --ink: var(--ok-ink); }
.tone-warn { --tone: var(--warn); --ink: var(--warn-ink); }
.tone-severe { --tone: var(--severe); --ink: var(--severe-ink); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--tone); }

/* --- the button board ----------------------------------------------------- */

#app.screen-board { height: var(--app-height, 100dvh); display: flex; flex-direction: column; }

.boardbar .who { flex: 1; display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.boardbar .who strong { font: 400 22px/1.15 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.boardbar .who span { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.board {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px 10px 12px;
  overflow-y: auto;
}

.sec { display: flex; flex-direction: column; min-height: min-content; }
.sec h2 {
  margin: 0 2px 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}
.sec h2 span { letter-spacing: .08em; color: #6b6b6b; }
.sec-drive { flex: 1; }
.sec-start { flex: 1.1; }

.grid { flex: 1; min-height: min-content; display: grid; gap: 8px; }
.sec-drive .grid { grid-template-rows: repeat(3, minmax(min-content, 1fr)); }
.sec-start .grid { grid-template-columns: 1fr 1fr; grid-auto-rows: minmax(min-content, 1fr); }
.topic.wide { grid-column: 1 / -1; }

/* Dark tiles tinted in their status colour, with a solid colour edge, and
   icon and count in the same colour: readable at a glance without shouting.
   Wide tiles run icon, label, count in a row; the half-width startup tiles
   put icon and count on top and give the label the full width below. */
.topic {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 8px 16px;
  text-align: left;
  color: var(--text);
  background: var(--surface-2);
  background: color-mix(in srgb, var(--tone) 17%, #0b0b0b);
  border: 1px solid color-mix(in srgb, var(--tone) 45%, transparent);
  border-left: 6px solid var(--tone);
}
.topic:active { background: color-mix(in srgb, var(--tone) 30%, #0b0b0b); }

.topic .ico { width: 34px; height: 34px; flex: none; color: var(--ink); }
.topic .label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.topic .title { font-size: 20px; font-weight: 650; line-height: 1.15; }
.topic .hint { font-size: 13.5px; font-weight: 500; line-height: 1.25; color: rgb(255 255 255 / .72); }
.topic .count {
  flex: none;
  margin-left: auto;
  min-width: 2ch;
  text-align: right;
  color: var(--ink);
  font: 400 40px/1 var(--serif);
  font-variant-numeric: tabular-nums lining-nums;
}

.sec-start .topic:not(.wide) {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr;
  align-items: start;
  gap: 2px 8px;
  padding: 9px 10px 9px 12px;
}
.sec-start .topic:not(.wide) .ico { grid-area: 1 / 1; width: 24px; height: 24px; }
.sec-start .topic:not(.wide) .count { grid-area: 1 / 2; justify-self: end; font-size: 26px; }
.sec-start .topic:not(.wide) .label { grid-area: 2 / 1 / 3 / 3; align-self: end; gap: 1px; }
.sec-start .topic:not(.wide) .title { font-size: 16px; }
.sec-start .topic:not(.wide) .hint { font-size: 12px; }

.topic.flash { animation: flash .6s ease-out; }
@keyframes flash {
  0% { box-shadow: inset 0 0 0 200px color-mix(in srgb, var(--tone) 75%, transparent); }
  100% { box-shadow: inset 0 0 0 200px transparent; }
}

/* Short screens (iPhone SE, any phone in landscape): tighter spacing and
   type, so all buttons fit without scrolling. */
@media (max-height: 700px) {
  .boardbar { min-height: 50px; padding-top: 4px; padding-bottom: 4px; }
  .board { gap: 8px; padding: 6px 10px 8px; }
  .sec h2 { margin-bottom: 4px; font-size: 10px; }
  .grid { gap: 6px; }
  .topic { min-height: 0; padding: 6px 14px; gap: 12px; }
  .topic .ico { width: 28px; height: 28px; }
  .topic .title { font-size: 18px; }
  .topic .hint { font-size: 12.5px; }
  .topic .count { font-size: 34px; }
  .sec-start .topic:not(.wide) { padding: 6px 8px 6px 10px; }
  .sec-start .topic:not(.wide) .ico { width: 20px; height: 20px; }
  .sec-start .topic:not(.wide) .count { font-size: 22px; }
  .sec-start .topic:not(.wide) .title { font-size: 15px; }
  .sec-start .topic:not(.wide) .hint { font-size: 11.5px; }
}

/* Landscape (phone mount): sections side by side. */
@media (orientation: landscape) and (max-height: 600px) {
  .board { flex-direction: row; }
  .sec-drive, .sec-start { flex: 1; }
  .topic .title { font-size: 18px; }
}

/* --- lists ---------------------------------------------------------------- */

.list { list-style: none; margin: 10px 0; padding: 0; }
.list li { margin: 8px 0; }

.item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 16px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
}
.item:active { background: var(--surface-2); }
.item .what { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.item .what strong { font: 400 19px/1.2 var(--serif); }
.item .when { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.facts-line { color: #c8c8c8; font-size: 15px; }
.facts-line:empty { display: none; }

.item.event { display: grid; grid-template-columns: auto auto 1fr; gap: 4px 10px; align-items: center; }
.item.event .when { color: var(--text); font-weight: 700; font-size: 16px; }
.item.event .what { font-size: 16px; }
.item.event .comment { grid-column: 1 / -1; white-space: pre-wrap; }
.item.event .comment:empty { display: none; }
.item.event .comment.missing { color: var(--warn-ink); font-size: 15px; }

.check {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 0;
  padding: 14px 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}
.item-body { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.item-body .what { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.item-body .what strong { font: 400 19px/1.2 var(--serif); }
.item-body .when { color: var(--muted); font-size: 15px; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 24px 0; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.facts dd.diag { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* --- the report ----------------------------------------------------------- */

.caption { font: 400 19px/1.35 var(--serif); margin: 18px 0 12px; }

.form-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.form-table th, .form-table td {
  border: 1px solid var(--line);
  padding: 7px 8px;
  vertical-align: top;
  text-align: left;
}
.form-table tr.head th { background: var(--surface-2); font-weight: 600; }
.form-table .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.form-table .details { font-variant-numeric: tabular-nums; color: #d6d6d6; }

.basis { margin: 10px 0 4px; }
.fig-table { width: 100%; border-collapse: collapse; margin: 10px 0 18px; font-size: 15px; }
.fig-table th {
  padding: 6px 6px 8px;
  text-align: right;
  vertical-align: bottom;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line-strong);
}
.fig-table td {
  padding: 8px 6px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--line);
}
.fig-table th:first-child, .fig-table td:first-child { text-align: left; padding-left: 0; }
/* The dot hangs in the margin, so a wrapped label stays aligned. */
.fig-table td:first-child { position: relative; padding-left: 18px; }
.fig-table td:first-child .dot { position: absolute; left: 0; top: 15px; }
.fig-table tr.total td { font-weight: 700; }
.fig-table td:last-child { padding-right: 0; }

/* --- overlays ------------------------------------------------------------- */

/* Top-aligned, so the on-screen keyboard does not cover the buttons. */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: calc(var(--top-pad) + 10px) 10px 10px;
  background: rgb(0 0 0 / .7);
}
.sheet {
  width: 100%;
  max-width: 640px;
  max-height: 100%;
  overflow: auto;
  padding: 18px 16px 12px;
  border-radius: var(--radius);
  background: #0d0d0d;
  border: 1px solid var(--line-strong);
}
.sheet-head { display: flex; align-items: center; gap: 10px; }
.sheet-head .ico { width: 26px; height: 26px; flex: none; color: var(--ink); }
.sheet-head strong { flex: 1; font: 400 21px/1.2 var(--serif); }
.sheet-head .time { font-variant-numeric: tabular-nums; font-weight: 700; }
.sheet textarea { min-height: 110px; resize: vertical; }
.sheet .ghost { width: 100%; margin-top: 2px; }

.toast, .update {
  position: fixed;
  left: 10px;
  right: 10px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
  padding: 10px 12px 10px 16px;
  border-radius: var(--radius);
  background: #1f1f1f;
  border: 1px solid var(--line-strong);
  font-weight: 600;
  box-shadow: 0 8px 28px rgb(0 0 0 / .6);
}
.toast { bottom: calc(var(--safe-bottom) + 12px); }
.update { top: calc(var(--top-pad) + 68px); border-color: var(--accent); }
.toast span, .update span { flex: 1; }
.toast[hidden], .update[hidden], body.sheet-open .update { display: none; }

/* Pull to reload: follows the finger down from under the top bar. */
.pull {
  position: fixed;
  left: 50%;
  top: calc(var(--top-pad) + 8px);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 12px;
  transform: translate(-50%, var(--pull, 0px));
  background: #1f1f1f;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 28px rgb(0 0 0 / .6);
}
.pull svg { width: 18px; height: 18px; transition: transform .15s; }
.pull.ready { color: var(--text); border-color: var(--accent); }
.pull.ready svg { transform: rotate(180deg); }
.pull.busy svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pull[hidden] { display: none; }
