:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #071018;
  color: #eaf3fb;
  --surface: #0d1923;
  --border: #203543;
  --border-strong: #2d4a5d;
  --muted: #8195a5;
  --quiet: #5f7484;
  --cyan: #35b8ff;
  --green: #36d98b;
  --amber: #f8b84e;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #071018; }
button, a { font: inherit; }
[hidden] { display: none !important; }
.auth-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0%, rgba(32, 105, 148, .27), transparent 42%); }
.login-card { width: min(440px, 100%); padding: 34px; border: 1px solid var(--border-strong); border-radius: 20px; background: rgba(13, 25, 35, .96); box-shadow: 0 28px 90px rgba(0, 0, 0, .34); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 34px; }
.login-brand strong, .login-brand small { display: block; }
.login-brand strong { font-size: 14px; }
.login-brand small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.login-card h1 { font-size: 34px; }
.login-card .subtitle { margin-bottom: 26px; }
.login-card label { display: block; margin: 15px 0 7px; color: #a8bbc8; font-size: 12px; font-weight: 650; }
.login-card input { width: 100%; border: 1px solid var(--border-strong); border-radius: 10px; padding: 12px 13px; outline: none; background: #08131c; color: #ecf7ff; font: inherit; }
.login-card input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(53, 184, 255, .11); }
.local-login { display: grid; gap: 14px; }
.primary-button { width: 100%; justify-content: center; margin-top: 20px; padding: 12px 16px; border-color: #2178a8; background: #17618a; font-weight: 750; }
.login-separator { display: flex; align-items: center; gap: 12px; margin: 17px 0; color: var(--quiet); font-size: 10px; text-transform: uppercase; }
.login-separator::before, .login-separator::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.oidc-button { width: 100%; display: flex; align-items: center; justify-content: center; border: 1px solid #355269; border-radius: 10px; padding: 12px 16px; background: #102331; color: #dff4ff; font-size: 13px; font-weight: 750; text-decoration: none; }
.oidc-button:hover { border-color: #3a7498; background: #163246; }
.login-note { display: block; margin-top: 16px; color: var(--quiet); font-size: 10px; line-height: 1.5; text-align: center; }
.login-error { margin: 14px 0 0; padding: 10px 12px; border: 1px solid #7c3f3f; border-radius: 9px; background: rgba(126, 41, 41, .18); color: #ffaaaa; font-size: 12px; }
.app-shell { min-height: 100vh; background: radial-gradient(circle at 10% -10%, rgba(32, 105, 148, .25), transparent 35%); }
.topbar { height: 74px; padding: 0 max(28px, calc((100vw - 1180px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid rgba(45, 74, 93, .7); background: rgba(7, 16, 24, .82); backdrop-filter: blur(16px); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid #2e6c91; border-radius: 11px; background: linear-gradient(145deg, #153951, #0d2332); color: #55c6ff; font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: .01em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.last-check { color: var(--quiet); font-size: 12px; }
.session-user { color: #a7bbc8; font-size: 11px; }
.quiet-button { border-color: transparent; background: transparent; color: var(--muted); }
button { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 14px; background: #112635; color: #dff4ff; cursor: pointer; transition: border-color .16s ease, background .16s ease, transform .16s ease; }
button:hover { border-color: #3a7498; background: #163246; }
button:active { transform: translateY(1px); }
button:disabled { cursor: progress; opacity: .65; }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 72px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; }
.eyebrow { margin: 0 0 8px; color: var(--cyan); font-size: 12px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(32px, 4vw, 46px); letter-spacing: -.04em; line-height: 1.04; }
.subtitle { max-width: 640px; margin: 12px 0 0; color: var(--muted); font-size: 15px; line-height: 1.55; }
.health-pill { min-width: 230px; display: flex; align-items: center; gap: 12px; padding: 13px 16px; border: 1px solid var(--border); border-radius: 13px; background: rgba(13, 25, 35, .9); }
.health-pill small, .health-pill strong { display: block; }
.health-pill small { color: var(--muted); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; }
.health-pill strong { margin-top: 3px; font-size: 13px; }
.dot { width: 11px; height: 11px; flex: 0 0 auto; border-radius: 50%; background: #71808c; box-shadow: 0 0 15px currentColor; }
.dot.ready { color: var(--green); background: var(--green); }
.dot.degraded { color: var(--amber); background: var(--amber); }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 30px 0 18px; }
.metric { min-width: 0; padding: 17px 19px; border: 1px solid var(--border); border-radius: 14px; background: rgba(13, 25, 35, .84); }
.metric span, .metric small { display: block; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { display: inline-block; margin: 7px 10px 0 0; font-size: 28px; line-height: 1; letter-spacing: -.04em; }
.metric small { display: inline; color: var(--quiet); font-size: 11px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.devices-panel, .system-panel { border: 1px solid var(--border); border-radius: 17px; background: rgba(10, 22, 31, .88); overflow: hidden; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.section-head.compact { padding-bottom: 19px; }
.section-head h2 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.section-head p { margin: 5px 0 0; color: var(--quiet); font-size: 12px; }
.count-badge { padding: 6px 9px; border-radius: 8px; background: #142633; color: #9db2c0; font-size: 11px; white-space: nowrap; }
.device-list { display: grid; gap: 1px; background: var(--border); }
.device-card { padding: 22px; background: var(--surface); }
.device-card[hidden] { display: none; }
.transport-chip[hidden] { display: none; }
.device-identity { display: flex; align-items: center; gap: 14px; }
.device-icon { width: 46px; height: 58px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid; border-radius: 12px; font-size: 13px; font-weight: 800; }
.device-icon.bluetooth { border-color: #216890; background: #0e3045; color: #62c6ff; }
.device-icon.usb { border-color: #594f9d; background: #211f42; color: #afa3ff; }
.device-name { min-width: 0; flex: 1; }
.device-title-line { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.device-title-line h3 { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.device-name p { display: flex; align-items: center; gap: 9px; margin: 8px 0 0; color: var(--quiet); font-size: 11px; }
.transport-chip { padding: 4px 7px; border: 1px solid var(--border); border-radius: 6px; color: #a3b5c1; font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.status-badge { padding: 6px 9px; border-radius: 999px; background: #1b2b36; color: #8295a3; font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.status-badge.ready { background: rgba(54, 217, 139, .11); color: #54e49e; }
.status-badge.partial { background: rgba(248, 184, 78, .11); color: #f7c66f; }
.capabilities { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 19px; }
.capability { min-width: 0; display: flex; align-items: center; gap: 9px; padding: 11px; border: 1px solid #1c3342; border-radius: 10px; background: #0b1720; }
.capability-icon { width: 21px; height: 21px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: rgba(54, 217, 139, .12); color: var(--green); font-size: 11px; font-weight: 800; }
.capability-icon.off { background: rgba(248, 184, 78, .1); color: var(--amber); }
.capability-icon.neutral { background: rgba(53, 184, 255, .1); color: var(--cyan); }
.capability small, .capability strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.capability small { color: var(--quiet); font-size: 10px; }
.capability strong { margin-top: 3px; font-size: 11px; font-weight: 650; }
.capability.muted { opacity: .58; }

.system-list { margin: 0; padding: 4px 22px 6px; }
.system-list div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; padding: 14px 0; border-bottom: 1px solid #1b303e; }
.system-list div:last-child { border-bottom: 0; }
.system-list dt { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.system-list dd { min-width: 0; margin: 0; overflow-wrap: anywhere; color: #c9d6df; font-size: 11px; text-align: right; }
.technical { color: #8fa3b2 !important; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px !important; }
.mini-dot { width: 7px; height: 7px; border-radius: 50%; background: #657886; }
.mini-dot.ready { background: var(--green); box-shadow: 0 0 8px rgba(54, 217, 139, .65); }
.mini-dot.degraded { background: var(--amber); }
.info-note { margin: 8px 14px 14px; padding: 14px; border: 1px solid #294557; border-radius: 11px; background: #0d2230; }
.info-note strong { color: #bfe8ff; font-size: 11px; }
.info-note p { margin: 7px 0 0; color: #7791a2; font-size: 11px; line-height: 1.5; }
.sessions-panel { margin-top: 18px; border: 1px solid var(--border); border-radius: 17px; background: rgba(10, 22, 31, .88); overflow: hidden; }
.session-list { display: grid; gap: 1px; background: var(--border); }
.session-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(140px, .7fr) auto; align-items: center; gap: 20px; padding: 16px 22px; background: var(--surface); }
.session-device strong, .session-device small { display: block; }
.session-device strong { font-size: 13px; }
.session-device small, .session-meta { margin-top: 4px; color: var(--quiet); font-size: 10px; }
.session-meta { margin: 0; line-height: 1.5; white-space: pre-line; }
.session-empty { margin: 0; padding: 22px; background: var(--surface); color: var(--quiet); font-size: 12px; }
.revoke-session { color: #ffc0c0; border-color: #58363a; background: #26181c; }
.revoke-session:disabled { cursor: default; color: var(--green); border-color: #28513f; background: #11251c; }
.warnings { margin-top: 18px; padding: 19px 22px; border: 1px solid #6c4d25; border-radius: 15px; background: rgba(77, 47, 16, .28); }
.warnings h2 { margin: 0; font-size: 14px; }
.warnings ul { margin: 11px 0 0; padding-left: 20px; color: #f4c578; font-size: 12px; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .system-panel { order: 2; }
}
@media (max-width: 760px) {
  .topbar { height: auto; padding: 14px 20px; }
  .last-check { display: none; }
  main { width: min(100% - 28px, 1180px); padding-top: 30px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .health-pill { min-width: 0; }
  .metrics { grid-template-columns: 1fr; }
  .capabilities { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .session-row { grid-template-columns: 1fr auto; }
  .session-meta { grid-column: 1; grid-row: 2; }
}
@media (max-width: 480px) {
  .brand small { display: none; }
  button { padding: 9px 11px; }
  .device-title-line { align-items: flex-start; flex-direction: column; gap: 8px; }
  .device-name p { align-items: flex-start; flex-direction: column; }
  .capabilities { grid-template-columns: 1fr; }
}
