/* ==========================================================================
   AgriWealth Scouting - dashboard design system  (v8)
   Same brand as the scout app (scout-app/style.css) and the AgriWealth logo: leaf greens + sun yellow,
   green-tinted neutrals, rounded surfaces, gradient green actions. Semantic red / amber / blue / green.
   Mobile first: phone -> tablet -> desktop sidebar.
   ========================================================================== */
:root {
  --brand-950:#062a18; --brand-900:#0b3d24; --brand-800:#0f5130; --brand-700:#146c3d;
  --brand-600:#18874a; --brand-500:#22a35a; --brand-400:#4cc27c; --brand-100:#dcf3e5; --brand-50:#eef9f2;
  --accent:#f2c230; --accent-ink:#3d2c00;

  --bg:#f2f5f3; --surface:#ffffff; --surface-2:#f7faf8; --surface-3:#e9efeb;
  --line:#e3e9e5; --line-strong:#cdd7d1;
  --text:#0f1d16; --text-2:#34443b; --muted:#66756d;

  --red:#d92d20;   --red-bg:#fef3f2;   --red-line:#fecdca;
  --amber:#b54708; --amber-bg:#fffaeb; --amber-line:#fedf89;
  --blue:#175cd3;  --blue-bg:#eff8ff;  --blue-line:#b2ddff;
  --green:#067647; --green-bg:#ecfdf3; --green-line:#abefc6;

  --radius:18px; --radius-md:14px; --radius-sm:12px;
  --shadow-xs:0 1px 2px rgba(16,24,40,.05);
  --shadow-sm:0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow:0 4px 10px -2px rgba(16,24,40,.07), 0 2px 4px -2px rgba(16,24,40,.05);
  --shadow-lg:0 20px 40px -12px rgba(16,24,40,.22);
  --focus:0 0 0 3px rgba(34,163,90,.30);
  --grad:linear-gradient(180deg, var(--brand-500), var(--brand-700));
  --glow:0 10px 22px -12px rgba(20,108,61,.85), inset 0 1px 0 rgba(255,255,255,.2);
  --font:"Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  --side-w:256px;
  --ease:cubic-bezier(.2,.7,.2,1);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; scroll-behavior:smooth; }
body { margin:0; font-family:var(--font); background:var(--bg); color:var(--text); font-size:14.5px; line-height:1.55;
  -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale; min-height:100vh;
  font-feature-settings:"ss01"; }
a { color:var(--brand-700); text-decoration:none; font-weight:500; }
a:hover { color:var(--brand-600); text-decoration:underline; text-underline-offset:2px; }
:focus-visible { outline:none; box-shadow:var(--focus); border-radius:6px; }
img { max-width:100%; }
::selection { background:var(--brand-100); }
.shell { min-height:100vh; display:flex; flex-direction:column; min-width:0; }

/* ---------- sidebar (desktop) / drawer (phone, tablet) ---------- */
.sidebar { position:fixed; inset:0 auto 0 0; width:var(--side-w); z-index:40; display:flex; flex-direction:column;
  background:linear-gradient(180deg, var(--brand-900) 0%, var(--brand-950) 100%); color:#cfe3d9;
  border-right:1px solid rgba(255,255,255,.04); padding:18px 14px 14px; overflow-y:auto; scrollbar-width:thin;
  scrollbar-color:rgba(255,255,255,.15) transparent; }
.side-head { display:flex; align-items:center; justify-content:space-between; padding:2px 6px 16px; }
.brand { display:flex; align-items:center; gap:11px; font-weight:700; font-size:15px; letter-spacing:-.005em; color:#fff; white-space:nowrap; line-height:1.2; }
.brand:hover { text-decoration:none; color:#fff; }
.brand small { display:block; font-weight:500; font-size:11px; color:#8fbca7; letter-spacing:.05em; text-transform:uppercase; margin-top:2px;
  max-width:170px; overflow:hidden; text-overflow:ellipsis; }
.brand-mark { width:38px; height:38px; border-radius:50%; display:grid; place-items:center; flex:none; background:#fff;
  box-shadow:0 0 0 3px rgba(255,255,255,.12), 0 6px 16px -6px rgba(0,0,0,.45); }
.brand-mark img { width:30px; height:30px; display:block; }
.menu-close { display:none; }

.side-label { display:block; font-size:10.5px; font-weight:700; letter-spacing:.09em; text-transform:uppercase; color:#6f9a87;
  padding:14px 10px 6px; }
.phsel { margin:0 2px 4px; padding:10px; border-radius:12px; background:rgba(255,255,255,.04); border:1px solid rgba(255,255,255,.07); }
.phsel .side-label { padding:0 2px 6px; }
.phsel select { width:100%; background-color:rgba(0,0,0,.18); color:#fff; border:1px solid rgba(255,255,255,.14); padding:8px 30px 8px 11px;
  font-size:13.5px; font-weight:600; border-radius:9px; appearance:none; cursor:pointer;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23c6dfd3' stroke-width='1.6' fill='none'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 11px center; }
.phsel select:hover { border-color:rgba(255,255,255,.28); }
.phsel select:focus { box-shadow:0 0 0 3px rgba(63,191,130,.35); border-color:var(--brand-400); }
.phsel option, .phsel optgroup { color:var(--text); background:#fff; }

.side-nav { display:flex; flex-direction:column; gap:2px; flex:1; }
.side-nav a { position:relative; display:flex; align-items:center; gap:11px; padding:9px 12px; border-radius:10px; color:#c3dacf;
  font-size:14px; font-weight:500; transition:background .18s var(--ease), color .18s var(--ease); }
.side-nav a .ico { flex:none; opacity:.8; transition:opacity .18s, transform .18s var(--ease); }
.side-nav a:hover { background:rgba(255,255,255,.06); color:#fff; text-decoration:none; }
.side-nav a:hover .ico { opacity:1; transform:translateX(1px); }
.side-nav a.on { background:linear-gradient(90deg, rgba(63,191,130,.20), rgba(63,191,130,.06)); color:#fff; font-weight:600; }
.side-nav a.on .ico { opacity:1; color:var(--brand-400); }
.side-nav a.on::before { content:""; position:absolute; left:-14px; top:8px; bottom:8px; width:3px; border-radius:0 3px 3px 0; background:var(--brand-400); }
.side-nav a.ext { color:#f1d48d; margin-top:6px; }
.side-nav a.ext .ico { color:var(--accent); opacity:1; }
.ext-arrow { margin-left:auto; font-size:12px; opacity:.7; }

.who { display:flex; align-items:center; gap:10px; margin-top:14px; padding:10px; border-radius:12px;
  background:rgba(255,255,255,.05); border:1px solid rgba(255,255,255,.07); font-size:13px; }
.who-text { min-width:0; flex:1; }
.avatar { width:34px; height:34px; border-radius:50%; flex:none; display:grid; place-items:center; font-weight:700; font-size:14px; text-transform:uppercase;
  background:linear-gradient(140deg, #f6cf6b, var(--accent)); color:var(--accent-ink); box-shadow:0 0 0 2px rgba(255,255,255,.12); }
.who .name { display:block; color:#fff; font-weight:600; line-height:1.25; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.who .role { display:block; font-size:11.5px; color:#8fbca7; text-transform:capitalize; line-height:1.3; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.who a.out { display:grid; place-items:center; width:34px; height:34px; border-radius:9px; color:#c3dacf; flex:none; transition:background .15s, color .15s; }
.who a.out:hover { background:rgba(255,255,255,.10); color:#fff; text-decoration:none; }

/* phone / tablet top bar */
.mobilebar { display:none; }
.scrim { position:fixed; inset:0; z-index:35; background:rgba(4,20,16,.5); backdrop-filter:blur(2px); }

@media (min-width: 1024px) {
  body.app .shell { margin-left:var(--side-w); }
}
@media (max-width: 1023.98px) {
  .mobilebar { display:flex; position:sticky; top:0; z-index:30; align-items:center; gap:12px; padding:10px 14px;
    padding-top:max(10px, env(safe-area-inset-top)); background:rgba(10,42,34,.96); backdrop-filter:saturate(1.4) blur(8px);
    color:#fff; box-shadow:0 1px 0 rgba(255,255,255,.05), 0 4px 14px -6px rgba(0,0,0,.35); }
  .mobilebar .brand { flex:1; min-width:0; }
  .mobilebar .brand > span { min-width:0; overflow:hidden; }
  .mobilebar .brand small { text-transform:none; letter-spacing:0; font-size:12px; max-width:52vw; }
  .mobilebar .avatar { width:32px; height:32px; font-size:13px; }
  .menu-btn { display:grid; place-items:center; width:40px; height:40px; padding:0; border-radius:10px; flex:none;
    background:rgba(255,255,255,.07); border:1px solid rgba(255,255,255,.10); color:#fff; box-shadow:none; }
  .menu-btn:hover { background:rgba(255,255,255,.14); }
  .sidebar { width:min(86vw, 300px); transform:translateX(-102%); transition:transform .28s var(--ease); box-shadow:none;
    padding-top:max(18px, env(safe-area-inset-top)); }
  body.menu-open .sidebar { transform:none; box-shadow:24px 0 60px -20px rgba(0,0,0,.5); }
  body.menu-open { overflow:hidden; }
  .menu-close { display:grid; place-items:center; width:36px; height:36px; padding:0; border-radius:9px;
    background:rgba(255,255,255,.07); border:none; color:#fff; box-shadow:none; }
  .menu-close:hover { background:rgba(255,255,255,.14); }
  .side-nav a.on::before { left:-14px; }
}

/* ---------- layout & type ---------- */
main { padding:28px 32px 48px; max-width:1440px; width:100%; margin:0 auto; flex:1; }
@media (max-width: 1023.98px) { main { padding:20px 20px 40px; } }
@media (max-width: 640px) { main { padding:16px 16px 36px; } }
footer.foot { color:var(--muted); font-size:12px; text-align:center; padding:18px 16px; border-top:1px solid var(--line); }
h1 { font-size:26px; line-height:1.2; font-weight:750; letter-spacing:-.022em; margin:2px 0 18px; color:var(--text); }
h2 { font-size:16.5px; font-weight:700; margin:30px 0 12px; color:var(--text); letter-spacing:-.012em; display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
h3 { font-size:14px; font-weight:650; margin:16px 0 8px; color:var(--text-2); }
@media (max-width: 640px) { h1 { font-size:21px; } h2 { font-size:15.5px; margin-top:24px; } }
.card { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:18px 20px; margin-bottom:16px; box-shadow:var(--shadow-sm); }
@media (max-width: 640px) { .card { padding:14px 15px; border-radius:12px; } }
.card > h2:first-child, .card > h3:first-child { margin-top:0; }
.cols { display:grid; gap:24px; grid-template-columns:minmax(0, 1fr); }
@media (min-width: 1100px) { .cols { grid-template-columns:minmax(0, 1fr) minmax(0, 1fr); } }
.cols > div > h2:first-child { margin-top:8px; }
.stack > * { margin-bottom:10px; }
.stack > *:last-child { margin-bottom:0; }
.muted { color:var(--muted); font-size:13px; }
.small { font-size:12.5px; }

/* ---------- page header: any top-level .filters row that holds the h1 ---------- */
main > .filters:has(> h1), main > form.filters:has(> h1) {
  padding-bottom:18px; margin-bottom:22px; border-bottom:1px solid var(--line); row-gap:12px; }
main > .filters:has(> h1) h1, main > form.filters:has(> h1) h1 { font-size:26px; }
@media (max-width: 640px) {
  main > .filters:has(> h1) h1, main > form.filters:has(> h1) h1 { font-size:21px; flex-basis:100%; }
}
.page-head { display:flex; flex-wrap:wrap; align-items:flex-end; justify-content:space-between; gap:14px 20px; margin-bottom:22px; }
.page-head h1 { margin:0; }
.page-head.hero { position:relative; overflow:hidden; align-items:center; padding:22px 24px; border-radius:22px; color:#fff;
  background:radial-gradient(120% 160% at 100% 0%, var(--brand-500) 0%, var(--brand-700) 45%, var(--brand-900) 100%);
  box-shadow:0 14px 34px -18px rgba(16,32,24,.45); }
.page-head.hero::after { content:""; position:absolute; right:-30px; bottom:-46px; width:170px; height:170px; opacity:.13; pointer-events:none;
  background:url("/scout/logo-mark.png") center / contain no-repeat; filter:brightness(0) invert(1); }
.page-head.hero h1 { color:#fff; }
.page-head.hero .eyebrow { color:#c9f0d9; }
.page-head.hero > * { position:relative; z-index:1; }
.page-head.hero .btn.secondary { background:rgba(255,255,255,.14); color:#fff; border-color:rgba(255,255,255,.25); box-shadow:none; }
.page-head.hero .btn.secondary:hover { background:rgba(255,255,255,.24); color:#fff; }
.page-head.hero input { background:rgba(255,255,255,.95); border-color:transparent; }
@media (max-width: 640px) { .page-head.hero { padding:18px; border-radius:18px; } }
.eyebrow { display:block; font-size:12px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--brand-600); margin-bottom:4px; }

/* ---------- KPI tiles ---------- */
.grid { display:grid; gap:14px; grid-template-columns:repeat(auto-fit, minmax(190px, 1fr)); }
@media (max-width: 640px) { .grid { grid-template-columns:repeat(2, minmax(0, 1fr)); gap:10px; } }
.kpi { position:relative; display:flex; flex-direction:column; gap:3px; background:var(--surface); border:1px solid var(--line);
  border-radius:var(--radius); padding:16px 18px; box-shadow:var(--shadow-sm); overflow:hidden;
  transition:transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s; }
.kpi:hover { transform:translateY(-2px); box-shadow:var(--shadow); border-color:var(--line-strong); }
.kpi b { display:block; order:2; font-size:28px; font-weight:750; letter-spacing:-.03em; line-height:1.1; color:var(--text); font-variant-numeric:tabular-nums; }
.kpi span { order:3; font-size:12.5px; color:var(--muted); font-weight:500; line-height:1.35; }
.kpi .kpi-ico { order:1; width:38px; height:38px; border-radius:12px; display:grid; place-items:center; margin-bottom:8px;
  background:var(--brand-50); color:var(--brand-700); border:1px solid var(--brand-100); }
.kpi .kpi-ico svg { display:block; }
.kpi b.amber { color:var(--amber); } .kpi:has(b.amber) .kpi-ico { background:var(--amber-bg); color:var(--amber); }
.kpi b.red { color:var(--red); } .kpi:has(b.red) .kpi-ico { background:var(--red-bg); color:var(--red); }
.kpi.blue .kpi-ico { background:var(--blue-bg); color:var(--blue); }
.kpi span a { font-weight:600; }
.kpi.link { cursor:pointer; }
.kpi .meter { order:4; height:5px; border-radius:3px; background:var(--surface-3); overflow:hidden; margin-top:10px; }
.kpi .meter > i { display:block; height:100%; border-radius:3px; background:linear-gradient(90deg, var(--brand-500), var(--brand-400)); }
@media (max-width: 640px) { .kpi { padding:13px 14px; } .kpi b { font-size:22px; } .kpi .kpi-ico { width:30px; height:30px; margin-bottom:6px; } }

/* ---------- tables ---------- */
.table-wrap { position:relative; overflow-x:auto; -webkit-overflow-scrolling:touch; border:1px solid var(--line); border-radius:var(--radius);
  background:var(--surface); box-shadow:var(--shadow-sm);
  background-image:linear-gradient(to right, var(--surface), var(--surface)), linear-gradient(to left, var(--surface), var(--surface)),
    linear-gradient(to right, rgba(16,24,40,.10), transparent), linear-gradient(to left, rgba(16,24,40,.10), transparent);
  background-position:left center, right center, left center, right center; background-repeat:no-repeat;
  background-size:20px 100%, 20px 100%, 12px 100%, 12px 100%; background-attachment:local, local, scroll, scroll; }
table { border-collapse:separate; border-spacing:0; width:100%; font-variant-numeric:tabular-nums; }
.table-wrap table { background:transparent; }
th, td { border-bottom:1px solid var(--line); padding:11px 14px; text-align:left; vertical-align:top; font-size:13.5px; }
th { background:var(--surface-2); font-weight:650; font-size:11.5px; color:var(--muted); text-transform:uppercase; letter-spacing:.055em;
  position:sticky; top:0; z-index:1; white-space:nowrap; }
tr:last-child td { border-bottom:none; }
tr:hover td { background:#f8fbf9; }
tr:has(th):hover td { background:inherit; }
td.n { text-align:right; }
.overdue td { background:var(--red-bg) !important; }
@media (max-width: 640px) {
  th, td { padding:9px 11px; font-size:13px; }
  .table-wrap > table:has(tr > :nth-child(4)) { min-width:600px; }   /* wide tables scroll instead of squashing */
  td:first-child { white-space:nowrap; }
}

/* ---------- text colours, pills, swatches ---------- */
.red { color:var(--red); font-weight:600; } .amber { color:var(--amber); font-weight:600; }
.pill { display:inline-flex; align-items:center; gap:5px; padding:2px 10px; border-radius:999px; font-size:12px; font-weight:600;
  background:var(--surface-3); color:var(--text-2); border:1px solid var(--line); white-space:nowrap; line-height:1.55; text-transform:capitalize; }
.pill::before { content:""; width:6px; height:6px; border-radius:50%; background:currentColor; opacity:.75; }
.pill.pending, .pill.uploading, .pill.uploaded, .pill.processing { background:var(--amber-bg); color:var(--amber); border-color:var(--amber-line); }
.pill.processing::before, .pill.uploading::before { animation:pulse 1.4s ease-in-out infinite; }
.pill.approved { background:var(--blue-bg); color:var(--blue); border-color:var(--blue-line); }
.pill.done, .pill.confirmed, .pill.changed, .pill.ready { background:var(--green-bg); color:var(--green); border-color:var(--green-line); }
.pill.verified { background:var(--brand-700); color:#fff; border-color:var(--brand-700); }
.pill.cancelled { background:var(--surface-3); color:#8a96a3; }
.pill.rejected, .pill.failed { background:var(--red-bg); color:var(--red); border-color:var(--red-line); }
@keyframes pulse { 50% { opacity:.25; } }
.sw { display:inline-block; width:11px; height:11px; border-radius:50%; vertical-align:-1px; box-shadow:0 0 0 1.5px #fff, 0 0 0 2.5px rgba(16,24,40,.12); margin-right:3px; }
.swatch { display:inline-block; width:11px; height:11px; border-radius:3px; vertical-align:-1px; }

/* ---------- forms & buttons ---------- */
form.inline { display:inline; }
input, select, textarea { font:inherit; font-size:14px; padding:9px 12px; border:1px solid var(--line-strong); border-radius:var(--radius-sm);
  background-color:var(--surface); color:var(--text); transition:border-color .15s, box-shadow .15s; max-width:100%; min-height:40px; }
input[type=checkbox], input[type=radio] { min-height:0; width:17px; height:17px; padding:0; accent-color:var(--brand-600); vertical-align:-3px; margin:0 4px 0 0; }
select { appearance:none; padding-right:32px; cursor:pointer;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235f6e7e' stroke-width='1.6' fill='none'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 12px center; }
input:hover, select:hover, textarea:hover { border-color:#9aa6b2; }
input:focus, select:focus, textarea:focus { outline:none; border-color:var(--brand-500); box-shadow:var(--focus); }
input::placeholder, textarea::placeholder { color:#97a3af; }
label { color:var(--text-2); font-size:13px; font-weight:550; }
button, .btn { font:inherit; font-size:14px; font-weight:600; letter-spacing:-.003em; color:#fff; cursor:pointer; padding:9px 16px; min-height:40px;
  border-radius:var(--radius-sm); border:1px solid var(--brand-700); text-decoration:none; display:inline-flex; align-items:center;
  justify-content:center; gap:7px; white-space:nowrap;
  background:var(--grad); box-shadow:var(--glow);
  transition:background .15s, box-shadow .15s, transform .08s, filter .15s; }
button:hover, .btn:hover { filter:brightness(1.06); color:#fff; text-decoration:none; box-shadow:0 12px 24px -10px rgba(20,108,61,.9), inset 0 1px 0 rgba(255,255,255,.2); }
button:active, .btn:active { transform:translateY(1px); }
button.secondary, .btn.secondary { background:var(--surface); color:var(--text-2); border-color:var(--line-strong); box-shadow:var(--shadow-xs); }
button.secondary:hover, .btn.secondary:hover { background:var(--surface-2); color:var(--text); border-color:#9aa6b2; filter:none; box-shadow:var(--shadow-sm); }
button.danger { background:linear-gradient(180deg, #ea5a4e, var(--red)); border-color:#b42318; box-shadow:0 10px 22px -12px rgba(217,45,32,.75), inset 0 1px 0 rgba(255,255,255,.2); }
button.danger:hover { box-shadow:0 4px 12px -4px rgba(217,45,32,.55); }
button.link { background:none; border:none; box-shadow:none; color:var(--red); padding:0 4px; font-weight:700; min-height:0; }
button.link:hover { background:none; text-decoration:underline; box-shadow:none; filter:none; color:var(--red); }
button:disabled { opacity:.55; cursor:not-allowed; }
.filters { display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin-bottom:16px; }
.filters h1 { margin-right:auto !important; }
.filters label:has(> input:not([type=checkbox]):not([type=radio]), > select) { display:inline-flex; align-items:center; gap:8px; }
@media (max-width: 640px) {
  main > form.filters > select, main > form.filters > input:not([type=hidden]),
  main > form.filters > label:has(> select, > input[type=date]) { flex:1 1 140px; }
  main > form.filters > label > select, main > form.filters > label > input[type=date] { flex:1; min-width:0; }
}
@media (min-width: 641px) { main > form.filters > select { max-width:280px; } }
.sevbtn { display:inline-flex; gap:4px; }
details summary { cursor:pointer; font-weight:600; color:var(--text-2); }
details[open] summary { margin-bottom:8px; }
.or { display:flex; align-items:center; gap:10px; color:var(--muted); margin:18px 0 12px; font-size:12.5px; }
.or::before, .or::after { content:""; flex:1; height:1px; background:var(--line); }
.seg { display:inline-flex; gap:0; padding:3px; border-radius:11px; background:var(--surface-3); border:1px solid var(--line); }
.seg .btn { min-height:34px; padding:6px 14px; border-radius:8px; border:none; box-shadow:none; }
.seg .btn.secondary { background:transparent; color:var(--muted); }
.seg .btn.secondary:hover { color:var(--text); background:rgba(255,255,255,.6); }
.seg .btn:not(.secondary) { background:var(--surface); color:var(--text); box-shadow:var(--shadow-sm); filter:none; }

/* ---------- alerts ---------- */
.alert { display:flex; gap:10px; align-items:flex-start; padding:12px 14px; border-radius:var(--radius-md); margin-bottom:10px;
  background:var(--surface); border:1px solid var(--line); color:var(--text); font-size:13.5px; box-shadow:var(--shadow-xs); }
.alert::before { content:""; flex:none; width:8px; height:8px; margin-top:6px; border-radius:50%; background:var(--muted); }
.alert.red { border-color:var(--red-line); background:var(--red-bg); color:#7a271a; font-weight:500; }
.alert.red::before { background:var(--red); box-shadow:0 0 0 4px rgba(217,45,32,.15); }
.alert.amber { border-color:var(--amber-line); background:var(--amber-bg); color:#7a2e0e; font-weight:500; }
.alert.amber::before { background:#f79009; box-shadow:0 0 0 4px rgba(247,144,9,.15); }
.empty { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; padding:26px 16px; text-align:center;
  color:var(--muted); font-size:13.5px; background:var(--surface); border:1px dashed var(--line-strong); border-radius:var(--radius); }
.empty svg { color:var(--brand-500); opacity:.8; }

/* ---------- map, media ---------- */
.gh-map { display:block; width:100%; max-width:1080px; margin:0 auto; height:auto; background:#fff; border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow-sm); padding:8px; }
.gh-map .bed { cursor:pointer; transition:stroke .1s; }
.gh-map .bed:hover { stroke:var(--brand-900); stroke-width:.25; }
.legend { max-width:1080px; margin-left:auto; margin-right:auto; display:flex; flex-wrap:wrap; gap:8px 18px; align-items:center; margin-top:14px; }
.legend span { white-space:nowrap; font-size:13px; color:var(--text-2); }
.legend .muted { white-space:normal; flex-basis:100%; }
.bed-strip { width:100%; height:auto; background:#fff; border-radius:8px; }
.sheet-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; background:#fff; border:1px solid var(--line); border-radius:var(--radius);
  max-width:1544px; margin:0 auto; box-shadow:var(--shadow-sm); }
.gh-sheet { display:block; width:100%; min-width:900px; height:auto; background:#fff; }
.sheet-wrap > .gh-sheet-web { min-width:0; max-height:80vh; margin:0 auto; }   /* screen drawing: fills the card, never taller than the screen */
.sheet-wrap:has(> .gh-sheet-web) { overflow:hidden; }
.sheet-wrap:has(> .gh-sheet-web)::after { display:none !important; }   /* whole map fits the width: no swipe hint */
.gh-sheet .bed-cell { cursor:pointer; transition:fill-opacity .12s; }
.gh-sheet .bed-cell:hover { fill:#1f6feb; fill-opacity:.12; }
.gh-sheet a:hover circle { stroke:#111; stroke-width:.3; }
@media (max-width: 640px) { .sheet-wrap::after { content:"Swipe sideways to see the whole polyhouse"; display:block; position:sticky; left:0;
  padding:8px 12px; font-size:12px; color:var(--muted); background:var(--surface-2); border-top:1px solid var(--line); } }
.thumbs { display:grid; gap:16px; grid-template-columns:repeat(auto-fill, minmax(200px, 1fr)); }
@media (max-width: 640px) { .thumbs { grid-template-columns:repeat(2, minmax(0, 1fr)); gap:10px; } }
.thumbs a { display:block; color:var(--text); font-size:13px; font-weight:400; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:8px 8px 11px; box-shadow:var(--shadow-sm); transition:box-shadow .2s var(--ease), transform .2s var(--ease), border-color .2s; line-height:1.6; }
.thumbs a:hover { box-shadow:var(--shadow-lg); transform:translateY(-3px); text-decoration:none; border-color:var(--line-strong); color:var(--text); }
.thumbs img { width:100%; border-radius:9px; aspect-ratio:4/3; object-fit:cover; margin-bottom:4px; display:block;
  background:linear-gradient(135deg, #e8edf1, #dfe6ec); }
.thumbs > p.muted, .thumbs > .empty { grid-column:1 / -1; padding:26px 16px; text-align:center; background:var(--surface);
  border:1px dashed var(--line-strong); border-radius:var(--radius); margin:0; }
.frames { display:grid; gap:12px; grid-template-columns:repeat(auto-fill, minmax(220px, 1fr)); }
.frames .fr { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:8px; font-size:13px; box-shadow:var(--shadow-sm); }
.frames img { width:100%; border-radius:8px; }
.frames label { display:inline-block; margin-right:6px; white-space:nowrap; }
video { width:100%; max-height:70vh; background:#000; border-radius:var(--radius-md); }

/* ---------- auth pages ---------- */
body.auth { background:
    radial-gradient(1000px 560px at 10% -10%, rgba(76,194,124,.20) 0%, transparent 60%),
    radial-gradient(800px 480px at 105% 110%, rgba(242,194,48,.14) 0%, transparent 55%),
    var(--bg); background-attachment:fixed; }
body.auth .shell { position:relative; }
body.auth main { display:flex; flex-direction:column; align-items:center; justify-content:center; padding:48px 16px; }
body.auth footer.foot { border:none; }
.auth-brand { display:flex; flex-direction:column; align-items:center; gap:8px; margin-bottom:24px; }
.auth-brand img { width:260px; max-width:72vw; height:auto; display:block; }
.auth-brand small { font-size:12.5px; font-weight:750; letter-spacing:.16em; text-transform:uppercase; color:var(--brand-600); }
.login { width:100%; max-width:420px; margin:0 auto; padding:30px 30px 26px; border:1px solid var(--line); border-top:5px solid var(--brand-500);
  box-shadow:0 24px 60px -24px rgba(16,32,24,.35); border-radius:22px; animation:rise .45s var(--ease) both; }
@media (max-width: 480px) { .login { padding:24px 20px 20px; border-radius:16px; } }
.login h1 { font-size:23px; margin-bottom:4px; }
.login label { display:block; margin-bottom:14px; }
.login input:not([type=checkbox]):not([type=radio]) { width:100%; margin-top:6px; padding:11px 13px; min-height:46px; font-size:15px; }
.login button, .login .btn { width:100%; min-height:46px; font-size:15px; }
.login-points { display:flex; flex-wrap:wrap; justify-content:center; gap:8px 18px; margin-top:22px; color:var(--muted); font-size:12.5px; font-weight:500; }
.login-points span { display:inline-flex; align-items:center; gap:6px; }
.login-points span::before { content:""; width:6px; height:6px; border-radius:50%; background:var(--brand-400); }
body.auth main > .alert { width:100%; max-width:420px; }
@keyframes rise { from { opacity:0; transform:translateY(10px); } }

/* ---------- page bar: back button + breadcrumb ---------- */
.pagebar { display:flex; align-items:center; gap:14px; margin:-4px 0 20px; flex-wrap:wrap; }
.back { display:inline-flex; align-items:center; gap:4px; padding:6px 13px 6px 9px; border-radius:999px; font-size:13px; font-weight:600;
  color:var(--text-2); background:var(--surface); border:1px solid var(--line-strong); box-shadow:var(--shadow-xs);
  transition:background .15s, color .15s, border-color .15s; }
.back:hover { text-decoration:none; color:var(--brand-700); border-color:var(--brand-500); background:var(--brand-50); }
.back:hover svg { transform:translateX(-2px); }
.back svg { transition:transform .15s; }
.crumbs { display:flex; align-items:center; gap:7px; font-size:13px; color:var(--muted); min-width:0; flex-wrap:wrap; }
.crumbs a { color:var(--muted); font-weight:500; }
.crumbs a:hover { color:var(--brand-700); }
.crumbs .sep { color:var(--line-strong); }
.crumbs .cur { color:var(--text); font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:60vw; }

/* ---------- busy buttons (form submitted) ---------- */
button.busy { position:relative; color:transparent !important; pointer-events:none; }
button.busy::after { content:""; position:absolute; inset:0; margin:auto; width:15px; height:15px; border-radius:50%;
  border:2px solid rgba(255,255,255,.45); border-top-color:#fff; animation:spin .7s linear infinite; }
button.secondary.busy::after, button.link.busy::after { border-color:rgba(16,24,40,.2); border-top-color:var(--brand-600); }
@keyframes spin { to { transform:rotate(360deg); } }

/* ---------- back to top ---------- */
.totop { position:fixed; right:20px; bottom:max(24px, env(safe-area-inset-bottom)); z-index:30; width:44px; height:44px; padding:0; border-radius:50%;
  background:var(--brand-900); border:1px solid rgba(255,255,255,.12); box-shadow:var(--shadow-lg); animation:rise .25s var(--ease) both; }
.totop:hover { background:var(--brand-700); }

/* ---------- page entrance ---------- */
main > * { animation:rise .35s var(--ease) both; }
main > *:nth-child(2) { animation-delay:.03s; } main > *:nth-child(3) { animation-delay:.06s; } main > *:nth-child(n+4) { animation-delay:.09s; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition:none !important; animation:none !important; scroll-behavior:auto !important; } }

/* ---------- print ---------- */
@media print {
  .sidebar, .mobilebar, .scrim, .pagebar, .totop, footer.foot, .filters button, .filters form, nav { display:none !important; }
  body.app .shell { margin-left:0 !important; }
  body { background:#fff; } main { padding:0; max-width:none; }
  main > * { animation:none !important; }
  .card, .kpi, .table-wrap, .gh-map, .sheet-wrap { box-shadow:none; break-inside:avoid; }
  .sheet-wrap { overflow:visible; border:none; } .sheet-wrap::after { display:none; }
  .gh-sheet { min-width:0; }
  a { color:inherit; }
}
.totop[hidden], [hidden] { display:none !important; }

/* ---------- AgriWealth integration, polyhouse list ---------- */
.aw-bar { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap;
  background:linear-gradient(100deg, var(--brand-50), var(--surface) 60%); border-color:var(--brand-100); }
.aw-bar form { margin:0; }
.ph-group { margin-bottom:8px; }
.ph-farm { font-size:17px; margin:22px 0 12px; display:flex; align-items:baseline; gap:10px; }
.ph-card { display:flex; flex-direction:column; gap:3px; position:relative; transition:transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s; margin-bottom:0; }
.ph-card:hover { transform:translateY(-2px); box-shadow:var(--shadow); border-color:var(--line-strong); }
.ph-card::before { content:""; position:absolute; left:0; right:0; top:0; height:3px; border-radius:var(--radius) var(--radius) 0 0;
  background:linear-gradient(90deg, var(--brand-500), var(--brand-400)); opacity:.85; }
.ph-card h2 { margin:2px 0 6px; font-size:17px; }
.ph-card[hidden], .ph-group[hidden] { display:none; }

/* ---------- map dot detail panel ---------- */
svg .dot { cursor:pointer; }
dialog.obs-dialog { border:none; border-radius:18px; padding:0; width:min(540px, calc(100vw - 24px)); max-height:calc(100vh - 32px);
  box-shadow:0 30px 80px -20px rgba(4,20,16,.55); background:var(--surface); color:var(--text); }
dialog.obs-dialog[open] { animation:pop .22s var(--ease) both; }
dialog.obs-dialog::backdrop { background:rgba(8,22,18,.5); backdrop-filter:blur(3px); }
@keyframes pop { from { opacity:0; transform:translateY(8px) scale(.98); } }
@media (max-width: 640px) {
  dialog.obs-dialog { width:100vw; max-width:100vw; margin:auto 0 0; border-radius:20px 20px 0 0; max-height:88vh; }
  dialog.obs-dialog[open] { animation:sheet .28s var(--ease) both; }
}
@keyframes sheet { from { transform:translateY(40px); opacity:.4; } }
.obs-card { padding:18px 20px 20px; display:flex; flex-direction:column; gap:12px; }
.obs-card-head { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; }
.obs-card-title { font-size:17px; font-weight:750; letter-spacing:-.01em; }
.obs-close { width:36px; height:36px; min-height:0; padding:0; font-size:20px; line-height:1; border-radius:50% !important; flex:none; }
.obs-card img, .obs-card video { width:100%; max-height:300px; object-fit:contain; background:#000; border-radius:12px; }
.obs-card-actions { display:flex; gap:8px; flex-wrap:wrap; }
.obs-final { display:flex; flex-direction:column; gap:4px; }
.findings { border:1px solid var(--line); border-radius:var(--radius-md); padding:12px 14px; background:var(--surface-2); }
.findings-head { font-weight:650; margin-bottom:8px; }
.frow { display:grid; grid-template-columns:auto minmax(0, 1.3fr) minmax(60px, 1fr) auto; gap:8px; align-items:center; padding:4px 0; }
.fname { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.fbar { height:8px; border-radius:4px; background:var(--line); overflow:hidden; }
.fbar > span { display:block; height:100%; border-radius:4px; }
.fnum { white-space:nowrap; font-size:13px; text-align:right; }
@media (max-width:520px) { .frow { grid-template-columns:auto 1fr auto; } .fbar { grid-column:1 / -1; } }

/* ---------- "Add beds": inputs and button on one baseline ---------- */
.filters.add-beds { align-items:flex-end; border-style:dashed; }
.filters.add-beds > b { line-height:40px; margin-right:4px; }
.filters.add-beds label { display:flex; flex-direction:column; gap:5px; }
.filters.add-beds input, .filters.add-beds select, .filters.add-beds button { height:40px; }
@media (max-width: 640px) { .filters.add-beds > label, .filters.add-beds > button { flex:1 1 140px; } .filters.add-beds input, .filters.add-beds select { width:100% !important; } }

/* ---------- Today: date switcher, sections ---------- */
.datenav { display:inline-flex; align-items:center; gap:6px; }
.datenav .btn { width:40px; padding:0; }
.datenav form { margin:0; }
.section-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:30px 0 12px; }
.section-head h2 { margin:0; }
.section-head a { font-size:13px; font-weight:600; }
.count { display:inline-grid; place-items:center; min-width:22px; height:22px; padding:0 7px; border-radius:999px; font-size:12px; font-weight:700;
  background:var(--surface-3); color:var(--text-2); border:1px solid var(--line); }
.count.hot { background:var(--red-bg); color:var(--red); border-color:var(--red-line); }
.qgrid { display:grid; grid-template-columns:repeat(auto-fit, minmax(120px, 1fr)); gap:10px; margin-top:12px; }
.qstat { padding:10px 12px; border-radius:var(--radius-md); background:var(--surface-2); border:1px solid var(--line); }
.qstat b { display:block; font-size:19px; font-weight:750; letter-spacing:-.02em; font-variant-numeric:tabular-nums; }
.qstat span { font-size:12px; color:var(--muted); font-weight:500; }
.qstat.bad b { color:var(--red); } .qstat.warn b { color:var(--amber); }
.chips { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.chip { display:inline-flex; align-items:center; gap:6px; padding:4px 10px; border-radius:999px; font-size:12.5px; font-weight:600;
  background:var(--surface); border:1px solid var(--line-strong); color:var(--text-2); }
a.chip:hover { border-color:var(--brand-500); color:var(--brand-700); background:var(--brand-50); text-decoration:none; }
.chip.hot { border-color:var(--red-line); background:var(--red-bg); color:var(--red); }
.hotlist { display:flex; flex-direction:column; }
.hotlist > div { display:flex; align-items:center; gap:12px; padding:10px 0; border-bottom:1px solid var(--line); }
.hotlist > div:last-child { border-bottom:none; padding-bottom:0; }
.hotlist > div:first-child { padding-top:0; }
.hotlist a { font-weight:700; min-width:64px; }


/* ==========================================================================
   Map page (map.html + map.js)
   header + filters · KPI tiles · map card (toolbar, stage) · detail cards
   ========================================================================== */

/* ---- header: title on the left, filters on the right ---- */
.mp-header { display:flex; flex-wrap:wrap; align-items:flex-end; justify-content:space-between; gap:10px 20px; margin-bottom:8px; }
.mp-heading h1 { margin:0; font-size:clamp(18px, 1.7vw, 22px); line-height:1.2; letter-spacing:-.01em; }
.mp-heading p { margin:3px 0 0; font-size:12.5px; }
.mp-heading p b { color:var(--text); font-weight:650; }
.mp-clear { margin-left:6px; font-size:12.5px; }
.mp-filters { display:flex; flex-wrap:wrap; align-items:flex-end; gap:10px; }
.mp-field { display:flex; flex-direction:column; gap:3px; margin:0; padding:0; border:0; min-width:0; }
.mp-field > span, .mp-field > legend { font-size:10.5px; font-weight:650; color:var(--muted); text-transform:uppercase; letter-spacing:.05em; padding:0; margin-bottom:5px; }
.mp-field > span { margin-bottom:0; }
.mp-field input, .mp-field select { height:34px; min-height:34px; padding-top:5px; padding-bottom:5px; font-size:13px; }
.mp-field select { max-width:220px; }
.mp-days .seg { padding:3px; }
.seg-opt { position:relative; display:inline-flex; margin:0; cursor:pointer; }
.seg-opt input { position:absolute; opacity:0; pointer-events:none; }
.seg-opt span { display:inline-flex; align-items:center; height:28px; padding:0 10px; border-radius:8px; font-size:13px; font-weight:600;
  color:var(--muted); transition:background .15s var(--ease), color .15s; }
.seg-opt:hover span { color:var(--text); }
.seg-opt input:checked + span { background:var(--surface); color:var(--text); box-shadow:var(--shadow-sm); }
.seg-opt input:focus-visible + span { box-shadow:var(--focus); }
.mp-apply { height:38px; }
.mp-filters.auto .mp-apply { display:none; }        /* filters apply on change when JS runs */

/* ---- KPI tiles ---- */
.mp-kpis { display:grid; grid-template-columns:repeat(4, minmax(0, 1fr)); gap:12px; margin-bottom:8px; }
.mp-kpi { position:relative; display:flex; flex-direction:row; align-items:center; justify-content:space-between; gap:8px; padding:12px 16px; background:var(--surface);
  border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow-xs); overflow:hidden; }
.mp-kpi::before { content:""; position:absolute; inset:0 auto 0 0; width:3px; background:var(--brand-500); opacity:.85; }
.mp-kpi.is-bad::before { background:var(--red); }
.mp-kpi.is-warn::before { background:#f39c12; }
.mp-kpi-label { font-size:11.5px; font-weight:650; color:var(--muted); text-transform:uppercase; letter-spacing:.06em; }
.mp-kpi b { font-size:22px; line-height:1.1; font-weight:750; color:var(--text); font-variant-numeric:tabular-nums; }
.mp-kpi b small { font-size:12.5px; font-weight:600; color:var(--muted); }
.mp-kpi.is-bad b { color:var(--red); }
.mp-kpi.is-warn b { color:var(--amber); }
.mp-meter { position:absolute; left:16px; right:16px; bottom:6px; height:3px; border-radius:2px; background:var(--surface-3); overflow:hidden; }
.mp-meter i { display:block; height:100%; border-radius:2px; background:linear-gradient(90deg, var(--brand-500), var(--brand-400)); }

/* ---- map card ---- */
.map-card { position:relative; padding:12px 14px 10px; margin-bottom:16px; }
.map-head { display:flex; align-items:center; gap:10px 12px; margin-bottom:10px; min-width:0; }
.map-head .seg { flex:none; }
.map-chips { display:flex; gap:6px; flex:1 1 auto; min-width:0; overflow-x:auto; padding:2px; scrollbar-width:none; }
.map-chips::-webkit-scrollbar { display:none; }
.map-chips .chip { --c:var(--brand-600); flex:none; display:inline-flex; align-items:center; gap:7px; height:34px; min-height:0; padding:0 12px;
  border-radius:999px; font-size:13px; font-weight:600; background:var(--surface); color:var(--text-2);
  border:1px solid var(--line-strong); box-shadow:none; cursor:pointer; transition:background .15s var(--ease), border-color .15s, color .15s; }
.map-chips .chip:hover { border-color:var(--c); color:var(--text); background:var(--surface); transform:none; }
.map-chips .chip.on { border-color:var(--c); background:color-mix(in srgb, var(--c) 11%, var(--surface)); color:var(--text);
  box-shadow:inset 0 0 0 1px var(--c); }
.map-chips .chip .n { font-size:11.5px; font-weight:700; color:var(--muted); background:var(--surface-3); border-radius:999px; padding:1px 7px; }
.map-chips .chip.on .n { background:var(--surface); color:var(--text); }
.map-chips .chip .sw { margin:0; }
.mp-empty-chip { display:inline-flex; align-items:center; height:34px; padding:0 12px; border-radius:999px; font-size:13px;
  color:var(--green); background:var(--green-bg); border:1px solid var(--green-line); white-space:nowrap; }
.map-tools { flex:none; display:inline-flex; align-items:center; gap:2px; padding:3px; border-radius:11px; background:var(--surface-3); border:1px solid var(--line); }
.map-tools .icon-btn { width:32px; height:32px; min-height:0; padding:0; display:grid; place-items:center; font-size:18px; line-height:1;
  background:transparent; color:var(--text-2); border:1px solid transparent; border-radius:8px; box-shadow:none; }
.map-tools .icon-btn:hover { background:var(--surface); border-color:var(--line); color:var(--text); }
.map-tools .icon-btn:active { transform:scale(.94); }
.zoom-pct { min-width:44px; text-align:center; font-size:12px; font-weight:600; font-variant-numeric:tabular-nums; color:var(--muted); }

/* stage: map.js sets its height (fills the width, never too short to read nor taller than the screen) */
.map-stage { position:relative; overflow:hidden; border:1px solid var(--line); border-radius:var(--radius-md);
  background:linear-gradient(180deg, #fbfcfd, #f3f6f5); touch-action:pan-x pan-y; outline:none;
  user-select:none; -webkit-user-select:none; }
.map-stage.zoomed { touch-action:none; cursor:grab; }
.map-stage.dragging { cursor:grabbing; }
.map-stage:focus-visible { box-shadow:var(--focus); }
.map-stage > svg { display:block; width:100%; height:auto; max-width:none !important; min-width:0; margin:0; border:0;
  border-radius:0; box-shadow:none; padding:0; background:transparent; }
.map-stage.sized > svg { height:100%; }
.map-stage > svg > rect:first-of-type { fill:transparent; }
.map-stage svg .dot { transition:opacity .2s, stroke-width .15s; }
.map-stage svg a:hover .dot, .map-stage svg .dot.hot { stroke:#0d1a2b; stroke-width:.35; }
.map-stage.filtering svg .dot.dim { opacity:.1; }
.map-stage svg .bed-cell:hover, .map-stage svg .bay:hover { fill:#1f6feb; fill-opacity:.1; }
.map-stage svg .bed:hover { stroke:var(--brand-700); stroke-width:.2; }
.map-pan-hint { position:absolute; left:50%; bottom:10px; transform:translateX(-50%); padding:5px 12px; border-radius:999px;
  background:rgba(13,26,43,.78); color:#fff; font-size:12px; pointer-events:none; opacity:0; transition:opacity .3s; white-space:nowrap; }
.map-stage.can-pan .map-pan-hint { opacity:1; }
.map-stage.can-pan.touched .map-pan-hint { opacity:0; }

.map-tip { position:fixed; z-index:60; width:max-content; max-width:min(300px, calc(100vw - 16px)); pointer-events:none; padding:8px 11px; border-radius:10px;
  background:rgba(13,26,43,.95); color:#fff; font-size:12.5px; line-height:1.4; box-shadow:var(--shadow-lg);
  transform:translate(-50%, calc(-100% - 12px)); }
.map-tip b { color:#fff; }
.map-tip .tip-sw { display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:6px; box-shadow:0 0 0 1.5px #fff; }
.map-tip .tip-sub { display:block; color:#b9c3cf; font-size:11.5px; margin-top:2px; }
.map-hint { margin:8px 2px 0; text-align:center; }
.map-hint .hint-touch { display:none; }
@media (hover:none) { .map-hint .hint-desk { display:none; } .map-hint .hint-touch { display:inline; } }

/* full screen */
.map-card:fullscreen, .map-card.is-full { margin:0; border-radius:0; display:flex; flex-direction:column; background:var(--surface); padding:14px; }
.map-card.is-full { position:fixed; inset:0; z-index:70; }
.map-card:fullscreen .map-stage, .map-card.is-full .map-stage { flex:1; }

/* ---- detail cards under the map ---- */
.mp-details { display:grid; grid-template-columns:repeat(auto-fit, minmax(260px, 1fr)); gap:12px; align-items:start; }
.mp-block { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:14px 16px; box-shadow:var(--shadow-xs); }
.mp-title { margin:0 0 10px; font-size:11.5px; font-weight:700; letter-spacing:.07em; text-transform:uppercase; color:var(--muted); }
.mp-legend { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; font-size:13.5px; color:var(--text-2); }
.mp-legend li { display:flex; align-items:center; gap:10px; }
.mp-dot { width:11px; height:11px; border-radius:50%; flex:none; box-shadow:0 0 0 2px #fff, 0 1px 3px rgba(13,26,43,.35); }
.mp-x { width:11px; text-align:center; font-weight:800; color:var(--text); flex:none; }
.mp-bed { width:11px; height:16px; border-radius:6px; flex:none; border:1px solid #d5dfd8; }
.mp-note { margin:12px 0 0; line-height:1.5; }
.mp-facts { margin:0; display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.mp-facts > div { background:var(--surface-2); border:1px solid var(--line); border-radius:9px; padding:8px 10px; min-width:0; }
.mp-facts dt { font-size:11px; color:var(--muted); }
.mp-facts dd { margin:2px 0 0; font-size:15px; font-weight:700; color:var(--text); font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
.mp-route { font-size:13px; border:1px solid var(--line); border-radius:9px; overflow:hidden; }
.mp-route-head, .mp-route-row { display:grid; grid-template-columns:1.6fr 1fr 1fr 1fr; }
.mp-route-head span, .mp-route-row span { padding:7px 9px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mp-route-head { background:var(--surface-2); color:var(--muted); font-weight:650; font-size:11px; text-transform:uppercase; letter-spacing:.04em; }
.mp-route-row { border-top:1px solid var(--line); }
.mp-route-row span:not(:first-child) { font-variant-numeric:tabular-nums; color:var(--text); font-weight:650; }

/* ---- responsive ---- */
@media (max-width: 900px) {
  .mp-header { align-items:stretch; }
  .mp-filters { width:100%; }
  .mp-kpis { grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .map-head { flex-wrap:wrap; }
  .map-chips { order:3; flex-basis:100%; }
  .map-tools { margin-left:auto; }
}
@media (max-width: 640px) {
  .mp-filters { display:grid; grid-template-columns:1fr 1fr; }
  .mp-days { grid-column:1 / -1; }
  .mp-days .seg { display:flex; }
  .mp-days .seg-opt { flex:1; }
  .mp-days .seg-opt span { width:100%; justify-content:center; height:34px; }
  .mp-field select { max-width:none; width:100%; }
  .mp-field input { width:100%; }
  .mp-kpi { padding:10px 13px; }
  .mp-kpi b { font-size:19px; }
  .map-card { padding:10px 10px 8px; margin-left:-6px; margin-right:-6px; border-radius:12px; }
  .zoom-pct { display:none; }
}
@media (prefers-reduced-motion: reduce) { .map-stage svg *, .map-chips .chip, .seg-opt span, .map-pan-hint { transition:none !important; } }
@media print {
  .mp-filters, .map-head .map-tools, .map-chips, .map-hint, .map-tip, .map-pan-hint { display:none !important; }
  .map-stage { border:none; overflow:visible; height:auto !important; background:#fff; }
  .mp-block, .mp-kpi { break-inside:avoid; box-shadow:none; }
}

/* ---------- Today: panels (one card per topic, header + body) ---------- */
.dash-row { display:grid; gap:16px; grid-template-columns:minmax(0, 1fr); margin-top:16px; }
@media (min-width: 1100px) { .dash-row { grid-template-columns:minmax(0, 1fr) minmax(0, 1fr); align-items:start; } }
.panel { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:16px 18px; box-shadow:var(--shadow-sm); min-width:0; }
.panel.flush { padding:0; overflow:hidden; margin-top:16px; }
.panel-head { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; margin-bottom:12px; }
.panel-head.pad { padding:16px 18px 0; }
.panel-head h2 { margin:0; font-size:15.5px; }
.panel-head a { font-size:13px; font-weight:600; }
.panel-empty { margin:0; padding:14px; border-radius:var(--radius-md); background:var(--brand-50); color:var(--brand-700); font-size:13.5px; font-weight:500; }
.rows { list-style:none; margin:0; padding:0; }
.rows > li + li { border-top:1px solid var(--line); }
.rows.scroll { max-height:340px; overflow-y:auto; margin-right:-8px; padding-right:8px; scrollbar-width:thin; }
.row-item { display:flex; align-items:flex-start; gap:10px; padding:9px 0; font-size:13.5px; color:var(--text-2); }
.row-item:first-child { padding-top:0; }
.row-item .sig { flex:none; width:8px; height:8px; margin-top:6px; border-radius:50%; background:var(--muted); }
.row-item.red .sig { background:var(--red); box-shadow:0 0 0 3px var(--red-bg); }
.row-item.amber .sig { background:#f79009; box-shadow:0 0 0 3px var(--amber-bg); }
.row-item.red span:last-child { color:#7a271a; font-weight:500; }
.row-link { display:flex; align-items:center; gap:10px; padding:9px 6px; margin:0 -6px; border-radius:var(--radius-sm); color:var(--text); font-weight:500; font-size:13.5px; }
.rows > li:first-child .row-link { margin-top:-6px; }
.row-link:hover { background:var(--brand-50); text-decoration:none; color:var(--text); }
.row-link .bed { min-width:64px; color:var(--brand-700); font-weight:700; }
.row-link .grow { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pdot { display:inline-block; width:9px; height:9px; border-radius:50%; flex:none; margin-right:5px; vertical-align:0; box-shadow:0 0 0 1.5px #fff, 0 0 0 2.5px rgba(16,24,40,.1); }
.note-bad { margin:-4px 0 10px; font-size:13px; font-weight:600; color:var(--red); }
.more-chips summary { margin-top:10px; font-size:13px; color:var(--brand-700); font-weight:600; }
.table-wrap.bare { border:0; border-radius:0; box-shadow:none; margin-top:12px; }
.table-wrap.bare tr > :first-child { padding-left:18px; } .table-wrap.bare tr > :last-child { padding-right:18px; }
table.zones th.n, table.zones td.n { text-align:right; white-space:nowrap; }
table.zones .v { font-weight:650; }
table.zones .up { color:var(--red); font-size:10px; } table.zones .down { color:var(--green); font-size:10px; }
.thumbs.compact { grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); gap:12px; }
/* KPI tiles: icon in the top-right corner, not on its own line - shorter tiles */
.kpi:has(> .kpi-ico) { padding-right:58px; }
.kpi > .kpi-ico { position:absolute; top:14px; right:14px; margin:0; }

/* =================== Overview (Today) - enterprise layout =================== */
.sr-only { position:absolute !important; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0; }
.ov-head { display:flex; flex-wrap:wrap; align-items:flex-end; justify-content:space-between; gap:14px 20px; margin-bottom:18px; }
.ov-title h1 { margin:0; font-size:24px; letter-spacing:-.02em; }
.ov-title p { margin:4px 0 0; font-size:13px; }
.ov-tools { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.ov-tools .btn { min-height:38px; padding:7px 14px; }
.datebar { display:inline-flex; align-items:center; height:38px; background:var(--surface); border:1px solid var(--line-strong); border-radius:var(--radius-sm); box-shadow:var(--shadow-xs); overflow:hidden; }
.datebar a { display:grid; place-items:center; width:36px; height:100%; color:var(--text-2); }
.datebar a:hover { background:var(--surface-2); color:var(--brand-700); text-decoration:none; }
.datebar form { margin:0; height:100%; border-left:1px solid var(--line); border-right:1px solid var(--line); }
.datebar input { height:100%; min-height:0; border:0; border-radius:0; box-shadow:none; padding:0 10px; font-size:13.5px; font-weight:600; }

/* one card, five metrics */
.kstrip { display:grid; grid-template-columns:repeat(4, minmax(0, 1fr)); background:var(--surface); border:1px solid var(--line);
  border-radius:var(--radius); box-shadow:var(--shadow-sm); overflow:hidden; }
.kcell { position:relative; display:flex; flex-direction:column; gap:2px; padding:16px 20px; min-width:0; color:var(--text); }
.kcell + .kcell { border-left:1px solid var(--line); }
a.kcell:hover { background:var(--surface-2); text-decoration:none; color:var(--text); }
.klabel { font-size:11.5px; font-weight:650; color:var(--muted); text-transform:uppercase; letter-spacing:.06em; }
.kval { font-size:28px; line-height:1.15; font-weight:750; letter-spacing:-.02em; font-variant-numeric:tabular-nums; margin-top:4px; }
.kval small { font-size:14px; font-weight:600; color:var(--muted); margin-left:3px; letter-spacing:0; }
.kval.is-bad { color:var(--red); } .kval.is-warn { color:var(--amber); }
.ksub { font-size:12.5px; color:var(--muted); }
a.kcell .ksub { color:var(--brand-700); font-weight:600; }
.t-bad { color:var(--red); }
.kbar { display:block; height:4px; margin:8px 0 6px; border-radius:2px; background:var(--surface-3); overflow:hidden; }
.kbar i { display:block; height:100%; border-radius:2px; background:var(--brand-500); }

/* grid: two columns, wide panels span both */
.ov-grid { display:grid; gap:16px; margin-top:16px; grid-template-columns:minmax(0, 1fr); }
@media (min-width: 1100px) { .ov-grid { grid-template-columns:minmax(0, 1.4fr) minmax(0, 1fr); align-items:start; } .ov-grid .span2 { grid-column:1 / -1; } }
.ov-grid .panel, .ov-grid .panel.flush { margin:0; }
.panel-head p { margin:2px 0 0; }
.panel-head { align-items:flex-start; }

/* trend: one series, thin bars on a recessive grid, tooltip on hover/focus */
.trend-total { text-align:right; line-height:1.1; }
.trend-total b { display:block; font-size:22px; font-weight:750; font-variant-numeric:tabular-nums; }
.tchart { position:relative; height:200px; margin-top:6px; padding:0 0 22px 28px; }
.tgrid { position:absolute; inset:0 0 22px 28px; display:flex; flex-direction:column; justify-content:space-between; }
.tline { position:relative; border-top:1px dashed var(--line); height:0; }
.tline:last-child { border-top:1px solid var(--line-strong); }
.tline span { position:absolute; left:-28px; top:-8px; width:22px; text-align:right; font-size:11px; color:var(--muted); font-variant-numeric:tabular-nums; }
.tbars { position:relative; height:100%; display:flex; align-items:stretch; gap:2px; }
.tcol { position:relative; flex:1; display:flex; align-items:flex-end; justify-content:center; outline:none; cursor:default; border-radius:4px; }
.tcol i { display:block; width:min(60%, 22px); min-height:2px; border-radius:4px 4px 0 0; background:var(--brand-400); transition:background .15s; }
.tcol.is-today i { background:var(--brand-700); }
.tcol:hover, .tcol:focus-visible { background:rgba(34,163,90,.07); }
.tcol:hover i, .tcol:focus-visible i { background:var(--brand-600); }
.tx { position:absolute; bottom:-20px; font-size:11px; color:var(--muted); white-space:nowrap; }
.tcol.is-today .tx { color:var(--text); font-weight:650; }
.tcol::after { content:attr(data-tip); position:absolute; bottom:calc(100% + 6px); left:50%; transform:translateX(-50%); z-index:5;
  white-space:nowrap; padding:6px 9px; border-radius:8px; background:#0f1d16; color:#fff; font-size:12px; font-weight:500;
  opacity:0; pointer-events:none; transition:opacity .12s; }
.tcol:first-child::after, .tcol:nth-child(2)::after { left:0; transform:none; }
.tcol:last-child::after, .tcol:nth-last-child(2)::after { left:auto; right:0; transform:none; }
.tcol:hover::after, .tcol:focus-visible::after { opacity:1; }

/* needs attention: severity = icon + word, never colour alone */
.att { list-style:none; margin:0; padding:0; max-height:236px; overflow-y:auto; scrollbar-width:thin; }
.att-item { display:flex; flex-direction:column; gap:3px; padding:10px 0; }
.att-item:first-child { padding-top:0; }
.att-item + .att-item { border-top:1px solid var(--line); }
.att-text { font-size:13.5px; color:var(--text); line-height:1.45; }
.sev { display:inline-flex; align-items:center; gap:5px; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; }
.att-item.red .sev, .sev.red { color:var(--red); }
.att-item.amber .sev { color:var(--amber); }
.ok-state { display:flex; align-items:center; gap:8px; margin:0; padding:12px 14px; border-radius:var(--radius-md);
  background:var(--brand-50); color:var(--brand-700); font-size:13.5px; font-weight:600; }

/* zone health */
.trend { display:inline-flex; align-items:center; gap:4px; font-size:12px; font-weight:650; padding:2px 8px; border-radius:999px; white-space:nowrap; }
.trend.up { color:var(--red); background:var(--red-bg); }
.trend.down { color:var(--green); background:var(--green-bg); }
.trend.flat { color:var(--muted); background:var(--surface-3); }
td.di { white-space:nowrap; }
td.di b { font-variant-numeric:tabular-nums; font-weight:650; }
.dibar, .cbar { display:inline-block; width:64px; height:6px; margin-right:8px; vertical-align:middle; border-radius:3px; background:var(--surface-3); overflow:hidden; }
.dibar i { display:block; height:100%; border-radius:3px; background:var(--red); opacity:.8; }
.cbar i { display:block; height:100%; border-radius:3px; background:var(--brand-500); }
.table-note { margin:0; padding:10px 18px 14px; border-top:1px solid var(--line); }

/* coverage */
table.cov { width:100%; }
table.cov th, table.cov td { padding:8px 0; background:none; }
table.cov th { position:static; font-size:11px; }
table.cov th.n, table.cov td.n { text-align:right; }
table.cov tr:hover td { background:none; }
.miss-hot { margin-top:14px; padding-top:12px; border-top:1px solid var(--line); }
.miss-hot .chips { margin-top:8px; }

@media (max-width: 1100px) { .kstrip { grid-template-columns:repeat(2, minmax(0, 1fr)); } .kcell:nth-child(3) { border-left:0; } .kcell:nth-child(n+3) { border-top:1px solid var(--line); } }
@media (max-width: 640px) {
  .kstrip { grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .kcell { padding:12px 14px; } .kval { font-size:22px; }
  .kcell:nth-child(3) { border-left:0; }
  .kcell:nth-child(n+3) { border-top:1px solid var(--line); }
  .ov-tools { width:100%; } .ov-tools .btn { flex:1; }
  .datebar { width:100%; } .datebar form { flex:1; } .datebar input { width:100%; }
  .dibar { width:48px; }
}
table.zones th, table.zones td { padding-left:10px; padding-right:10px; }
.tcol:nth-last-child(2) .tx { display:none; }   /* keeps "Today" clear of the label before it */
.att { -webkit-mask-image:linear-gradient(#000 calc(100% - 28px), transparent); mask-image:linear-gradient(#000 calc(100% - 28px), transparent); padding-bottom:20px; }   /* scrolls: fade says there is more */

/* =================== error pages (templates/error.html) =================== */
.err-page .err-wrap { min-height:100vh; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:40px 16px; }
.err-logo { margin-bottom:22px; }
.err-logo img { display:block; width:190px; height:auto; }
.err-card { width:100%; max-width:480px; padding:30px 30px 26px; text-align:center; background:var(--surface); border:1px solid var(--line);
  border-top:5px solid var(--brand-500); border-radius:22px; box-shadow:0 24px 60px -24px rgba(16,32,24,.35); animation:rise .4s var(--ease) both; }
.err-icon { width:56px; height:56px; margin:0 auto 14px; display:grid; place-items:center; border-radius:16px; background:var(--brand-50); color:var(--brand-700); border:1px solid var(--brand-100); }
.err-icon.bad { background:var(--red-bg); color:var(--red); border-color:var(--red-line); }
.err-icon.lock { background:var(--amber-bg); color:var(--amber); border-color:var(--amber-line); }
.err-code { display:inline-block; font-size:11.5px; font-weight:700; letter-spacing:.1em; text-transform:uppercase; color:var(--muted); }
.err-card h1 { margin:4px 0 8px; font-size:22px; line-height:1.25; }
.err-msg { margin:0 auto; max-width:380px; color:var(--text-2); font-size:14.5px; }
.err-details { margin:14px 0 0; padding:10px 14px 10px 30px; text-align:left; font-size:13px; color:var(--text-2);
  background:var(--surface-2); border:1px solid var(--line); border-radius:var(--radius-md); }
.err-details li { margin:2px 0; }
.err-actions { display:flex; flex-wrap:wrap; justify-content:center; gap:8px; margin-top:22px; }
.err-actions .btn { min-width:120px; }
.err-ref { display:flex; align-items:center; justify-content:center; gap:8px; margin-top:22px; padding-top:16px; border-top:1px solid var(--line);
  font-size:12.5px; color:var(--muted); flex-wrap:wrap; }
.err-ref code { font-family:ui-monospace, SFMono-Regular, Consolas, monospace; font-size:13px; color:var(--text); background:var(--surface-3);
  padding:3px 8px; border-radius:6px; }
.err-copy { min-height:0; padding:3px 10px; font-size:12px; color:var(--brand-700); background:var(--brand-50); border:1px solid var(--brand-100);
  box-shadow:none; border-radius:6px; }
.err-copy:hover { color:var(--brand-800); filter:none; box-shadow:none; }
.err-hint { margin:8px auto 0; max-width:360px; font-size:12px; color:var(--muted); }
@media (max-width: 480px) { .err-card { padding:24px 18px 20px; } .err-actions .btn { flex:1; min-width:0; } }
