/* Bảng màu theo design system Beiwanglu (CLAUDE.md của v1) + một màu cam cho mức Vàng. */
:root {
  --primary: #0E7960; --primary-dark: #0a5c49; --primary-light: #E7F2EF; --primary-ink: #0B6650;
  --surface: #FFFFFF; --bg: #F4F5F7; --sidebar: #111621; --sidebar-text: #A8ABBA;
  --text: #1A1C23; --sub: #5F6370; --border: #E2E4E9; --border-strong: #C8CBD4; --track: #ECEEF2;
  --error: #D92D20; --error-ink: #B42318; --error-soft: #FEE4E2;
  --warn: #DC8A16; --warn-ink: #B45309; --warn-soft: #FBEFD9;
  --success: #027A48; --success-soft: #E3F3EA;
  --font-body: 'Be Vietnam Pro', 'Segoe UI', system-ui, 'Microsoft JhengHei', 'PingFang TC', sans-serif;
  --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-mono: Consolas, 'Courier New', monospace;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: var(--font-display); font-weight: 600; }
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 20px; }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }
.sub { color: var(--sub); }
.grow { flex: 1; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.ic.sm { width: 16px; height: 16px; stroke-width: 2; }

/* Khung: sidebar cố định 220px, header 56px */
.app { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 220px; background: var(--sidebar); padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; z-index: 40; }
.content { flex: 1; min-width: 0; margin-left: 220px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 12px; margin-bottom: 24px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-name { color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 1.2; }
.nav-group { padding: 0 12px; margin: 16px 0 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #8D91A0; }
.brand + .nav-group { margin-top: 0; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 9px 14px; border-radius: 8px; color: var(--sidebar-text); font-size: 13.5px; font-weight: 500; text-decoration: none; transition: background .15s, color .15s; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #E2E4E9; }
.nav-item.active { background: rgba(14, 121, 96, .25); color: #7EDBC4; font-weight: 600; }
.nav-badge { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--error); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.me { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid rgba(255, 255, 255, .1); display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.me-name { color: #fff; font-size: 13px; font-weight: 600; }
.me-role { color: var(--sidebar-text); font-size: 11.5px; }

.topbar { position: sticky; top: 0; z-index: 30; min-height: 56px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 8px 24px; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.crumbs .sep { color: var(--border-strong); }
.crumbs .cur { font-weight: 600; }
.search { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--sub); }
.search input { border: 0; outline: 0; background: transparent; font: inherit; font-size: 13px; color: var(--text); width: 190px; max-width: 100%; }
.lang { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang button { min-height: 38px; padding: 0 12px; border: 0; background: var(--surface); color: var(--sub); font-size: 12.5px; font-weight: 600; }
.lang button + button { border-left: 1px solid var(--border); }
.lang button.on { background: var(--primary-light); color: var(--primary-ink); font-weight: 700; }
.icon-btn { position: relative; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); display: flex; align-items: center; justify-content: center; }
.dot-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--error); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.btn-primary { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px; border: 0; border-radius: 8px; background: var(--primary); color: #fff; font-size: 13px; font-weight: 600; transition: background .15s; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; }
.btn-outline:hover { background: var(--bg); }
.btn-outline:disabled { opacity: .6; cursor: default; }

.main { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.title-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.subtitle { margin-top: 4px; font-size: 13.5px; color: var(--sub); }
.live { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--success-soft); color: var(--success); font-size: 12.5px; font-weight: 600; }
.live-pill.bad { background: var(--error-soft); color: var(--error-ink); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.banner { padding: 12px 16px; border-radius: 10px; background: var(--error-soft); color: var(--error-ink); font-size: 13.5px; font-weight: 500; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.kpi.pending { background: transparent; border-style: dashed; border-color: var(--border-strong); }
.kpi-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--sub); }
.kpi-value { font-family: var(--font-display); font-weight: 600; font-size: 36px; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi.pending .kpi-value { font-size: 22px; color: var(--sub); padding: 7px 0; }
.kpi-note { font-size: 12.5px; color: var(--sub); }
.levelbar { display: flex; gap: 3px; height: 8px; border-radius: 4px; overflow: hidden; }
.levelbar span { min-width: 0; }
.levelbar .do { background: var(--error); } .levelbar .vang { background: var(--warn); } .levelbar .xanh { background: var(--primary); }

.body-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 20px; }
.col-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.col-rail { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chips-label { font-size: 12.5px; font-weight: 600; color: var(--sub); margin-right: 2px; }
.chip { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.sec-head { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; }
.sec-head .sub { font-size: 12.5px; }
.empty { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: 12px; padding: 20px; font-size: 13.5px; color: var(--sub); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.card { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.level { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.level::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.level.do { background: var(--error-soft); color: var(--error-ink); }
.level.vang { background: var(--warn-soft); color: var(--warn-ink); }
.golive { font-size: 12.5px; color: var(--sub); white-space: nowrap; }
.golive b { color: var(--text); font-variant-numeric: tabular-nums; }
.name-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.code { font-family: var(--font-mono); font-size: 12px; color: var(--sub); background: var(--bg); padding: 1px 6px; border-radius: 4px; }
.card h3 { font-size: 15.5px; font-weight: 700; line-height: 1.3; }
.modules { font-size: 12px; color: var(--sub); margin-top: 2px; }
.why { font-size: 13px; font-weight: 500; line-height: 1.45; }
.why.do { color: var(--error-ink); } .why.vang { color: var(--warn-ink); }
.meter-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--sub); margin-bottom: 4px; }
.meter-head b { color: var(--text); font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.funds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fund-label { font-size: 11.5px; color: var(--sub); }
.fund-text { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fund .bar { height: 4px; margin-top: 4px; }
.fund.low .fund-text { color: var(--error-ink); }
.fund.low .bar > span { background: var(--error); }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding-top: 12px; border-top: 1px solid #F0F1F4; font-size: 12.5px; color: var(--sub); }
.card-foot b { color: var(--text); font-variant-numeric: tabular-nums; }
.card-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; }
.who { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); font-weight: 600; }
.who i { width: 22px; height: 22px; border-radius: 50%; background: var(--primary-light); color: var(--primary-ink); font-size: 11px; font-weight: 700; font-style: normal; display: inline-flex; align-items: center; justify-content: center; }
.open-link { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; font-size: 13px; font-weight: 600; color: var(--primary-ink); text-decoration: none; }
.open-link:hover { color: var(--primary-dark); }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
.table { min-width: 780px; }
.tr { display: grid; grid-template-columns: minmax(170px, 2fr) 92px minmax(110px, 1.2fr) 92px 84px 104px 52px; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--bg); font-size: 13.5px; }
.tr:last-child { border-bottom: 0; }
.tr.head { padding: 10px 16px; background: #FAFBFC; border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--sub); }
.tr:not(.head):hover { background: #FAFBFC; }
.td-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.td-name::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.td-name a { font-weight: 600; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-pct { display: flex; align-items: center; gap: 8px; }
.td-pct .bar { flex: 1; height: 6px; }
.td-pct b { width: 36px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.panel h2 { font-size: 18px; margin-bottom: 8px; }
.todo { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 0; border-bottom: 1px solid #F0F1F4; text-decoration: none; color: var(--text); }
.todo-n { flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px; font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.todo-n.do { background: var(--error-soft); color: var(--error-ink); }
.todo-n.vang { background: var(--warn-soft); color: var(--warn-ink); }
.todo-n.zero { background: var(--success-soft); color: var(--success); }
.todo-text { flex: 1; min-width: 0; }
.todo-text b { display: block; font-size: 13.5px; font-weight: 600; }
.todo-text span { display: block; font-size: 12px; color: var(--sub); }
.panel-note { font-size: 12px; color: var(--sub); padding-top: 10px; }
.wk { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid #F0F1F4; }
.wk:last-child { border-bottom: 0; }
.wk-day { font-size: 12px; font-weight: 700; color: var(--sub); }
.wk.today .wk-day { color: var(--primary-ink); }
.wk-text b { display: block; font-size: 13px; font-weight: 600; }
.wk-text span { display: block; font-size: 12px; color: var(--sub); }
.pill { padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.pill.saved { background: var(--success-soft); color: var(--success); }
.pill.today { background: var(--primary); color: #fff; }
.pill.upcoming { background: var(--track); color: #464A57; }
.pill.overdue { background: var(--warn-soft); color: var(--warn-ink); }
.sys { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; padding: 6px 0; }
.sys::before { content: ''; margin-top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.sys b { display: block; font-weight: 600; }
.sys span { display: block; font-size: 12px; color: var(--sub); }
.sys-action { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-top: 10px; margin-top: 6px; border-top: 1px solid #F0F1F4; }
.sys-result { font-size: 12.5px; color: var(--sub); }
.sys-result.ok { color: var(--success); font-weight: 600; }
.sys-result.bad { color: var(--error-ink); font-weight: 600; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { position: static; width: auto; }
  .content { margin-left: 0; }
  .topbar { position: static; }
  .main { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
