/* Incoming Control Center — light/dark theme, vanilla CSS. */

:root,
:root[data-theme="light"] {
  color-scheme: light;
  --page:        #f9f9f7;
  --surface:     #fcfcfb;
  --surface-2:   #f0efec;
  --ink:         #0b0b0b;
  --ink-2:       #52514e;
  --muted:       #898781;
  --grid:        #e1e0d9;
  --baseline:    #c3c2b7;
  --border:      rgba(11,11,11,0.10);
  --accent:      #2a78d6;
  --accent-ink:  #ffffff;
  --series-1:    #2a78d6;
  --series-2:    #eb6834;
  --series-3:    #1baf7a;
  --seq-250:     #86b6ef;
  --seq-400:     #3987e5;
  --seq-550:     #1c5cab;
  --good:        #0ca30c;
  --good-text:   #006300;
  --warning:     #fab219;
  --serious:     #ec835a;
  --critical:    #d03b3b;
  --shadow:      0 10px 30px rgba(11,11,11,0.08);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page:        #0d0d0d;
  --surface:     #1a1a19;
  --surface-2:   #232322;
  --ink:         #ffffff;
  --ink-2:       #c3c2b7;
  --muted:       #898781;
  --grid:        #2c2c2a;
  --baseline:    #383835;
  --border:      rgba(255,255,255,0.10);
  --accent:      #3987e5;
  --accent-ink:  #ffffff;
  --series-1:    #3987e5;
  --series-2:    #d95926;
  --series-3:    #199e70;
  --seq-250:     #86b6ef;
  --seq-400:     #3987e5;
  --seq-550:     #1c5cab;
  --good:        #0ca30c;
  --good-text:   #0ca30c;
  --warning:     #fab219;
  --serious:     #ec835a;
  --critical:    #d03b3b;
  --shadow:      0 10px 30px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ── Layout ─────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 14px;
  font-weight: 700; font-size: 15px;
}
.logo-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.nav-section {
  font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); padding: 14px 8px 4px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 1px 0;
  border-radius: 8px; color: var(--ink-2);
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav-link.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 600; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px; }
.whoami { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-2); color: var(--ink);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.whoami-name { font-weight: 600; font-size: 13px; }
.whoami-role { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.sidebar-actions { display: flex; gap: 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--page) 80%, var(--surface));
  position: sticky; top: 0; z-index: 5; backdrop-filter: blur(6px);
}
.page-title { font-size: 17px; }
.topbar-right { margin-left: auto; }
.menu-btn { display: none; }
.content { padding: 20px 24px 60px; }

/* Theme toggle icons */
:root[data-theme="dark"] .theme-icon-dark { display: none; }
:root[data-theme="light"] .theme-icon-light { display: none; }

/* ── Cards & grids ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 13px; font-weight: 650; color: var(--ink-2); margin-bottom: 10px; }
.grid { display: grid; gap: 14px; }
.kpi-row { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.two-col { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

.stat-tile .stat-label { font-size: 12px; color: var(--muted); }
.stat-tile .stat-value { font-size: 26px; font-weight: 700; margin-top: 2px; }
.stat-tile .stat-sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.stat-tile .delta-good { color: var(--good-text); font-weight: 600; }
.stat-tile .delta-bad  { color: var(--critical); font-weight: 600; }

/* ── Tables ─────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th {
  text-align: left; font-size: 11px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
  padding: 8px 10px; border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--ink); }
table.data td {
  padding: 9px 10px; border-bottom: 1px solid var(--grid);
  vertical-align: top;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.clickable { cursor: pointer; }
table.data .num { text-align: right; }
.empty-state { text-align: center; color: var(--muted); padding: 32px 0; }

/* Status pills */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--ink-2);
  white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill-good     { color: var(--good-text); }    .pill-good::before     { background: var(--good); }
.pill-warning  { color: var(--ink); }          .pill-warning::before  { background: var(--warning); }
.pill-serious  { color: var(--ink); }          .pill-serious::before  { background: var(--serious); }
.pill-critical { color: var(--critical); }     .pill-critical::before { background: var(--critical); }
.pill-info     { color: var(--accent); }       .pill-info::before     { background: var(--accent); }

/* ── Controls ───────────────────────────────────────────────────────── */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 12px;
}
.toolbar .spacer { flex: 1; }
input[type=text], input[type=search], input[type=password], input[type=number],
input[type=date], select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 0;
}
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 13px;
  font: inherit; font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 85%, black); }
.btn-danger { color: var(--critical); }
.btn-danger:hover { background: color-mix(in srgb, var(--critical) 12%, transparent); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Pagination */
.pager {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; font-size: 13px; color: var(--ink-2);
}
.pager .spacer { flex: 1; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--grid); margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  padding: 8px 14px; cursor: pointer; border: 0; background: none;
  font: inherit; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Charts ─────────────────────────────────────────────────────────── */
.chart { position: relative; }
.chart svg { display: block; width: 100%; }
.chart-legend {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 12px; color: var(--ink-2); margin-bottom: 6px;
}
.chart-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
.chart-tip {
  position: absolute; pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow);
  padding: 8px 10px; font-size: 12px;
  z-index: 10; min-width: 120px;
  display: none;
}
.chart-tip .tip-title { font-weight: 700; margin-bottom: 3px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.chart-tip .tip-row .swatch { width: 8px; height: 8px; border-radius: 2px; }
.chart-tip .tip-val { font-weight: 600; font-variant-numeric: tabular-nums; margin-left: 10px; }

/* ── Modal / drawer / toasts ────────────────────────────────────────── */
.modal-backdrop, .drawer-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.45);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 60px);
  margin: 40px auto; display: flex; flex-direction: column;
}
.modal-head, .drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--grid);
}
.modal-head h2, .drawer-head h2 { font-size: 15px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.drawer {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(720px, 94vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.drawer-body { padding: 18px; overflow-y: auto; }
.detail-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px 18px; margin-bottom: 8px;
}
.detail-grid .dt { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.detail-grid .dd { font-size: 13px; word-break: break-word; }
.section-h {
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin: 20px 0 8px;
  border-bottom: 1px solid var(--grid); padding-bottom: 5px;
}
pre.json {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow-y: auto;
}

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 10px; box-shadow: var(--shadow);
  padding: 10px 14px; min-width: 220px; max-width: 360px;
  animation: toast-in .18s ease-out;
}
.toast-error { border-left-color: var(--critical); }
.toast-good  { border-left-color: var(--good); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.alert { border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; font-size: 13px; }
.alert-error {
  background: color-mix(in srgb, var(--critical) 12%, transparent);
  color: var(--critical);
  border: 1px solid color-mix(in srgb, var(--critical) 35%, transparent);
}
.reveal-box {
  background: var(--surface-2); border: 1px dashed var(--baseline);
  border-radius: 8px; padding: 10px 12px; margin: 8px 0;
}

/* ── Login ──────────────────────────────────────────────────────────── */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--page);
}
.login-card {
  width: min(380px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
  padding: 30px 28px;
}
.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand h1 { font-size: 18px; margin-top: 10px; }
.login-brand .logo-dot { display: inline-block; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 40;
    transform: translateX(-100%); transition: transform .18s ease-out;
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .content { padding: 14px; }
}
