:root {
  color-scheme: dark;
  --bg: #111318;
  --surface: #191c23;
  --surface-raised: #20242d;
  --border: #343a48;
  --text: #f3f5f8;
  --muted: #abb3c3;
  --primary: #96b9ff;
  --primary-ink: #091327;
  --danger: #ff9e9e;
  --danger-ink: #2a0a0b;
  --warning: #ffd58a;
  --success: #8be0ba;
  --focus: #ffffff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(92, 118, 180, 0.18), transparent 34rem),
    var(--bg);
}

button, input { font: inherit; }

button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.52; }

button:focus-visible, input:focus-visible, dialog:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.operator-shell { width: min(1240px, 100%); margin: 0 auto; padding: 36px 24px 72px; }
.app-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.eyebrow { margin: 0 0 10px; color: var(--primary); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.14em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.8rem, 3vw, 2.8rem); line-height: 1.05; letter-spacing: -0.035em; }
h2 { margin-bottom: 8px; font-size: 1.2rem; }
h3 { margin: 0; font-size: 1rem; }
.subtitle, .muted { color: var(--muted); }
.subtitle { margin-bottom: 0; }
.header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.mode-pill, .state-pill, .fixture-badge, .count-label, .expiry { display: inline-flex; align-items: center; border-radius: 999px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em; }
.mode-pill { padding: 8px 12px; }
.mode-fixture { color: #171109; background: var(--warning); }
.mode-live { color: #071a12; background: var(--success); }
.button { min-height: 42px; border: 1px solid transparent; border-radius: 10px; padding: 9px 14px; color: var(--text); font-weight: 750; transition: transform 120ms ease, background 120ms ease, border-color 120ms ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button-primary { background: var(--primary); color: var(--primary-ink); }
.button-secondary { background: var(--surface-raised); border-color: var(--border); }
.button-danger { background: var(--danger); color: var(--danger-ink); }
.fixture-banner, .security-banner, .notice { border: 1px solid var(--border); border-radius: 14px; padding: 15px 17px; line-height: 1.5; }
.fixture-banner { margin-bottom: 26px; color: #ffe8bb; background: rgba(117, 83, 18, 0.24); border-color: rgba(255, 213, 138, 0.42); }
.security-banner { margin-bottom: 26px; color: #c6d8ff; background: rgba(52, 83, 150, 0.24); border-color: rgba(150, 185, 255, 0.42); }
.notice { display: grid; gap: 4px; margin: 0 0 18px; }
.notice-info { background: rgba(92, 119, 178, 0.18); }
.notice-success { color: #c7f8df; background: rgba(37, 119, 79, 0.2); border-color: rgba(139, 224, 186, 0.42); }
.notice-warning { color: #ffe4ad; background: rgba(133, 93, 14, 0.22); border-color: rgba(255, 213, 138, 0.42); }
.notice-error { color: #ffcaca; background: rgba(135, 35, 39, 0.22); border-color: rgba(255, 158, 158, 0.42); }
.notice-title { font-weight: 800; }
.notice-detail { color: inherit; opacity: 0.92; }
.notice-code { width: fit-content; padding: 2px 6px; border-radius: 5px; color: inherit; background: rgba(0, 0, 0, 0.22); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading p { margin-bottom: 0; }
.count-label { padding: 6px 10px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); }
.connection-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.connection-card { display: flex; min-height: 300px; flex-direction: column; gap: 13px; padding: 20px; background: rgba(25, 28, 35, 0.92); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16); }
.connection-card.state-ready { border-color: rgba(139, 224, 186, 0.36); }
.connection-card.state-reconnect, .connection-card.state-reauth { border-color: rgba(255, 213, 138, 0.46); }
.connection-card.state-revoked { opacity: 0.78; }
.card-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.platform { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.7rem; font-weight: 850; letter-spacing: 0.12em; }
.card-topline h2 { margin-bottom: 0; line-height: 1.2; }
.state-pill { flex: 0 0 auto; padding: 7px 10px; color: #dce5f7; background: rgba(104, 122, 158, 0.25); }
.state-ready .state-pill { color: #b8f2d5; background: rgba(52, 143, 99, 0.28); }
.state-reauth .state-pill, .state-reconnect .state-pill, .state-auth-qr .state-pill, .state-auth-code .state-pill, .state-auth-2fa .state-pill { color: #ffe2a4; background: rgba(151, 106, 27, 0.28); }
.state-revoked .state-pill { color: #ffc4c4; background: rgba(142, 50, 54, 0.3); }
.account-label, .state-detail { margin-bottom: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.fixture-badge { width: fit-content; padding: 5px 8px; color: #241a08; background: var(--warning); font-size: 0.65rem; }
.inline-error { display: grid; gap: 3px; padding: 10px 12px; border-left: 3px solid var(--danger); color: #ffcaca; background: rgba(135, 35, 39, 0.18); font-size: 0.86rem; line-height: 1.4; }
.challenge { display: grid; gap: 12px; margin-top: 4px; padding: 14px; border: 1px solid rgba(150, 185, 255, 0.32); border-radius: 13px; background: rgba(36, 45, 67, 0.34); }
.challenge-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.expiry { padding: 5px 8px; color: #cce0ff; background: rgba(71, 106, 176, 0.34); white-space: nowrap; }
.expiry-expired { color: #ffcaca; background: rgba(142, 50, 54, 0.34); }
.qr-placeholder { display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: repeat(7, 1fr); width: min(180px, 100%); aspect-ratio: 1; gap: 3px; padding: 10px; margin: 0 auto; background: #f3f5f8; border-radius: 8px; }
.qr-cell { display: block; background: #f3f5f8; }
.qr-cell-dark { background: #111318; }
.qr-image { display: block; width: min(220px, 100%); aspect-ratio: 1; margin: 0 auto; object-fit: contain; background: #fff; border-radius: 8px; }
.auth-form { display: grid; gap: 9px; }
.auth-form label { font-size: 0.87rem; font-weight: 750; }
.auth-form input { min-height: 44px; width: 100%; padding: 9px 11px; color: var(--text); background: #11151c; border: 1px solid var(--border); border-radius: 9px; }
.field-help { color: var(--muted); font-size: 0.78rem; line-height: 1.4; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: auto; padding-top: 4px; }
.card-footer { display: flex; justify-content: space-between; gap: 12px; padding-top: 10px; border-top: 1px solid rgba(52, 58, 72, 0.72); color: var(--muted); font-size: 0.72rem; }
code { color: #d6e3ff; font-family: "SFMono-Regular", Consolas, monospace; }
.empty-state, .boot-state { display: grid; place-items: center; min-height: 320px; padding: 28px; text-align: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; margin-bottom: 14px; border: 3px solid rgba(150, 185, 255, 0.25); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.confirm-dialog { width: min(520px, calc(100% - 32px)); padding: 0; color: var(--text); background: transparent; border: 0; }
.confirm-dialog::backdrop { background: rgba(4, 7, 12, 0.75); backdrop-filter: blur(4px); }
.dialog-panel { padding: 24px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45); }
.dialog-panel p { color: var(--muted); line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.noscript { max-width: 680px; margin: 40px auto; padding: 16px; color: #ffcaca; }

@media (max-width: 820px) {
  .operator-shell { padding: 24px 16px 52px; }
  .app-header { flex-direction: column; }
  .header-actions { width: 100%; justify-content: flex-start; }
  .connection-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .card-topline, .challenge-heading, .card-footer, .section-heading { align-items: flex-start; flex-direction: column; }
  .header-actions .button { flex: 1; }
  .actions .button { flex: 1 1 100%; }
  .dialog-actions .button { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
