/* Courier Performance Portal — palette: dataviz reference instance (validated). */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface-1: #fcfcfb; --surface-2: #ffffff;
  --text-primary: #0b0b0b; --text-secondary: #52514e; --text-muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11,11,11,0.10);
  --series-1: #2a78d6; --accent-ink: #1c5cab;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --neutral-fill: #c3c2b7; --cell-empty: #f0efec; --good-ink: #006300;
  --tip-bg: #0b0b0b; --tip-ink: #f0efec;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d; --surface-1: #1a1a19; --surface-2: #1f1f1e;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10);
    --series-1: #3987e5; --accent-ink: #86b6ef;
    --neutral-fill: #52514e; --cell-empty: #262625; --good-ink: #0ca30c;
    --tip-bg: #f0efec; --tip-ink: #0b0b0b;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--text-primary); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
header.top { display: flex; align-items: center; gap: 20px; padding: 10px 24px; background: var(--surface-1); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
header.top .brand { font-weight: 650; }
header.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
header.top nav a { padding: 6px 10px; border-radius: 6px; color: var(--text-secondary); }
header.top nav a.on { background: var(--cell-empty); color: var(--text-primary); font-weight: 600; }
header.top .who { margin-left: auto; color: var(--text-muted); display: flex; gap: 10px; align-items: center; }
header.top .who button { background: none; border: 0; color: var(--accent-ink); cursor: pointer; font: inherit; padding: 0; }
main { padding: 20px 24px 60px; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.sub { color: var(--text-secondary); margin: 0 0 16px; }
.muted { color: var(--text-muted); }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }

/* filters: one row above the charts */
form.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 16px; }
form.filters select, form.filters input[type=search] { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text-primary); font: inherit; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg a { padding: 6px 10px; color: var(--text-secondary); border-right: 1px solid var(--border); }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--cell-empty); color: var(--text-primary); font-weight: 600; }

/* KPI row */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.tile .label { color: var(--text-secondary); font-size: 12px; }
.tile .value { font-size: 26px; font-weight: 650; margin-top: 2px; }
.tile .note { color: var(--text-muted); font-size: 12px; }
.tile.alert .value::before { content: "▲ "; font-size: 14px; color: var(--critical); vertical-align: 3px; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.me td { background: color-mix(in srgb, var(--series-1) 9%, transparent); font-weight: 600; }
.scroll { overflow-x: auto; }

/* meter (single ratio vs its whole) */
.meter { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.meter .track { flex: 1; height: 8px; background: var(--cell-empty); border-radius: 4px; overflow: hidden; }
.meter .fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.meter .fig { min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }

/* thin segmented bar (status split) — 2px surface gaps between parts */
.segbar { display: flex; gap: 2px; height: 10px; min-width: 140px; }
.segbar span { display: block; height: 100%; }
.segbar span:first-child { border-radius: 4px 0 0 4px; }
.segbar span:last-child { border-radius: 0 4px 4px 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-secondary); font-size: 12px; margin: 4px 0 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.s-delivered { background: var(--good); }
.s-active { background: var(--neutral-fill); }
.s-returned { background: var(--critical); }

/* column chart */
.cols { display: flex; align-items: flex-end; gap: 2px; height: 140px; border-bottom: 1px solid var(--axis); padding-top: 8px; }
.cols .col { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; }
.cols .col span { display: block; width: 100%; background: var(--series-1); border-radius: 4px 4px 0 0; min-height: 0; }
.cols .col:hover span { filter: brightness(1.15); }
.axis-x { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 11px; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* horizontal bars (aging) */
.hbars .row { display: grid; grid-template-columns: 90px 1fr 110px; gap: 8px; align-items: center; margin: 6px 0; position: relative; }
.hbars .bar { height: 14px; background: var(--cell-empty); border-radius: 0 4px 4px 0; }
.hbars .bar span { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.hbars .fig { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); }

/* heatmap */
table.heat td.cell { text-align: center; min-width: 92px; border: 2px solid var(--surface-1); border-radius: 4px; font-variant-numeric: tabular-nums; position: relative; }
table.heat td.cell small { display: block; font-size: 11px; opacity: .85; }
.heat-scale { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 12px; }
.heat-scale .ramp { width: 180px; height: 10px; border-radius: 4px; background: linear-gradient(90deg, #cde2fb, #86b6ef, #3987e5, #1c5cab, #0d366b); }

/* hover tooltips (hit target = whole element) */
[data-tip] { position: relative; }
[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--tip-bg); color: var(--tip-ink); padding: 5px 8px; border-radius: 6px; font-size: 12px; white-space: pre; z-index: 10; pointer-events: none; font-weight: 400; }

/* status pills: icon + label, never color alone */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--cell-empty); color: var(--text-primary); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--neutral-fill); }
.pill.delivered::before { background: var(--good); }
.pill.attempt_failed::before, .pill.unknown::before { background: var(--warning); }
.pill.rto_initiated::before, .pill.rto_in_transit::before, .pill.returned::before { background: var(--serious); }
.pill.lost::before, .pill.damaged::before { background: var(--critical); }
.pill.out_for_delivery::before, .pill.in_transit::before, .pill.at_destination::before, .pill.picked_up::before { background: var(--series-1); }

/* timeline */
ol.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--grid); }
ol.timeline li { padding: 6px 0 10px 16px; position: relative; }
ol.timeline li::before { content: ""; position: absolute; left: -6px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface-1); border: 2px solid var(--series-1); }
ol.timeline .when { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* forms, messages */
.msgs { list-style: none; padding: 0; margin: 0 0 16px; }
.msgs li { padding: 8px 12px; border-radius: 8px; margin-bottom: 6px; background: var(--cell-empty); }
.msgs li.error { border-left: 4px solid var(--critical); }
.msgs li.success { border-left: 4px solid var(--good); }
.msgs li.info { border-left: 4px solid var(--series-1); }
.formgrid p { margin: 0 0 10px; }
.formgrid label { display: block; color: var(--text-secondary); font-size: 12px; margin-bottom: 3px; }
.formgrid input, .formgrid select, .formgrid textarea { width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text-primary); font: inherit; }
.formgrid .helptext { color: var(--text-muted); font-size: 12px; }
button.primary, a.button { display: inline-block; background: var(--series-1); color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.banner { padding: 8px 12px; border-radius: 8px; background: color-mix(in srgb, var(--warning) 22%, transparent); margin-bottom: 14px; }
.banner::before { content: "⚠ "; }
.login { max-width: 360px; margin: 10vh auto; }
