/* ============================================================
   SiteStatus — Design Tokens & Base
   ============================================================ */

:root {
  /* Brand */
  --accent: #22c55e;
  --accent-strong: #16a34a;
  --accent-soft: rgba(34, 197, 94, 0.12);
  --accent-ring: rgba(34, 197, 94, 0.30);

  /* Status palette */
  --up: #22c55e;
  --down: #ef4444;
  --warn: #f59e0b;
  --paused: #64748b;
  --maintenance: #6366f1;

  /* Dark theme (default) */
  --bg: #07090d;
  --bg-elev: #0d1117;
  --surface: #11161f;
  --surface-2: #161c27;
  --surface-hover: #1a2230;
  --border: #1f2733;
  --border-strong: #2a3442;
  --text: #e6edf3;
  --text-dim: #9aa6b2;
  --text-faint: #6b7684;
  --text-inverse: #0b0f17;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,.35), 0 1px 2px rgba(0,0,0,.3);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.3);

  /* Type */
  --font-sans: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'Geist Mono', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Layout */
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 56px;
}

[data-theme="light"] {
  --bg: #f7f8fa;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --surface-hover: #edf0f4;
  --border: #e5e8ee;
  --border-strong: #d3d8e0;
  --text: #0b0f17;
  --text-dim: #4b5563;
  --text-faint: #8a93a0;
  --text-inverse: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow-md: 0 4px 12px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.12), 0 2px 8px rgba(15,23,42,.06);
  --accent-soft: rgba(34, 197, 94, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'tnum';
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ============================================================
   App shell
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  background: var(--bg);
}

/* ===== Sidebar ===== */
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}
.sidebar-brand .logo-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  display: grid; place-items: center;
  color: #fff;
  position: relative;
  flex-shrink: 0;
}
.sidebar-brand .logo-mark::after {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1.5px solid rgba(255,255,255,.85);
  border-radius: 50%;
  border-top-color: transparent;
  border-right-color: transparent;
  transform: rotate(-45deg);
}
.sidebar-brand .logo-text {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.sidebar-brand .logo-text .badge {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 6px;
  font-weight: 600;
  vertical-align: middle;
}

.nav-group {
  padding: 10px 10px;
}
.nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 8px 10px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  user-select: none;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.nav-item .icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-faint); }
.nav-item.active .icon { color: var(--accent); }
.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  background: var(--surface-2);
  color: var(--text-dim);
  padding: 1px 6px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.nav-item .pulse {
  margin-left: auto;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--down);
  box-shadow: 0 0 0 0 var(--down);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,.55); }
  70%  { box-shadow: 0 0 0 7px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .plan { font-size: 11px; color: var(--text-faint); }

/* ===== Main column ===== */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0; /* prevent overflow */
}

.topbar {
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg-elev) 80%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .hamburger { display: none; background: none; border: 0; color: var(--text); padding: 6px; border-radius: 6px; }
.topbar .hamburger:hover { background: var(--surface-hover); }
.topbar .crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.topbar .crumbs .sep { color: var(--text-faint); }
.topbar .crumbs .current { color: var(--text); font-weight: 500; }
.topbar .spacer { flex: 1; }
.topbar .search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-dim);
  min-width: 240px;
}
.topbar .search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.topbar .search input {
  border: 0; outline: 0; background: transparent; color: var(--text);
  flex: 1; font-size: 13px;
}
.topbar .search kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text-faint);
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  position: relative;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--down);
  border: 1.5px solid var(--bg-elev);
}

.content {
  padding: 24px 28px 40px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

/* ===== Page header ===== */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-header h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.page-header .sub {
  color: var(--text-dim);
  font-size: 13px;
}
.page-header .actions { display: flex; gap: 8px; align-items: center; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
}
.btn:hover { background: var(--surface-hover); }
.btn.primary {
  background: var(--accent);
  color: #062b13;
  border-color: var(--accent-strong);
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-strong); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-hover); }
.btn .icon { width: 14px; height: 14px; }

/* ===== Summary cards ===== */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.stat-card .label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.stat-card .label .icon-badge {
  width: 22px; height: 22px;
  border-radius: 6px;
  display: grid; place-items: center;
  background: var(--surface-2);
  color: var(--text-dim);
}
.stat-card.up .icon-badge { background: var(--accent-soft); color: var(--up); }
.stat-card.down .icon-badge { background: rgba(239,68,68,.12); color: var(--down); }
.stat-card.warn .icon-badge { background: rgba(245,158,11,.12); color: var(--warn); }
.stat-card.neutral .icon-badge { background: rgba(99,102,241,.12); color: #818cf8; }

.stat-card .value {
  font-size: 28px;
  font-weight: 600;
  font-feature-settings: 'tnum';
  letter-spacing: -0.02em;
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.stat-card .value .unit { font-size: 14px; color: var(--text-faint); font-weight: 500; }
.stat-card .delta {
  font-size: 11px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-faint);
}
.stat-card .delta.pos { color: var(--up); }
.stat-card .delta.neg { color: var(--down); }
.stat-card .spark {
  position: absolute;
  right: 12px; top: 12px;
  width: 80px; height: 36px;
  opacity: 0.85;
}

/* ===== Status pill ===== */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: capitalize;
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.pill.up { background: var(--accent-soft); color: var(--up); border-color: rgba(34,197,94,.22); }
.pill.up .dot { background: var(--up); box-shadow: 0 0 0 2px rgba(34,197,94,.25); }
.pill.down { background: rgba(239,68,68,.10); color: var(--down); border-color: rgba(239,68,68,.25); }
.pill.down .dot { background: var(--down); animation: pulse-red 1.4s infinite; }
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); }
  50% { box-shadow: 0 0 0 4px rgba(239,68,68,0); }
}
.pill.paused { background: rgba(100,116,139,.12); color: var(--paused); border-color: rgba(100,116,139,.25); }
.pill.paused .dot { background: var(--paused); }
.pill.warn { background: rgba(245,158,11,.10); color: var(--warn); border-color: rgba(245,158,11,.25); }
.pill.warn .dot { background: var(--warn); }
.pill.maint { background: rgba(99,102,241,.10); color: #818cf8; border-color: rgba(99,102,241,.25); }
.pill.maint .dot { background: var(--maintenance); }

/* ===== Sites table ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.panel-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.panel-header .count-tag {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.panel-header .spacer { flex: 1; }

.filter-chips { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: var(--r-sm); }
.filter-chips button {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: 500;
}
.filter-chips button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.filter-chips button .num { color: var(--text-faint); margin-left: 4px; font-variant-numeric: tabular-nums; font-size: 11px; }
.filter-chips button.active .num { color: var(--accent); }

.sites-table {
  width: 100%;
  border-collapse: collapse;
}
.sites-table th, .sites-table td {
  text-align: left;
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.sites-table thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 8px 14px;
  background: var(--surface-2);
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--border);
}
.sites-table tbody tr { transition: background .15s; }
.sites-table tbody tr:hover { background: var(--surface-hover); }
.sites-table tbody tr:last-child td { border-bottom: 0; }
.sites-table tbody tr.selected { background: var(--accent-soft); }

.checkbox {
  appearance: none;
  width: 14px; height: 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: all .15s;
  flex-shrink: 0;
}
.checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox:checked::after {
  content: '';
  position: absolute;
  left: 3px; top: 0px;
  width: 4px; height: 8px;
  border: solid #062b13;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.site-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.site-favicon {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.site-cell .meta { min-width: 0; }
.site-cell .name { font-weight: 600; color: var(--text); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.site-cell .url { color: var(--text-faint); font-size: 11.5px; font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

/* Uptime bars (mini sparkbars) */
.uptime-bars {
  display: flex;
  gap: 1.5px;
  align-items: end;
  height: 22px;
}
.uptime-bars .bar {
  width: 3px;
  border-radius: 1px;
  background: var(--up);
  flex-shrink: 0;
}
.uptime-bars .bar.down { background: var(--down); }
.uptime-bars .bar.warn { background: var(--warn); }
.uptime-bars .bar.paused { background: var(--border-strong); }

.tnum { font-variant-numeric: tabular-nums; }

.flag {
  width: 16px; height: 12px;
  border-radius: 2px;
  background: var(--surface-2);
  display: inline-block;
  position: relative;
  overflow: hidden;
  vertical-align: middle;
  border: 1px solid var(--border);
}

.location-stack { display: flex; align-items: center; gap: -4px; }
.location-stack .flag + .flag { margin-left: -4px; box-shadow: -1px 0 0 var(--surface); }
.location-stack .more {
  font-size: 10px;
  color: var(--text-dim);
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

.row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.sites-table tbody tr:hover .row-actions { opacity: 1; }
.row-actions button {
  width: 24px; height: 24px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  border-radius: 4px;
  display: grid; place-items: center;
}
.row-actions button:hover { background: var(--surface-2); color: var(--text); }

/* ===== Right column ===== */
.split {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  margin-top: 16px;
}

.side-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
}
.side-panel h4 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.side-panel h4 .count-tag {
  font-size: 10px;
  background: var(--surface-2);
  color: var(--text-dim);
  padding: 1px 6px;
  border-radius: 999px;
}

.incident-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
}
.incident-item:last-child { border-bottom: 0; padding-bottom: 0; }
.incident-item:first-child { padding-top: 0; }
.incident-item .indicator {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--down);
  margin-top: 6px;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(239,68,68,.15);
}
.incident-item.resolved .indicator { background: var(--up); box-shadow: 0 0 0 3px var(--accent-soft); }
.incident-item .body { flex: 1; min-width: 0; }
.incident-item .site { font-size: 12.5px; font-weight: 600; }
.incident-item .desc { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.incident-item .time { font-size: 10.5px; color: var(--text-faint); margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.incident-item .time .duration {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* ===== Floating action bar (bulk) ===== */
.bulk-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: 8px 8px 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  animation: slide-up .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes slide-up {
  from { transform: translate(-50%, 30px); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}
.bulk-bar .count {
  font-size: 13px;
  font-weight: 600;
}
.bulk-bar .count span { color: var(--accent); }
.bulk-bar .divider { width: 1px; height: 18px; background: var(--border); }
.bulk-bar .btn { height: 30px; padding: 0 10px; font-size: 12px; }

/* ===== Mobile ===== */
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 25;
  backdrop-filter: blur(2px);
}

@media (max-width: 1100px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
  }
  .app.menu-open .sidebar { transform: translateX(0); }
  .app.menu-open .scrim { display: block; }
  .topbar .hamburger { display: grid; place-items: center; }
  .topbar .search { display: none; }
  .topbar { padding: 0 14px; }
  .content { padding: 16px 14px 80px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-card .value { font-size: 22px; }
  .stat-card .spark { width: 50px; height: 26px; }
  .panel-header { padding: 12px 14px; gap: 8px; }
  .filter-chips { width: 100%; overflow-x: auto; }

  /* Card list on mobile instead of table */
  .sites-table thead { display: none; }
  .sites-table, .sites-table tbody, .sites-table tr, .sites-table td { display: block; width: 100%; }
  .sites-table tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px 12px;
    align-items: center;
  }
  .sites-table td { padding: 0; border: 0; font-size: 12.5px; }
  .sites-table td.col-check { grid-row: 1 / span 2; }
  .sites-table td.col-site { grid-column: 2; }
  .sites-table td.col-status { grid-column: 3; justify-self: end; }
  .sites-table td.col-bars { grid-column: 2 / span 2; }
  .sites-table td.col-uptime,
  .sites-table td.col-response,
  .sites-table td.col-location,
  .sites-table td.col-actions { display: none; }
  .site-cell .url { max-width: 200px; }
}

@media (max-width: 480px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-header h1 { font-size: 18px; }
  .stat-card .spark { display: none; }
}
