/* Design tokens mirror apps/ops-web/src/styles/tokens.css. The console ships
   no JS (CSP blocks scripts), so the theme follows prefers-color-scheme
   instead of the ops-web data-theme toggle. Dark is the default. */
:root {
  color-scheme: dark;
  --bg: #08101d;
  --surface: #0e1828;
  --surface-2: #132036;
  --sidebar: #0a1423;
  --border: #223551;
  --border-strong: #314766;
  --text: #f1f5fb;
  --text-dim: #a7b5c9;
  --text-faint: #7687a1;
  --primary: #5c8df6;
  --primary-hover: #72a0ff;
  --primary-soft: rgba(92, 141, 246, .14);
  --green: #36d17f;
  --red: #ff6b78;
  --green-text: #4ade80;
  --red-text: #f87171;
  --accent-text: #8db2ff;
  --nav-active-text: #e7efff;
  --row-hover: rgba(255, 255, 255, .02);
  --selection-bg: rgba(92, 141, 246, .42);
  --topbar-bg: rgba(14, 24, 40, .96);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, .5);
  --radius-sm: 9px;
  --radius: 12px;
  --control-h: 40px;
  --sidebar-w: 232px;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f2f4f7;
    --sidebar: #ffffff;
    --border: #e3e7ed;
    --border-strong: #cbd2dc;
    --text: #0f1729;
    --text-dim: #566179;
    --text-faint: #8792a6;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, .10);
    --green: #15803d;
    --red: #dc2626;
    --green-text: #15803d;
    --red-text: #b91c1c;
    --accent-text: #1d4ed8;
    --nav-active-text: #1d4ed8;
    --row-hover: rgba(15, 23, 41, .03);
    --selection-bg: rgba(37, 99, 235, .22);
    --topbar-bg: rgba(255, 255, 255, .96);
    --shadow-lg: 0 18px 48px rgba(16, 24, 40, .16);
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font: 14px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { color: var(--text); background: var(--selection-bg); }
button, input { font: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* App shell: sidebar + topbar + content */
.app { 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;
  padding: 12px 10px 10px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 7px 8px 14px; }
.brand-mark {
  width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto;
  color: var(--accent-text);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  border-radius: 10px;
  background: var(--primary-soft);
  font-size: 16px; font-weight: 850;
}
.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-logo { color: var(--text); font-size: 16px; font-weight: 820; letter-spacing: .01em; }
.brand-copy small {
  margin-top: 2px; color: var(--text-faint);
  font-size: 9px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase;
}
.nav-group-title {
  padding: 6px 10px; color: var(--text-faint);
  font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--text-dim); font-size: 13.5px; font-weight: 500;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar-spacer { flex: 1; }
.sidebar-user { padding: 10px; border-top: 1px solid var(--border); }
.sidebar-user .who { display: block; margin-bottom: 8px; color: var(--text-dim); font-size: 12px; overflow-wrap: anywhere; }
.sidebar-user form { margin: 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  min-height: 64px; padding: 10px 20px;
  display: flex; align-items: center; gap: 16px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 16px; font-weight: 700; }
.content { padding: 24px; max-width: 1680px; width: 100%; }

/* Page header */
.page-header { margin-bottom: 20px; }
.page-eyebrow {
  display: block; margin-bottom: 5px; color: var(--primary);
  font-size: 11px; font-weight: 750; letter-spacing: .11em; text-transform: uppercase;
}
.page-header h2 { margin: 0; font-size: 24px; font-weight: 760; letter-spacing: -.035em; line-height: 1.15; }
.page-header p { max-width: 720px; margin: 7px 0 0; color: var(--text-dim); font-size: 13px; line-height: 1.5; }
h2.section { margin: 26px 0 10px; font-size: 15px; font-weight: 600; }

/* Panels and tables */
.panel {
  margin-bottom: 20px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.panel > p { margin: 0; padding: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  height: 38px; padding: 9px 12px; text-align: left; white-space: nowrap;
  color: var(--text-faint); background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 10px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase;
}
td { height: 46px; padding: 9px 12px; white-space: nowrap; border-bottom: 1px solid var(--border); font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--row-hover); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Status text and badges */
.muted { color: var(--text-faint); }
.up, .down {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.up { color: var(--green-text); background: color-mix(in srgb, var(--green) 13%, transparent); }
.down { color: var(--red-text); background: color-mix(in srgb, var(--red) 13%, transparent); }
td.up, td.down { display: table-cell; padding: 9px 12px; background: none; border-radius: 0; font-size: 12px; font-weight: 600; }
p.down { display: block; padding: 14px; border-radius: 0; background: none; font-size: 13px; }
.error { color: var(--red-text); font-size: 12.5px; margin: 0 0 15px; }

/* Buttons and inputs */
button {
  min-height: var(--control-h); padding: 0 14px;
  color: #fff; background: var(--primary);
  border: 0; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
button:hover { background: var(--primary-hover); }
.sidebar-user button {
  width: 100%; min-height: 34px;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
}
.sidebar-user button:hover { background: var(--border); }
input {
  width: 100%; min-height: var(--control-h); padding: 8px 10px;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px;
}
input:focus { border-color: var(--primary); outline: none; }

/* Login */
.login-wrap {
  min-height: 100vh; padding: 24px; display: grid; place-items: center;
  background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--primary) 18%, transparent), transparent 40%),
    var(--bg);
}
.login {
  width: min(400px, 100%); padding: 30px;
  background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 18px;
  box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; }
.login-brand .brand-mark { width: 42px; height: 42px; border-radius: 13px; font-size: 21px; font-weight: 900; }
.login h1 { margin: 0; font-size: 22px; letter-spacing: -.04em; line-height: 1; }
.login-brand small { display: block; margin-top: 5px; color: var(--text-faint); font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.login label { display: block; margin-bottom: 15px; color: var(--text-dim); font-size: 11px; font-weight: 650; }
.login label input { display: block; margin-top: 6px; min-height: 47px; font-size: 16px; }
.login button { width: 100%; min-height: 47px; margin-top: 3px; }

@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { min-height: 0; padding: 4px 8px; }
  .nav-group-title, .sidebar-spacer { display: none; }
  .sidebar-user { margin-left: auto; padding: 0; border: 0; display: flex; align-items: center; gap: 8px; }
  .sidebar-user .who { margin: 0; }
  .sidebar-user button { width: auto; }
  .content { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Administration pages */
.notice { color: var(--green-text); font-size: 12.5px; margin: 0 0 15px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 14px; }
.inline-form label { color: var(--text-dim); font-size: 11px; font-weight: 650; }
.inline-form label input { display: block; margin-top: 6px; width: 240px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; height: auto; }
.row-actions form { display: flex; gap: 6px; align-items: center; margin: 0; }
.row-actions input[name="password"] { width: 250px; }
.row-actions .confirm { display: flex; align-items: center; gap: 4px; color: var(--text-dim); font-size: 12px; }
.row-actions .confirm input { width: auto; min-height: 0; }
button.danger { background: var(--red); }
.filter { display: flex; gap: 8px; margin-bottom: 14px; max-width: 420px; }
.pager { display: flex; gap: 16px; margin: 14px 0 0; font-size: 13px; }
td.ua { max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.secret { padding: 14px; }
.secret p { margin: 0 0 14px; }
.secret code { font-size: 14px; overflow-wrap: anywhere; user-select: all; }
.secret svg { display: block; margin-top: 6px; border-radius: 6px; }
