/* FTS Fleet: shop-yard palette. Galvanized steel, slate ink, forklift yellow. */
:root {
  --bg: #e4e8e7;
  --panel: #ffffff;
  --panel-2: #f2f4f3;
  --ink: #1c2b33;
  --ink-2: #4c5c64;
  --ink-3: #74838a;
  --line: #c8d0cf;
  --yellow: #f2b705;
  --yellow-2: #d9a300;
  --on-yellow: #1c2b33;
  --steel: #35586b;
  --red: #b3261e;
  --red-bg: #fbe9e7;
  --orange: #b4560a;
  --orange-bg: #fdf0e3;
  --green: #2c7a4b;
  --green-bg: #e5f3ea;
  --badge-bg: #ffffff;
  --badge-ink: #10181c;
  --focus: #1f6fd1;
  --radius: 6px;
  --shadow: 0 1px 0 rgba(28, 43, 51, 0.08);
  --font: "Barlow", "Segoe UI", system-ui, sans-serif;
  --cond: "Barlow Condensed", "Arial Narrow", "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12191d; --panel: #1b252a; --panel-2: #222d33; --ink: #e7ecec; --ink-2: #a3b1b6; --ink-3: #7f8f95;
    --line: #2f3d44; --steel: #8db4c7; --red: #f08a80; --red-bg: #3a1f1d; --orange: #f0a35e; --orange-bg: #3a2a1a;
    --green: #74c79a; --green-bg: #1b3326; --badge-bg: #e9edec; --badge-ink: #10181c; --focus: #7fb2ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12191d; --panel: #1b252a; --panel-2: #222d33; --ink: #e7ecec; --ink-2: #a3b1b6; --ink-3: #7f8f95;
  --line: #2f3d44; --steel: #8db4c7; --red: #f08a80; --red-bg: #3a1f1d; --orange: #f0a35e; --orange-bg: #3a2a1a;
  --green: #74c79a; --green-bg: #1b3326; --badge-bg: #e9edec; --badge-ink: #10181c; --focus: #7fb2ff; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
a { color: var(--steel); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.15; margin: 0; }
h1 { font-family: var(--cond); font-weight: 700; font-size: 2rem; letter-spacing: 0.01em; }
h2 { font-family: var(--cond); font-weight: 700; font-size: 1.45rem; }
h3 { font-size: 1.05rem; font-weight: 600; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.side { display: none; }
.main { padding: 16px 16px 96px; max-width: 1120px; width: 100%; margin: 0 auto; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 20;
}
:root[data-theme="dark"] .topbar { background: #0b1114; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .topbar { background: #0b1114; } }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--cond); font-weight: 700; font-size: 1.3rem; text-decoration: none; color: inherit; }
.brand-mark { width: 30px; height: 30px; display: block; }
.topbar .icon-btn { color: #fff; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 9px; text-decoration: none;
  color: var(--ink-2); font-size: 0.75rem; font-weight: 600;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 3px 0 var(--yellow); }
.tabbar .count { background: var(--red); color: #fff; border-radius: 9px; font-size: 0.68rem; padding: 0 5px; margin-left: 2px; }

@media (min-width: 900px) {
  .shell { grid-template-columns: 228px 1fr; }
  .topbar, .tabbar { display: none; }
  .side {
    display: flex; flex-direction: column; gap: 4px; background: var(--ink); color: #fff; padding: 18px 12px;
    position: sticky; top: 0; height: 100vh; align-self: start;
  }
  :root[data-theme="dark"] .side { background: #0b1114; }
  .side .brand { padding: 4px 8px 18px; font-size: 1.45rem; }
  .side nav { display: flex; flex-direction: column; gap: 2px; }
  .side nav a {
    display: flex; align-items: center; gap: 10px; padding: 10px 10px; border-radius: var(--radius);
    color: #c9d4d8; text-decoration: none; font-weight: 600;
  }
  .side nav a svg { width: 20px; height: 20px; }
  .side nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
  .side nav a[aria-current="page"] { background: rgba(242, 183, 5, 0.14); color: #fff; box-shadow: inset 3px 0 0 var(--yellow); }
  .side .count { margin-left: auto; background: var(--red); color: #fff; border-radius: 9px; font-size: 0.75rem; padding: 0 7px; }
  .side .who { margin-top: auto; padding: 10px; font-size: 0.85rem; color: #9fb0b6; border-top: 1px solid rgba(255,255,255,0.1); }
  .side .who strong { color: #fff; display: block; font-size: 0.95rem; }
  .main { padding: 28px 32px 48px; }
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .side { background: #0b1114; } }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 18px; }
.page-head p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--yellow); border-color: var(--yellow-2); color: var(--on-yellow); }
.btn.primary:hover { background: var(--yellow-2); }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 34px; padding: 0 10px; font-size: 0.875rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.icon-btn { background: none; border: 0; padding: 8px; cursor: pointer; border-radius: var(--radius); display: inline-flex; }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- unit number badge: the door-decal number ---------- */
.badge {
  --size: 1.5rem;
  display: inline-flex; align-items: center; justify-content: center; min-width: 3.4em; height: 2.1em;
  padding: 0 0.45em 0 0.75em; font-family: var(--cond); font-weight: 700; font-size: var(--size); line-height: 1;
  letter-spacing: 0.02em; background: var(--badge-bg); color: var(--badge-ink); border: 2px solid var(--badge-ink);
  border-radius: 4px; position: relative; overflow: hidden; flex-shrink: 0; text-transform: uppercase;
}
.badge::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 0.32em;
  background: repeating-linear-gradient(-45deg, var(--yellow) 0 5px, var(--badge-ink) 5px 10px);
}
.badge.xl { --size: 3.6rem; border-width: 3px; }
.badge.lg { --size: 2.4rem; }
.badge.sm { --size: 1.1rem; border-width: 1.5px; min-width: 3.1em; }

/* ---------- panels and lists ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 20px; }
.section { margin-bottom: 24px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 16px; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; }
.section-title .n { font-family: var(--cond); font-weight: 700; color: var(--ink-3); font-size: 1.2rem; }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.rows > li:last-child .row, .rows > .row:last-child { border-bottom: 0; }
a.row:hover, button.row:hover { background: var(--panel-2); }
button.row { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { color: var(--ink-2); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; }
.row .end { text-align: right; flex-shrink: 0; }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-2); }
.empty p { margin: 0 0 12px; }

/* status marks */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.pill.red { color: var(--red); background: var(--red-bg); }
.pill.orange { color: var(--orange); background: var(--orange-bg); }
.pill.green { color: var(--green); background: var(--green-bg); }
.pill.gray { color: var(--ink-2); background: var(--panel-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.red { background: var(--red); } .dot.orange { background: var(--orange); } .dot.green { background: var(--green); } .dot.gray { background: var(--line); }
.due-red { color: var(--red); font-weight: 600; }
.due-orange { color: var(--orange); font-weight: 600; }

/* summary strip on dashboard */
.strip { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 22px; }
.strip a { background: var(--panel); padding: 12px 14px; text-decoration: none; color: inherit; display: flex; align-items: baseline; gap: 8px; }
.strip a:hover { background: var(--panel-2); }
.strip b { font-family: var(--cond); font-size: 1.9rem; line-height: 1; }
.strip span { color: var(--ink-2); font-size: 0.9rem; }
.strip a.red b { color: var(--red); } .strip a.orange b { color: var(--orange); }
@media (min-width: 640px) { .strip { grid-template-columns: repeat(4, 1fr); } }

/* filters */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.search { flex: 1 1 220px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 6px 12px; font-weight: 600; font-size: 0.875rem; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }

/* unit hero */
.unit-hero { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin: 4px 0 18px; }
.unit-hero .meta { flex: 1; min-width: 220px; }
.unit-hero h1 { font-size: 1.8rem; }
.unit-hero .facts { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; color: var(--ink-2); }
.unit-photo { width: 100%; max-height: 260px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); display: block; background: var(--panel-2); }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--yellow); }

.facts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0; margin: 0; }
.facts-grid div { padding: 10px 16px; border-bottom: 1px solid var(--line); }
.facts-grid dt { font-size: 0.8rem; color: var(--ink-3); font-weight: 600; }
.facts-grid dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

.cols { display: grid; gap: 20px; }
@media (min-width: 960px) { .cols.two { grid-template-columns: 3fr 2fr; align-items: start; } }

table.data { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.data th, table.data td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
table.data th { font-size: 0.8rem; color: var(--ink-3); font-weight: 600; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* timeline */
.timeline .row { align-items: flex-start; }
.kind { font-size: 0.75rem; font-weight: 700; padding: 3px 8px; border-radius: 4px; background: var(--panel-2); color: var(--ink-2); flex-shrink: 0; min-width: 78px; text-align: center; }
.kind.maint { background: var(--ink); color: var(--panel); }
.kind.issue { background: var(--red-bg); color: var(--red); }
.kind.insp { background: var(--green-bg); color: var(--green); }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.thumbs img, .thumbs a.pdf { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); background: var(--panel-2); cursor: zoom-in; }
.thumbs a.pdf { display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; color: var(--ink-2); text-decoration: none; cursor: pointer; }
.pre { white-space: pre-wrap; }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; }
.form .grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form .grid.g2 { grid-template-columns: 1fr 1fr; } .form .grid.g3 { grid-template-columns: 1fr 1fr 1fr; } }
.field { display: grid; gap: 5px; }
.field label, .field .label { font-weight: 600; font-size: 0.9rem; }
.field .hint { font-size: 0.8rem; color: var(--ink-3); }
.field input, .field select, .field textarea {
  min-height: 44px; padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); width: 100%;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--focus); outline: 2px solid color-mix(in srgb, var(--focus) 25%, transparent); outline-offset: 0; }
.checks { display: grid; gap: 6px; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; }
legend { font-weight: 600; padding: 0 6px; }
.form-error { color: var(--red); background: var(--red-bg); border: 1px solid var(--red); padding: 10px 12px; border-radius: var(--radius); font-weight: 500; }
.form-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }

/* inspection items: big tap targets for gloves */
.insp-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.insp-item:last-child { border-bottom: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 0 16px; min-height: 44px; font-weight: 700; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.ok[aria-pressed="true"] { background: var(--green); color: #fff; }
.seg button.bad[aria-pressed="true"] { background: var(--red); color: #fff; }
.insp-item .note { grid-column: 1 / -1; }

/* driver tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 8px; text-decoration: none; color: inherit; justify-items: start; }
.tile:hover { border-color: var(--ink-3); }
.tile .sub { color: var(--ink-2); font-size: 0.875rem; }
.big-actions { display: grid; gap: 10px; }
.big-actions .btn { min-height: 64px; font-size: 1.1rem; justify-content: flex-start; padding: 0 18px; }
.big-actions .btn svg { width: 26px; height: 26px; }

/* ---------- modal sheet ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 18, 22, 0.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 680px; max-height: 92vh; overflow: auto; border-radius: 12px 12px 0 0;
  padding: 0 0 env(safe-area-inset-bottom); animation: rise 0.18s ease-out;
}
.sheet-head { position: sticky; top: 0; background: var(--panel); border-bottom: 1px solid var(--line); padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; z-index: 2; }
.sheet-body { padding: 16px; }
@media (min-width: 720px) { .overlay { align-items: center; } .sheet { border-radius: 10px; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.viewer { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.88); display: flex; align-items: center; justify-content: center; padding: 16px; }
.viewer img { max-width: 100%; max-height: 100%; }
.viewer .icon-btn { position: absolute; top: 12px; right: 12px; color: #fff; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: var(--radius); font-weight: 600; z-index: 70; box-shadow: 0 6px 20px rgba(0,0,0,0.25); max-width: calc(100% - 32px); }
.toast.err { background: var(--red); color: #fff; }
@media (min-width: 900px) { .toast { bottom: 28px; } }

/* ---------- sign in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--ink); }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border-radius: 10px; padding: 26px 22px; }
.auth-card .brand { color: var(--ink); margin-bottom: 18px; font-size: 1.6rem; }
.auth-card h1 { font-size: 1.6rem; margin-bottom: 6px; }

.loading { padding: 60px 16px; text-align: center; color: var(--ink-2); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.banner { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--yellow); border-radius: var(--radius); margin-bottom: 16px; flex-wrap: wrap; }
@media print { .side, .topbar, .tabbar, .actions, .btn { display: none !important; } body { background: #fff; } .main { padding: 0; } }
