:root {
  --bg: #0b0f17;
  --card: #121826;
  --card2: #0f1521;
  --line: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --up: #22c55e;
  --degraded: #f59e0b;
  --down: #ef4444;
  --disabled: #64748b;
  --pending: #475569;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.wrap { max-width: 860px; margin: 0 auto; padding: 28px 18px 60px; }

/* ---- Header ---- */
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.brand { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.brand span { letter-spacing: -.2px; }
.top-right { display: flex; align-items: center; gap: 14px; }
.updated { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.admin-link { color: var(--muted); text-decoration: none; font-size: 12px; border: 1px solid var(--line); padding: 4px 10px; border-radius: 7px; }
.admin-link:hover { color: var(--text); border-color: #334155; }

/* ---- Overall status banner ---- */
.overall {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 18px; margin-bottom: 22px;
}
.ov-icon { width: 14px; height: 14px; border-radius: 50%; background: var(--pending); flex: none; box-shadow: 0 0 0 4px rgba(255,255,255,.03); }
.ov-icon.up { background: var(--up); box-shadow: 0 0 0 4px rgba(34,197,94,.15); }
.ov-icon.degraded { background: var(--degraded); box-shadow: 0 0 0 4px rgba(245,158,11,.15); }
.ov-icon.down { background: var(--down); box-shadow: 0 0 0 4px rgba(239,68,68,.15); }
.ov-text { flex: 1; min-width: 0; }
.ov-title { font-size: 16px; font-weight: 700; }
.ov-sub { color: var(--muted); font-size: 12.5px; }
.ov-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; border: 1px solid; letter-spacing: .3px; }
.badge.up { color: var(--up); border-color: rgba(34,197,94,.4); }
.badge.degraded { color: var(--degraded); border-color: rgba(245,158,11,.4); }
.badge.down { color: var(--down); border-color: rgba(239,68,68,.4); }
.badge.disabled { color: var(--disabled); border-color: rgba(100,116,139,.4); }

/* ---- Monitor cards ---- */
.grid { display: flex; flex-direction: column; gap: 14px; }
.mon {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 18px;
}
.mon.down { border-color: rgba(239,68,68,.35); }
.mon-head { display: flex; align-items: center; gap: 11px; cursor: pointer; user-select: none; }
.chevron { color: var(--muted); font-size: 12px; flex: none; transition: transform .18s; width: 12px; }
.mon.open .chevron { transform: rotate(90deg); }
.mon-pct { font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; flex: none; }
.mon-pct.good { color: var(--up); } .mon-pct.warn { color: var(--degraded); }
.mon-pct.bad { color: var(--down); } .mon-pct.na { color: var(--muted); }
/* thu gọn mặc định: ẩn danh sách check cho tới khi mở */
.checks { display: none; }
.mon.open .checks { display: flex; flex-direction: column; }
.t-avatar {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: var(--card2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; overflow: hidden;
}
.t-avatar img { width: 100%; height: 100%; object-fit: cover; }
.mon-id { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.mon-name { font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; gap: 8px; flex: none; }
.mon-host { color: var(--muted); font-size: 12px; font-family: ui-monospace, Menlo, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.t-tag { font-size: 9.5px; font-weight: 800; padding: 1px 7px; border-radius: 999px; border: 1px solid; }
.t-tag.maint { color: #60a5fa; border-color: rgba(96,165,250,.45); }
.t-tag.ack { color: var(--degraded); border-color: rgba(245,158,11,.45); }
.pill {
  font-size: 11px; font-weight: 800; padding: 4px 11px; border-radius: 999px;
  border: 1px solid; flex: none;
}
.pill.up { color: var(--up); border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.07); }
.pill.degraded { color: var(--degraded); border-color: rgba(245,158,11,.4); background: rgba(245,158,11,.07); }
.pill.down { color: var(--down); border-color: rgba(239,68,68,.4); background: rgba(239,68,68,.07); }
.pill.disabled { color: var(--disabled); border-color: rgba(100,116,139,.4); }
.pill.pending { color: var(--muted); border-color: var(--line); }

/* ---- Per-check ---- */
.checks { margin-top: 14px; flex-direction: column; gap: 14px; }
.chk { border-top: 1px solid var(--line); padding-top: 13px; }
.chk:first-child { border-top: none; padding-top: 2px; }
.chk-top { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--pending); }
.dot.up { background: var(--up); } .dot.degraded { background: var(--degraded); }
.dot.down { background: var(--down); } .dot.disabled { background: var(--disabled); }
.badge-type {
  font-size: 9.5px; font-weight: 800; letter-spacing: .5px;
  padding: 2px 6px; border-radius: 5px; border: 1px solid var(--line);
  color: var(--muted); flex: none;
}
.badge-type[data-type="ping"] { color: #38bdf8; border-color: rgba(56,189,248,.4); }
.badge-type[data-type="tcp"] { color: #a78bfa; border-color: rgba(167,139,250,.4); }
.badge-type[data-type="http"] { color: #f472b6; border-color: rgba(244,114,182,.4); }
.badge-type[data-type="ssh"] { color: #fbbf24; border-color: rgba(251,191,36,.4); }
.badge-type[data-type="snmp"] { color: #34d399; border-color: rgba(52,211,153,.4); }
.chk-label { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-info { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 8px; }
.c-info.err { color: var(--down); }
.chk-lat { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; flex: none; }
.chk-pct { font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; flex: none; min-width: 52px; text-align: right; }
.chk-pct.good { color: var(--up); } .chk-pct.warn { color: var(--degraded); }
.chk-pct.bad { color: var(--down); } .chk-pct.na { color: var(--muted); }

/* ---- Uptime bars (UptimeRobot style) ---- */
.bar { display: flex; gap: 2px; height: 28px; align-items: stretch; }
.bar .seg { flex: 1 1 0; border-radius: 2px; background: var(--pending); transition: background .2s; min-width: 0; }
.bar .seg.up { background: var(--up); }
.bar .seg.degraded { background: var(--degraded); }
.bar .seg.down { background: var(--down); }
.bar .seg.disabled { background: var(--disabled); }
.bar .seg.none { background: #1a2233; }
.bar .seg:hover { filter: brightness(1.25); }
/* khung dài (90 ngày, 1 năm): ô vuông nhỏ, tự xuống nhiều dòng */
.bar.grid { display: grid; grid-template-columns: repeat(auto-fill, 13px); gap: 4px; height: auto; }
.bar.grid .seg { width: 13px; height: 13px; border-radius: 3px; }

/* ---- Range switch ---- */
.rangebar { display: flex; align-items: center; gap: 6px; margin: 0 2px 14px; }
.rb-label { color: var(--muted); font-size: 12px; margin-right: 4px; }
.rb-btn {
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
  font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 8px; cursor: pointer;
}
.rb-btn:hover { color: var(--text); border-color: #334155; }
.rb-btn.active { color: var(--up); border-color: rgba(34,197,94,.45); background: rgba(34,197,94,.07); }

/* ---- Search ---- */
.status-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  margin-left: auto;
  min-width: 260px;
}
.status-search-ic { color: var(--muted); font-size: 13px; }
.status-search input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
}
.status-search input::placeholder { color: #64748b; }

/* ---- Bar axis + stat ---- */
.bar-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 10.5px; margin-top: 4px; }
.chk-stat { color: var(--muted); font-size: 11.5px; margin-top: 5px; font-variant-numeric: tabular-nums; }

/* ---- Incidents ---- */
.incidents { margin-top: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.inc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.inc-title { font-weight: 700; font-size: 14px; }
.inc-all { color: var(--up); text-decoration: none; font-size: 12.5px; font-weight: 600; }
.inc-all:hover { text-decoration: underline; }
.inc-count { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.inc-list { display: flex; flex-direction: column; }
.inc-empty { color: var(--muted); font-size: 13px; padding: 6px 0; }
.inc-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.inc-row:first-child { border-top: none; }
.inc-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.inc-dot.down { background: var(--down); } .inc-dot.degraded { background: var(--degraded); }
.inc-when { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; min-width: 96px; }
.inc-tag { font-size: 9.5px; font-weight: 800; padding: 1px 7px; border-radius: 999px; border: 1px solid; flex: none; }
.inc-tag.down { color: var(--down); border-color: rgba(239,68,68,.4); }
.inc-tag.degraded { color: var(--degraded); border-color: rgba(245,158,11,.4); }
.inc-main { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inc-reason { color: var(--muted); }
.inc-dur { flex: none; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inc-dur.live { color: var(--down); font-weight: 700; }
.inc-dot.live { animation: pulse 1.3s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ---- Footer ---- */
.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 28px; }

@media (max-width: 560px) {
  .rangebar { flex-wrap: wrap; }
  .status-search { margin-left: 0; width: 100%; min-width: 0; }
  .chk-lat { display: none; }
  .mon-host { max-width: 140px; }
}
