/* ═══════════════════════ Kanshi — design tokens ═══════════════════════ */
:root {
  --font-ui: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-num: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 28px;
  --fs-3xl: 36px;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --z-sidebar: 20;
  --z-topbar: 10;
  --z-modal: 50;
  --z-toast: 60;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --sidebar-w: 236px;
  /* Màu nhận diện Mirei (xám xanh từ logo) */
  --brand: #6F8483;
}

/* Sáng — giao diện mặc định: nền trắng, chủ đạo xám xanh Mirei */
:root, :root[data-theme='light'] {
  --bg: #F6F8F8;
  --bg-2: #FFFFFF;
  --panel: #FFFFFF;
  --panel-2: #F7FAFA;
  --panel-3: #EBF1F1;
  --line: #E0E7E7;
  --line-strong: #C7D3D2;
  --text: #182323;
  --text-2: #3A4B4B;
  --muted: #5E7170;
  --accent: #4C6A69;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(76, 106, 105, .12);
  --brand-ink: #6F8483;

  --up: #13875C;
  --warn: #A86A00;
  --down: #C8303A;
  --maint: #6B55D9;
  --pending: #687B7A;
  --up-soft: rgba(19, 135, 92, .1);
  --warn-soft: rgba(201, 135, 0, .12);
  --down-soft: rgba(200, 48, 58, .09);
  --maint-soft: rgba(107, 85, 217, .1);
  --pending-soft: rgba(104, 123, 122, .12);

  --shadow: 0 1px 2px rgba(24, 35, 35, .04), 0 8px 24px -18px rgba(24, 35, 35, .22);
  --overlay: rgba(24, 35, 35, .4);
  --chart-grid: rgba(94, 113, 112, .15);
}

/* Đêm — tuỳ chọn, bật bằng nút ở góc dưới thanh bên */
:root[data-theme='dark'] {
  --bg: #0E1616;
  --bg-2: #0A1111;
  --panel: #141E1E;
  --panel-2: #192525;
  --panel-3: #203030;
  --line: #263636;
  --line-strong: #344949;
  --text: #E6EDEC;
  --text-2: #B7C6C5;
  --muted: #8A9D9C;
  --accent: #93BDBA;
  --accent-ink: #0E1616;
  --accent-soft: rgba(147, 189, 186, .14);
  --brand-ink: #C9D8D7;

  --up: #34C08B;
  --warn: #F2B33D;
  --down: #F0525A;
  --maint: #A896F7;
  --pending: #6E8483;
  --up-soft: rgba(52, 192, 139, .13);
  --warn-soft: rgba(242, 179, 61, .14);
  --down-soft: rgba(240, 82, 90, .15);
  --maint-soft: rgba(155, 138, 245, .15);
  --pending-soft: rgba(110, 132, 131, .16);

  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -18px rgba(0, 0, 0, .7);
  --overlay: rgba(4, 10, 10, .66);
  --chart-grid: rgba(138, 157, 156, .14);
}

/* ═══════════════════════ Nền tảng ═══════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; }
p { margin: 0; }
code, .mono { font-family: var(--font-num); font-size: .92em; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.lg { width: 22px; height: 22px; }

/* ═══════════════════════ Khung ứng dụng ═══════════════════════ */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 12px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  z-index: var(--z-sidebar);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
/* Logo Mirei dùng làm mặt nạ để tự đổi màu theo giao diện sáng/đêm */
.brand-mark {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  background: var(--brand); border-radius: 10px;
}
.brand-mark i {
  display: block; width: 26px; height: 16px; background: #fff;
  -webkit-mask: url('/img/mirei-mark.png') center / contain no-repeat;
  mask: url('/img/mirei-mark.png') center / contain no-repeat;
}
.brand-word {
  display: block; width: 76px; height: 23px; background: var(--brand-ink);
  -webkit-mask: url('/img/mirei-wordmark.png') left center / contain no-repeat;
  mask: url('/img/mirei-wordmark.png') left center / contain no-repeat;
}
.brand-sub { display: block; margin-top: 3px; font-size: var(--fs-xs); color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  min-height: 42px; padding: 0 12px;
  border-radius: var(--r-md);
  color: var(--text-2); font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a[aria-current='page'] { background: var(--panel-3); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav .count {
  margin-left: auto; min-width: 22px; padding: 0 7px;
  border-radius: 999px; text-align: center;
  font-size: var(--fs-xs); font-weight: 600; line-height: 20px;
  background: var(--down); color: #fff;
}
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.live { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); color: var(--muted); }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pending); }
.live.on .dot { background: var(--up); box-shadow: 0 0 0 3px var(--up-soft); }
.user-row { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--panel-3); color: var(--text-2); font-weight: 600; font-size: var(--fs-sm);
  text-transform: uppercase;
}

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  display: flex; align-items: center; gap: 12px;
  min-height: 64px; padding: 10px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: var(--fs-xl); }
.topbar .crumb { color: var(--muted); font-size: var(--fs-sm); }
.topbar .spacer { flex: 1; }
.btn.menu-btn { display: none; }
.content { padding: 24px 28px 48px; display: grid; gap: 24px; max-width: 1600px; width: 100%; }

/* ═══════════════════════ Thành phần chung ═══════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--panel-2); color: var(--text);
  font-weight: 500; font-size: var(--fs-md);
  cursor: pointer; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.btn:hover { background: var(--panel-3); border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, var(--line)); background: transparent; }
.btn.danger:hover { background: var(--down-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn.icon { width: 38px; padding: 0; }
.btn.icon.sm { width: 32px; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  min-width: 0;
}
.panel-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: var(--fs-lg); }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 18px 20px; }
.panel-body.flush { padding: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px;
  border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 600; white-space: nowrap;
  background: var(--pending-soft); color: var(--pending);
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.up { background: var(--up-soft); color: var(--up); }
.badge.warning { background: var(--warn-soft); color: var(--warn); }
.badge.down { background: var(--down-soft); color: var(--down); }
.badge.maintenance { background: var(--maint-soft); color: var(--maint); }
.badge.neutral { background: var(--panel-3); color: var(--text-2); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--pending); flex: none; }
.dot.up { background: var(--up); }
.dot.warning { background: var(--warn); }
.dot.down { background: var(--down); box-shadow: 0 0 0 3px var(--down-soft); }
.dot.maintenance { background: var(--maint); }

.os { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: var(--fs-sm); white-space: nowrap; }
.os svg { width: 16px; height: 16px; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--text-2); font-size: var(--fs-sm); font-weight: 500;
  cursor: pointer;
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip[aria-pressed='true'] { background: var(--panel-3); border-color: var(--line-strong); color: var(--text); }
.chip .n { font-family: var(--font-num); font-size: var(--fs-xs); color: var(--muted); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* Biểu mẫu */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--bg); color: var(--text);
  font-size: var(--fs-md);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
textarea.input { min-height: 84px; resize: vertical; line-height: 1.5; }
.input::placeholder { color: var(--muted); opacity: .8; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.search { padding-left: 38px; background-image: none; }
.search-wrap { position: relative; min-width: 220px; flex: 1 1 260px; max-width: 380px; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
select.input { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: var(--fs-md); }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.form-error { color: var(--down); font-size: var(--fs-sm); min-height: 0; }
.form-error:empty { display: none; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.section-title { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); padding-top: 4px; }

/* Bảng */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.table th {
  text-align: left; font-weight: 500; font-size: var(--fs-sm); color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: var(--panel);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr.link { cursor: pointer; }
.table tbody tr.link:hover { background: var(--panel-2); }
.table .actions { text-align: right; white-space: nowrap; }
.cell-main { display: grid; gap: 1px; min-width: 0; }
.cell-main strong { font-weight: 600; }
.cell-main .sub { color: var(--muted); font-size: var(--fs-sm); font-family: var(--font-num); }

/* Thanh tỉ lệ nhỏ CPU/RAM/Disk */
.meter { display: grid; grid-template-columns: 34px minmax(40px, 1fr) 44px; align-items: center; gap: 8px; font-size: var(--fs-xs); }
.meter .lbl { color: var(--muted); }
.meter .val { text-align: right; font-family: var(--font-num); color: var(--text-2); }
.bar { height: 6px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--up); transition: width .4s var(--ease); }
.bar.warn > span { background: var(--warn); }
.bar.crit > span { background: var(--down); }
.meters { display: grid; gap: 5px; min-width: 150px; }

/* Trạng thái rỗng / đang tải */
.empty { display: grid; justify-items: center; gap: 10px; padding: 44px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 34px; height: 34px; color: var(--line-strong); }
.empty h3 { color: var(--text); font-size: var(--fs-lg); }
.empty p { max-width: 46ch; }
.skeleton { background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-md); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ═══════════════════════ Tổng quan ═══════════════════════ */
.verdict { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: end; }
.verdict h2 {
  font-size: var(--fs-3xl); font-weight: 600; letter-spacing: -.02em; line-height: 1.15;
  max-width: 24ch;
}
.verdict h2 .lead { color: var(--up); }
.verdict.warning h2 .lead { color: var(--warn); }
.verdict.down h2 .lead { color: var(--down); }
.verdict .meta { margin-top: 10px; color: var(--muted); font-size: var(--fs-sm); display: flex; gap: 18px; flex-wrap: wrap; }
.verdict .meta b { color: var(--text-2); font-weight: 600; }

.tally { display: flex; gap: 6px; }
.tally a {
  display: grid; gap: 2px; min-width: 92px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--panel); color: var(--text);
}
.tally a:hover { text-decoration: none; border-color: var(--line-strong); }
.tally .v { font-family: var(--font-num); font-size: var(--fs-xl); font-weight: 500; line-height: 1.2; }
.tally .k { font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; gap: 6px; }
.tally a.is-down .v { color: var(--down); }
.tally a.is-warning .v { color: var(--warn); }

.fleet-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--panel-3); gap: 2px; }
.fleet-bar span { display: block; height: 100%; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.side-stack { display: grid; gap: 24px; }

/* Bản đồ đội máy chủ — điểm nhấn của trang */
.fleet-group + .fleet-group { margin-top: 22px; }
.fleet-group-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.fleet-group-head h3 { font-size: var(--fs-md); font-weight: 600; }
.fleet-group-head span { font-size: var(--fs-xs); color: var(--muted); }
.fleet { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: grid; gap: 10px;
  padding: 12px 14px 13px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--panel-2); color: var(--text);
  overflow: hidden;
  transition: border-color .15s var(--ease), transform .15s var(--ease);
}
.tile:hover { text-decoration: none; border-color: var(--line-strong); transform: translateY(-1px); }
.tile::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--pending); }
.tile.up::before { background: var(--up); }
.tile.warning::before { background: var(--warn); }
.tile.maintenance::before { background: var(--maint); }
.tile.down { border-color: color-mix(in srgb, var(--down) 55%, var(--line)); background: linear-gradient(180deg, var(--down-soft), transparent 70%), var(--panel-2); }
.tile.down::before { background: var(--down); }
.tile.down::after {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 0 1px var(--down), 0 0 22px -4px var(--down);
  animation: lantern 2.4s ease-in-out infinite;
}
@keyframes lantern { 0%, 100% { opacity: .25; } 50% { opacity: .9; } }
.tile-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tile-top strong { font-weight: 600; font-size: var(--fs-md); }
.tile-top .os { margin-left: auto; }
.tile-host { font-family: var(--font-num); font-size: var(--fs-xs); color: var(--muted); margin-top: -6px; }
.tile-state { font-size: var(--fs-xs); color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.tile.down .tile-state .s { color: var(--down); font-weight: 600; }
.tile.warning .tile-state .s { color: var(--warn); font-weight: 600; }
.tile.maintenance .tile-state .s { color: var(--maint); font-weight: 600; }

/* Danh sách sự cố */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .dot { margin-top: 7px; }
.feed .title { font-weight: 500; }
.feed .meta { grid-column: 2; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: var(--fs-xs); color: var(--muted); }
.feed .detail { grid-column: 2; font-size: var(--fs-sm); color: var(--text-2); }
.feed .act { grid-column: 2; display: flex; gap: 8px; margin-top: 4px; }

.timeline { list-style: none; margin: 0; padding: 4px 0; }
.timeline li { display: grid; grid-template-columns: 112px 16px minmax(0, 1fr); gap: 12px; align-items: start; padding: 8px 20px; }
.timeline time { font-family: var(--font-num); font-size: var(--fs-xs); color: var(--muted); padding-top: 2px; text-align: right; }
.timeline .dot { margin-top: 6px; }
.timeline .t { font-size: var(--fs-sm); }
.timeline .t .muted { font-size: var(--fs-xs); }

/* ═══════════════════════ Chi tiết máy chủ ═══════════════════════ */
.detail-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.detail-head .who { display: grid; gap: 6px; min-width: 0; flex: 1 1 320px; }
.detail-head h2 { font-size: var(--fs-2xl); letter-spacing: -.01em; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-head .facts { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: var(--fs-sm); }
.detail-head .facts span { display: inline-flex; align-items: center; gap: 6px; }
.detail-head .acts { display: flex; gap: 8px; flex-wrap: wrap; }

.gauges { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.gauge { padding: 16px 18px; display: grid; gap: 10px; }
.gauge .k { font-size: var(--fs-sm); color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.gauge .v { font-family: var(--font-num); font-size: var(--fs-2xl); line-height: 1; }
.gauge .v small { font-size: var(--fs-md); color: var(--muted); margin-left: 2px; }
.gauge .bar { height: 8px; }
.gauge .sub { font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-num); }

.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
.chart-cell { padding: 16px 20px 12px; border-bottom: 1px solid var(--line); min-width: 0; }
.chart-cell:nth-child(odd) { border-right: 1px solid var(--line); }
.chart-cell:nth-last-child(-n + 2) { border-bottom: 0; }
.chart-cell h3 { font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.chart-cell h3 .num { color: var(--text); }
.chart { position: relative; width: 100%; height: 150px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .tip {
  position: absolute; top: 0; pointer-events: none; z-index: 2;
  padding: 6px 9px; border-radius: var(--r-sm);
  background: var(--panel-3); border: 1px solid var(--line-strong);
  font-size: var(--fs-xs); white-space: nowrap; box-shadow: var(--shadow);
  transform: translateX(-50%);
}
.chart .tip b { font-family: var(--font-num); font-weight: 500; }
.chart-empty { height: 150px; display: grid; place-items: center; color: var(--muted); font-size: var(--fs-sm); border: 1px dashed var(--line); border-radius: var(--r-md); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-md); background: var(--panel-2); border: 1px solid var(--line); }
.seg button { min-height: 30px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; }
.seg button[aria-pressed='true'] { background: var(--panel-3); color: var(--text); }

.info-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 18px; font-size: var(--fs-sm); margin: 0; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.disk-row { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.disk-row:last-child { border-bottom: 0; }
.disk-row .top { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-sm); }

.strip { display: flex; gap: 2px; height: 22px; align-items: stretch; min-width: 180px; }
.strip i { flex: 1; border-radius: 2px; background: var(--panel-3); }
.strip i.ok { background: var(--up); }
.strip i.partial { background: var(--warn); }
.strip i.bad { background: var(--down); }

.cmd {
  position: relative; display: block;
  padding: 14px 52px 14px 14px; border-radius: var(--r-md);
  background: var(--bg-2); border: 1px solid var(--line);
  font-family: var(--font-num); font-size: var(--fs-sm); line-height: 1.6;
  white-space: pre-wrap; word-break: break-all; color: var(--text);
}
.cmd .btn { position: absolute; top: 8px; right: 8px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { min-height: 40px; padding: 0 14px; border: 0; background: none; color: var(--muted); font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected='true'] { color: var(--text); border-bottom-color: var(--accent); }
.callout { padding: 12px 14px; border-radius: var(--r-md); background: var(--warn-soft); color: var(--text); font-size: var(--fs-sm); display: flex; gap: 10px; align-items: flex-start; }
.callout svg { color: var(--warn); margin-top: 1px; }
.callout.info { background: var(--accent-soft); }
.callout.info svg { color: var(--accent); }

.two-col { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: start; }

/* ═══════════════════════ Hộp thoại & thông báo ═══════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: grid; place-items: center; padding: 20px;
  background: var(--overlay);
  animation: fade .15s var(--ease);
}
.modal {
  width: min(640px, 100%); max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .6);
  animation: rise .2s var(--ease);
}
.modal.wide { width: min(780px, 100%); }
.modal.narrow { width: min(440px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: var(--fs-lg); flex: 1; }
.modal-body { padding: 20px 22px; overflow-y: auto; display: grid; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.99); } }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: var(--z-toast); display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r-md);
  background: var(--panel-3); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  font-size: var(--fs-sm);
  animation: rise .2s var(--ease);
}
.toast svg { margin-top: 1px; }
.toast.ok svg { color: var(--up); }
.toast.err svg { color: var(--down); }

/* ═══════════════════════ Đăng nhập ═══════════════════════ */
.login {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr);
}
.login-art {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 44px; background: var(--bg-2); border-right: 1px solid var(--line);
}
.login-art .kanji { font-size: clamp(120px, 18vw, 240px); font-weight: 700; line-height: .9; color: var(--panel-3); letter-spacing: -.04em; user-select: none; }
.login-art p { max-width: 40ch; color: var(--text-2); font-size: var(--fs-lg); }
.login-grid { display: grid; grid-template-columns: repeat(12, 14px); gap: 6px; }
.login-grid i { width: 14px; height: 14px; border-radius: 3px; background: var(--panel-3); }
.login-grid i.u { background: var(--up); opacity: .8; }
.login-grid i.w { background: var(--warn); }
.login-grid i.d { background: var(--down); }
.login-form { display: grid; place-items: center; padding: 32px 20px; }
.login-form form { width: min(360px, 100%); display: grid; gap: 18px; }
.login-form h1 { font-size: var(--fs-2xl); }

/* ═══════════════════════ Đáp ứng ═══════════════════════ */
@media (max-width: 1280px) {
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
  .side-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  .gauges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts { grid-template-columns: minmax(0, 1fr); }
  .chart-cell:nth-child(odd) { border-right: 0; }
  .chart-cell:nth-last-child(2) { border-bottom: 1px solid var(--line); }
  .verdict { grid-template-columns: minmax(0, 1fr); align-items: start; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 264px;
    transform: translateX(-100%); transition: transform .2s var(--ease);
    box-shadow: 20px 0 50px -20px rgba(0, 0, 0, .6);
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open::after { content: ''; position: fixed; inset: 0; background: var(--overlay); z-index: calc(var(--z-sidebar) - 1); }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 18px 16px 40px; gap: 18px; }
  .side-stack { grid-template-columns: minmax(0, 1fr); }
  .verdict h2 { font-size: var(--fs-2xl); }
  .tally { flex-wrap: wrap; }
  .tally a { flex: 1 1 90px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-art { display: none; }
  .panel-head, .panel-body { padding-left: 16px; padding-right: 16px; }
  .feed li { padding: 12px 16px; }
  .timeline li { grid-template-columns: 84px 12px minmax(0, 1fr); padding: 8px 16px; gap: 10px; }
  .hide-sm { display: none !important; }
  .search-wrap { max-width: none; }
}
@media (max-width: 520px) {
  .gauges { grid-template-columns: minmax(0, 1fr); }
  .fleet { grid-template-columns: minmax(0, 1fr); }
  body { font-size: 15px; }
  .meters { min-width: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .tile.down::after { opacity: .8; }
}

.theme-toggle { justify-content: flex-start; width: 100%; color: var(--text-2); }
