/* ============================================================
   CẦN THƠ 2030 · UDT — Hệ thống thiết kế "Phòng điều hành IOC"
   Display: Bricolage Grotesque · Body: Be Vietnam Pro · Data: IBM Plex Mono
   ============================================================ */

:root {
  --bg0: #04111a;
  --bg1: #071a24;
  --panel: #0a212d;
  --panel-2: #0c2937;
  --line: #143544;
  --line-2: #1d4658;
  --text: #d9eaec;
  --muted: #7da0a8;
  --faint: #54737c;
  --accent: #2fd9b5;       /* ngọc Mê Kông */
  --accent-dim: #1b8f7b;
  --cyan: #54c8f0;         /* nước */
  --amber: #ffb454;
  --red: #ff5d68;
  --risk0: #16323d;
  --risk1: #2fd9b5;
  --risk2: #ffb454;
  --risk3: #ff5d68;
  --font-d: 'Bricolage Grotesque', 'Be Vietnam Pro', sans-serif;
  --font-b: 'Be Vietnam Pro', sans-serif;
  --font-m: 'IBM Plex Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: dark; }

body {
  font-family: var(--font-b);
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(47, 217, 181, .07), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(84, 200, 240, .06), transparent 55%),
    var(--bg0);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
}

/* lưới đẳng trị nền — gợi bản đồ địa hình */
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 47px, rgba(84, 200, 240, .035) 47px 48px),
    repeating-linear-gradient(90deg, transparent 0 47px, rgba(84, 200, 240, .025) 47px 48px);
}

.mono { font-family: var(--font-m); }
.display { font-family: var(--font-d); }

/* Khung biểu đồ ECharts: bề rộng theo khung chứa, cao cố định inline */
.echart { width: 100%; min-width: 0; overflow: hidden; }
.spark-cap { font-family: var(--font-m); font-size: 9.5px; color: var(--faint); margin-top: 3px; }

/* Chặn grid blowout: phần tử trong track 1fr không được nở theo nội dung */
.ov-grid > *, .ov-charts > *, .fc-grid > *, .ctl-grid > *,
.mt-grid > *, .arch-grid > *, .ctl-grid .col > * { min-width: 0; }

/* ================= TOPBAR ================= */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 22px;
  padding: 10px 22px;
  background: linear-gradient(180deg, rgba(7, 26, 36, .97), rgba(7, 26, 36, .92));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-text strong {
  font-family: var(--font-d); font-size: 17px; font-weight: 800;
  letter-spacing: .04em; display: block; line-height: 1.1;
}
.brand-text strong span { color: var(--accent); }
.brand-text em { font-style: normal; font-size: 10.5px; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; }

.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tab {
  font-family: var(--font-b); font-size: 13px; font-weight: 600;
  color: var(--muted); background: none; border: 1px solid transparent;
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
  transition: all .18s ease;
}
.tab:hover { color: var(--text); background: var(--panel); }
.tab.active {
  color: var(--accent); background: rgba(47, 217, 181, .09);
  border-color: rgba(47, 217, 181, .35);
}

.top-status { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.twinloop svg { width: 56px; height: 36px; display: block; }
.loop-a, .loop-b { stroke-width: 2.4; stroke-dasharray: 5 5; stroke-linecap: round; }
.loop-a { stroke: var(--cyan); animation: dashflow 1.6s linear infinite; }
.loop-b { stroke: var(--accent); animation: dashflow 1.6s linear infinite reverse; }
.loop-lab { font-family: var(--font-m); font-size: 7px; fill: var(--faint); letter-spacing: .1em; }
@keyframes dashflow { to { stroke-dashoffset: -20; } }

.clockbox { text-align: right; line-height: 1.15; }
.clockbox span { font-size: 19px; font-weight: 600; color: var(--text); letter-spacing: .02em; }
.clockbox em { display: block; font-style: normal; font-size: 10px; color: var(--muted); }

.badge {
  font-family: var(--font-m); font-size: 10.5px; font-weight: 600;
  letter-spacing: .08em; padding: 6px 11px; border-radius: 6px;
  border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap;
}
.badge-level { color: var(--accent); border-color: rgba(47, 217, 181, .4); background: rgba(47, 217, 181, .07); }
.badge.bd0 { color: var(--muted); }
.badge.bd1 { color: var(--cyan); border-color: rgba(84, 200, 240, .45); background: rgba(84, 200, 240, .08); }
.badge.bd2 { color: var(--amber); border-color: rgba(255, 180, 84, .45); background: rgba(255, 180, 84, .08); }
.badge.bd3 { color: var(--red); border-color: rgba(255, 93, 104, .5); background: rgba(255, 93, 104, .1); animation: blink 1.2s ease infinite; }
@keyframes blink { 50% { opacity: .55; } }

.linkpills { display: flex; gap: 6px; }
.pill {
  font-family: var(--font-m); font-size: 10px; font-weight: 600;
  padding: 5px 9px; border-radius: 5px; letter-spacing: .1em;
}
.pill.ok { color: var(--accent); background: rgba(47, 217, 181, .1); border: 1px solid rgba(47, 217, 181, .3); }
.pill.ok::after { content: ' ●'; font-size: 8px; animation: blink 2.4s ease infinite; }

/* ================= LAYOUT ================= */
#main { position: relative; z-index: 1; padding: 18px 22px 30px; max-width: 1680px; margin: 0 auto; }
.view { display: none; animation: viewin .35s ease; }
.view.active { display: block; }
@keyframes viewin { from { opacity: 0; transform: translateY(8px); } }

.card {
  background: linear-gradient(180deg, var(--panel), rgba(10, 33, 45, .82));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  position: relative;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 {
  font-family: var(--font-d); font-size: 15px; font-weight: 700; letter-spacing: .01em;
}
.card-head h2 small { font-family: var(--font-b); font-weight: 400; font-size: 11.5px; color: var(--muted); margin-left: 8px; }
.fc-tag { color: var(--accent); border-bottom: 1px dashed var(--accent); }

/* ================= KPI STRIP ================= */
.kpi-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi {
  background: linear-gradient(180deg, var(--panel), rgba(10, 33, 45, .7));
  border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 16px 11px; position: relative; overflow: hidden;
  animation: viewin .4s ease backwards;
}
.kpi:nth-child(2) { animation-delay: .05s; } .kpi:nth-child(3) { animation-delay: .1s; }
.kpi:nth-child(4) { animation-delay: .15s; } .kpi:nth-child(5) { animation-delay: .2s; }
.kpi::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); opacity: .85;
}
.kpi.warn::before { background: var(--amber); }
.kpi h4 { font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.kpi .val { font-family: var(--font-d); font-size: 25px; font-weight: 800; line-height: 1; letter-spacing: -.01em; }
.kpi .val small { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.kpi .sub { font-size: 10.5px; color: var(--faint); margin-top: 5px; font-family: var(--font-m); }

/* ================= OVERVIEW GRID ================= */
.ov-grid { display: grid; grid-template-columns: 1fr 372px; gap: 14px; align-items: stretch; }
.ov-right { display: flex; flex-direction: column; gap: 14px; }
.ov-right .grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ov-charts { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-top: 14px; }

/* ================= MAP ================= */
.map-card { display: flex; flex-direction: column; }
.map-wrap { flex: 1; min-height: 480px; }
#basin-map { width: 100%; height: 100%; display: block; }

.legend { display: flex; gap: 13px; font-size: 11px; color: var(--muted); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.sw.r0 { background: var(--risk0); border: 1px solid var(--line-2); }
.sw.r1 { background: var(--risk1); } .sw.r2 { background: var(--risk2); } .sw.r3 { background: var(--risk3); }

.river-body { opacity: .9; }
.river-line { stroke: url(#river-g); stroke-width: 26; fill: none; stroke-linecap: round; opacity: .95; }
.river-line.thin { stroke-width: 12; }
.flowline {
  fill: none; stroke: rgba(140, 220, 245, .35); stroke-width: 1.6;
  stroke-dasharray: 3 14; animation: dashflow 3.2s linear infinite;
}
.flowline.f2 { animation-duration: 4.4s; opacity: .6; }
.flowline.f3 { stroke-width: 1.2; stroke-dasharray: 2 16; animation-duration: 5s; }
.river-name { font-family: var(--font-m); font-size: 15px; letter-spacing: .42em; fill: rgba(140, 220, 245, .5); font-weight: 600; }
.river-name.sm { font-size: 11px; letter-spacing: .3em; }
.river-name.xs { font-size: 9px; letter-spacing: .22em; }

.cell {
  stroke: var(--line-2); stroke-width: 1; cursor: pointer;
  transition: fill .6s ease, filter .25s ease, stroke .25s ease;
}
.cell.r0 { fill: var(--risk0); }
.cell.r1 { fill: rgba(47, 217, 181, .38); }
.cell.r2 { fill: rgba(255, 180, 84, .5); }
.cell.r3 { fill: rgba(255, 93, 104, .58); animation: cellpulse 1.6s ease infinite; }
.cell:hover, .cell.sel { stroke: var(--accent); stroke-width: 2; filter: url(#cellglow); }
@keyframes cellpulse { 50% { fill: rgba(255, 93, 104, .82); } }

.cell-label { font-family: var(--font-b); font-size: 11.5px; font-weight: 600; fill: var(--text); pointer-events: none; }
.cell-depth { font-family: var(--font-m); font-size: 9.5px; fill: var(--amber); pointer-events: none; font-weight: 600; }

.dev-marker { cursor: pointer; }
.dev-marker rect {
  fill: var(--bg1); stroke: var(--faint); stroke-width: 1.4; rx: 4;
  transition: stroke .3s ease;
}
.dev-marker.on rect { stroke: var(--accent); fill: rgba(47, 217, 181, .15); }
.dev-marker.rec rect { stroke: var(--amber); animation: blink 1s ease infinite; }
.dev-marker text { font-family: var(--font-m); font-size: 9px; fill: var(--muted); font-weight: 600; pointer-events: none; }
.dev-marker.on text { fill: var(--accent); }
.dev-ring { fill: none; stroke: var(--accent); opacity: 0; }
.dev-marker.on .dev-ring { opacity: 1; animation: ring 2s ease infinite; }
@keyframes ring { from { r: 10; opacity: .7; } to { r: 22; opacity: 0; } }

.st-marker circle { fill: var(--bg1); stroke: var(--cyan); stroke-width: 1.5; }
.st-marker.rain circle { stroke: var(--accent); }
.st-marker text { font-family: var(--font-m); font-size: 8.5px; fill: var(--cyan); font-weight: 600; }
.st-marker.rain text { fill: var(--accent); }

/* ================= CELL PANEL ================= */
.cell-card .card-head h2 { font-size: 14px; }
.cell-body { font-size: 12.5px; }
.cell-body .crow { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.cell-body .crow:last-child { border: none; }
.cell-body .crow b { font-family: var(--font-m); font-weight: 600; }
.risk-chip { font-family: var(--font-m); font-size: 10px; font-weight: 700; letter-spacing: .08em; padding: 3px 9px; border-radius: 5px; }
.risk-chip.r0 { background: var(--risk0); color: var(--muted); }
.risk-chip.r1 { background: rgba(47, 217, 181, .15); color: var(--risk1); }
.risk-chip.r2 { background: rgba(255, 180, 84, .15); color: var(--risk2); }
.risk-chip.r3 { background: rgba(255, 93, 104, .18); color: var(--risk3); }
.cell-spark { width: 100%; height: 54px; margin-top: 8px; }

/* ================= STATIONS & FEED ================= */
.stations { display: flex; flex-direction: column; gap: 7px; }
.station { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.station .sid { font-family: var(--font-m); font-size: 9.5px; color: var(--faint); width: 40px; flex: none; }
.station .sname { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.station .sval { font-family: var(--font-m); font-size: 13px; font-weight: 600; }
.station .sval.hi { color: var(--amber); }
.station .sval.crit { color: var(--red); }
.station .strend { font-size: 10px; width: 14px; text-align: center; }
.strend.up { color: var(--red); } .strend.dn { color: var(--accent); } .strend.fl { color: var(--faint); }

.feeds { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); display: grid; gap: 5px; }
.feedsrc { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--faint); }
.feedsrc b { color: var(--muted); font-weight: 500; }
.feedsrc span { font-family: var(--font-m); font-size: 9.5px; }

.eventfeed { overflow-y: auto; max-height: 250px; flex: 1; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.evt { display: flex; gap: 9px; font-size: 11.5px; line-height: 1.45; animation: viewin .3s ease; }
.evt time { font-family: var(--font-m); font-size: 10px; color: var(--faint); flex: none; padding-top: 1px; }
.evt .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; margin-top: 5px; }
.evt.info .dot { background: var(--cyan); } .evt.warn .dot { background: var(--amber); }
.evt.crit .dot { background: var(--red); } .evt.ok .dot { background: var(--accent); }
.evt p { color: var(--muted); } .evt p b { color: var(--text); font-weight: 600; }

/* ================= SCENARIOS ================= */
.scenario-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.scen {
  text-align: left; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px; cursor: pointer; color: var(--text);
  font-family: var(--font-b); transition: all .2s ease;
}
.scen:hover { border-color: var(--line-2); transform: translateY(-2px); }
.scen.active { border-color: var(--accent); background: rgba(47, 217, 181, .08); box-shadow: 0 0 0 1px var(--accent), 0 8px 24px -12px rgba(47, 217, 181, .5); }
.scen .ic { font-size: 21px; display: block; margin-bottom: 7px; }
.scen b { font-size: 13.5px; display: block; margin-bottom: 4px; font-weight: 700; }
.scen p { font-size: 11px; color: var(--muted); line-height: 1.45; }

/* ================= PIPELINE ================= */
.fc-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 14px; margin-top: 14px; margin-bottom: 14px; }
.pipeline { display: flex; flex-direction: column; gap: 0; }
.pl-stage { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.pl-stage + .pl-stage { border-top: 1px dashed var(--line); }
.pl-led { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; animation: blink 2s ease infinite; }
.pl-stage:nth-child(2) .pl-led { animation-delay: .3s; } .pl-stage:nth-child(3) .pl-led { animation-delay: .6s; }
.pl-stage:nth-child(4) .pl-led { animation-delay: .9s; } .pl-stage:nth-child(5) .pl-led { animation-delay: 1.2s; }
.pl-stage b { font-family: var(--font-m); font-size: 12.5px; width: 150px; flex: none; }
.pl-stage span { font-size: 11.5px; color: var(--muted); flex: 1; }
.pl-stage em { font-family: var(--font-m); font-style: normal; font-size: 10.5px; color: var(--faint); }

.fc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.fcs { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; }
.fcs h5 { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.fcs .v { font-family: var(--font-d); font-size: 19px; font-weight: 700; }
.fcs .v.warn { color: var(--amber); } .fcs .v.crit { color: var(--red); } .fcs .v.ok { color: var(--accent); }

/* ================= TABLES ================= */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: left; font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--faint); font-weight: 600; padding: 7px 10px; border-bottom: 1px solid var(--line-2);
}
td { padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--muted); }
td b { color: var(--text); font-weight: 600; }
td .mono { font-size: 12px; }
tr:hover td { background: rgba(84, 200, 240, .03); }
.trend-up { color: var(--red); } .trend-dn { color: var(--accent); } .trend-fl { color: var(--faint); }

/* ================= CONTROL / HITL ================= */
.hitl-banner { display: flex; gap: 20px; align-items: center; justify-content: space-between; margin-bottom: 14px; border-color: rgba(47, 217, 181, .25); }
.hitl-mode strong { font-family: var(--font-d); font-size: 15px; color: var(--accent); display: block; margin-bottom: 4px; }
.hitl-mode p { font-size: 12px; color: var(--muted); max-width: 760px; }
.lv4-toggle {
  flex: none; text-align: left; font-family: var(--font-b); cursor: not-allowed;
  background: repeating-linear-gradient(135deg, var(--panel-2) 0 10px, rgba(20, 53, 68, .55) 10px 20px);
  border: 1px dashed var(--line-2); color: var(--muted); border-radius: 10px;
  padding: 11px 16px; font-size: 12.5px; font-weight: 600; line-height: 1.4;
}
.lv4-toggle .lock { color: var(--amber); margin-right: 4px; }
.lv4-toggle em { display: block; font-style: normal; font-family: var(--font-m); font-size: 10px; color: var(--faint); }

.ctl-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; align-items: start; }
.ctl-grid .col { display: flex; flex-direction: column; gap: 14px; }

.rec-list { display: flex; flex-direction: column; gap: 12px; min-height: 60px; }
.rec-empty { font-size: 12px; color: var(--faint); padding: 10px 0; font-style: italic; }
.rec {
  border: 1px solid rgba(255, 180, 84, .4); border-radius: 10px; padding: 13px 15px;
  background: linear-gradient(180deg, rgba(255, 180, 84, .06), transparent);
  animation: viewin .4s ease;
}
.rec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.rec-head b { font-size: 13.5px; font-family: var(--font-d); }
.rec-head .conf { font-family: var(--font-m); font-size: 10.5px; color: var(--amber); }
.rec .xai { font-size: 11.5px; color: var(--muted); margin-bottom: 9px; }
.rec .xai li { margin-left: 16px; margin-top: 2px; }
.rec .xai-tag { font-size: 9.5px; letter-spacing: .12em; color: var(--amber); font-family: var(--font-m); font-weight: 600; }
.rec-actions { display: flex; gap: 8px; }
.btn {
  font-family: var(--font-b); font-weight: 600; font-size: 12px; cursor: pointer;
  border-radius: 7px; padding: 7px 14px; border: 1px solid transparent; transition: all .15s ease;
}
.btn-ok { background: var(--accent); color: #04261f; }
.btn-ok:hover { background: #4ce8c8; }
.btn-ghost { background: none; border-color: var(--line-2); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--faint); }

.device-grid { display: grid; grid-template-columns: 1fr; gap: 9px; }
.device { display: flex; align-items: center; gap: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 13px; }
.device.on { border-color: rgba(47, 217, 181, .45); }
.dv-id { font-family: var(--font-m); font-size: 10px; color: var(--faint); width: 44px; flex: none; }
.dv-name { flex: 1; }
.dv-name b { display: block; font-size: 13px; }
.dv-name span { font-size: 10.5px; color: var(--faint); font-family: var(--font-m); }
.dv-power { width: 92px; flex: none; }
.dv-bar { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.dv-bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .8s ease; }
.dv-pct { font-family: var(--font-m); font-size: 9.5px; color: var(--muted); }
.switch {
  flex: none; width: 42px; height: 22px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--bg1); cursor: pointer; position: relative; transition: all .25s ease;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--faint); transition: all .25s ease;
}
.switch.on { background: rgba(47, 217, 181, .2); border-color: var(--accent); }
.switch.on::after { left: 22px; background: var(--accent); }

.audit-log { display: flex; flex-direction: column; gap: 10px; max-height: 560px; overflow-y: auto; padding-right: 4px; }
.au {
  border-left: 2px solid var(--line-2); padding: 2px 0 2px 12px; font-size: 11.5px;
  animation: viewin .3s ease;
}
.au.ok { border-color: var(--accent); } .au.no { border-color: var(--red); }
.au time { font-family: var(--font-m); font-size: 10px; color: var(--faint); display: block; }
.au b { font-weight: 600; }
.au .sig { font-family: var(--font-m); font-size: 9.5px; color: var(--faint); display: block; margin-top: 2px; word-break: break-all; }
.au .sig b { color: var(--accent-dim); font-weight: 500; }

/* ================= ARCHITECTURE ================= */
.arch-intro { margin-bottom: 14px; padding: 22px 26px; }
.arch-intro h2 { font-size: 27px; font-weight: 800; letter-spacing: -.01em; margin-bottom: 8px;
  background: linear-gradient(90deg, var(--accent), var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.arch-intro p { color: var(--muted); max-width: 980px; font-size: 13px; }

.arch-grid { display: grid; grid-template-columns: 1fr 320px; gap: 14px; }
.arch-stack { display: flex; flex-direction: column; gap: 9px; }
.layer {
  display: grid; grid-template-columns: 52px 230px 1fr; gap: 16px; align-items: start;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 16px; transition: all .2s ease; animation: viewin .4s ease backwards;
}
.layer:hover { border-color: var(--accent-dim); transform: translateX(4px); }
.layer .ln {
  font-family: var(--font-d); font-size: 25px; font-weight: 800; color: var(--accent);
  opacity: .85; line-height: 1;
}
.layer .lt b { font-family: var(--font-d); font-size: 14.5px; display: block; }
.layer .lt p { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.layer .lp { display: flex; flex-wrap: wrap; gap: 6px; }
.lp span {
  font-size: 10.5px; font-family: var(--font-m); color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 4px 8px;
}

.arch-side { display: flex; flex-direction: column; gap: 9px; }
.layer.trans { grid-template-columns: 1fr; gap: 8px; flex: 1;
  background: repeating-linear-gradient(135deg, var(--panel) 0 14px, rgba(12, 41, 55, .7) 14px 28px); }
.layer.trans .ln { font-size: 19px; }
.layer.trans .ln::after { content: ' · XUYÊN SUỐT'; font-family: var(--font-m); font-size: 8.5px; letter-spacing: .14em; color: var(--faint); }

.arch-note { margin-top: 14px; }
.arch-note h3 { font-family: var(--font-d); font-size: 14px; margin-bottom: 12px; }
.gateflow { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 13px; }
.gf-node {
  font-size: 11.5px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: 7px; padding: 7px 12px;
}
.gf-node em { display: block; font-style: normal; font-size: 9px; font-family: var(--font-m); color: var(--faint); }
.gf-node.hot { border-color: var(--amber); color: var(--amber); background: rgba(255, 180, 84, .07); }
.gf-arrow { color: var(--faint); }
.gate-checks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 24px; list-style: none; }
.gate-checks li { font-size: 11.5px; color: var(--muted); padding-left: 18px; position: relative; }
.gate-checks li::before { content: '◆'; position: absolute; left: 0; color: var(--accent); font-size: 9px; top: 3px; }

/* ================= MATURITY ================= */
.maturity-track { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.mlevel {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px 15px; position: relative;
  background: var(--panel-2);
}
.mlevel .mn { font-family: var(--font-d); font-size: 30px; font-weight: 800; color: var(--faint); line-height: 1; }
.mlevel b { font-family: var(--font-d); font-size: 14.5px; display: block; margin: 6px 0 2px; }
.mlevel .yr { font-family: var(--font-m); font-size: 10px; color: var(--faint); }
.mlevel p { font-size: 10.5px; color: var(--muted); margin-top: 7px; line-height: 1.5; }
.mlevel .mstat { position: absolute; top: 12px; right: 13px; font-family: var(--font-m); font-size: 9px; letter-spacing: .1em; padding: 3px 7px; border-radius: 4px; }
.mlevel.done { border-color: rgba(47, 217, 181, .3); }
.mlevel.done .mn { color: var(--accent-dim); }
.mlevel.done .mstat { color: var(--accent); background: rgba(47, 217, 181, .1); }
.mlevel.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 10px 30px -14px rgba(47, 217, 181, .6); background: rgba(47, 217, 181, .06); }
.mlevel.current .mn { color: var(--accent); }
.mlevel.current .mstat { color: #04261f; background: var(--accent); font-weight: 700; }
.mlevel.target .mstat { color: var(--cyan); background: rgba(84, 200, 240, .1); }
.mlevel.locked { opacity: .62; }
.mlevel.locked .mstat { color: var(--red); background: rgba(255, 93, 104, .1); }

.mt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
.roadmap { display: flex; flex-direction: column; }
.rstep { display: grid; grid-template-columns: 26px 1fr; gap: 13px; position: relative; padding-bottom: 16px; }
.rstep:last-child { padding-bottom: 0; }
.rstep::before { content: ''; position: absolute; left: 12px; top: 26px; bottom: 2px; width: 2px; background: var(--line); }
.rstep:last-child::before { display: none; }
.rdot {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-2);
  background: var(--bg1); display: grid; place-items: center;
  font-family: var(--font-m); font-size: 10.5px; font-weight: 600; color: var(--muted); z-index: 1;
}
.rstep.done .rdot { border-color: var(--accent); color: var(--accent); }
.rstep.active .rdot { border-color: var(--amber); color: var(--amber); animation: blink 1.6s ease infinite; }
.rstep b { font-size: 13px; font-family: var(--font-d); }
.rstep .rs { font-family: var(--font-m); font-size: 9px; letter-spacing: .1em; margin-left: 8px; padding: 2px 7px; border-radius: 4px; }
.rstep.done .rs { color: var(--accent); background: rgba(47, 217, 181, .1); }
.rstep.active .rs { color: var(--amber); background: rgba(255, 180, 84, .12); }
.rstep.plan .rs { color: var(--faint); background: var(--panel-2); }
.rstep p { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

.kpi-table { display: flex; flex-direction: column; }
.kt-row { display: grid; grid-template-columns: 1.5fr 1fr 1fr 22px; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 12px; }
.kt-row:last-child { border: none; }
.kt-row .ktn { color: var(--muted); }
.kt-row .ktt { font-family: var(--font-m); font-size: 11px; color: var(--faint); }
.kt-row .kta { font-family: var(--font-m); font-size: 12px; font-weight: 600; }
.kt-ok { color: var(--accent); } .kt-no { color: var(--amber); }

.std-table td:first-child { white-space: nowrap; }
.std-status { font-family: var(--font-m); font-size: 10px; letter-spacing: .06em; padding: 3px 8px; border-radius: 4px; white-space: nowrap; }
.std-status.dat { color: var(--accent); background: rgba(47, 217, 181, .1); }
.std-status.dgd { color: var(--amber); background: rgba(255, 180, 84, .1); }

.legal { margin-top: 14px; }
.legal h3 { font-family: var(--font-d); font-size: 14px; margin-bottom: 10px; }
.legal ul { list-style: none; display: grid; gap: 7px; }
.legal li { font-size: 12px; color: var(--muted); padding-left: 18px; position: relative; }
.legal li::before { content: '§'; position: absolute; left: 0; color: var(--accent); font-family: var(--font-d); }
.legal b { color: var(--text); }

/* ================= MODAL ================= */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(2, 10, 15, .78); backdrop-filter: blur(4px);
  place-items: center;
}
.modal-backdrop.open { display: grid; }
.gate-modal {
  width: min(520px, 92vw); background: var(--bg1); border: 1px solid var(--line-2);
  border-radius: 14px; padding: 22px 24px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 180, 84, .15);
  animation: modalin .3s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes modalin { from { opacity: 0; transform: scale(.92) translateY(12px); } }
.gate-head { display: flex; gap: 13px; align-items: center; margin-bottom: 16px; }
.gate-icon { font-size: 26px; color: var(--amber); }
.gate-head h3 { font-family: var(--font-d); font-size: 16px; }
.gate-head em { font-style: normal; font-size: 11.5px; color: var(--muted); font-family: var(--font-m); }
.gate-steps { list-style: none; display: grid; gap: 9px; margin-bottom: 14px; }
.gate-steps li {
  display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: var(--faint);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px;
  transition: all .25s ease;
}
.gate-steps li i {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); flex: none;
  display: grid; place-items: center; font-style: normal; font-size: 9px;
}
.gate-steps li.run { color: var(--text); border-color: var(--amber); }
.gate-steps li.run i { border-color: var(--amber); animation: spin 1s linear infinite; border-top-color: transparent; }
.gate-steps li.pass { color: var(--text); border-color: rgba(47, 217, 181, .4); }
.gate-steps li.pass i { border-color: var(--accent); background: var(--accent); color: #04261f; }
.gate-steps li.pass i::after { content: '✓'; font-weight: 700; }
@keyframes spin { to { transform: rotate(360deg); } }
.gate-result { font-size: 12.5px; min-height: 22px; font-family: var(--font-m); }
.gate-result.ok { color: var(--accent); }

/* ================= FOOTER ================= */
.foot {
  position: relative; z-index: 1;
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 14px 22px 20px; max-width: 1680px; margin: 0 auto;
  font-size: 10.5px; color: var(--faint); border-top: 1px solid var(--line);
}

/* ================= SCROLLBAR & RESPONSIVE ================= */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1280px) {
  .ov-grid, .fc-grid, .ctl-grid, .mt-grid, .arch-grid { grid-template-columns: 1fr; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .ov-charts { grid-template-columns: 1fr; }
  .scenario-grid { grid-template-columns: repeat(2, 1fr); }
  .maturity-track { grid-template-columns: 1fr 1fr; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .topbar { flex-wrap: wrap; gap: 10px; }
}
