:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e7eaf0;
  --muted: #99a0ad;
  --accent: #e11d2a;      /* Autobahn red */
  --accent-2: #ff3b46;
  --radius: 10px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

/* ───────── Sidebar ───────── */
#sidebar {
  width: 360px;
  min-width: 360px;
  height: 100%;
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
#brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.role-btn {
  background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 9px; font-size: 11px; cursor: pointer; white-space: nowrap;
}
.role-btn:hover { color: var(--text); border-color: #3a4150; }
.role-btn.unlocked { color: #4ade80; border-color: rgba(74,222,128,.4); background: rgba(22,163,74,.12); }

/* View-only mode: hide supervisor-only controls */
body.locked .sup-only { display: none !important; }
.brand-mark {
  font-weight: 800;
  letter-spacing: 3px;
  font-size: 20px;
  color: #fff;
}
.brand-mark::before { content: ""; }
.brand-sub { color: var(--muted); font-size: 12px; margin-top: 2px; letter-spacing: .5px; }

.panel { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-bottom: 10px; font-weight: 600;
}
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.hint a { color: var(--accent-2); }

.row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.search-row { display: flex; gap: 8px; margin-top: 10px; }

/* Buttons & inputs */
.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #262b36; border-color: #3a4150; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-ghost { background: transparent; }
/* Destructive actions. Muted until hovered so a Delete sitting in every row of a table doesn't
   shout, but unmistakable once the pointer is on it. */
.btn-danger { color: #f87171; border-color: #4a2c30; }
.btn.btn-danger:hover { background: #3a1f22; border-color: #b91c1c; color: #fecaca; }
.btn.btn-danger:disabled { opacity: .55; cursor: default; }
.btn-primary, #bulk-add { background: var(--accent); border-color: var(--accent); color: #fff; }
/* keep accent buttons accent-colored on hover (beat the generic .btn:hover) */
.btn.btn-primary:hover, #bulk-add:hover { background: var(--accent-2); border-color: var(--accent-2); }

textarea, input[type=text] {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
textarea { min-height: 56px; margin-bottom: 4px; }
#zip-search { flex: 1; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* Dropdowns */
.sel {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.sel:focus { outline: none; border-color: var(--accent); }
.filter-row { display: flex; gap: 8px; margin-bottom: 10px; }
.filter-row .sel { flex: 1; min-width: 0; }

/* Territory list */
#territory-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.terr {
  display: flex; flex-direction: column; gap: 7px;
  padding: 9px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.terr.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.terr-row1 { display: flex; align-items: center; gap: 10px; }
.terr-row2 { display: flex; align-items: center; gap: 6px; }
.terr-row2 .sel { flex: 1; min-width: 0; }
.terr .swatch { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 auto; }
.terr .terr-name {
  flex: 1; min-width: 0;
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: transparent; border: none; padding: 0;
}
.terr .terr-name:focus { outline: none; }
.terr .terr-stats { font-size: 11px; color: var(--muted); white-space: nowrap; }
/* dealer email — links the territory to its BigCommerce account for purchase history */
.terr .terr-email {
  background: transparent; border: none; padding: 0;
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.terr .terr-email:focus { outline: none; color: var(--text); }
.terr .terr-sales { color: var(--accent-2, #7dd3fc); font-weight: 600; }
.rep-table .acct-none { color: var(--muted); font-style: italic; }
.terr .terr-actions { display: flex; gap: 4px; opacity: .5; }
.terr:hover .terr-actions { opacity: 1; }
.status-pill {
  font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  padding: 2px 6px; border-radius: 5px; flex: 0 0 auto;
}
.status-pill.signed { background: rgba(22,163,74,.18); color: #4ade80; }
.status-pill.proposed { background: rgba(217,119,6,.18); color: #fbbf24; }
.icon-btn {
  background: transparent; border: none; color: var(--muted);
  cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 5px;
}
.icon-btn:hover { color: #fff; background: #2a2f3a; }
.empty-note { color: var(--muted); font-size: 12px; padding: 8px 2px; }

/* Selected summary */
#selected-summary .stat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px;
}
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px;
}
.stat .v { font-size: 17px; font-weight: 700; }
.stat .k { font-size: 11px; color: var(--muted); margin-top: 1px; }
.stat.wide { grid-column: 1 / -1; }

/* Heat map toggle + legend */
#heat-toggle.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.heat-legend { margin-top: 8px; }
.heat-legend .hl-label { font-size: 11px; color: var(--muted); }
.hl-scale { display: flex; margin-top: 4px; border-radius: 5px; overflow: hidden; border: 1px solid var(--line); }
.hl-scale span { flex: 1; text-align: center; font-size: 10.5px; padding: 3px 0; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.65); }
.hl-scale span[data-c="#1f2733"] { background: #1f2733; }
.hl-scale span[data-c="#3b4a2a"] { background: #3b4a2a; }
.hl-scale span[data-c="#6b6b1f"] { background: #6b6b1f; }
.hl-scale span[data-c="#a6701c"] { background: #a6701c; }
.hl-scale span[data-c="#cf5a17"] { background: #cf5a17; }
.hl-scale span[data-c="#e23b1e"] { background: #e23b1e; }

/* Prospective dealer field */
.prospect-row { margin: 0 0 10px; }
.prospect-row label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.prospect-input { width: 100%; box-sizing: border-box; padding: 6px 9px; font-size: 13px; }

/* Dealer list inside selected-territory summary */
.dealer-head { font-size: 12px; color: var(--muted); margin: 12px 0 5px; }
.dealer-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px; }
.dealer-item { display: flex; justify-content: space-between; gap: 8px; align-items: center;
  padding: 6px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 12px; }
.dealer-item:last-child { border-bottom: none; }
.dealer-item:hover { background: var(--panel); }
.dl-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-rev { font-weight: 700; color: #4ade80; white-space: nowrap; }
.dealer-more { padding: 6px 10px; font-size: 11px; color: var(--muted); }
.report-prospect { color: var(--muted); font-size: 11px; }

#foot { margin-top: auto; padding: 12px 16px; color: var(--muted); font-size: 11px; }

/* ───────── Map ───────── */
#map-wrap { position: relative; flex: 1; height: 100%; }
#map { position: absolute; inset: 0; background: #0b0d11; }
.map-msg {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(20,22,28,.92); border: 1px solid var(--line);
  color: var(--text); padding: 8px 14px; border-radius: 20px; font-size: 13px;
  z-index: 600; backdrop-filter: blur(6px);
}
.loading {
  position: absolute; bottom: 16px; left: 16px;
  background: rgba(20,22,28,.92); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 8px; font-size: 12px; color: var(--muted);
  z-index: 600;
}

/* ZIP polygon tooltips */
.zip-tip {
  background: #11141a; border: 1px solid var(--line); color: var(--text);
  font-size: 12px; border-radius: 8px; padding: 8px 10px; min-width: 170px;
  box-shadow: 0 6px 22px rgba(0,0,0,.5);
}
.zip-tip b { color: #fff; }
.leaflet-tooltip-top.zip-tip::before { border-top-color: var(--line); }
.tip-head { font-size: 13px; margin-bottom: 5px; }
.tip-tag {
  font-size: 9px; font-weight: 700; letter-spacing: .5px; vertical-align: middle;
  background: #2a2f3a; color: var(--muted); padding: 1px 4px; border-radius: 4px; margin-left: 2px;
}
.tip-demo { display: flex; flex-direction: column; gap: 2px; }
.tip-row { display: flex; justify-content: space-between; gap: 14px; }
.tip-row span { color: var(--muted); }
.tip-dim { color: var(--muted); font-style: italic; }
.tip-terr {
  margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line);
}
.tip-terr .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.tip-terr .tip-sub { color: var(--muted); margin-top: 2px; }

/* ───────── Modal ───────── */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px; width: min(480px, 92vw);
}
.modal-card h3 { margin: 0 0 8px; }
.modal-card ol { padding-left: 18px; }
.modal-card input { margin: 10px 0; }
.modal-wide { width: min(820px, 94vw); max-height: 88vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; }
/* ───────── CS claim photos ───────── */
.cs-thumbs{display:flex;gap:8px;flex-wrap:wrap}
.cs-thumb{position:relative;display:inline-block}
.cs-thumb img{width:84px;height:84px;object-fit:cover;border-radius:9px;border:1px solid var(--line);display:block}
.cs-thumb-x{position:absolute;top:-6px;right:-6px;width:20px;height:20px;border-radius:50%;
  border:1px solid var(--line);background:var(--panel);color:var(--muted);font-size:11px;
  line-height:1;cursor:pointer;padding:0}
.cs-thumb-x:hover{color:#f87171;border-color:rgba(248,113,113,.6)}

/* ───────── Warranty claims: inline settlement cells ───────── */
/* The claims table gained Approved / Method / Payout / Reference columns, which is more than fits
   on a laptop. Scroll the table itself rather than the page. */
.w-scroll { overflow-x: auto; }
.w-scroll > table { min-width: 100%; }
.w-num { text-align: right; white-space: nowrap; }
.w-cell {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px;
  color: var(--text); padding: 5px 8px; font-size: 12.5px; font-family: inherit;
}
.w-cell:focus { outline: none; border-color: var(--accent); }
.w-money { width: 92px; text-align: right; }
/* Approved, but nobody has said what we are paying — the row a person still has to settle. */
.w-cell.w-need { border-color: rgba(251,191,36,.65); background: rgba(217,119,6,.12); }
.w-cell.w-saved { border-color: rgba(74,222,128,.55); transition: border-color 1.2s ease-out; }
.w-cell.w-bad { border-color: rgba(248,113,113,.8); }
/* "paid" is the warranty wording, "issued" the CS one — same meaning, same band. */
.w-pst-paid,
.w-pst-issued { border-color: rgba(74,222,128,.45) !important; }
.w-pst-pending { border-color: rgba(251,191,36,.5) !important; }

/* ───────── Dealer Success onboarding board ───────── */
.ob-note { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
           color: var(--text); padding: 6px 8px; font: inherit; font-size: 12.5px;
           min-width: 200px; resize: vertical; }
.ob-note:focus { outline: none; border-color: var(--accent); }
.ob-files { display: flex; flex-direction: column; gap: 4px; }
.ob-file { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.ob-file a { color: var(--accent-2); text-decoration: none; }
.ob-file a:hover { text-decoration: underline; }
.ob-file-x { background: none; border: 0; color: var(--muted); font-size: 11px; cursor: pointer; padding: 0 2px; }
.ob-file-x:hover { color: #f87171; }
/* A dealer who has gone quiet is stalled work, not finished work — flag it like a problem.
   Needs `.ob-table select` specificity, or the table's own select colour wins. */
.ob-table select.ob-st-unresponsive { border-color: rgba(248,113,113,.55); color: #f87171; }
.ob-brand { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
            padding: 16px 18px; margin-bottom: 16px; }
.ob-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.ob-head h2 { margin: 0; font-size: 17px; }
.ob-mode { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 20px; }
.ob-mode.virtual { background: rgba(37,99,235,.2); color: #7aa5f5; }
.ob-mode.person { background: rgba(147,51,234,.22); color: #c084fc; }
.ob-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.ob-flag { color: #fbbf24; font-weight: 600; }
.ob-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ob-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
               color: var(--muted); padding: 6px 10px 6px 0; font-weight: 700; white-space: nowrap; }
.ob-table td { padding: 9px 10px 9px 0; border-top: 1px solid var(--line); vertical-align: top; }
.ob-table tr.done td { opacity: .55; }
.ob-co { font-weight: 600; }
.ob-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ob-table select, .ob-table input[type="date"] {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; color: var(--text);
  padding: 6px 9px; font-size: 13px; font-family: inherit; max-width: 100%;
}
.ob-table select:focus, .ob-table input[type="date"]:focus { outline: none; border-color: var(--accent); }
/* Keep "start to end" on one line — wrapped, the "to" ends up orphaned above the second date
   and the range stops reading as a range. */
.ob-dates { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.ob-dates input[type="date"] { min-width: 0; flex: 1 1 auto; }
.ob-table td:nth-child(3) { min-width: 250px; }
.ob-dates .to { color: var(--muted); font-size: 12px; }
.ob-st-unscheduled { border-color: rgba(248,113,113,.5) !important; }
.ob-st-scheduled { border-color: rgba(74,222,128,.45) !important; }
.ob-empty { color: var(--muted); font-size: 13px; padding: 10px 0 2px; }
.ob-near-btn { background: none; border: 0; color: var(--accent-2); font: inherit; font-size: 12px;
               cursor: pointer; padding: 0; margin-top: 5px; text-decoration: underline; }
.ob-near { margin-top: 8px; background: var(--panel-2); border: 1px solid var(--line);
           border-radius: 10px; padding: 10px 12px; }
.ob-near .t { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.ob-near ul { margin: 0; padding-left: 16px; }
.ob-near li { margin-bottom: 3px; line-height: 1.45; }
.ob-near .why { color: var(--muted); font-size: 12px; }
@media (max-width: 820px) {
  .ob-table, .ob-table tbody, .ob-table tr, .ob-table td { display: block; width: 100%; }
  .ob-table thead { display: none; }
  .ob-table tr { border-top: 1px solid var(--line); padding: 10px 0; }
  .ob-table td { border-top: 0; padding: 4px 0; }
}

/* ───────── Access editor (Admin) ───────── */
/* The card is capped at 88vh; without this the form runs off the bottom of the screen and the
   Save button goes with it. Head and foot stay put, only the middle scrolls. */
#ad-modal .modal-head { flex: 0 0 auto; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
#ad-modal .modal-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 2px 4px; min-height: 0; }
#ad-modal .ad-foot { flex: 0 0 auto; margin-top: 0; }
.ad-sec { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
.ad-sec:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.ad-sec > h4 { margin: 0 0 3px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.ad-sec > .ad-note { color: var(--muted); font-size: 12.5px; margin-bottom: 9px; }
.ad-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.ad-opt { display: flex; gap: 8px; align-items: flex-start; padding: 8px 11px; border: 1px solid var(--line);
          border-radius: 9px; cursor: pointer; font-size: 13.5px; background: var(--panel-2); }
.ad-opt:hover { border-color: var(--accent); }
.ad-opt input { margin: 2px 0 0; flex: 0 0 auto; }
/* Selected, not errored. A bare accent border reads as a validation failure in this theme, since
   accent and the error colour are both red — the fill is what makes it say "chosen". */
.ad-opt.on { border-color: var(--accent); background: rgba(225,29,42,.13); }
.ad-opt .lbl { line-height: 1.35; }
.ad-opt .sub { display: block; color: var(--muted); font-size: 12px; }
/* The roster grid: enough columns to scan, never so many the names wrap awkwardly */
.ad-reps { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 7px; }
.ad-perms { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 7px; }
.ad-grp { margin-top: 11px; }
.ad-grp > .t { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.ad-diff { display: inline-block; margin-left: 6px; font-size: 10.5px; font-weight: 700; padding: 1px 6px;
           border-radius: 20px; background: rgba(147,51,234,.22); color: #c084fc; vertical-align: middle; }
.ad-preview { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
              padding: 12px 14px; font-size: 13.5px; line-height: 1.55; }
.ad-preview b { color: var(--text); }
.ad-preview .off { color: var(--muted); }
.ad-foot { border-top: 1px solid var(--line); padding-top: 13px; margin-top: 14px;
           display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.ad-foot-btns { display: flex; gap: 8px; margin-left: auto; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
@media (max-width: 640px) { .ad-perms, .ad-reps { grid-template-columns: 1fr; } }

.report-controls { margin: 12px 0; align-items: center; }
.report-controls .sel { min-width: 150px; }

/* Report tables */
.report-body { overflow-y: auto; }
.report-summary { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.report-summary .card {
  flex: 1; min-width: 150px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
}
.report-summary .card .big { font-size: 22px; font-weight: 800; }
.report-summary .card .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.report-summary .card.signed .big { color: #4ade80; }
.report-summary .card.proposed .big { color: #fbbf24; }

table.rep-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.rep-table th, table.rep-table td { padding: 7px 9px; text-align: right; border-bottom: 1px solid var(--line); }
table.rep-table th:first-child, table.rep-table td:first-child,
table.rep-table th:nth-child(2), table.rep-table td:nth-child(2) { text-align: left; }
table.rep-table thead th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
table.rep-table tr.rep-head td {
  background: var(--panel-2); font-weight: 700; font-size: 13px;
  text-transform: none; letter-spacing: 0; color: #fff; padding-top: 12px;
}
table.rep-table tr.subtotal td { color: var(--muted); font-style: italic; }
table.rep-table tr.grand td { font-weight: 800; border-top: 2px solid var(--line); color: #fff; }
table.rep-table td .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.report-empty { color: var(--muted); padding: 24px; text-align: center; }

/* Reps editor */
#reps-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.rep-edit { display: flex; align-items: center; gap: 8px; }
.rep-edit span { color: var(--muted); font-size: 12px; width: 46px; }
.rep-edit input { margin: 0; }

/* ───────── Mobile / responsive (territory map) ───────── */
@media (max-width: 760px) {
  #app { flex-direction: column; height: 100vh; }
  #sidebar {
    width: 100%; min-width: 0; height: auto;
    max-height: 48vh; border-right: none; border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
  }
  #map-wrap { flex: 1 1 auto; min-height: 280px; }
  #brand { padding: 12px 14px 10px; }
  .brand-mark { font-size: 16px; }
  .panel { padding-left: 14px; padding-right: 14px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .modal-wide { width: 96vw; max-height: 90vh; }
  .report-controls { flex-wrap: wrap; }
  .report-controls .sel { min-width: 120px; flex: 1; }
  .report-body { -webkit-overflow-scrolling: touch; overflow-x: auto; }
  table.rep-table { font-size: 11px; min-width: 640px; }
  .report-summary { gap: 8px; }
  .report-summary .card { min-width: 120px; }
  /* bigger tap targets */
  .terr .terr-actions { opacity: 1; }
  .icon-btn { padding: 6px 8px; }
}
@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  #sidebar { max-height: 52vh; }
}

@media print {
  body * { visibility: hidden; }
  #report-modal, #report-modal * { visibility: visible; }
  #report-modal { position: absolute; inset: 0; background: #fff; color: #000; }
  .modal-wide { box-shadow: none; border: none; max-height: none; width: 100%; }
  .report-controls, #close-report { display: none; }
  table.rep-table th, table.rep-table td { color: #000 !important; border-color: #ccc; }
  table.rep-table tr.rep-head td, .report-summary .card { background: #f0f0f0 !important; color: #000 !important; }
}
