:root {
  --ink: #1B2433;
  --ink-2: #3A4659;
  --muted: #6B7A90;
  --line: #DCE2EA;
  --line-soft: #EBEFF4;
  --paper: #F5F7FA;
  --surface: #FFFFFF;
  --teal: #0E7C86;
  --teal-dark: #0A5F67;
  --teal-soft: #E2F2F3;
  --ok: #1F8A5B;
  --warn: #B7791F;
  --bad: #C2362B;
  --unknown: #6B7A90;
  --side: #16202E;
  --radius: 8px;
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- Khung ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--side); color: #C9D3E0; display: flex; flex-direction: column;
  padding: 20px 14px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; color: #fff; font-weight: 700; font-size: 16px; }
.brand svg { flex: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  color: #C9D3E0; padding: 8px 10px; border-radius: 6px; font-weight: 500; display: flex; justify-content: space-between; align-items: center;
}
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(92,200,194,.14); color: #fff; }
.nav .count { font-size: 12px; background: var(--bad); color: #fff; border-radius: 10px; padding: 0 7px; font-weight: 600; }
.nav-sep { height: 1px; background: rgba(255,255,255,.08); margin: 14px 8px; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot .role { font-size: 12px; color: #8C9AAE; }
.side-foot .links { display: flex; gap: 14px; margin-top: 10px; font-size: 13px; }
.side-foot a, .side-foot button { background: none; border: 0; padding: 0; color: #9FDCD8; font: inherit; cursor: pointer; }
.side-foot button:hover { text-decoration: underline; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 18px 32px; background: var(--paper);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { flex: 1; }
.page { padding: 24px 32px 48px; max-width: 1320px; width: 100%; }
.btn.menu-btn { display: none; }

/* ---------- Nút, form ---------- */
.btn {
  font: inherit; font-weight: 600; border-radius: 6px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.btn:hover { border-color: #C3CCD8; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.link { border: 0; background: none; padding: 0; color: var(--teal); font-weight: 500; }

label.field { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 13px; color: var(--ink-2); }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=time], input[type=search], input[type=url], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; min-width: 0;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; color: var(--ink); }
.check input { margin-top: 3px; accent-color: var(--teal); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; background: var(--surface); }
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days label:has(input:checked) { background: var(--teal); border-color: var(--teal); color: #fff; }
.days label:has(input:focus-visible) { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ---------- Khối ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; }
.panel-body { padding: 0 18px 18px; }
.panel + .panel { margin-top: 18px; }
.notice { border: 1px solid #F0D9A8; background: #FDF7EA; color: #6B4A0E; border-radius: 8px; padding: 12px 14px; margin-bottom: 18px; }
.notice.error { border-color: #F1C7C3; background: #FDF1F0; color: #7D2019; }
.empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 6px; }

/* ---------- Chuỗi link: site ── domain (điểm nhấn) ---------- */
.chain { display: inline-flex; align-items: center; gap: 0; min-width: 0; max-width: 100%; font-weight: 600; }
.chain .site, .chain .dom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chain .dom { color: var(--ink-2); font-weight: 500; }
.chain .wire { position: relative; flex: none; width: 46px; height: 12px; margin: 0 6px; }
.chain .wire::before, .chain .wire::after {
  content: ''; position: absolute; top: 5px; height: 2px; background: currentColor; border-radius: 2px;
}
.chain .wire::before { left: 0; right: 0; }
.chain .wire::after { display: none; }
.chain .wire i { position: absolute; top: 2px; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chain .wire i:first-child { left: -1px; }
.chain .wire i:last-child { right: -1px; }
.chain.ok .wire { color: var(--ok); }
.chain.degraded .wire { color: var(--warn); }
.chain.degraded .wire::before { background: repeating-linear-gradient(90deg, currentColor 0 5px, transparent 5px 9px); }
.chain.broken .wire { color: var(--bad); }
.chain.broken .wire::before { right: 58%; }
.chain.broken .wire::after { display: block; left: 58%; right: 0; transform: translateY(3px) rotate(-14deg); transform-origin: left; }
.chain.broken .wire i:last-child { background: transparent; border: 2px solid currentColor; }
.chain.unknown .wire, .chain.pending .wire { color: #AEB9C8; }
.chain.unknown .wire::before, .chain.pending .wire::before { background: repeating-linear-gradient(90deg, currentColor 0 2px, transparent 2px 6px); }
.chain.big { font-size: 18px; }
.chain.big .wire { width: 80px; }

/* ---------- Nhãn trạng thái ---------- */
.tag { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.tag::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.tag.ok { color: var(--ok); }
.tag.degraded { color: var(--warn); }
.tag.broken { color: var(--bad); }
.tag.unknown, .tag.pending { color: var(--unknown); }
.tag.plain::before { display: none; }

/* ---------- Dải trạng thái (tổng quan) ---------- */
.overview-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 16px; flex-wrap: wrap; }
.overview-head .total { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.overview-head .total span { font-size: 16px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; margin-left: 6px; }
.strip { display: flex; height: 18px; border-radius: 5px; overflow: hidden; background: var(--line-soft); gap: 2px; }
.strip a { display: block; height: 100%; min-width: 4px; }
.strip a:hover { filter: brightness(1.1); }
.strip .ok { background: var(--ok); }
.strip .degraded { background: var(--warn); }
.strip .broken { background: var(--bad); }
.strip .sitebad { background: #7D2019; }
.strip .unknown { background: #AEB9C8; }
.strip .pending { background: #D5DCE5; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 12px; }
.legend a { color: var(--ink); display: inline-flex; gap: 8px; align-items: baseline; }
.legend a b { font-size: 17px; }
.legend .sw.ok { background: var(--ok); }
.legend .sw.degraded { background: var(--warn); }
.legend .sw.broken { background: var(--bad); }
.legend .sw.sitebad { background: #7D2019; }
.legend .sw.unknown { background: #AEB9C8; }
.legend .sw.pending { background: #D5DCE5; }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; align-self: center; }
.cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; margin-top: 22px; align-items: start; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 12px 18px; border-top: 1px solid var(--line-soft); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; cursor: pointer; }
.feed li:hover { background: #FAFBFC; }
.feed .why { grid-column: 1 / -1; color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars td { padding: 7px 0; }
.bar { height: 6px; background: var(--line-soft); border-radius: 3px; overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--bad); }

/* ---------- Bảng ---------- */
.filters { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(5, minmax(120px, 1fr)) auto; gap: 10px; margin-bottom: 14px; align-items: end; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
table.list th button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
table.list th button[aria-sort] { color: var(--ink); }
table.list td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #FAFBFC; }
table.list tr.sel td { background: var(--teal-soft); }
.sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.detail-cell { max-width: 380px; color: var(--ink-2); font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px 0; color: var(--muted); }

/* ---------- Ngăn chi tiết ---------- */
.drawer-bg { position: fixed; inset: 0; background: rgba(22,32,46,.28); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 21; overflow-y: auto;
  border-left: 1px solid var(--line); padding: 22px 24px 40px; animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: .4; } }
.drawer .close { position: absolute; top: 16px; right: 16px; }
.facts { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; margin: 18px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.status-box { border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin: 14px 0; }
.status-box p { margin-top: 6px; color: var(--ink-2); overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 10px 0 0; padding: 0 0 0 4px; }
.timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--line-soft); }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid currentColor; }
.timeline li.ok { color: var(--ok); }
.timeline li.degraded { color: var(--warn); }
.timeline li.broken { color: var(--bad); }
.timeline li.unknown { color: var(--unknown); }
.timeline .t { color: var(--ink); font-weight: 600; font-size: 13px; }
.timeline .d { color: var(--ink-2); font-size: 12.5px; overflow-wrap: anywhere; }

/* ---------- Tiến trình ---------- */
.progress { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.progress .track { width: 140px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress .track i { display: block; height: 100%; background: var(--teal); transition: width .4s; }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } .progress .track i { transition: none; } }

/* ---------- Đăng nhập ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 440px); }
.auth-art { background: var(--side); color: #C9D3E0; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art .brand { padding: 0; }
.auth-art .demo { display: flex; flex-direction: column; gap: 16px; max-width: 440px; }
.auth-art .demo .chain { color: #fff; font-size: 17px; }
.auth-art .demo .chain .dom { color: #9FB0C6; }
.auth-art .demo .tag { margin-left: 10px; font-size: 13px; }
.auth-art .demo .tag.ok { color: #5CC8A0; }
.auth-art .demo .tag.degraded { color: #E3B45C; }
.auth-art .demo .tag.broken { color: #F08A80; }
.auth-art .demo .chain.ok .wire { color: #5CC8A0; }
.auth-art .demo .chain.degraded .wire { color: #E3B45C; }
.auth-art .demo .chain.broken .wire { color: #F08A80; }
.auth-art p.lead { font-size: 15px; max-width: 420px; color: #9FB0C6; }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: 48px; background: var(--surface); }
.auth-form form { display: flex; flex-direction: column; gap: 16px; }
.auth-form h1 { margin-bottom: 4px; }
.auth-form .err { color: var(--bad); font-size: 13px; min-height: 20px; }

/* ---------- Thông báo nổi ---------- */
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
#toast div { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 500; max-width: 90vw; }
#toast div.error { background: var(--bad); }

code.k { background: var(--line-soft); padding: 1px 6px; border-radius: 4px; font-size: 12.5px; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; }
.chips { display: flex; gap: 4px 14px; flex-wrap: wrap; }

/* ---------- Màn hình nhỏ ---------- */
@media (max-width: 1100px) {
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .side { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 14px 16px; }
  .page { padding: 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-form { padding: 32px 22px; }
  .hide-sm { display: none; }
  .kv { grid-template-columns: 1fr; }
}
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 26px 0 18px; }
.panel-body.pad { padding: 18px; }
.cols .panel + .panel { margin-top: 0; }
.drawer > h2 { padding-right: 70px; }
.row input.narrow { width: 320px; flex: none; max-width: 100%; }
