/* Theme color — overridden at boot from admin branding settings */
:root { --accent: #0076BB; --accent-dark: #005A91; }
/* Fleetistry — design tokens (default identity):
   UPA blue var(--accent), ink navy, and the logo's blue→crimson dot matrix as signature. */
:root {
  --upa-blue: var(--accent);
  --upa-blue-dark: var(--accent-dark);
  --ink: #16293B;
  --steel: #5B6B78;
  --paper: #F4F7F9;
  --card: #FFFFFF;
  --line: #DCE4EA;
  --crimson: #C8175D;
  --amber: #C97B12;
  --green: #1E8E5A;
  --radius: 12px;
  --dotgrad: linear-gradient(90deg, var(--accent) 0%, #4A63AE 35%, #8A4392 65%, #C8175D 100%);
}

* { 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; }

/* ---------- 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(--upa-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: 8px; 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: 2px 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(--upa-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; }
.tile .n { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.tile .l { font-size: 12px; color: var(--steel); text-transform: uppercase; letter-spacing: .05em; }
.tile.warn .n { color: var(--amber); } .tile.bad .n { color: var(--crimson); } .tile.ok .n { color: var(--upa-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: 10px;
  font-size: 16px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--upa-blue); outline-offset: 1px;
}
textarea { min-height: 80px; resize: vertical; }

.btn {
  display: inline-block; border: none; border-radius: 10px; padding: 12px 18px;
  font-size: 15px; font-weight: 700; cursor: pointer; background: var(--upa-blue); color: #fff;
  text-decoration: none; text-align: center;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: #fff; color: var(--upa-blue); border: 1.5px solid var(--upa-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: 10px; overflow: hidden; }
.seg button {
  flex: 1; border: none; background: #fff; 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: 8px; 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(--upa-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 ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.badge.pass { background: #E2F3EA; color: var(--green); }
.badge.fail { background: #FAE3EC; color: var(--crimson); }
.badge.attention { background: #FBEEDC; color: var(--amber); }
.badge.gray { background: #EAEFF3; color: var(--steel); }
.badge.blue { background: #E0EFF8; color: var(--upa-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: #EDF2F6; 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-bottom: 1px; }
#tabbar a.active { color: var(--upa-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: 3px; margin: 4px 0 22px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px;
  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: 10px; 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: 2px; margin-top: 10px; }
  #tabbar a {
    flex: 0 0 auto; display: flex; align-items: center; gap: 12px; text-align: left;
    padding: 11px 12px; font-size: 13px; border-radius: 10px; letter-spacing: .05em;
  }
  #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: 3px; margin-top: 6px; overflow: hidden; }
.wiz-bar div { height: 100%; background: linear-gradient(90deg, var(--accent), #22a7e0); border-radius: 3px; 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: 12px; border: 2px solid;
  background: #fff; 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: 10px; 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: 10px; 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(--accent); font-weight: 600; }

/* brand logo */
.brand-chip{display:inline-flex;align-items:center;background:#fff;border-radius:8px;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: 14px; display: block; margin-bottom: 12px; border: 1px solid var(--line); }
.v-thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); flex: 0 0 auto; }

/* driver-only mode: navigation reduced to My Vehicle + Account */
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"] { 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(--accent); 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(--accent); 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: 8px; display: block; }

/* ---------- inspection upload progress ---------- */
.up-bar { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.up-fill {
  height: 100%; width: 0%; background: var(--accent); border-radius: 5px;
  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); }
