:root {
  color-scheme: dark;
  --background: #0f172a;
  --surface: #121d32;
  --surface-raised: #17233a;
  --surface-soft: #10192e;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f8fafc;
  --text-muted: #aebbd0;
  --primary: #2f6da7;
  --primary-hover: #3e7eb9;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.11);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.11);
  --ring: #60a5fa;
  --radius: 14px;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
  font-family: Tahoma, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--background); }
body { margin: 0; min-height: 100vh; color: var(--text); background:
  radial-gradient(circle at 15% -5%, rgba(47, 109, 167, 0.23), transparent 28rem),
  var(--background); }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
button:disabled { cursor: wait; opacity: 0.55; }
[hidden] { display: none !important; }

.skip-link { position: fixed; z-index: 100; top: 8px; right: 8px; padding: 10px 14px; color: #08111f; background: #fff; border-radius: 8px; transform: translateY(-150%); }
.skip-link:focus { transform: none; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(100%, 430px); padding: 36px; border: 1px solid var(--border); border-radius: 22px; background: rgba(18, 29, 50, 0.88); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.brand-mark { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 24px; color: #fff; background: linear-gradient(145deg, #316faa, #1d4d7d); border: 1px solid rgba(255,255,255,.15); border-radius: 16px; box-shadow: 0 10px 28px rgba(47,109,167,.3); }
.brand-mark svg { width: 30px; fill: currentColor; }
.brand-mark.small { width: 42px; height: 42px; margin: 0; border-radius: 12px; }
.brand-mark.small svg { width: 24px; }
.eyebrow { margin: 0 0 8px; color: #7fb6e6; font: 700 12px/1.4 Consolas, monospace; letter-spacing: .1em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(24px, 4vw, 34px); line-height: 1.35; }
h2 { margin-bottom: 5px; font-size: 18px; }
.muted { color: var(--text-muted); line-height: 1.7; }
label { display: block; margin: 20px 0 8px; color: #dce6f4; font-size: 14px; font-weight: 600; }
input { width: 100%; min-height: 48px; padding: 10px 13px; color: var(--text); background: #0c1527; border: 1px solid var(--border-strong); border-radius: 10px; }
input:hover { border-color: rgba(255,255,255,.28); }
.form-error { min-height: 24px; margin: 12px 0 0; color: #fda4af; font-size: 13px; }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; color: var(--text); border: 1px solid transparent; border-radius: 10px; transition: background-color 180ms ease, border-color 180ms ease, opacity 180ms ease; }
.button svg { width: 20px; fill: currentColor; }
.button.primary { background: var(--primary); }
.button.primary:hover { background: var(--primary-hover); }
.button.secondary { background: #273750; border-color: var(--border-strong); }
.button.secondary:hover, .button.ghost:hover { background: rgba(255,255,255,.08); }
.button.ghost { background: transparent; border-color: var(--border); }
.button.danger { color: #fecaca; background: var(--danger-soft); border-color: rgba(248,113,113,.32); }
.button.danger:hover { background: rgba(248,113,113,.18); }
.button.full { width: 100%; margin-top: 26px; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; color: var(--text-muted); background: transparent; border: 1px solid var(--border); border-radius: 10px; transition: background-color 180ms ease, color 180ms ease; }
.icon-button:hover { color: var(--text); background: rgba(255,255,255,.07); }
.icon-button svg { width: 21px; fill: currentColor; }
.spinner { display: none; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; }
button.loading .spinner { display: block; }

.topbar { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px clamp(16px, 4vw, 48px); background: rgba(15, 23, 42, .86); border-bottom: 1px solid var(--border); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 20; }
.brand-inline, .topbar-actions, .page-heading, .panel-heading, .request-top, .request-actions, .dialog-heading, .dialog-actions { display: flex; align-items: center; }
.brand-inline { gap: 12px; }
.brand-inline div { display: grid; gap: 2px; }
.brand-inline strong { font-size: 16px; }
.brand-inline div span { color: var(--text-muted); font-size: 12px; }
.topbar-actions { gap: 10px; }
.content { width: min(1440px, 100%); margin: 0 auto; padding: 32px clamp(16px, 4vw, 48px) 64px; }
.page-heading { justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading p:last-child { margin-bottom: 0; }
.status-pill { min-height: 32px; display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; font-size: 12px; font-weight: 700; border: 1px solid var(--border); border-radius: 999px; }
.status-pill::before { content: ""; width: 7px; height: 7px; background: currentColor; border-radius: 50%; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 15%, transparent); }
.status-pill.success { color: #86efac; background: var(--accent-soft); border-color: rgba(34,197,94,.25); }
.status-pill.warning { color: #fde68a; background: var(--warning-soft); border-color: rgba(251,191,36,.25); }
.status-pill.neutral { color: var(--text-muted); }
.banner { margin-bottom: 20px; padding: 13px 16px; line-height: 1.6; border: 1px solid; border-radius: 10px; }
.banner.warning { color: #fde68a; background: var(--warning-soft); border-color: rgba(251,191,36,.25); }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.metric-card, .panel { background: linear-gradient(180deg, rgba(23,35,58,.95), rgba(18,29,50,.95)); border: 1px solid var(--border); border-radius: var(--radius); }
.metric-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 16px; padding: 18px 20px; }
.metric-card strong { grid-row: 1 / span 2; grid-column: 2; font: 700 30px/1 Consolas, monospace; }
.metric-label { font-weight: 700; }
.metric-hint { color: var(--text-muted); font-size: 12px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .75fr); gap: 18px; align-items: start; }
.panel { overflow: hidden; }
.panel-heading { justify-content: space-between; gap: 16px; padding: 19px 20px; border-bottom: 1px solid var(--border); }
.panel-heading p { margin: 0; color: var(--text-muted); font-size: 12px; line-height: 1.6; }
.timestamp { color: var(--text-muted); font-size: 11px; }
.request-list, .compact-list { padding: 8px; }
.request-item { padding: 16px; border: 1px solid transparent; border-radius: 10px; }
.request-item + .request-item { border-top-color: var(--border); border-top-left-radius: 0; border-top-right-radius: 0; }
.request-top { justify-content: space-between; align-items: flex-start; gap: 12px; }
.request-title { margin: 0 0 5px; font-size: 15px; }
.request-meta { color: var(--text-muted); font-size: 12px; }
.request-description { margin: 14px 0; padding: 12px 14px; color: #dbe6f5; background: rgba(6,12,24,.3); border-right: 3px solid #3b82f6; border-radius: 8px; line-height: 1.7; }
.request-actions { justify-content: flex-end; gap: 8px; }
.request-actions .button { min-height: 40px; }
.side-stack { display: grid; gap: 18px; }
.compact-item { display: grid; gap: 8px; padding: 13px 12px; border-radius: 8px; }
.compact-item + .compact-item { border-top: 1px solid var(--border); border-radius: 0; }
.compact-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.compact-title { font-size: 14px; font-weight: 700; }
.compact-meta { color: var(--text-muted); font: 12px/1.6 Consolas, Tahoma, monospace; overflow-wrap: anywhere; }
.dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: #64748b; }
.dot.online { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.empty-state { padding: 32px 18px; text-align: center; color: var(--text-muted); line-height: 1.8; }

dialog { width: min(92vw, 520px); color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(2, 6, 15, .7); backdrop-filter: blur(4px); }
.dialog-card { padding: 10px; }
.dialog-heading { justify-content: space-between; gap: 20px; }
.dialog-card > p { color: var(--text-muted); line-height: 1.7; }
.optional { color: var(--text-muted); font-size: 12px; font-weight: 400; }
.field-help { margin: 7px 0 0; color: var(--text-muted); font-size: 12px; line-height: 1.65; }
.pair-code { padding: 20px; color: #bbf7d0; background: #091523; border: 1px dashed rgba(34,197,94,.35); border-radius: 12px; text-align: center; font: 700 clamp(22px, 7vw, 32px)/1.2 Consolas, monospace; letter-spacing: .08em; }
.dialog-actions { justify-content: flex-start; gap: 8px; margin-top: 22px; }
.toast { position: fixed; z-index: 100; bottom: 24px; left: 24px; max-width: min(380px, calc(100vw - 32px)); padding: 12px 16px; color: #e2e8f0; background: #1e293b; border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; }
.toast.show { opacity: 1; transform: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .auth-card { padding: 26px 20px; }
  .topbar { align-items: flex-start; }
  .brand-inline div span, #system-health { display: none; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .metrics { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: 1fr; }
  .request-top { flex-direction: column; }
  .request-actions { align-items: stretch; flex-direction: column; }
  .request-actions .button { width: 100%; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .toast { right: 16px; bottom: 16px; left: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
