/* The national dashboard's styles (docs/dashboard.html), shared with the
   public national dashboard (docs/public-dashboard.html) so the two look
   the same. Moved here unchanged from dashboard.html's own <style>. */
:root{
  --navy:#0b2d52; --navy-2:#123a68; --blue-3:#1d5fa8; --blue-4:#2e86de;
  --panel:#ffffff; --bg:#eef1f5; --ink:#132238; --muted:#5c6b80; --line:#d9e0ea;
  --vl:#4472c4; --eid:#ed7d31; --tb:#a5a5a5; --tb-dark:#636363;
  --red:#c0202f; --red-bg:#fdeceb;
  --green:#1e8f4e; --green-bg:#e8f6ee;
  --amber:#b8860b; --amber-bg:#fdf3dc;
  --radius:12px;
}
*{box-sizing:border-box;}
body{ margin:0; font-family:'Segoe UI', system-ui, -apple-system, sans-serif; background:var(--bg); color:var(--ink); font-weight:600; }
header{
  background:linear-gradient(120deg,var(--navy) 0%,var(--blue-3) 55%,var(--blue-4) 130%);
  color:#fff; padding:16px 26px; display:grid; grid-template-columns:1fr auto 1fr;
  align-items:center; gap:18px; box-shadow:0 4px 18px rgba(8,30,58,.25); position:relative; z-index:20;
}
.brand-logos{ display:flex; align-items:center; gap:14px; }
.brand-logos.right{ justify-content:flex-end; }
.brand-logos img{ height:78px; width:78px; object-fit:contain; background:#fff; border-radius:12px; padding:6px; box-shadow:0 2px 8px rgba(0,0,0,.18); }
.brand-logos img.wide{ width:auto; max-width:235px; height:70px; }
header .title-block{ text-align:center; }
header .title-block h1{ font-size:30px; letter-spacing:1.8px; margin:0; font-weight:900; text-shadow:0 2px 8px rgba(0,0,0,.18); }
header .sub{ font-size:14px; opacity:.95; margin-top:5px; font-weight:800; letter-spacing:.7px; text-transform:uppercase; }
@media (max-width:900px){ header{grid-template-columns:1fr;text-align:center;} .brand-logos, .brand-logos.right{justify-content:center;} }

main{ padding:18px 20px 44px; max-width:1800px; margin:0 auto; }

.section-header{ display:flex; align-items:center; gap:12px; margin:26px 0 12px; }
.section-header:first-of-type{ margin-top:8px; }
.section-header h2{ font-size:17px; font-weight:900; letter-spacing:.6px; text-transform:uppercase; color:var(--navy); margin:0; }
.section-header.reject h2{ color:var(--red); }
.section-header .bar{ height:4px; flex:1; border-radius:2px; background:linear-gradient(90deg,var(--navy),transparent); }
.section-header.reject .bar{ flex:2; background:linear-gradient(90deg,var(--red),transparent); }
/* Sample Rejections and Supplies/Commodities share one header line --
   the red bar ends about 2/3 across (flex:2, matching the 2 rejection
   panels) and the black one picks up from there (flex:1, matching the
   1 commodities panel) instead of dropping to a second line. */
.section-header.reject h2.supplies-label{ color:#000; font-weight:900; white-space:nowrap; }
.section-header .bar.supplies{ flex:1; background:linear-gradient(90deg,#000,transparent); }

.filter-panel{ background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:14px 16px; box-shadow:0 2px 10px rgba(8,30,58,.06); }
.filter-panel.reject-panel{ border:1.5px solid var(--red); }
.filter-panel-title{ font-size:12px; font-weight:900; text-transform:uppercase; letter-spacing:.6px; color:var(--navy); margin-bottom:10px; }
.filter-panel.reject-panel .filter-panel-title{ color:var(--red); }
.filters-row{ display:flex; gap:12px; flex-wrap:wrap; align-items:end; }
.filter-field{ display:flex; flex-direction:column; gap:4px; }
.filter-field > label{ font-size:11px; text-transform:uppercase; letter-spacing:.5px; color:var(--muted); font-weight:800; }
.reset-btn{ align-self:end; background:var(--navy); color:#fff; border:none; border-radius:7px; padding:9px 16px; font-size:13.5px; cursor:pointer; font-weight:800; }
.reset-btn:hover{ background:var(--navy-2); }
.reject-panel .reset-btn{ background:var(--red); }
.reject-panel .reset-btn:hover{ background:#96181f; }

/* collapsible wrapper around the filters, so they can be tucked away once set */
.filters-collapsible{ margin-bottom:4px; }
.filters-toggle-btn{
  display:flex; align-items:center; gap:8px; width:100%; text-align:left;
  background:var(--panel); border:1px solid var(--line); border-radius:8px;
  padding:9px 14px; font-size:13px; font-weight:800; color:var(--navy); cursor:pointer;
  box-shadow:0 1px 6px rgba(8,30,58,.05);
}
.filters-toggle-btn:hover{ border-color:var(--blue-3); }
.filters-toggle-btn .chevron{ display:inline-block; transition:transform .15s; }
.filters-toggle-btn.expanded .chevron{ transform:rotate(90deg); }
.filter-badge{ background:var(--blue-4); color:#fff; border-radius:10px; padding:1px 8px; font-size:11px; font-weight:800; }

/* side-by-side transport + rejection filters, shrunk to fit on one row */
.filters-side-by-side{ display:flex; gap:14px; flex-wrap:wrap; margin-top:10px; }
.filters-side-by-side.collapsed{ display:none; }
.filters-side-by-side > .filter-panel{ flex:1 1 380px; min-width:0; }
.filter-panel.compact{ padding:10px 12px; }
.filter-panel.compact .filters-row{ gap:8px; }
.filter-panel.compact .filter-panel-title{ font-size:11px; margin-bottom:7px; }
.filter-panel.compact .filter-field > label{ font-size:9.5px; }
.filter-panel.compact .cb-dropdown{ min-width:100px; }
.filter-panel.compact .cb-btn{ padding:6px 8px; font-size:11.5px; }
.filter-panel.compact .date-stack input[type=date]{ min-width:100px; padding:5px 6px; font-size:11px; }
.filter-panel.compact .reset-btn{ padding:7px 10px; font-size:12px; }

/* stacked date field: From above To */
.date-stack{ display:flex; flex-direction:column; gap:4px; }
.date-stack .date-row{ display:flex; align-items:center; gap:6px; }
.date-stack .date-row span{ font-size:10px; color:var(--muted); font-weight:800; width:30px; }
.date-stack input[type=date]{ padding:6px 8px; border:1px solid var(--line); border-radius:7px; font-size:12.5px; font-weight:600; min-width:135px; background:#fbfcfe; color:var(--ink); }

/* checkbox multi-select dropdown */
.cb-dropdown{ position:relative; min-width:150px; }
.cb-btn{ width:100%; text-align:left; padding:8px 10px; border:1px solid var(--line); border-radius:7px; background:#fbfcfe; font-size:13px; font-weight:700; cursor:pointer; display:flex; justify-content:space-between; align-items:center; gap:6px; }
.cb-btn:hover{ border-color:var(--blue-3); }
.cb-btn .caret{ font-size:10px; opacity:.6; }
.cb-panel{ display:none; position:absolute; top:calc(100% + 4px); left:0; z-index:30; background:#fff; border:1px solid var(--line); border-radius:8px; box-shadow:0 8px 24px rgba(8,30,58,.18); padding:8px; min-width:220px; max-height:260px; overflow-y:auto; }
.cb-panel.open{ display:block; }
.cb-item{ display:flex; align-items:center; gap:8px; padding:5px 6px; font-size:13px; font-weight:600; border-radius:5px; cursor:pointer; white-space:nowrap; }
.cb-item:hover{ background:var(--bg); }
.cb-item input{ cursor:pointer; }
.cb-ok-btn{ width:100%; margin-top:6px; background:var(--navy); color:#fff; border:none; border-radius:6px; padding:6px 10px; font-size:12px; font-weight:800; cursor:pointer; }

main .kpi-row{ display:grid; grid-template-columns:repeat(auto-fit, minmax(130px,1fr)); gap:10px; margin-bottom:18px; }
.kpi{ background:var(--blue-4); border:1px solid var(--blue-3); border-radius:var(--radius); padding:14px 10px; text-align:center; box-shadow:0 2px 10px rgba(8,30,58,.12); }
.kpi .val{ font-size:25px; font-weight:900; color:#ffffff; }
.kpi .lbl{ font-size:11px; color:#ffffff; opacity:.92; text-transform:uppercase; letter-spacing:.4px; margin-top:5px; line-height:1.3; font-weight:800; }
.kpi.alert{ background:var(--red-bg); border-color:#f3c6c6; }
.kpi.alert .val{ color:var(--red); }
.kpi.alert .lbl{ color:#7a0f1a; opacity:1; }

.transport-grid{ display:grid; grid-template-columns:0.9fr 0.9fr 1.35fr; grid-template-rows:auto auto; gap:14px; }
@media (max-width:1150px){ .transport-grid{ grid-template-columns:1fr; } }
.tat-pair{ display:flex; gap:10px; min-width:0; }
.tat-pair .panel{ flex:1; min-width:0; }

.pie-pair{ display:flex; gap:8px; min-width:0; flex:1; }
.pie-pair-item{ flex:1; min-width:0; display:flex; flex-direction:column; align-items:center; }
.pie-pair-label{ font-size:11.5px; font-weight:800; color:var(--muted); text-transform:uppercase; letter-spacing:.3px; margin-bottom:2px; }
.pie-pair canvas{ width:100% !important; max-height:420px; }
.pie-pair-legend{ display:flex; justify-content:center; gap:16px; margin-top:4px; }
.pie-legend-item{ display:inline-flex; align-items:center; gap:5px; font-size:12px; font-weight:700; color:var(--ink); }
.pie-legend-swatch{ width:12px; height:12px; border-radius:3px; display:inline-block; }

.grid{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:14px; }
@media (max-width:1100px){ .grid{grid-template-columns:1fr;} }

.panel{ background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:14px; display:flex; flex-direction:column; box-shadow:0 2px 10px rgba(8,30,58,.06); min-width:0; }
.panel.reject-outline{ border:2px solid var(--red); }
.panel.transport-outline{ border:2px solid var(--blue-4); }
.panel.neutral-outline{ border:2px solid #000; }
.panel h3{ font-size:13.5px; margin:0 0 8px; text-transform:uppercase; letter-spacing:.4px; color:var(--navy); font-weight:900; text-align:center; }
.panel.reject-outline h3{ color:var(--red); }
.panel.transport-outline h3{ color:var(--blue-4); }
.panel.neutral-outline h3{ color:#000; font-weight:900; }
.panel canvas{ width:100% !important; max-height:250px; }
.panel.tall canvas{ max-height:300px; }
/* Pulls these 3 charts' own built-in Chart.js legend row up against the
   h3 title -- each chart reserves blank canvas space above its legend
   (layout.padding.top, in its own render function) purely as headroom
   for the tallest bar's rotated value label, which otherwise clips
   against the canvas edge. That reserved space reads as a gap between
   the title and the legend; this negative margin closes it without
   touching the padding the label headroom still depends on. Matches the
   value dashboard-print.html already uses for the same two charts. */
#chartSamplesByRegion, #chartResultsByRegion, #chartRejectedByRegion{ margin-top:-24px; }
.panel.compact canvas{ max-height:280px; }
.panel.compact h3{ font-size:13.5px; }
/* 260px, not the old 190px -- matches this row's actual height, driven
   by its taller row-mates (the combined pie box: 240px canvas + ~24px
   legend row; the Other Samples & Results table: 250px). The old 190px
   cap left real empty space below the chart while also squeezing the
   legend and plotted lines into too little room at the top.
   (flex:1/max-height:none was tried here first and made the canvas grow
   without bound instead -- grid's "auto" row sizing has no fixed height
   to measure against once the canvas itself no longer has one, so it and
   Chart.js's own responsive resize kept inflating each other. A concrete
   number avoids that feedback loop entirely.) */
.panel.small canvas{ max-height:260px; }

.no-data-msg{
  display:none; flex:1; align-items:center; justify-content:center; text-align:center;
  font-size:12.5px; font-weight:700; color:var(--muted); padding:20px 10px;
  background:var(--bg); border-radius:8px; border:1px dashed var(--line);
}
.no-data-msg.show{ display:flex; }

.table-scroll{ max-height:250px; overflow-y:auto; }
table.other-items-table{ width:100%; border-collapse:collapse; font-size:12.5px; }
table.other-items-table thead th{
  position:sticky; top:0; background:var(--navy); color:#fff; text-transform:uppercase;
  letter-spacing:.3px; font-size:11px; font-weight:800; padding:7px 10px; text-align:left;
}
table.other-items-table thead th.num{ text-align:right; }
table.other-items-table tbody td{ padding:6px 10px; border-bottom:1px solid var(--line); font-weight:600; color:var(--ink); }
table.other-items-table tbody tr:nth-child(even){ background:var(--bg); }
table.other-items-table tbody td.num{ text-align:right; font-variant-numeric:tabular-nums; font-weight:800; }
table.other-items-table tbody tr.total td{ background:var(--navy); color:#fff; font-weight:900; }
.kpi .sub-note{ font-size:9.5px; font-weight:700; color:var(--muted); opacity:.75; margin-top:2px; }

footer{ text-align:center; font-size:12px; color:var(--muted); padding:16px 0 26px; font-weight:700; }

/* ---------- app shell / left nav (shared across index.html, dashboard.html, factsheet.html) ---------- */
.app-shell{ display:flex; align-items:stretch; min-height:100vh; }
.app-sidebar{
  flex:none; width:222px; background:var(--navy); color:#fff;
  display:flex; flex-direction:column; padding:18px 0; position:sticky; top:0; height:100vh; z-index:30; overflow-y:auto;
}
.app-sidebar .side-brand{ font-size:14px; font-weight:900; letter-spacing:.6px; padding:0 20px 18px; opacity:.95; }
.app-sidebar .side-nav{ display:flex; flex-direction:column; gap:6px; }
.app-sidebar .side-link{
  display:flex; align-items:center; gap:10px; margin:0 12px; padding:9px 14px; color:#c7d7ee; text-decoration:none;
  font-size:13px; font-weight:800; border:1px solid rgba(255,255,255,.16); border-radius:8px; background:rgba(255,255,255,.05);
  transition:background .15s,color .15s,border-color .15s;
}
.app-sidebar .side-link svg{ width:16px; height:16px; flex:none; stroke:currentColor; fill:none; stroke-width:1.8; }
.app-sidebar .side-link:hover{ background:rgba(255,255,255,.12); color:#fff; border-color:rgba(255,255,255,.32); }
.app-sidebar .side-link.active{ background:rgba(255,255,255,.18); color:#fff; border-color:var(--blue-4); box-shadow:0 2px 10px rgba(46,134,222,.35); }
.app-sidebar .side-user{
  margin-top:auto; display:flex; align-items:center; gap:10px;
  padding:14px 20px; border-top:1px solid rgba(255,255,255,.14);
}
.app-sidebar .side-user .user-icon{
  flex:none; width:32px; height:32px; border-radius:50%; background:rgba(255,255,255,.12);
  display:flex; align-items:center; justify-content:center;
}
.app-sidebar .side-user .user-icon svg{ width:17px; height:17px; stroke:#fff; fill:none; stroke-width:1.8; }
.app-sidebar .side-user .user-info{ min-width:0; overflow:hidden; }
.app-sidebar .side-user .user-name{
  display:block; font-size:12.5px; font-weight:800; color:#fff; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.app-sidebar .side-user .user-meta{ display:flex; align-items:center; gap:6px; font-size:10.5px; color:#9fb4d1; text-transform:capitalize; }
.app-sidebar .side-user .user-meta .logout-link{
  background:none; border:none; color:#8fb8ee; font-weight:800; font-size:10.5px; cursor:pointer; padding:0; text-transform:none;
}
.app-sidebar .side-user .user-meta .logout-link:hover{ text-decoration:underline; color:#fff; }
.app-main{ flex:1; min-width:0; }
@media (max-width:820px){
  .app-shell{ flex-direction:column; }
  .app-sidebar{ width:100%; height:auto; position:relative; flex-direction:row; align-items:center; padding:10px 14px; gap:14px; }
  .app-sidebar .side-brand{ padding:0; }
  .app-sidebar .side-nav{ flex-direction:row; }
  .app-sidebar .side-link{ margin:0; padding:6px 12px; border-radius:6px; }
  .app-sidebar .side-user{ margin-top:0; margin-left:auto; border-top:none; padding:6px 10px; }
}


.side-group-title{ font-size:10px; font-weight:800; letter-spacing:.8px; text-transform:uppercase; opacity:.6; margin:16px 0 6px 12px; }
.side-group-title:first-child{ margin-top:4px; }
