/* Giam sat AIHAKI - tokens follow the dataviz reference palette */
:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --grid: #e9e8e3;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77766f;
  --accent: #2a78d6;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-ink: #006300; --critical-ink: #b02727;
  --warn-bg: #fff6e0; --crit-bg: #fdeceb; --info-bg: #eaf2fc;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface-1: #1a1a19; --surface-2: #232322; --border: #2e2e2c; --grid: #2a2a28;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
    --accent: #3987e5;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --good-ink: #3fcf3f; --critical-ink: #ff8a8a;
    --warn-bg: #2d2513; --crit-bg: #331b1b; --info-bg: #17243a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface-1: #1a1a19; --surface-2: #232322; --border: #2e2e2c; --grid: #2a2a28;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
  --accent: #3987e5;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --good-ink: #3fcf3f; --critical-ink: #ff8a8a;
  --warn-bg: #2d2513; --crit-bg: #331b1b; --info-bg: #17243a;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 16px; }
h3 { font-size: 14px; margin-bottom: 10px; }
.muted { color: var(--text-muted); font-weight: 400; }
.small { font-size: 12px; }
button { font: inherit; color: inherit; }

/* header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 30px; height: 30px; border-radius: 7px; background: var(--accent) url("/favicon.svg") center/cover; flex: none; }
.brand h1 { font-size: 17px; letter-spacing: .2px; }
.sub { margin: 0; color: var(--text-secondary); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70vw; }
.top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.top-right form { margin: 0; }
.ghost { background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; cursor: pointer; color: var(--text-secondary); }
.ghost:hover { color: var(--text-primary); border-color: var(--text-muted); }
.clock { color: var(--text-secondary); font-size: 13px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-secondary); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.live[data-s="ok"] i { background: var(--good); box-shadow: 0 0 0 0 rgba(12,163,12,.5); animation: pulse 2s infinite; }
.live[data-s="loi"] i { background: var(--critical); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(12,163,12,.45); } 70% { box-shadow: 0 0 0 7px rgba(12,163,12,0); } 100% { box-shadow: 0 0 0 0 rgba(12,163,12,0); } }
@media (prefers-reduced-motion: reduce) { .live[data-s="ok"] i { animation: none; } }

/* tabs */
.tabs {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 2px; overflow-x: auto;
  padding: 0 16px; background: var(--surface-1); border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.tabs a {
  padding: 10px 12px; color: var(--text-secondary); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; font-weight: 500;
}
.tabs a:hover { color: var(--text-primary); }
.tabs a.on { color: var(--text-primary); border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; line-height: 18px; text-align: center; margin-left: 4px; color: #fff; background: var(--critical); }
.badge:empty { display: none; }
.badge.w { background: #9a6a00; }

main { padding: 16px 20px 32px; max-width: 1600px; margin: 0 auto; }
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; margin: 0 0 14px; box-shadow: var(--shadow); min-width: 0;
}
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 4px 0 10px; }
.card .row-head { margin-top: 0; }
.card .row-head h3 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
.grid-2 > .card { margin: 0 0 14px; }

/* alerts */
.alerts { margin-bottom: 14px; }
.alert {
  display: grid; grid-template-columns: 22px 1fr auto; align-items: start; gap: 8px;
  padding: 9px 12px; border-radius: 8px; margin-bottom: 6px; border: 1px solid var(--border);
  background: var(--surface-1);
}
.alert.nghiemTrong { background: var(--crit-bg); border-color: color-mix(in srgb, var(--critical) 35%, transparent); }
.alert.canhBao { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.alert.thongTin { background: var(--info-bg); }
.alert b { font-weight: 600; }
.alert .d { color: var(--text-secondary); }
.alert .since { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.alert.ok { background: var(--surface-1); }
.ico { width: 18px; height: 18px; display: inline-grid; place-items: center; border-radius: 50%; font-size: 11px; font-weight: 700; color: #fff; flex: none; margin-top: 1px; }
.ico.good { background: var(--good); }
.ico.warning { background: var(--warning); color: #3a2a00; }
.ico.serious { background: var(--serious); }
.ico.critical { background: var(--critical); }
.ico.info { background: var(--accent); }
.alerts .more { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 2px 0; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px 8px; min-width: 0; box-shadow: var(--shadow); }
.tile .lb { color: var(--text-secondary); font-size: 12.5px; display: flex; justify-content: space-between; gap: 6px; }
.tile .v { font-size: 26px; font-weight: 600; letter-spacing: -.3px; margin: 2px 0 0; white-space: nowrap; }
.tile .v small { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-left: 3px; }
.tile .s { color: var(--text-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .spark { height: 34px; margin-top: 4px; }
.tile .spark canvas { display: block; width: 100%; height: 100%; }
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

/* charts */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.seg button { background: var(--surface-1); border: 0; padding: 5px 12px; cursor: pointer; color: var(--text-secondary); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 14px; margin-bottom: 14px; }
.charts .card { margin: 0; }
figure { margin: 0; }
figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.cap-note { color: var(--text-muted); font-size: 12px; }
.legend { display: inline-flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.sq { height: 10px; width: 10px; border-radius: 2px; }
.chart { position: relative; height: 190px; }
.chart.tall { height: 230px; }
.chart canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.tip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12.5px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18); min-width: 150px;
}
.tip .t { color: var(--text-muted); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tip .r span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.tip .r i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.tip .r b { font-weight: 600; }

/* disks, cores, kv */
.disk { margin-bottom: 12px; }
.disk .hd { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.meter { height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 18%, var(--surface-2)); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.meter.w > i { background: var(--warning); }
.meter.c > i { background: var(--critical); }
.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; margin-bottom: 12px; }
.core { font-size: 11.5px; color: var(--text-secondary); }
.core .bar { height: 46px; border-radius: 4px; background: var(--surface-2); position: relative; overflow: hidden; margin-bottom: 3px; }
.core .bar i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--accent); border-radius: 4px 4px 0 0; transition: height .4s; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.q { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; cursor: pointer; text-decoration: none; color: inherit; display: block; }
.q:hover { border-color: var(--text-muted); }
.q .n { font-size: 20px; font-weight: 600; }
.q .l { color: var(--text-secondary); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }

/* tables */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 500; color: var(--text-muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
.tbl th.sort { cursor: pointer; }
.tbl th.sort:hover { color: var(--text-primary); }
.tbl th.asc::after { content: " ▲"; font-size: 9px; }
.tbl th.desc::after { content: " ▼"; font-size: 9px; }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.n, .tbl th.n { text-align: right; white-space: nowrap; }
.tbl td.w { white-space: nowrap; }
.tbl td.wrap { overflow-wrap: anywhere; min-width: 180px; }
.tbl tr.dim td { color: var(--text-muted); }
.tbl .sub2 { color: var(--text-muted); font-size: 12px; }
.tbl .empty { color: var(--text-muted); text-align: center; padding: 14px; }
.bad { color: var(--critical-ink); font-weight: 600; }
.okc { color: var(--good-ink); }
.mini { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--surface-2); vertical-align: middle; margin-left: 6px; overflow: hidden; }
.mini i { display: block; height: 100%; background: var(--accent); }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--text-secondary); font-size: 13px; cursor: pointer; }

.foot { text-align: center; color: var(--text-muted); font-size: 12px; padding: 0 16px 20px; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 26px 24px; }
.login-card h1 { font-size: 19px; margin-bottom: 18px; }
.login-card label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.login-card input { width: 100%; padding: 9px 11px; font: inherit; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); color: var(--text-primary); }
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-card button { margin-top: 14px; width: 100%; padding: 9px; border: 0; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.login-msg { color: var(--critical-ink); font-size: 13px; margin: 10px 0 0; }
.login-hint { color: var(--text-muted); font-size: 12px; margin-top: 16px; }

@media (max-width: 640px) {
  .top { padding: 10px 16px; }
  main { padding: 12px 16px 24px; }
  .charts, .grid-2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile .v { font-size: 21px; }
  .clock { display: none; }
}
