/* ============================================================
   HFMP — Harbur Farm Management Platform
   Premium dark agritech theme · zero dependencies
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #0a0e13;
  --bg-2: #0d1219;
  --panel: #121a24;
  --panel-2: #16202c;
  --panel-3: #1b2735;
  --elevate: #1e2c3c;
  --line: rgba(148, 178, 210, 0.10);
  --line-strong: rgba(148, 178, 210, 0.18);

  /* Text */
  --text: #e7eef6;
  --text-2: #aebccd;
  --muted: #6f8198;
  --faint: #4d5f74;

  /* Brand / accents */
  --accent: #34d399;      /* signal green */
  --accent-2: #22d3ee;    /* cyan */
  --accent-3: #a78bfa;    /* violet */
  --warn: #fbbf24;        /* amber */
  --danger: #f87171;      /* red */
  --good: #34d399;
  --info: #60a5fa;
  --pink: #f472b6;
  --lime: #a3e635;
  --orange: #fb923c;

  --accent-soft: rgba(52, 211, 153, 0.12);
  --warn-soft: rgba(251, 191, 36, 0.12);
  --danger-soft: rgba(248, 113, 113, 0.12);
  --info-soft: rgba(96, 165, 250, 0.12);

  --shadow: 0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 28px rgba(0,0,0,0.45);
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.35);
  --radius: 14px;
  --radius-sm: 9px;

  --font: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;

  --header-h: 58px;
  --ctx-h: 38px;
  --tab-h: 46px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(34, 211, 238, 0.06), transparent 60%),
    radial-gradient(1000px 600px at -10% 10%, rgba(52, 211, 153, 0.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(52,211,153,0.28); }

/* Scrollbars */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3a4d; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #38506a; background-clip: content-box; }

a { color: var(--accent-2); text-decoration: none; }

/* ===================== HEADER ===================== */
.app-header {
  position: sticky; top: 0; z-index: 60;
  height: var(--header-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px;
  background: linear-gradient(180deg, rgba(15,22,31,0.96), rgba(12,18,25,0.92));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 250px; }
.brand-mark { display: grid; place-items: center; filter: drop-shadow(0 0 10px rgba(52,211,153,0.25)); }
.brand-title { font-weight: 800; font-size: 15px; letter-spacing: 0.14em; }
.brand-sub { font-weight: 500; color: var(--muted); letter-spacing: 0.04em; font-size: 11px; }
.brand-tag { font-size: 10px; color: var(--faint); letter-spacing: 0.06em; margin-top: 1px; }

.header-search {
  flex: 1; max-width: 460px;
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 0 11px; height: 36px;
  color: var(--muted);
}
.header-search input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 13px; font-family: var(--font); }
.header-search input::placeholder { color: var(--faint); }
.header-search kbd {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  border: 1px solid var(--line-strong); border-radius: 5px; padding: 2px 5px; background: var(--panel);
}
.search-ico { color: var(--muted); }

.header-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.hpill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 11.5px; font-weight: 600; color: var(--text-2); white-space: nowrap;
}
.hpill-live { color: var(--accent); }
.hpill-season strong { color: var(--text); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-live { background: var(--accent); box-shadow: 0 0 0 0 rgba(52,211,153,0.6); animation: pulse 2.4s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52,211,153,0.5); }
  70% { box-shadow: 0 0 0 6px rgba(52,211,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}
.icon-btn {
  position: relative; height: 32px; width: 32px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--text); }
.badge-count {
  position: absolute; top: -5px; right: -5px; background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700; height: 15px; min-width: 15px; padding: 0 3px;
  border-radius: 8px; display: grid; place-items: center; border: 2px solid var(--bg);
}
.user-chip { display: flex; align-items: center; gap: 8px; padding-left: 6px; cursor: pointer; }
.avatar {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06231b;
  font-weight: 800; font-size: 12px;
}
.user-meta { line-height: 1.2; }
.user-name { font-size: 12px; font-weight: 700; }
.user-role { font-size: 10px; color: var(--muted); }

/* ===================== CONTEXT BAR ===================== */
.context-bar {
  position: sticky; top: var(--header-h); z-index: 55;
  height: var(--ctx-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; background: var(--bg-2); border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.context-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.field-switch {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px;
}
.field-switch .fs-org { color: var(--muted); }
.field-switch .fs-field { font-weight: 700; }
.field-switch .caret { color: var(--muted); }
.ctx-chip { color: var(--text-2); }
.ctx-chip .muted { color: var(--faint); margin-right: 3px; }
.ctx-stage strong { color: var(--accent); }
.context-right { display: flex; align-items: center; gap: 11px; color: var(--muted); }
.ctx-mini { font-size: 11.5px; }
.ctx-coords { font-family: var(--mono); font-size: 11px; }
.ctx-divider { width: 1px; height: 14px; background: var(--line-strong); display: inline-block; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ===================== TAB BAR ===================== */
.tab-bar {
  position: sticky; top: calc(var(--header-h) + var(--ctx-h)); z-index: 50;
  height: var(--tab-h); display: flex; align-items: stretch; gap: 2px;
  padding: 0 12px; background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 0 14px;
  font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap;
  border: none; background: none; cursor: pointer; position: relative; height: 100%;
  border-bottom: 2px solid transparent;
}
.tab svg { opacity: 0.8; }
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab.active svg { opacity: 1; color: var(--accent); }
.tab .tab-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--warn); }

/* ===================== LAYOUT ===================== */
.view { max-width: 1640px; margin: 0 auto; padding: 22px 22px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; margin: 0; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px;
  border-radius: 9px; border: 1px solid var(--line-strong); background: var(--panel);
  color: var(--text-2); font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: var(--font);
}
.btn:hover { background: var(--panel-2); color: var(--text); }
.btn-accent { background: linear-gradient(135deg, var(--accent), #1fae7e); color: #06231b; border: none; }
.btn-accent:hover { filter: brightness(1.06); color: #06231b; }
.btn-ghost { background: transparent; }
.btn svg { opacity: 0.9; }

/* ===================== GRID ===================== */
.grid { display: grid; gap: 16px; }
/* Let grid children shrink below their content's intrinsic width so inner
   scroll containers (.tbl-wrap) clip instead of stretching the track —
   otherwise wide tables blow out the page width on narrow screens. */
.grid > * { min-width: 0; }
.card { min-width: 0; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-5 { grid-template-columns: repeat(5, 1fr); }
.g-6 { grid-template-columns: repeat(6, 1fr); }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.col-2-1 { grid-template-columns: 2fr 1fr; }
.col-1-2 { grid-template-columns: 1fr 2fr; }
.col-3-2 { grid-template-columns: 3fr 2fr; }
@media (max-width: 1200px) {
  .g-4, .g-5, .g-6 { grid-template-columns: repeat(2, 1fr); }
  .g-3 { grid-template-columns: repeat(2, 1fr); }
  .col-2-1, .col-1-2, .col-3-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}
@media (max-width: 760px) {
  .g-2, .g-3, .g-4, .g-5, .g-6, .g-auto { grid-template-columns: 1fr; }
}

/* ===================== CARD / PANEL ===================== */
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.card.tight { padding: 13px; }
.card.pad-0 { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.card-title { font-size: 13px; font-weight: 700; letter-spacing: 0.01em; }
.card-title .sub { color: var(--muted); font-weight: 500; font-size: 11px; margin-left: 6px; }
.card-tools { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.card-tag { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.09em; font-weight: 700; }

.section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--faint); font-weight: 700; margin: 26px 0 12px;
  display: flex; align-items: center; gap: 9px;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ===================== KPI / STAT CARD ===================== */
.stat {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 15px;
  position: relative; overflow: hidden; box-shadow: var(--shadow-sm);
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: 0.85; }
.stat.s-warn::before { background: var(--warn); }
.stat.s-danger::before { background: var(--danger); }
.stat.s-info::before { background: var(--info); }
.stat.s-violet::before { background: var(--accent-3); }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700; }
.stat-ico { color: var(--muted); opacity: 0.7; }
.stat-value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin-top: 8px; line-height: 1; }
.stat-value .unit { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.stat-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 9px; gap: 8px; }
.stat-sub { font-size: 11px; color: var(--faint); }
.trend { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 700; padding: 2px 6px; border-radius: 6px; }
.trend.up { color: var(--good); background: var(--accent-soft); }
.trend.down { color: var(--danger); background: var(--danger-soft); }
.trend.flat { color: var(--muted); background: rgba(148,178,210,0.08); }
.stat-spark { margin-top: 10px; }

/* ===================== BADGES ===================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px; letter-spacing: 0.02em; line-height: 1.4;
  border: 1px solid transparent; white-space: nowrap;
}
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-good { color: var(--good); background: var(--accent-soft); border-color: rgba(52,211,153,0.25); }
.b-warn { color: var(--warn); background: var(--warn-soft); border-color: rgba(251,191,36,0.25); }
.b-danger { color: var(--danger); background: var(--danger-soft); border-color: rgba(248,113,113,0.25); }
.b-info { color: var(--info); background: var(--info-soft); border-color: rgba(96,165,250,0.25); }
.b-neutral { color: var(--text-2); background: rgba(148,178,210,0.08); border-color: var(--line); }
.b-violet { color: var(--accent-3); background: rgba(167,139,250,0.12); border-color: rgba(167,139,250,0.25); }

/* ===================== TABLE ===================== */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tbl th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); font-weight: 700; padding: 9px 11px; border-bottom: 1px solid var(--line-strong);
  white-space: nowrap; position: sticky; top: 0; background: var(--panel-2);
}
table.tbl td { padding: 9px 11px; border-bottom: 1px solid var(--line); color: var(--text-2); white-space: nowrap; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr:hover td { background: rgba(148,178,210,0.035); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
table.tbl td.strong { color: var(--text); font-weight: 700; }
.tbl-tight td, .tbl-tight th { padding: 7px 10px; }

/* ===================== MAP ===================== */
.map-shell { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line-strong); background: #05080c; }
.map-svg { display: block; width: 100%; height: auto; }
.map-legend {
  position: absolute; bottom: 12px; left: 12px; background: rgba(10,14,19,0.82);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; backdrop-filter: blur(8px);
  font-size: 11px; max-width: 230px;
}
.map-legend .lg-row { display: flex; align-items: center; gap: 7px; margin: 3px 0; color: var(--text-2); }
.map-legend .lg-swatch { width: 11px; height: 11px; border-radius: 3px; }
.map-controls { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 6px; }
.map-layer-btn {
  background: rgba(10,14,19,0.82); border: 1px solid var(--line); color: var(--text-2);
  border-radius: 8px; padding: 6px 10px; font-size: 11.5px; font-weight: 600; cursor: pointer; backdrop-filter: blur(8px); text-align: left;
}
.map-layer-btn:hover { color: var(--text); border-color: var(--line-strong); }
.map-layer-btn.active { color: var(--accent); border-color: rgba(52,211,153,0.4); background: rgba(52,211,153,0.10); }
.map-badge {
  position: absolute; top: 12px; left: 12px; background: rgba(10,14,19,0.82); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 11px; backdrop-filter: blur(8px);
}
.map-scale { position: absolute; bottom: 12px; right: 12px; background: rgba(10,14,19,0.7); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 10px; color: var(--text-2); }
.map-scale .bar { display: inline-block; width: 40px; height: 4px; border-bottom: 2px solid var(--text-2); border-left: 2px solid var(--text-2); border-right: 2px solid var(--text-2); margin-right: 6px; vertical-align: middle; }

/* ===================== MISC ELEMENTS ===================== */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 12.5px; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--text); text-align: right; font-weight: 600; }
.kv-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.kv-row:last-child { border-bottom: none; }
.kv-row .k { color: var(--muted); }
.kv-row .v { font-weight: 700; }

.progress { height: 7px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.progress.warn > span { background: linear-gradient(90deg, var(--warn), var(--orange)); }
.progress.danger > span { background: linear-gradient(90deg, var(--danger), var(--pink)); }

.gauge-wrap { display: flex; align-items: center; gap: 16px; }
.legend-inline { display: flex; flex-wrap: wrap; gap: 10px 16px; font-size: 11.5px; color: var(--text-2); margin-top: 10px; }
.legend-inline .li { display: inline-flex; align-items: center; gap: 6px; }
.legend-inline .li .sw { width: 10px; height: 10px; border-radius: 3px; }

.tl { position: relative; padding-left: 22px; }
.tl::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--line-strong); }
.tl-item { position: relative; padding: 0 0 16px 6px; }
.tl-item::before { content: ""; position: absolute; left: -19px; top: 3px; width: 11px; height: 11px; border-radius: 50%; background: var(--panel); border: 2px solid var(--muted); }
.tl-item.done::before { background: var(--accent); border-color: var(--accent); }
.tl-item.now::before { background: var(--warn); border-color: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.tl-date { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.tl-title { font-weight: 700; font-size: 13px; margin: 1px 0; }
.tl-desc { font-size: 12px; color: var(--text-2); }

.note { font-size: 12.5px; color: var(--text-2); line-height: 1.55; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.meta-row b { color: var(--text-2); font-weight: 600; }

.alert {
  display: flex; gap: 11px; padding: 12px 14px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--panel-2); align-items: flex-start;
}
.alert .a-ico { flex: none; margin-top: 1px; }
.alert.a-warn { border-color: rgba(251,191,36,0.3); background: var(--warn-soft); }
.alert.a-info { border-color: rgba(96,165,250,0.3); background: var(--info-soft); }
.alert.a-good { border-color: rgba(52,211,153,0.3); background: var(--accent-soft); }
.alert .a-title { font-weight: 700; font-size: 13px; }
.alert .a-body { font-size: 12px; color: var(--text-2); }

/* Webcam */
.webcam {
  position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line-strong);
  background: #04070b; aspect-ratio: 16/9;
}
.webcam img { width: 100%; height: 100%; object-fit: cover; filter: saturate(1.05) contrast(1.03); }
.webcam .wc-overlay { position: absolute; inset: 0; pointer-events: none; }
.webcam .wc-tl, .webcam .wc-tr, .webcam .wc-bl, .webcam .wc-br { position: absolute; font-family: var(--mono); font-size: 10.5px; color: #d6f5e6; text-shadow: 0 1px 3px #000; padding: 8px 10px; }
.webcam .wc-tl { top: 0; left: 0; }
.webcam .wc-tr { top: 0; right: 0; text-align: right; }
.webcam .wc-bl { bottom: 0; left: 0; }
.webcam .wc-br { bottom: 0; right: 0; text-align: right; }
.wc-rec { display: inline-flex; align-items: center; gap: 5px; color: #ff6b6b; font-weight: 700; }
.wc-rec .dot { background: #ff5b5b; animation: pulse 1.6s infinite; }
.scanline { position: absolute; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, rgba(52,211,153,0.5), transparent); animation: scan 6s linear infinite; }
@keyframes scan { 0% { top: 0; } 100% { top: 100%; } }

/* Sensor tiles */
.sensor {
  display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line);
  border-radius: 11px; background: var(--panel-2);
}
.sensor .s-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--bg-2); color: var(--accent-2); flex: none; }
.sensor .s-val { font-size: 18px; font-weight: 800; line-height: 1; }
.sensor .s-name { font-size: 11px; color: var(--muted); margin-top: 3px; }

.pill-tab { display: inline-flex; gap: 4px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.pill-tab button { border: none; background: none; color: var(--muted); font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 6px; cursor: pointer; font-family: var(--font); }
.pill-tab button.active { background: var(--panel-3); color: var(--text); }

.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { font-size: 11.5px; padding: 4px 10px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); color: var(--text-2); }

.heat-cell { stroke: var(--bg); stroke-width: 1.5; }
.mono { font-family: var(--mono); }
.tnum { font-variant-numeric: tabular-nums; }
.tcenter { text-align: center; }
.tright { text-align: right; }
.nowrap { white-space: nowrap; }
.big-num { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }

.donut-center { font-weight: 800; }
.svg-chart { display: block; width: 100%; height: auto; overflow: visible; }
.axis-label { font-size: 10px; fill: var(--faint); font-family: var(--font); }
.grid-line { stroke: var(--line); stroke-width: 1; }
.tip {
  position: fixed; z-index: 999; pointer-events: none; background: rgba(8,12,17,0.96);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px; font-size: 11.5px;
  color: var(--text); box-shadow: var(--shadow-sm); max-width: 240px; transition: opacity .08s; opacity: 0;
}
.tip .t-k { color: var(--muted); }

.report-card { display: flex; gap: 14px; align-items: center; }
.report-ico { width: 46px; height: 46px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--bg-2); }

.app-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px;
  flex-wrap: wrap; background: var(--bg-2);
}
.foot-left, .foot-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.fadein { animation: fadein .28s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.hr { height: 1px; background: var(--line); margin: 14px 0; border: none; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mb-1 { margin-bottom: 8px; }
.flex { display: flex; } .between { justify-content: space-between; } .center { align-items: center; } .gap { gap: 10px; } .wrap { flex-wrap: wrap; }
.text-good { color: var(--good); } .text-warn { color: var(--warn); } .text-danger { color: var(--danger); } .text-info { color: var(--info); }
.small { font-size: 11.5px; } .xsmall { font-size: 10.5px; }

/* ===================== TABLET CHROME (≤1000px) ===================== */
@media (max-width: 1000px) {
  .header-search { max-width: 260px; }
  #header-weather, .hpill-season { display: none; }
  .brand { min-width: 0; }
}

/* ===================== MOBILE CHROME (≤760px) =====================
   The header/context/tab bars are a stacked sticky group whose
   `top` offsets assume fixed heights. On narrow screens their
   contents used to wrap and overflow, so each bar overlapped the
   next. Here we (a) compact the header to a single row, (b) drop the
   context bar out of the sticky stack into a single horizontal-scroll
   strip, and (c) pin the tab bar directly under the header. */
@media (max-width: 760px) {
  :root { --header-h: 52px; }

  /* Header — one clean row: brand + avatar */
  .app-header { gap: 8px; padding: 0 12px; }
  .brand { min-width: 0; flex: 1; gap: 9px; overflow: hidden; }
  .brand-mark svg { width: 28px; height: 28px; }
  .brand-title { font-size: 13px; letter-spacing: 0.08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand-sub, .brand-tag { display: none; }
  .header-search { display: none; }
  .header-right { gap: 6px; margin-left: auto; flex: none; }
  #header-weather, .hpill-season, .hpill-live { display: none; }
  .icon-btn { height: 30px; width: 30px; }
  .user-meta { display: none; }
  .user-chip { padding-left: 2px; }
  .avatar { width: 30px; height: 30px; }

  /* Context bar — leaves the sticky stack, becomes a scroll strip */
  .context-bar {
    position: static; height: auto; min-height: 36px;
    padding: 7px 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .context-bar::-webkit-scrollbar { display: none; }
  .context-left { flex-wrap: nowrap; white-space: nowrap; gap: 9px; }
  .context-left > * { flex: none; }
  .context-right { display: none; }

  /* Tab bar — pinned directly beneath the (now single-row) header */
  .tab-bar { top: var(--header-h); padding: 0 6px; }
  .tab { padding: 0 12px; font-size: 12.5px; }

  /* Content + headings */
  .view { padding: 14px 12px 30px; }
  .page-head { margin-bottom: 14px; gap: 10px; }
  .page-title { font-size: 19px; }
  .page-sub { font-size: 12px; }
  .page-actions { gap: 6px; }
  .page-actions .btn { height: 32px; padding: 0 11px; font-size: 12px; }
  .section-label { margin: 20px 0 10px; }

  /* Map overlays sit closer in on small screens */
  .map-controls { top: 8px; right: 8px; gap: 4px; }
  .map-layer-btn { padding: 5px 8px; font-size: 10.5px; }
  .map-legend { left: 8px; bottom: 8px; padding: 8px 10px; font-size: 10px; max-width: 160px; }

  /* Footer stacks */
  .app-footer { padding: 12px 14px; gap: 8px; }
  .stat-value { font-size: 24px; }
}

/* ===================== SMALL PHONES (≤420px) ===================== */
@media (max-width: 420px) {
  .header-right .icon-btn { display: none; }      /* drop the bell, keep avatar */
  .brand-title { font-size: 12px; }
  .map-legend { display: none; }                  /* too cramped to be useful */
}
