:root {
  --bg: #f3f5f1;
  --surface: #ffffff;
  --surface-2: #f8faf7;
  --ink: #0f2419;
  --ink-2: #33473c;
  --muted: #6b7c72;
  --line: #e2e8e3;
  --line-2: #eef2ee;
  --brand: #166534;
  --brand-2: #15803d;
  --brand-soft: #dcfce7;
  --lc: #b4501a;
  --lc-soft: #ffedd5;
  --gold: #c8962e;
  --danger: #dc2626; --danger-soft: #fee2e2;
  --warn: #d97706;   --warn-soft: #fef3c7;
  --info: #2563eb;   --info-soft: #dbeafe;
  --ok: #16a34a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 36, 25, .05), 0 4px 16px rgba(16, 36, 25, .05);
  --sidebar: 248px;
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------ Layout ------------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: none; position: fixed; inset: 0 auto 0 0; z-index: 1200;
  background: radial-gradient(120% 60% at 0% 0%, #1d4d33 0%, #0c2a1b 55%, #081d12 100%);
  color: #d5e5da; display: flex; flex-direction: column; padding: 18px 14px; transition: transform .25s;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 4px 8px 20px; }
.brand-logo { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(140deg, #4ade80, #15803d 60%, #b4501a); display: grid; place-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.brand-logo svg { width: 26px; height: 26px; }
.brand-name { font-weight: 700; font-size: 16px; color: #fff; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: #8fb39c; margin-top: 1px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #6f9580; padding: 14px 12px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; text-decoration: none;
  color: #c3d8ca; font-weight: 500; cursor: pointer; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(74, 222, 128, .14); color: #fff; box-shadow: inset 3px 0 0 #4ade80; }
.nav a .badge { margin-left: auto; background: #dc2626; color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.sidebar-foot { margin-top: auto; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; padding: 12px; font-size: 12px; }
.sidebar-foot b { color: #fff; display: block; font-size: 13px; margin-bottom: 2px; }
.demo-tag { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; color: #fbbf24; font-weight: 600; font-size: 11px; }
.demo-tag::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #fbbf24; box-shadow: 0 0 0 3px rgba(251,191,36,.2); }

.main { margin-left: var(--sidebar); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1100; display: flex; align-items: center; gap: 14px;
  background: rgba(243,245,241,.86); backdrop-filter: blur(12px); padding: 14px 28px; border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; margin: 0; letter-spacing: -.02em; }
.topbar .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.wx-chip { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px 6px 8px; font-size: 12.5px; }
.wx-chip .ico { color: var(--gold); }
.wx-chip .live { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; }
.wx-chip .live.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.icon-btn { position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { border-color: #c8d3cb; }
.icon-btn .dot { position: absolute; top: -5px; right: -5px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; min-width: 19px; height: 19px; border-radius: 99px; display: grid; place-items: center; border: 2px solid var(--bg); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, #166534, #b4501a); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }

.view { padding: 24px 28px 48px; flex: 1; animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ------------------------------ Elements ----------------------------- */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; transition: all .15s; }
.btn:hover { border-color: #c2cec5; background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #14532d; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn .ico { width: 16px; height: 16px; }

.grid { display: grid; gap: 18px; }
.g-kpi { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.g-32 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.mt { margin-top: 18px; }
.span-2 { grid-column: span 2; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-h h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.card-h .hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-h .ico { color: var(--brand-2); }

.kpi { position: relative; overflow: hidden; }
.kpi .k-label { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 7px; }
.kpi .k-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.kpi .k-ico.lc { background: var(--lc-soft); color: var(--lc); }
.kpi .k-ico.red { background: var(--danger-soft); color: var(--danger); }
.kpi .k-ico.gold { background: #fef9c3; color: #a16207; }
.kpi .k-ico .ico { width: 16px; height: 16px; }
.kpi .k-val { font-size: 25px; font-weight: 700; letter-spacing: -.03em; margin: 12px 0 4px; }
.kpi .k-val small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 3px; }
.kpi .k-foot { font-size: 12px; color: var(--muted); }
.up { color: var(--ok); font-weight: 600; }
.down { color: var(--danger); font-weight: 600; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--line-2); color: var(--ink-2); }
.pill .sw { width: 7px; height: 7px; border-radius: 50%; }
.pill.critical { background: var(--danger-soft); color: #b91c1c; }
.pill.warning { background: var(--warn-soft); color: #b45309; }
.pill.info { background: var(--info-soft); color: #1d4ed8; }
.pill.ok { background: var(--brand-soft); color: var(--brand); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 5px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 500; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .sw { width: 8px; height: 8px; border-radius: 3px; }

.seg { display: inline-flex; background: var(--line-2); padding: 3px; border-radius: 10px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.input, select.input { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 12px; outline: none; min-width: 0; }
.input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(22,163,74,.12); }
.search { position: relative; }
.search .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search .input { padding-left: 32px; width: 220px; }

.table-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; cursor: default; }
.tbl th.sort { cursor: pointer; }
.tbl th.sort:hover { color: var(--ink); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: #f5faf6; }
.tbl .r { text-align: right; }
.lot-id { font-weight: 700; display: inline-flex; align-items: center; gap: 7px; }
.lot-id .sw { width: 10px; height: 10px; border-radius: 3px; }

.bar { height: 7px; background: var(--line-2); border-radius: 99px; overflow: hidden; position: relative; }
.bar > i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--brand-2); }
.bar.thin { height: 5px; }
.stockbar { position: relative; height: 8px; border-radius: 99px; background: var(--line-2); }
.stockbar i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 99px; }
.stockbar b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--danger); border-radius: 2px; }

.empty { color: var(--muted); text-align: center; padding: 30px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* ------------------------------ Hero --------------------------------- */
.hero {
  position: relative; overflow: hidden; border-radius: 18px; padding: 24px 26px; color: #fff; margin-bottom: 18px;
  background: linear-gradient(115deg, rgba(8,35,21,.94) 0%, rgba(14,61,35,.86) 45%, rgba(120,53,15,.55) 100%), url('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/15/15295/26209') center/cover;
  display: flex; gap: 24px; align-items: center; flex-wrap: wrap;
}
.hero h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.02em; }
.hero p { margin: 0; color: #cfe3d6; max-width: 640px; line-height: 1.55; }
.hero .hero-stats { margin-left: auto; display: flex; gap: 26px; }
.hero .hs b { display: block; font-size: 22px; letter-spacing: -.02em; }
.hero .hs span { font-size: 12px; color: #b5d1bf; }

/* ------------------------------ Map ---------------------------------- */
.map-wrap { position: relative; height: calc(100vh - 140px); min-height: 560px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); }
#bigmap, .minimap { width: 100%; height: 100%; background: #1f2d24; }
.minimap { height: 380px; border-radius: 10px; overflow: hidden; }
.map-ctrl { position: absolute; z-index: 600; top: 14px; left: 58px; right: 14px; display: flex; gap: 10px; flex-wrap: wrap; pointer-events: none; }
.map-ctrl > * { pointer-events: auto; }
.glass { background: rgba(255,255,255,.94); backdrop-filter: blur(8px); border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.18); border: 1px solid rgba(255,255,255,.6); }
.map-ctrl .seg { background: rgba(255,255,255,.94); box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.legend { position: absolute; z-index: 600; left: 14px; bottom: 14px; padding: 12px 14px; font-size: 12px; min-width: 200px; }
.legend h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.legend .li { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.legend .li .sw { width: 14px; height: 10px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); }
.legend .grad { height: 10px; border-radius: 5px; background: linear-gradient(90deg, #dc2626, #f59e0b, #facc15, #4ade80, #15803d); margin: 6px 0 4px; }
.map-stats { position: absolute; z-index: 600; right: 14px; bottom: 14px; padding: 10px 14px; font-size: 12px; display: flex; gap: 18px; }
.map-stats b { display: block; font-size: 16px; }
.lot-label { background: transparent; border: 0; box-shadow: none; color: #fff; font-weight: 700; font-size: 11px; text-shadow: 0 1px 3px rgba(0,0,0,.9), 0 0 2px rgba(0,0,0,.8); padding: 0; }
.lot-label::before { display: none; }
.leaflet-tooltip.tip { border-radius: 10px; padding: 8px 10px; font-family: inherit; box-shadow: 0 6px 20px rgba(0,0,0,.2); border: 0; }
.mush-marker { width: 22px; height: 22px; border-radius: 50%; background: #fff7ed; border: 2px solid #c2410c; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.mush-marker svg { width: 13px; height: 13px; stroke: #c2410c; fill: #fdba74; stroke-width: 2; }
.pulse { width: 16px; height: 16px; border-radius: 50%; background: #dc2626; border: 2px solid #fff; box-shadow: 0 0 0 0 rgba(220,38,38,.7); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,.7); } 70% { box-shadow: 0 0 0 14px rgba(220,38,38,0); } 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); } }

/* Drawer */
.drawer { position: absolute; z-index: 700; top: 0; right: 0; bottom: 0; width: 420px; max-width: 100%; background: var(--surface); box-shadow: -10px 0 40px rgba(0,0,0,.2); transform: translateX(105%); transition: transform .28s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-h { padding: 18px 20px 14px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #f2f8f3, #fff); }
.drawer-h h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
.drawer-b { padding: 16px 20px 24px; overflow: auto; flex: 1; }
.drawer .close { position: absolute; top: 14px; right: 14px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; }
.stat span { font-size: 11.5px; color: var(--muted); }
.stat b { display: block; font-size: 17px; letter-spacing: -.02em; margin-top: 2px; }
.sec-t { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin: 20px 0 10px; display: flex; align-items: center; gap: 8px; }
.sec-t::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.batch { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.batch-h { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 8px; }
.stagebar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; position: relative; }
.stagebar span { height: 100%; opacity: .35; }
.stagebar span.done { opacity: 1; }
.stagebar .now { position: absolute; top: -3px; bottom: -3px; width: 3px; background: var(--ink); border-radius: 2px; }

/* ------------------------------ Alerts ------------------------------- */
.alert-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.alert-item:last-child { border-bottom: 0; }
.a-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.a-ico.critical { background: var(--danger-soft); color: var(--danger); }
.a-ico.warning { background: var(--warn-soft); color: var(--warn); }
.a-ico.info { background: var(--info-soft); color: var(--info); }
.a-title { font-weight: 600; font-size: 13.5px; line-height: 1.35; }
.a-meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.alert-card { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid; border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; box-shadow: var(--shadow); }
.alert-card.critical { border-left-color: var(--danger); }
.alert-card.warning { border-left-color: var(--warn); }
.alert-card.info { border-left-color: var(--info); }
.alert-card.done { opacity: .55; }
.alert-card .detail { color: var(--ink-2); font-size: 13px; margin: 6px 0; line-height: 1.5; }
.alert-card .action { background: #f0fdf4; border: 1px dashed #86efac; color: #14532d; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; line-height: 1.5; display: flex; gap: 8px; }
.alert-card .action .ico { color: var(--brand-2); width: 16px; height: 16px; margin-top: 1px; }
.alert-card .acts { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.sev-count { display: flex; align-items: center; gap: 12px; }
.sev-count .big { font-size: 30px; font-weight: 700; letter-spacing: -.03em; }
.rule-row { display: grid; grid-template-columns: 1fr 120px 54px; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 12.5px; }
.rule-row input[type=range] { width: 100%; accent-color: var(--brand-2); }
.rule-row .v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.rule-group { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--brand); margin: 14px 0 2px; }
.toggle { position: relative; width: 36px; height: 20px; border-radius: 99px; background: #cbd5e1; cursor: pointer; flex: none; transition: background .2s; border: 0; }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle.on { background: var(--brand-2); }
.toggle.on::after { transform: translateX(16px); }
.pipeline { display: flex; align-items: stretch; gap: 0; margin: 4px 0; }
.pipe-step { flex: 1; text-align: center; padding: 12px 6px; background: var(--surface-2); border: 1px solid var(--line); position: relative; font-size: 12px; }
.pipe-step:first-child { border-radius: 10px 0 0 10px; }
.pipe-step:last-child { border-radius: 0 10px 10px 0; }
.pipe-step + .pipe-step { border-left: 0; }
.pipe-step b { display: block; font-size: 12.5px; margin: 6px 0 2px; }
.pipe-step .ico { color: var(--brand-2); }

/* ------------------------------ Efficiency --------------------------- */
.quad-card { border-radius: 12px; padding: 14px; border: 1px solid var(--line); background: var(--surface); }
.quad-card .q-n { font-size: 26px; font-weight: 700; letter-spacing: -.03em; }
.sol-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--surface); margin-bottom: 12px; }
.sol-card .sol-h { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sol-issue { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 8px 0; border-top: 1px dashed var(--line); font-size: 12.5px; line-height: 1.5; }
.sol-issue .n { width: 20px; height: 20px; border-radius: 6px; background: var(--danger-soft); color: var(--danger); font-weight: 700; font-size: 11px; display: grid; place-items: center; }
.sol-issue .fix { color: #14532d; }
.score-ring { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; position: relative; }

/* ------------------------------ Gantt -------------------------------- */
.gantt { position: relative; font-size: 12px; }
.g-row { display: grid; grid-template-columns: 150px 1fr; align-items: center; min-height: 34px; border-bottom: 1px solid var(--line-2); }
.g-row .g-l { font-weight: 600; padding-right: 10px; }
.g-row .g-l small { display: block; color: var(--muted); font-weight: 400; }
.g-track { position: relative; height: 34px; overflow: hidden; }
.g-bar { position: absolute; top: 9px; height: 16px; display: flex; border-radius: 5px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.15); cursor: default; }
.g-bar span { height: 100%; }
.g-axis { display: grid; grid-template-columns: 150px 1fr; font-size: 11px; color: var(--muted); }
.g-axis .ticks { position: relative; height: 22px; }
.g-axis .ticks span { position: absolute; transform: translateX(-50%); }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 2; }
.g-axis .g-today::before { content: 'Hôm nay'; position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 10.5px; font-weight: 700; color: var(--danger); white-space: nowrap; }

/* Circular model */
.cycle-svg text { font-family: inherit; }

/* Weather */
.wx-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wx-day { text-align: center; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 2px; font-size: 11.5px; }
.wx-day b { display: block; font-size: 13px; margin: 4px 0 1px; }
.wx-day .rain { color: var(--info); font-weight: 600; }
.wx-day .ico { width: 20px; height: 20px; color: var(--gold); }
.wx-day.rainy .ico { color: var(--info); }

/* Modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(8, 24, 15, .5); backdrop-filter: blur(3px); z-index: 3000; display: grid; place-items: center; padding: 20px; animation: fade .2s; }
.modal { background: var(--surface); border-radius: 16px; width: 520px; max-width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal-h { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-h h3 { margin: 0; font-size: 17px; }
.modal-b { padding: 18px 22px; display: grid; gap: 14px; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field .input { width: 100%; }
.toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 4000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); display: flex; gap: 10px; align-items: center; font-size: 13px; animation: fade .25s; max-width: 380px; }
.toast .ico { color: #4ade80; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

.zone-card { border-radius: 12px; padding: 14px; border: 1px solid var(--line); background: var(--surface); position: relative; overflow: hidden; }
.zone-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--zc); }
.zone-card h4 { margin: 0; font-size: 14px; }
.zone-card .zd { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.zone-card .zr { display: flex; justify-content: space-between; font-size: 12.5px; margin: 3px 0; }

.store-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--surface); }
.store-card.bad { border-color: #fca5a5; background: #fff7f7; }
.store-card .t { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }

.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.chart-box.lg { height: 340px; }

.foot-note { color: var(--muted); font-size: 11.5px; text-align: center; margin-top: 30px; }

/* ------------------------------ Responsive --------------------------- */
@media (max-width: 1400px) { .g-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1100px) {
  .g-21, .g-12, .g-32, .g-3 { grid-template-columns: 1fr; }
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: auto; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 20px 0 60px rgba(0,0,0,.4); }
  .main { margin-left: 0; }
  .menu-btn { display: grid; }
  .topbar { padding: 12px 16px; }
  .view { padding: 16px; }
  .g-kpi, .g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wx-chip, .hide-sm { display: none !important; }
  .hero .hero-stats { margin-left: 0; }
  .alert-card { grid-template-columns: 1fr; }
  .alert-card .acts { flex-direction: row; }
  .drawer { width: 100%; }
  .g-row, .g-axis { grid-template-columns: 90px 1fr; }
}
@media (max-width: 600px) {
  .topbar .sub { display: none; }
  .hero { padding: 20px; }
  .hero h2 { font-size: 20px; }
  .hero .hero-stats { gap: 16px; }
  .hero .hs b { font-size: 17px; }
  .kpi .k-val { font-size: 21px; }
}
