/*
  Comments and descriptions were added for ease of use by Ensight Plus with the assistance of AI.

  WHAT THIS FILE DOES
  The stylesheet: design tokens (light default, dark palette token-only),
  outline icon system, squared 'Console' geometry, layout, navigation rail,
  forms, tables, and the theme toggle.
*/
/* Theme color — overridden at boot from admin branding settings */
:root { --accent: #0B63CE; --accent-dark: #08479A; }
/* Fleetistry — "Console" design tokens.
   Squared geometry, outline icons, and high-contrast data display: the numbers
   are meant to read across a shop floor. Light is the default; dark is opt-in
   via data-theme="dark" on <html> (or the OS preference when the user has not
   chosen). Admins can still override --accent from branding settings, so a
   customer's own colour flows through every token below. */
:root {
  --brand-blue: var(--accent);
  --brand-blue-dark: var(--accent-dark);
  --ink: #0F1720;
  --steel: #59677A;
  --paper: #EDEFF2;
  --card: #FFFFFF;
  --card-2: #F5F7F9;
  --line: #C9D2DC;
  --line-soft: #E4E9EF;
  --crimson: #C8175D;
  --amber: #B4720F;
  --green: #197D4F;
  --pass-bg: #E4F2EA;
  --fail-bg: #F9E3EB;
  --attn-bg: #FAEEDB;
  --blue-bg: #DEEAFB;
  --nav-bg: #0F1720;
  --nav-ink: #96A6B8;
  --nav-active-bg: var(--accent);
  --nav-active-ink: #FFFFFF;
  --radius: 0px;
  --stroke: 2;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --dotgrad: linear-gradient(90deg, var(--accent) 0%, #4A63AE 35%, #8A4392 65%, #C8175D 100%);
}

/* Dark palette. Defined at token level ONLY, so every component below keeps
   working through the same variable names in both themes. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #EAF0F7;
    --steel: #8A9AAC;
    --paper: #080B0F;
    --card: #121820;
    --card-2: #171F29;
    --line: #232C37;
    --line-soft: #1B222B;
    --crimson: #F2588C;
    --amber: #E6A53F;
    --green: #4ECB8B;
    --pass-bg: #122C21;
    --fail-bg: #331823;
    --attn-bg: #2E2415;
    --blue-bg: #0F2540;
    --nav-bg: #05080B;
    --nav-ink: #8A9AAC;
    --nav-active-ink: #FFFFFF;
  /* The accent is admin-configurable, so it cannot simply be replaced in dark:
       lift whatever colour the customer chose until it carries on a near-black
       ground. The literal is the fallback where color-mix() is unavailable. */
    --brand-blue: #5AA6F2;
    --brand-blue: color-mix(in srgb, var(--accent) 45%, #FFFFFF);
    --brand-blue-dark: #8FC4F7;
    --brand-blue-dark: color-mix(in srgb, var(--accent) 25%, #FFFFFF);
    --accent-lift: var(--brand-blue);
  }
}
:root[data-theme="dark"] {
  --ink: #EAF0F7;
  --steel: #8A9AAC;
  --paper: #080B0F;
  --card: #121820;
  --card-2: #171F29;
  --line: #232C37;
  --line-soft: #1B222B;
  --crimson: #F2588C;
  --amber: #E6A53F;
  --green: #4ECB8B;
  --pass-bg: #122C21;
  --fail-bg: #331823;
  --attn-bg: #2E2415;
  --blue-bg: #0F2540;
  --nav-bg: #05080B;
  --nav-ink: #8A9AAC;
  --nav-active-ink: #FFFFFF;
  /* The accent is admin-configurable, so it cannot simply be replaced in dark:
     lift whatever colour the customer chose until it carries on a near-black
     ground. The literal is the fallback where color-mix() is unavailable. */
  --brand-blue: #5AA6F2;
  --brand-blue: color-mix(in srgb, var(--accent) 45%, #FFFFFF);
  --brand-blue-dark: #8FC4F7;
  --brand-blue-dark: color-mix(in srgb, var(--accent) 25%, #FFFFFF);
  --accent-lift: var(--brand-blue);
}

/* ---------- outline ("ghost") icon system ----------
   One inline sprite in index.html; every icon inherits currentColor and takes
   its weight from --stroke, so nav, buttons, and empty states stay consistent
   and nothing is fetched over the network (CSP is script/style 'self'). */
.ico { fill: none; stroke: currentColor; stroke-width: var(--stroke); stroke-linecap: round; stroke-linejoin: round; }
svg.tab-ico { width: 20px; height: 20px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
.hidden { display: none !important; }

/* Content links had no rule at all and were falling back to the browser's
   default #0000EE — unreadable on the dark ground and off-brand on the light
   one. They follow the (theme-lifted) brand colour now. Nav sets its own. */
a { color: var(--brand-blue); text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
a:hover { text-decoration-color: currentColor; }
a:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px; }

/* ---------- header ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20; background: var(--card);
  display: flex; align-items: center; gap: 12px; padding: 10px 16px 0;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 8px; padding-bottom: 8px; }
.brand-mark {
  font-weight: 800; font-size: 26px; letter-spacing: -1.5px; color: var(--brand-blue);
  font-family: "Arial Rounded MT Bold", -apple-system, sans-serif;
}
.brand-name { font-weight: 600; font-size: 17px; color: var(--steel); letter-spacing: .04em; text-transform: uppercase; }
.icon-btn {
  margin-left: auto; margin-bottom: 8px; background: none; border: 1px solid var(--line);
  border-radius: var(--radius); width: 38px; height: 38px; font-size: 18px; color: var(--steel); cursor: pointer;
}
.dotstrip { order: 3; flex-basis: 100%; height: 4px; background: var(--dotgrad); border-radius: var(--radius) 2px 0 0; }

/* ---------- layout ---------- */
.container { max-width: 960px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 8px 0 14px; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 20px 0 10px; color: var(--steel); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.sub { color: var(--steel); font-size: 14px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px;
}
.card.tappable { cursor: pointer; transition: box-shadow .12s; }
.card.tappable:active { box-shadow: 0 0 0 2px var(--brand-blue) inset; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 6px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; border-top: 3px solid var(--line);
}
.tile .n {
  font-size: 30px; font-weight: 900; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; font-family: var(--mono);
}
.tile .l { font-size: 11.5px; color: var(--steel); text-transform: uppercase; letter-spacing: .09em; font-weight: 600; }
.tile.warn .n { color: var(--amber); } .tile.bad .n { color: var(--crimson); } .tile.ok .n { color: var(--brand-blue); }
.tile.warn { border-top-color: var(--amber); }
.tile.bad { border-top-color: var(--crimson); }
.tile.ok { border-top-color: var(--brand-blue); }

/* ---------- forms ---------- */
label.f { display: block; margin: 12px 0 4px; font-size: 13px; font-weight: 600; color: var(--steel); }
input[type=text], input[type=number], input[type=email], input[type=password], input[type=date],
input:not([type]), select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 16px; background: var(--card); color: var(--ink);
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--brand-blue); outline-offset: 1px;
}
textarea { min-height: 80px; resize: vertical; }

.btn {
  display: inline-block; border: none; border-radius: var(--radius); padding: 12px 18px;
  font-size: 15px; font-weight: 700; cursor: pointer; background: var(--brand-blue); color: #fff;
  text-decoration: none; text-align: center;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--card); color: var(--brand-blue); border: 1.5px solid var(--brand-blue); }
.btn.danger { background: var(--crimson); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.block { display: block; width: 100%; }

/* pass/fail segmented control */
.seg { display: flex; border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button {
  flex: 1; border: none; background: var(--card); padding: 11px 0; font-size: 15px; font-weight: 700;
  color: var(--steel); cursor: pointer;
}
.seg button.sel-pass { background: var(--green); color: #fff; }
.seg button.sel-fail { background: var(--crimson); color: #fff; }
.seg button.sel-na { background: var(--steel); color: #fff; }

/* photo capture */
.photo-field { border: 2px dashed var(--line); border-radius: var(--radius); padding: 14px; text-align: center; }
.photo-field.has-photo { border-style: solid; border-color: var(--green); }
.photo-thumbs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.photo-thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }

/* inspection progress dots (signature motif) */
.progress-dots { display: flex; gap: 6px; margin: 10px 0 4px; }
.progress-dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.progress-dots span.done { background: var(--brand-blue); }
.progress-dots span.done:nth-child(4n+2) { background: #4A63AE; }
.progress-dots span.done:nth-child(4n+3) { background: #8A4392; }
.progress-dots span.done:nth-child(4n) { background: var(--crimson); }

/* ---------- badges ---------- */
/* Status chips: squared and outlined so state reads as a shape, not just a
   colour — and so they hold up in both themes without a second palette. */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: var(--radius);
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  border: 1px solid currentColor;
}
.badge.pass { background: var(--pass-bg); color: var(--green); }
.badge.fail { background: var(--fail-bg); color: var(--crimson); }
.badge.attention { background: var(--attn-bg); color: var(--amber); }
.badge.gray { background: var(--card-2); color: var(--steel); }
.badge.blue { background: var(--blue-bg); color: var(--brand-blue-dark); }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.tbl th { text-align: left; padding: 9px 10px; background: var(--card-2); color: var(--steel); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tbl td { padding: 9px 10px; border-top: 1px solid var(--line); }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- tab bar ---------- */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar a {
  flex: 1; text-align: center; padding: 8px 0 6px; font-size: 11px; font-weight: 700;
  color: var(--steel); text-decoration: none; text-transform: uppercase; letter-spacing: .04em;
}
#tabbar a .tab-ico { display: block; font-size: 19px; margin: 0 auto 1px; } /* v155: centred over its label in the bottom bar (the 20px block sat at the left edge); the sidebar rule below overrides */
#tabbar a.active { color: var(--brand-blue); }
#tabbar a.active .tab-ico { transform: translateY(-1px); }

/* ---------- login ---------- */
.login-wrap { max-width: 380px; margin: 8vh auto 0; }
.login-logo { text-align: center; margin-bottom: 8px; }
.login-logo .brand-mark { font-size: 56px; }
.login-dots { height: 6px; background: var(--dotgrad); border-radius: var(--radius); margin: 4px 0 22px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  /* inverts with the theme: --ink/--paper swap, so the toast is always the
     opposite of the page it sits on */
  background: var(--ink); color: var(--paper); padding: 11px 18px; border-radius: var(--radius);
  font-size: 14px; z-index: 50; max-width: 90vw;
}
#toast.err { background: var(--crimson); }

/* form builder */
.fb-field { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin: 8px 0; background: #FAFCFD; }
.fb-field .row { gap: 6px; }
.fb-field input, .fb-field select { padding: 8px 10px; font-size: 14px; }

/* nav extras: hidden on mobile (bottom tab bar), shown in the desktop sidebar */
.side-brand, .side-account { display: none; }

/* ---------- desktop: left sidebar navigation ---------- */
@media (min-width: 900px) {
  #topbar { display: none !important; }
  #tabbar {
    position: fixed; top: 0; bottom: 0; left: 0; right: auto; width: 225px;
    flex-direction: column; align-items: stretch; gap: 2px;
    border-top: 0; border-right: 1px solid var(--line);
    padding: 14px 10px calc(14px + env(safe-area-inset-bottom));
    overflow-y: auto;
  }
  .side-brand { display: block; padding: 2px 8px 14px; }
  .side-brand .brand-chip img { height: 30px; }
  .side-brand-name {
    display: block; margin-top: 6px; font-weight: 700; font-size: 13px;
    color: var(--steel); text-transform: uppercase; letter-spacing: .12em;
  }
  .side-dots { height: 4px; background: var(--dotgrad); border-radius: var(--radius); margin-top: 10px; }
  #tabbar a {
    flex: 0 0 auto; display: flex; align-items: center; gap: 12px; text-align: left;
    padding: 11px 12px; font-size: 11.5px; border-radius: var(--radius); letter-spacing: .07em;
  }
  #tabbar a .tab-ico { display: inline-block; font-size: 18px; margin: 0; width: 22px; text-align: center; }
  #tabbar a.active { background: #E8F2FA; }
  #tabbar a:hover { background: #F1F6FA; }
  .side-account { display: flex !important; margin-top: auto; border-top: 1px solid var(--line); border-radius: 0 !important; padding-top: 14px !important; }
  body { padding-bottom: 24px; }
  main.container { max-width: 1200px; padding: 22px 28px; margin-left: auto; margin-right: auto; }
  body.signed-in main.container { margin-left: 225px; margin-right: 0; }
  h1 { font-size: 26px; }
  #toast { bottom: 32px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- inspection wizard ---- */
.wiz-head { position: sticky; top: 0; background: var(--bg, #f5f7fa); padding: 8px 0 6px; z-index: 5; }
.wiz-bar { height: 6px; background: #dfe6ee; border-radius: var(--radius); margin-top: 6px; overflow: hidden; }
.wiz-bar div { height: 100%; background: linear-gradient(90deg, var(--accent), #22a7e0); border-radius: var(--radius); transition: width .25s ease; }
.wiz-body { min-height: 46vh; display: flex; flex-direction: column; justify-content: flex-start; padding-top: 8px; }
.wiz-choices { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.wiz-choice { font-size: 19px; font-weight: 700; padding: 18px; border-radius: var(--radius); border: 2px solid;
  background: var(--card); cursor: pointer; transition: transform .06s ease; }
.wiz-choice:active { transform: scale(.97); }
.wiz-nav { position: sticky; bottom: 12px; margin-top: 18px; gap: 10px; }
.wiz-nav .btn { padding: 15px; font-size: 16px; }
.wiz-photo { margin-top: 12px; }
.wiz-thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.wiz-thumb { position: relative; }
.wiz-thumb img { width: 104px; height: 104px; object-fit: cover; border-radius: var(--radius); border: 2px solid #dfe6ee; }
.wiz-thumb button { position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: #d64541; color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }

/* ---- maps & search ---- */
.map-box { height: 280px; border-radius: var(--radius); margin-top: 10px; background: #eef2f6; }
.map-tall { height: 62vh; min-height: 380px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.leaflet-popup-content a { color: var(--brand-blue); font-weight: 600; }

/* brand logo */
.brand-chip{display:inline-flex;align-items:center;background:var(--card);border-radius: var(--radius);padding:4px 8px}
.brand-chip img{height:24px;display:block}
.login-logo img{max-width:280px;width:80%;display:block;margin:0 auto 6px}

/* vehicle profile photos */
.v-hero { width: 100%; max-height: 260px; object-fit: cover; border-radius: var(--radius); display: block; margin-bottom: 12px; border: 1px solid var(--line); }
.v-thumb { width: 46px; height: 46px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); flex: 0 0 auto; }

/* driver-only mode: navigation reduced to My Vehicle + Documents + Account
   (v155: Maintenance and Fuel joined the hidden list — a driver has no
   permission on either page, so the tabs were dead ends; the Documents tab
   is shown for driver-only sign-ins by app.js) */
body.driver-mode #tabbar a[data-tab="vehicles"],
body.driver-mode #tabbar a[data-tab="work"],
body.driver-mode #tabbar a[data-tab="issues"],
body.driver-mode #tabbar a[data-tab="inspections"],
body.driver-mode #tabbar a[data-tab="exports"],
body.driver-mode #tabbar a[data-tab="maintenance"],
body.driver-mode #tabbar a[data-tab="fuel"] { display: none !important; }

/* ---------- footer ---------- */
#app-footer {
  text-align: center; color: var(--steel); font-size: 12.5px;
  padding: 22px 16px calc(84px + env(safe-area-inset-bottom));
  opacity: .8;
}
#app-footer strong { color: var(--brand-blue); letter-spacing: .02em; }
@media (min-width: 900px) { #app-footer { padding-bottom: 26px; } }
body.driver-mode #app-footer { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

/* ---------- vehicle profile: consolidated sections + photo rail ---------- */
.vp-expand {
  display: block; width: 100%; border: 1px dashed var(--line); background: none;
  color: var(--brand-blue); font-size: 13.5px; font-weight: 600; padding: 8px;
  border-radius: var(--radius); margin: 2px 0 10px; cursor: pointer;
}
.vp-expand:hover { background: rgba(0,0,0,.03); }
.vp-rail { display: none; }
@media (min-width: 1100px) {
  .vp-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
  .vp-rail { display: block; position: sticky; top: 72px; }
}
.vp-rail-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.vp-rail-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); display: block; }

/* ---------- inspection upload progress ---------- */
.up-bar { height: 10px; background: var(--line); border-radius: var(--radius); overflow: hidden; }
.up-fill {
  height: 100%; width: 0%; background: var(--accent); border-radius: var(--radius);
  transition: width .25s ease;
}
.up-fill.up-working {
  background: repeating-linear-gradient(45deg, var(--accent), var(--accent) 12px,
    var(--accent-dark, var(--accent)) 12px, var(--accent-dark, var(--accent)) 24px);
  background-size: 34px 34px;
  animation: up-slide 1s linear infinite;
}
@keyframes up-slide { to { background-position: 34px 0; } }

a.tile:hover { filter: brightness(0.97); box-shadow: 0 1px 6px rgba(0,0,0,.08); }

/* vehicle group pill — the project it lives in, front and center */
.vp-group {
  display: inline-block; background: var(--accent); color: #fff; text-decoration: none;
  font-size: 14.5px; font-weight: 700; padding: 7px 14px; border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.vp-group:hover { filter: brightness(1.08); }

/* vehicle profile expanded details grid */
.vp-details { display: grid; grid-template-columns: 130px 1fr; gap: 3px 12px; margin-top: 8px; }
.vp-dt { color: var(--steel, #5b6570); font-size: 13px; padding-top: 1px; }
.vp-dd { font-size: 14px; font-weight: 500; word-break: break-word; }
@media (max-width: 560px) { .vp-details { grid-template-columns: 108px 1fr; } }


/* ---------- Console: navigation rail ----------
   The rail is its own dark surface in BOTH themes — it frames the data and
   keeps the app's silhouette recognisable when someone switches to dark. */
#tabbar { background: var(--nav-bg); border-color: var(--line); }
#tabbar a { color: var(--nav-ink); }
#tabbar a.active { background: var(--nav-active-bg); color: var(--nav-active-ink); }
#tabbar a.active .tab-ico { transform: none; }
#tabbar a:focus-visible { outline: 2px solid var(--nav-active-ink); outline-offset: -2px; }
.side-brand-name { color: var(--nav-ink); }

/* mobile tab bar keeps the same rail treatment */
@media (max-width: 899px) {
  #tabbar a { font-size: 10px; letter-spacing: .06em; }
  #tabbar a.active { background: transparent; color: var(--nav-active-ink); box-shadow: inset 0 2px 0 var(--brand-blue); }
}

/* ---------- Console: data display ----------
   Figures line up in columns wherever they are compared. */
.tbl td, .amt, .money, .tile .n { font-variant-numeric: tabular-nums; }
.tbl td { font-family: var(--mono); font-size: 13px; }
.tbl tbody tr + tr td { border-top: 1px solid var(--line-soft); }

/* theme toggle in the footer */
#btn-theme { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
#btn-theme .ico { width: 15px; height: 15px; }

/* Cards and inputs are square now; keep focus obvious without a radius cue. */
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--brand-blue); outline-offset: 1px;
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
