:root {
  --bg: #f4f6fb; --card: #ffffff; --text: #1d2433; --muted: #6b7489; --line: #e6e9f0;
  --brand: #1565c0; --brand2: #0d47a1; --ok: #2e7d32; --warn: #ef6c00; --bad: #c62828;
  --side: #0f1b33; --side-text: #c9d3ea;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--brand); }
button { font: inherit; cursor: pointer; border: 0; border-radius: 8px; padding: 8px 14px; background: var(--brand); color: #fff; }
button:hover { background: var(--brand2); }
button.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
button.danger { background: var(--bad); }
button.small { padding: 4px 10px; font-size: 12px; }
input, select { font: inherit; padding: 9px 11px; border: 1px solid #cfd6e4; border-radius: 8px; width: 100%; background: #fff; color: var(--text); }
input:focus { outline: 2px solid #90caf9; border-color: var(--brand); }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }

/* ---------- đăng nhập */
.auth { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px;
        background: radial-gradient(circle at 20% 20%, #1e3a74, #0b1428 70%); }
.auth .box { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth h1 { margin: 0 0 4px; font-size: 22px; color: var(--brand2); }
.auth p { margin: 0 0 8px; color: var(--muted); }
.auth button { width: 100%; margin-top: 18px; padding: 11px; }
.err { color: var(--bad); margin-top: 10px; min-height: 18px; font-size: 13px; }
.logo { display: inline-flex; width: 40px; height: 40px; border-radius: 10px; background: var(--brand); color: #fff;
        align-items: center; justify-content: center; font-weight: 700; margin-bottom: 12px; }

/* ---------- khung chính */
.layout { display: flex; min-height: 100%; }
.side { width: 220px; background: var(--side); color: var(--side-text); padding: 18px 12px; flex-shrink: 0; }
.side .brand { color: #fff; font-weight: 700; font-size: 17px; padding: 0 10px 18px; display: flex; gap: 10px; align-items: center; }
.side .brand .logo { width: 30px; height: 30px; margin: 0; font-size: 13px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--side-text);
         text-decoration: none; margin-bottom: 2px; }
.nav a.active, .nav a:hover { background: #1c2c4f; color: #fff; }
.nav .badge { margin-left: auto; background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.main { flex: 1; padding: 22px 26px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.top h2 { margin: 0; font-size: 20px; }
.who { color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.charts { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-top: 14px; }
.chart h3, .card h3 { margin: 0 0 10px; font-size: 14px; }
.chart canvas { width: 100%; height: 150px; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:hover td { background: #fafbfe; }
.tablewrap { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.pill.info { background: #e3f2fd; color: var(--brand2); }
.pill.warn { background: #fff3e0; color: var(--warn); }
.pill.alert { background: #ffebee; color: var(--bad); }
.pill.ok { background: #e8f5e9; color: var(--ok); }
.lvl { font-size: 22px; font-weight: 700; text-transform: uppercase; }
.lvl.an-toan { color: var(--ok); } .lvl.theo-doi { color: var(--brand); } .lvl.canh-bao { color: var(--warn); } .lvl.nguy-hiem { color: var(--bad); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > div { flex: 1; min-width: 160px; }
.note { background: #fff8e1; border: 1px solid #ffe082; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-top: 12px; }
.mono { font-family: Consolas, ui-monospace, monospace; }
.muted { color: var(--muted); }
.toast { position: fixed; right: 18px; bottom: 18px; background: #263238; color: #fff; padding: 11px 16px; border-radius: 10px; opacity: 0; transition: .25s; pointer-events: none; }
.toast.show { opacity: 1; }
.section { display: none; } .section.active { display: block; }
.mt { margin-top: 14px; }
.qr { background: #fff; padding: 10px; display: inline-block; border: 1px solid var(--line); border-radius: 8px; }
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .side { width: 100%; padding: 10px; }
  .nav { display: flex; overflow-x: auto; gap: 4px; }
  .nav a { white-space: nowrap; }
  .main { padding: 16px; }
}
