/* ── reset & tokens ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── NTSL brand ── */
  --green:        #1B5E20;   /* primary — deep forest green */
  --green-light:  #2E7D32;   /* hover */
  --green-tint:   #E8F5E9;   /* light green bg */
  --red:          #C62828;   /* accent red */
  --red-light:    #FFEBEE;   /* light red bg */

  /* ── legacy aliases (keep for backward compat) ── */
  --navy:       var(--green);
  --navy-light: var(--green-light);
  --blue:       var(--green);
  --blue-light: var(--green-tint);

  --bg:         #EEF2EE;     /* green-tinted page bg */
  --surface:    #FFFFFF;
  --border:     #DDE8DD;     /* green-tinted border */
  --text:       #1A202C;
  --muted:      #4A6741;     /* green-tinted muted */
  --subtle:     #80A080;     /* green-tinted subtle */

  --available:    #2E7D32;
  --available-bg: #E8F5E9;
  --expiring:     #E65100;
  --expiring-bg:  #FFF3E0;
  --overdue:      #BF360C;
  --overdue-bg:   #FBE9E7;
  --failed:       #B71C1C;
  --failed-bg:    #FFEBEE;
  --missed:       #546E7A;
  --missed-bg:    #ECEFF1;

  --radius:     8px;
  --radius-sm:  4px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,.10);

  /* ── type scale (rem-based, ~1.2 minor-third) — respects user font size ── */
  --fs-3xs:   0.5625rem;   /*  9px — floor: micro-labels (held)  */
  --fs-2xs:   0.625rem;    /* 10px — delta, CTA, card label (held) */
  --fs-xs:    0.625rem;    /* 10px — caption, group label        */
  --fs-sm:    0.6875rem;   /* 11px                               */
  --fs-md:    0.75rem;     /* 12px — split number, section title */
  --fs-lg:    0.875rem;    /* 14px                               */
  --fs-xl:    0.9375rem;   /* 15px — panel / section title       */
  --fs-value: clamp(0.9375rem, 1.1vw + 0.3rem, 1.3125rem);  /* 15→21px fluid headline */

  /* ── chart chrome vs data ── green is reserved for data; chrome is slate ── */
  --fg-axis: #64748B;      /* slate — axes, ticks, counts, axis titles */
  --fg-data: #2E7D32;      /* green — data value labels                */

  --nav-h:      64px;
  --filter-h:   auto;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* ── nav ────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: #ffffff;
  border-bottom: 3px solid var(--green);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.nav__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.nav__logo-img {
  height: 38px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.nav__brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--green);
  letter-spacing: .2px;
}

.nav__divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.nav__portal-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  font-weight: 500;
}

.nav__period {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.nav__period:empty { display: none; }

.nav__spacer { flex: 1; }

.nav__client-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--green-tint);
  border: 1px solid #c8e6c9;
  border-radius: 20px;
  padding: 4px 12px 4px 8px;
}

.nav__client-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-light);
  flex-shrink: 0;
  animation: dot-pulse 2.5s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(46,125,50,.5); }
  60% { opacity: 0.85; box-shadow: 0 0 0 4px rgba(46,125,50,0); }
}

.nav__client-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
}

.nav__logout {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}

.nav__logout:hover {
  color: var(--red);
  background: var(--red-light);
}

.nav__search {
  position: relative;
  flex-shrink: 0;
}

.nav__search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--subtle);
  pointer-events: none;
}

.nav__search input {
  height: 32px;
  padding: 0 28px 0 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  width: 170px;
  transition: border-color .15s, box-shadow .15s;
}

.nav__search input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(27,94,32,.15);
  background: var(--surface);
}

.nav__search input::placeholder { color: var(--subtle); }

.nav__search-clear {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--subtle);
  display: none;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.nav__search-clear.visible { display: block; }
.nav__search-clear:hover { color: var(--text); }

/* ── main layout ─────────────────────────────────────────────────── */
.main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ── filter bar ──────────────────────────────────────────────────── */
.filter-search {
  position: relative;
  flex-shrink: 0;
  margin-left: auto;     /* push search + clear to the right edge of the row */
}

.filter-search__icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--subtle);
  pointer-events: none;
}

.filter-search input {
  height: 32px;
  padding: 0 28px 0 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  width: 132px;
  transition: border-color .15s, box-shadow .15s;
}

.filter-search input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(27,94,32,.15);
  background: var(--surface);
}

.filter-search input::placeholder { color: var(--subtle); }

.filter-search__clear {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--subtle);
  display: none;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.filter-search__clear.visible { display: block; }
.filter-search__clear:hover   { color: var(--text); }

.filter-bar {
  background: var(--surface);
  border: none;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.04);
  padding: 9px 16px;
  margin-bottom: 14px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;       /* wraps only on truly narrow / portrait widths */
}

.filter-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 2px;
}

.filter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  white-space: nowrap;
  min-width: 90px;
}


/* period select */
.filter-select {
  height: 34px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 8px center;
  appearance: none;
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
  min-width: 108px;
}

.filter-select--sm { min-width: 90px; }

.filter-select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(27,94,32,.15);
  background-color: var(--surface);
}

/* date filter group */
.date-filter-group {
  display: contents;
}

.date-filter-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  white-space: nowrap;
}

.date-type-select {
  min-width: 112px !important;
}

.filter-date-input {
  height: 34px;
  width: 116px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
}

.filter-date-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(27,94,32,.15);
  background: var(--surface);
}

.date-presets {
  display: flex;
  gap: 4px;
}

.date-preset {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--bg);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}

.date-preset:hover { border-color: var(--green); color: var(--green); }

.date-preset.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

/* status multi-select dropdown */
.status-dropdown {
  position: relative;
  flex-shrink: 0;
}

.status-dropdown__btn {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: border-color .15s;
  min-width: 108px;
}

.status-dropdown__btn:hover,
.status-dropdown__btn:focus { border-color: var(--green); outline: none; }

.status-dropdown__panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  min-width: 200px;
  z-index: 200;
  padding: 6px 0;
}

.status-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background .1s;
}

.status-option:hover { background: var(--bg); }

.status-option input[type=checkbox] {
  accent-color: var(--green);
  cursor: pointer;
  flex-shrink: 0;
}

.status-option__count {
  margin-left: auto;
  font-size: 11px;
  color: var(--subtle);
}

/* colored dot (reused inside status dropdown panel) */
.chip__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chip__dot--available { background: var(--available); }
.chip__dot--expiring  { background: var(--expiring);  }
.chip__dot--overdue   { background: var(--overdue);   }
.chip__dot--failed    { background: var(--failed);    }
.chip__dot--missed    { background: var(--missed);    }

/* clear all */
.filter-clear {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--green);
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  white-space: nowrap;
  font-weight: 500;
  display: none;
}

.filter-clear.visible { display: block; }
.filter-clear:hover { text-decoration: underline; }

/* active filter count badge */
.filter-bar__active-count {
  font-size: 11px;
  background: var(--green);
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-weight: 600;
  display: none;
}

.filter-bar__active-count.visible { display: inline-block; }

/* ── placeholder sections ───────────────────────────────────────── */
.section-placeholder {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--subtle);
  font-size: 13px;
  margin-bottom: 20px;
}

.section-placeholder strong {
  display: block;
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 4px;
}

/* ── KPI strip ──────────────────────────────────────────────────── */
/* §1 section container + title rule */
.kpi-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid #E6ECE8;
}

.kpi-header__title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.kpi-header__date {
  font-size: var(--fs-sm);
  color: var(--subtle);
}

.kpi-groups {
  display: flex;
  flex-wrap: wrap;            /* responsive: groups wrap instead of squeezing */
  align-items: stretch;
  gap: 12px;
}

/* §2 per-group panels with muted tint + colored label */
.kpi-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid #ECECEC;
  border-radius: 14px;
  padding: 12px 12px 11px;
  box-shadow: 0 1px 2px rgba(16,24,40,0.04), 0 6px 16px rgba(16,24,40,0.05);
}

/* flex-basis sets the wrap point: 3-up wide, then reflows on narrower / portrait */
.kpi-group--coverage    { flex: 3 1 330px; background: linear-gradient(180deg,#F2F7FB 0%,#FFFFFF 46%); }
.kpi-group--compliance  { flex: 3 1 330px; background: linear-gradient(180deg,#F1F8F3 0%,#FFFFFF 46%); }
.kpi-group--performance { flex: 2 1 250px; background: linear-gradient(180deg,#FBF6F0 0%,#FFFFFF 46%); }

.kpi-group__label {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 8px;
  white-space: nowrap;
}

.kpi-group--coverage    .kpi-group__label { color: #3B6EA5; }
.kpi-group--compliance  .kpi-group__label { color: #2F855A; }
.kpi-group--performance .kpi-group__label { color: #B7791F; }

/* old vertical dividers removed — panels provide separation */
.kpi-group__sep { display: none; }

.kpi-cards {
  display: grid;
  gap: 10px;
  flex: 1;
  align-items: stretch;
}

.kpi-cards--coverage    { grid-template-columns: repeat(3, 1fr); }
.kpi-cards--compliance  { grid-template-columns: 1.4fr 1fr 1fr; }
.kpi-cards--performance { grid-template-columns: 1fr 1.4fr; }

/* §3 white cards, light depth, equal height (capped compact) */
.kpi-card {
  position: relative;
  background: #fff;
  border: 1px solid #F0F0F0;
  border-radius: 12px;
  padding: 11px 12px 10px;
  box-shadow: 0 1px 2px rgba(16,24,40,0.05);
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: box-shadow .18s ease, transform .18s ease;
  cursor: default;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(16,24,40,.08), 0 10px 24px rgba(16,24,40,.07);
}

.kpi-card--clickable { cursor: pointer; }

/* §5 state accents — driven by value, not label */
.kpi-card--state-alert {
  border-color: rgba(220,38,38,0.25);
}
.kpi-card--state-alert::before {
  content: "";
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
  background: linear-gradient(180deg,#ef4444,#dc2626);
}
.kpi-card--state-alert:hover  { box-shadow: 0 4px 8px rgba(0,0,0,.07), 0 10px 24px rgba(220,38,38,.18); }
.kpi-card--state-alert .kpi-sub { color: #dc2626; font-weight: 600; }

.kpi-card--state-warn {
  border-color: rgba(183,121,31,0.25);
}
.kpi-card--state-warn::before {
  content: "";
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
  background: linear-gradient(180deg,#ED8936,#B7791F);
}
.kpi-card--state-warn:hover  { box-shadow: 0 4px 8px rgba(0,0,0,.07), 0 10px 24px rgba(183,121,31,.16); }

.kpi-card__top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 16px;     /* clears the absolute info icon so the label can wrap */
}

/* §4a icon chip — applied to all cards, color follows state (§5) */
.kpi-chip {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #EFF1F0;
  color: #5C6B62;
}

.kpi-chip svg { width: 17px; height: 17px; }

.kpi-chip--neutral { background: #EFF1F0; color: #5C6B62; }
.kpi-chip--healthy { background: #E7F3EA; color: #2F855A; }
.kpi-chip--alert   { background: #FEE2E2; color: #DC2626; }
.kpi-chip--warn    { background: #FBEEDC; color: #B7791F; }

/* ── Fit for Road split sub-row ─────────────────────────────────── */
.kpi-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-top: 1px;
}

.kpi-split__cell {
  border-radius: 6px;
  padding: 4px 6px;
  min-width: 0;
}

.kpi-split__cell--valid    { background: var(--available-bg); }
.kpi-split__cell--expiring { background: var(--expiring-bg);  }

.kpi-split__num {
  font-size: var(--fs-md);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.kpi-split__cell--valid    .kpi-split__num { color: var(--available); }
.kpi-split__cell--expiring .kpi-split__num { color: var(--expiring);  }

.kpi-split__lbl {
  font-size: var(--fs-3xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* §7 / §10 — allow label to wrap so "INSP. RATE" / "TOTAL TRUCKS" never truncate */
.kpi-label {
  font-size: var(--fs-2xs);
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  line-height: 1.25;
  min-width: 0;
}

/* §4 body zone — value left-aligned; grows + vertically centers so the
   equal-height slack splits evenly instead of pooling at the bottom (c) */
.kpi-card__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 3px;
}

/* split cards (Fit for Road) keep the value at the top, split fills below */
.kpi-card--split .kpi-card__body { flex: 0 0 auto; justify-content: flex-start; }

/* caption line — holds the sub-text and the delta badge (b) */
.kpi-card__cap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* §7 — value is constant: dark, never recolored by state */
.kpi-value {
  font-size: var(--fs-value);
  font-weight: 700;
  color: #1A202C;
  line-height: 1.0;
  font-family: 'Inter', -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.kpi-sub {
  font-size: var(--fs-xs);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-sub--positive { color: var(--available); font-weight: 600; }
.kpi-sub--negative { color: var(--failed);    font-weight: 600; }

/* §6 delta badge — sits inline on the caption line, after the sub-text (b) */
.kpi-delta {
  font-size: var(--fs-2xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  line-height: 1.4;
  flex-shrink: 0;
}

.kpi-delta--positive { color: #2F855A; background: #E7F3EA; }
.kpi-delta--negative { color: #DC2626; background: #FEE2E2; }

.kpi-card__foot-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 16px;
}

/* §4 footer — bottom-anchored so all footers align across the row */
.kpi-card__foot {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}

.kpi-cta {
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--green);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-align: left;
  white-space: nowrap;
}

.kpi-cta:hover { text-decoration: underline; }

.kpi-cta--muted {
  font-size: var(--fs-2xs);
  color: var(--available);
  font-weight: 500;
}

.kpi-cta--active {
  color: var(--failed);
}

/* Info icon on KPI card — out of flow so it never steals label width (a) */
.kpi-info {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--subtle);
  display: inline-flex;
  align-items: center;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}

.kpi-info svg { width: 12px; height: 12px; }

.kpi-card:hover .kpi-info { opacity: 1; color: var(--green); }

.kpi-card[data-tip-title] { cursor: help; }
.kpi-card--clickable[data-tip-title] { cursor: pointer; }

/* KPI tooltip (body-attached, fixed positioning) */
.kpi-tooltip {
  position: fixed;
  z-index: 300;
  background: #1a202c;
  color: #fff;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 6px 20px rgba(0,0,0,.22);
  max-width: 280px;
  pointer-events: none;
}

.kpi-tooltip[hidden] { display: none; }

.kpi-tt-title {
  font-weight: 700;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,.18);
  padding-bottom: 5px;
}

.kpi-tt-body {
  color: rgba(255,255,255,.9);
  font-weight: 400;
}

.kpi-tt-body strong { color: #6ee7b7; }

/* Road-worthy summary strip */
.kpi-roadworthy {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border-left: 4px solid var(--available);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 14px rgba(46,125,50,.08);
}

.kpi-rw__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--available);
  flex-shrink: 0;
}

.kpi-rw__icon svg { width: 16px; height: 16px; }

.kpi-rw__count {
  font-size: 22px;
  font-weight: 700;
  color: var(--available);
  line-height: 1;
}

.kpi-rw__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
}

.kpi-rw__split {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}

.kpi-sparkline {
  height: 26px;
  width: 72px;
  flex-shrink: 0;
  margin-left: auto;
}

.kpi-gauge-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0 0;
}

.kpi-gauge {
  width: 62px;
  height: 62px;
  flex-shrink: 0;
}

/* §4b — Fleet Health gauge card: center body + caption to match the radial gauge */
.kpi-card--gauge .kpi-card__body { justify-content: center; align-items: center; }
.kpi-card--gauge .kpi-card__foot-row {
  justify-content: center;
  text-align: center;
}
.kpi-card--gauge .kpi-sub { white-space: normal; }
.kpi-card--gauge .kpi-card__foot { justify-content: center; }
.kpi-card--gauge .kpi-sparkline { margin-left: 0; }

/* ── loading state ──────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px;
  color: var(--muted);
  font-size: 14px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── trend chart ────────────────────────────────────────────────── */
.kpi-strip {
  background: #F7FAF8;
  border: 1px solid #E6ECE8;
  border-radius: 16px;
  padding: 14px 18px 16px;
  margin-bottom: 16px;
}

.trend-section {
  background: var(--surface);
  border: none;
  border-radius: 12px;
  padding: 20px 32px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.04);
}

.trend-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.trend-title {
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--text);
}

.trend-sub {
  font-size: 12px;
  color: var(--subtle);
}

.trend-wrap {
  width: 100%;
  overflow-x: auto;
  position: relative;
}

.trend-axis-lbl {
  font-size: var(--fs-xs);
  fill: var(--fg-axis);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.trend-tooltip {
  position: absolute;
  pointer-events: none;
  background: #1a202c;
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  z-index: 50;
  min-width: 160px;
  transform: translate(0, -100%);
}

.trend-tooltip[hidden] { display: none; }

.trend-tt-title {
  font-weight: 600;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,.18);
  padding-bottom: 4px;
}

.trend-tt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: rgba(255,255,255,.85);
}

.trend-tt-row strong { color: #fff; font-weight: 600; }

.trend-svg {
  display: block;
  width: 100%;
  min-width: 480px;
  height: auto;
}

.trend-tick {
  font-size: var(--fs-sm);
  fill: var(--fg-axis);
  font-weight: 500;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.trend-xlbl {
  font-size: 10px;
}

.trend-pnum {
  font-size: 9px;
  fill: var(--subtle);
}

.trend-target-lbl {
  font-size: 10px;
  fill: var(--available);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
}

.trend-val-lbl {
  font-size: var(--fs-xs);
  fill: var(--fg-data);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
}

.trend-bar { cursor: pointer; transition: opacity 0.15s; }
.trend-bar:hover { opacity: 0.85 !important; }

.trend-bar-lbl {
  font-size: var(--fs-3xs);
  fill: var(--fg-axis);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
}

.trend-strip-lbl {
  font-size: var(--fs-xs);
  fill: var(--fg-axis);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.trend-dot {
  cursor: pointer;
  transition: r 0.15s;
}

.trend-dot:hover { r: 6; }

.trend-empty {
  text-align: center;
  color: var(--subtle);
  padding: 40px 0;
  font-size: 13px;
}

/* ── truck table ────────────────────────────────────────────────── */
.truck-section {
  background: var(--surface);
  border: none;
  border-radius: 12px;
  padding: 20px 24px 4px;
  margin-bottom: 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.04);
}

.truck-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.truck-export {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  background: var(--surface);
  border: 1px solid var(--green);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.truck-export:hover {
  background: var(--green);
  color: #fff;
}

.truck-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.truck-filter-banner {
  font-size: 12px;
  color: var(--muted);
  background: var(--green-tint);
  border-left: 3px solid var(--green);
  padding: 7px 12px;
  margin-bottom: 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.truck-filter-banner__note {
  color: var(--subtle);
}

.truck-count {
  font-size: 12px;
  color: var(--subtle);
}

.truck-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.truck-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.truck-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--subtle);
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.truck-table tbody tr {
  border-bottom: 1px solid var(--border);
}

.truck-table tbody tr:last-child { border-bottom: none; }

.truck-row td {
  padding: 10px 10px;
  height: 54px;
  vertical-align: middle;
  color: var(--text);
}

.truck-row--expandable { cursor: pointer; }
.truck-row--expandable:hover { background: var(--bg); }

.th-sortable {
  cursor: pointer;
  user-select: none;
}

.th-sortable:hover { color: var(--green); }

.th-arrow {
  margin-left: 4px;
  font-size: 10px;
  color: var(--green);
}

.th-arrow--off {
  color: var(--subtle);
  opacity: 0.5;
}

.truck-model {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.truck-reg {
  font-weight: 600;
  font-family: 'Fira Code', ui-monospace, "Cascadia Code", monospace;
  font-size: 12px;
  white-space: nowrap;
}

.truck-score-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.truck-score-val {
  min-width: 32px;
  font-weight: 600;
  font-size: 13px;
}

.truck-hbar-wrap {
  width: 56px;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.truck-hbar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.truck-cert { text-align: center; }

.truck-advisor {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.truck-systems { max-width: 240px; }

.truck-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--green-tint);
  color: var(--green);
  margin: 2px 2px 2px 0;
  white-space: nowrap;
}

.truck-tag--more {
  background: var(--border);
  color: var(--muted);
  font-weight: 600;
}

.truck-none { color: var(--subtle); }

.truck-expiring { color: var(--expiring); font-weight: 600; }

/* IA expand row */
.truck-ia-row td { padding: 0; }
.truck-ia-cell {
  padding: 8px 16px 12px 40px;
  background: var(--bg);
  border-top: 1px dashed var(--border);
}

.truck-ia-list {
  margin: 0;
  padding-left: 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
}

/* badges */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
}

.badge--available  { background: var(--available-bg);  color: var(--available); }
.badge--failed     { background: var(--failed-bg);     color: var(--failed); }
.badge--overdue    { background: var(--overdue-bg);    color: var(--overdue); }
.badge--expiring   { background: var(--expiring-bg);   color: var(--expiring); }
.badge--missed     { background: var(--missed-bg);     color: var(--missed); }

.badge--risk { letter-spacing: 0.02em; }
.risk-high { background: var(--failed-bg);    color: var(--failed); }
.risk-med  { background: var(--expiring-bg);  color: var(--expiring); }
.risk-low  { background: var(--available-bg); color: var(--available); }

/* ── slide-out panel ────────────────────────────────────────────── */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
}

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  min-width: 380px;
  background: var(--surface);
  box-shadow: -4px 0 40px rgba(0,0,0,0.6);
  z-index: 201;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel[hidden], .panel-overlay[hidden] { display: none; }

.panel__header {
  position: relative;
  padding: 20px 48px 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.panel__header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.panel__reg {
  font-size: 18px;
  font-weight: 700;
  font-family: 'Fira Code', ui-monospace, "Cascadia Code", monospace;
  color: var(--text);
}

.panel__brand {
  font-size: 13px;
  color: var(--muted);
}

.panel__header-sub {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
}

.panel__close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--subtle);
  line-height: 1;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
}

.panel__close:hover { background: var(--border); color: var(--text); }

.panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 32px;
}

.panel__section {
  padding: 18px 24px 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
}

.panel__section:last-child { border-bottom: none; }

.panel__section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--subtle);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel__section-date {
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
}

.panel__trend-svg {
  display: block;
  width: 100%;
  height: auto;
}

.panel__ia-systems {
  margin-bottom: 10px;
}

.panel__ia-list {
  margin: 0;
  padding-left: 16px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.9;
}

.panel__ia-list--spaced li { margin-bottom: 2px; }

.panel__none {
  font-size: 13px;
  color: var(--subtle);
  margin: 0;
}

.panel__hist-wrap { overflow-x: auto; }

.panel__hist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.panel__hist-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--subtle);
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.panel__hist-table tbody tr { border-bottom: 1px solid var(--border); }
.panel__hist-table tbody tr:last-child { border-bottom: none; }
.panel__hist-table tbody td { padding: 8px 8px; vertical-align: middle; }

.panel__hist-period { font-size: 12px; color: var(--muted); }
.panel__hist-center { text-align: center; }
.panel__hist-ia     { color: var(--failed); font-weight: 600; }
.panel__hist-ok     { color: var(--available); }

.panel__cert--ok   { color: var(--available); font-weight: 700; }
.panel__cert--fail { color: var(--failed);    font-weight: 700; }

/* period tabs */
.panel__period-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.panel__period-tab {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.panel__period-tab:hover { background: var(--green-tint); color: var(--green); }

.panel__period-tab--active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.panel__period-tab--has-ia { border-color: var(--expiring); }
.panel__period-tab--active.panel__period-tab--has-ia { background: var(--green); border-color: var(--green); }

/* issues meta row */
.panel__issues-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 12px;
}

.panel__issues-date { color: var(--muted); }

.panel__issues-counts { display: flex; gap: 10px; font-weight: 600; }
.panel__issues-ia  { color: var(--failed); }
.panel__issues-fa  { color: var(--expiring); }
.panel__issues-ok  { color: var(--available); }

.panel__issues-note {
  font-size: 11px;
  color: var(--subtle);
  margin-top: 10px;
}

/* history legend */
.panel__hist-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

/* active history row */
.panel__hist-row--active { background: var(--green-tint); }

.panel__section-note {
  font-size: 10px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--subtle);
}

.truck-row--clickable { cursor: pointer; }
.truck-row--clickable:hover { background: var(--bg); }

/* ── responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .panel { width: 100%; min-width: unset; }
  .main { padding: 12px 16px 32px; }

  .nav__portal-label,
  .nav__divider { display: none; }

  .filter-search input { width: 160px; }

  .filter-label { min-width: 70px; }

  .filter-select { min-width: 110px; }
}

@media (max-width: 480px) {
  .nav__client-badge { display: none; }
  .filter-row { gap: 6px; }
  .status-dropdown__btn { min-width: 110px; font-size: 12px; }
}
