:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #000;
  color: #f4f4f5;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #000; }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid #ef4444; outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: #929298; }
.mono, code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; overflow-wrap: anywhere; }
.eyebrow { margin: 0 0 7px; color: #77777f; font-size: 11px; font-weight: 700; letter-spacing: 0; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: 25px; line-height: 1.2; }
h2 { margin: 0; font-size: 19px; }
h3 { margin: 0; font-size: 14px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(100%, 400px); padding: 32px; border: 1px solid #242427; background: #050505; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 28px; border: 1px solid #3b0c0c; color: #ef4444; font-family: Georgia, serif; font-size: 29px; }
.brand-mark.small { width: 30px; height: 30px; margin: 0; font-size: 18px; }
.login-panel > .muted { margin: 9px 0 28px; font-size: 14px; }

label { display: grid; gap: 8px; margin: 18px 0; color: #c7c7cc; font-size: 13px; font-weight: 600; }
input { width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid #303034; border-radius: 4px; background: #080808; color: #fff; }
input:hover { border-color: #48484d; }
input::placeholder { color: #626268; }
.form-error { min-height: 20px; margin: 10px 0; color: #f87171; font-size: 13px; }

button { min-height: 36px; padding: 0 13px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: #e4e4e7; font-size: 13px; font-weight: 650; transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, opacity 160ms ease; }
button:disabled { cursor: not-allowed; opacity: .42; }
.primary { border-color: #dc2626; background: #dc2626; color: #fff; }
.primary:hover:not(:disabled) { border-color: #ef4444; background: #ef4444; }
.secondary { border-color: #303034; background: #0a0a0a; }
.secondary:hover:not(:disabled) { border-color: #55555b; background: #111; }
.quiet { padding: 0; color: #a1a1aa; text-align: left; }
.quiet:hover { color: #fff; }
.danger, .danger:hover { border-color: #b91c1c; background: #b91c1c; color: #fff; }
.danger-text { padding: 0; color: #f87171; }
.danger-text:hover { color: #fca5a5; }
.full { width: 100%; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 19px 14px; border-right: 1px solid #202024; background: #030303; }
.brand-row { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; font-size: 14px; font-weight: 700; }
.nav-item { width: 100%; display: flex; align-items: center; justify-content: flex-start; margin: 2px 0; color: #9b9ba1; }
.nav-item:hover { color: #fff; background: #0c0c0d; }
.nav-item.active { border-left: 2px solid #ef4444; border-radius: 0 4px 4px 0; background: #101010; color: #fff; }
.session-block { display: grid; gap: 6px; margin-top: auto; padding: 16px 9px 2px; border-top: 1px solid #202024; font-size: 11px; color: #77777f; }
.session-block strong { color: #c8c8cc; font-size: 12px; overflow-wrap: anywhere; }

.workspace { min-width: 0; padding: 0 28px 24px; }
.topbar { min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid #242427; }
.top-actions, .dialog-actions { display: flex; align-items: center; gap: 9px; }
.toolbar { min-height: 68px; display: flex; align-items: center; gap: 16px; }
.search-field { width: min(400px, 50vw); margin: 0; }
.check-control { display: flex; align-items: center; gap: 9px; margin: 0; font-weight: 500; }
.check-control input { width: 15px; min-height: 15px; accent-color: #dc2626; }
.result-count { margin-left: auto; color: #77777f; font-size: 12px; }
.dashboard-view { padding: 22px 0 8px; }
.dashboard-status { min-height: 34px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.live-status { display: inline-flex; align-items: center; gap: 8px; color: #a1a1aa; font-size: 12px; }
.live-status > span:first-child { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 10px rgb(34 197 94 / 55%); }
.live-status.unavailable > span:first-child { background: #71717a; box-shadow: none; }
.metric-section { padding: 24px 0 32px; border-top: 1px solid #242427; }
.metric-section .section-heading { margin-bottom: 16px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.metric-item { min-height: 112px; display: flex; flex-direction: column; justify-content: space-between; padding: 16px; border: 1px solid #242427; border-radius: 4px; background: #050505; }
.metric-item span { color: #929298; font-size: 12px; font-weight: 600; }
.metric-item strong { color: #f4f4f5; font-size: 30px; font-weight: 650; line-height: 1; }
.realtime-metrics .metric-item:first-child, .realtime-metrics .metric-item:nth-child(2), .realtime-metrics .metric-item:nth-child(3) { border-color: #382020; }
.notice { margin-bottom: 14px; padding: 11px 13px; border-left: 2px solid #ef4444; background: #100505; color: #fecaca; font-size: 13px; }
.loading, .empty-state { padding: 70px 20px; color: #838389; text-align: center; }
.empty-state h2 { margin-bottom: 8px; color: #d4d4d8; }
.empty-state p { margin: 0; }

.table-wrap { min-height: 420px; overflow-x: auto; border-top: 1px solid #29292d; border-bottom: 1px solid #29292d; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { height: 42px; color: #77777f; font-size: 11px; font-weight: 700; text-align: left; text-transform: uppercase; }
.users-table th:nth-child(1) { width: 34%; }
.users-table th:nth-child(2), .users-table th:nth-child(3) { width: 20%; }
.users-table th:nth-child(4) { width: 16%; }
.users-table th:nth-child(5) { width: 10%; }
.rooms-table th:nth-child(1) { width: 34%; }
.rooms-table th:nth-child(2) { width: 29%; }
.rooms-table th:nth-child(3) { width: 13%; }
.rooms-table th:nth-child(4) { width: 14%; }
.rooms-table th:nth-child(5) { width: 10%; }
td { height: 54px; padding-right: 18px; border-top: 1px solid #18181b; color: #c9c9ce; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tbody tr:hover { background: #080808; }
td strong { color: #f2f2f3; }
.status { display: inline-flex; align-items: center; gap: 7px; }
.status::before { width: 6px; height: 6px; border-radius: 50%; background: #3f3f46; content: ""; }
.status.active::before { background: #22c55e; }
.status.admin::before { background: #ef4444; }
.row-actions { display: flex; justify-content: flex-end; gap: 8px; padding-right: 0; }
.row-actions button { min-height: 30px; opacity: .72; }
tr:hover .row-actions button, .row-actions button:focus-visible { opacity: 1; }
.pagination { min-height: 62px; display: flex; align-items: center; justify-content: flex-end; gap: 12px; color: #77777f; font-size: 12px; }

dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; overflow: auto; border: 1px solid #333338; border-radius: 6px; background: #050505; color: #f4f4f5; }
#room-dialog { width: min(760px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / 78%); backdrop-filter: blur(3px); }
.dialog-form { padding: 24px; }
.dialog-form.wide { width: min(760px, calc(100vw - 32px)); }
.dialog-form.compact { max-width: 520px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.dialog-heading .muted { margin: 8px 0 0; font-size: 12px; }
.close-button { min-height: 30px; padding: 0; color: #85858c; }
.close-button:hover { color: #fff; }
.joined-input { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; border: 1px solid #303034; border-radius: 4px; background: #080808; }
.joined-input span { padding: 0 10px; color: #77777f; font-family: ui-monospace, monospace; }
.joined-input input { min-width: 0; border: 0; border-right: 1px solid #303034; border-left: 1px solid #303034; border-radius: 0; }
.dialog-actions { margin-top: 24px; }
.spacer { flex: 1; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 0 0 24px; background: #202024; border: 1px solid #202024; }
.detail-grid div { min-width: 0; padding: 13px; background: #070707; }
.detail-grid dt { color: #77777f; font-size: 11px; text-transform: uppercase; }
.detail-grid dd { margin: 6px 0 0; color: #dddde1; font-size: 13px; overflow-wrap: anywhere; }
.section-heading { display: flex; align-items: center; margin-bottom: 10px; }
.member-add-form { padding: 12px 0 14px; border-top: 1px solid #29292d; }
.member-add-form > label { margin: 0 0 8px; }
.member-add-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
.member-add-controls input { min-width: 0; }
.member-add-form .form-error, .member-add-form .form-success { min-height: 0; margin: 8px 0 0; }
.form-success { color: #86efac; font-size: 13px; }
.member-list { max-height: 220px; overflow: auto; border-top: 1px solid #29292d; border-bottom: 1px solid #29292d; }
.member-list div { padding: 10px 4px; border-top: 1px solid #18181b; color: #c7c7cc; font-family: ui-monospace, monospace; font-size: 12px; }
.member-list div:first-child { border-top: 0; }

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; display: grid; grid-template-columns: 1fr auto; padding: 12px 16px; border-right: 0; border-bottom: 1px solid #202024; }
  .brand-row { padding: 0; }
  #primary-nav { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 10px; }
  .nav-item { justify-content: center; }
  .nav-item.active { border-left: 0; border-bottom: 2px solid #ef4444; border-radius: 4px 4px 0 0; }
  .session-block { margin: 0; padding: 0; border: 0; text-align: right; }
  .session-block > span, .session-block strong { display: none; }
  .workspace { padding: 0 16px 18px; }
  .topbar { min-height: 78px; }
  .toolbar { flex-wrap: wrap; padding: 12px 0; }
  .search-field { width: 100%; }
  .result-count { margin-left: 0; }
  .dashboard-status .result-count { margin-left: auto; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-item { min-height: 98px; }
  .metric-item strong { font-size: 26px; }
  table { min-width: 720px; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .dialog-actions { flex-wrap: wrap; }
  .member-add-controls { grid-template-columns: 1fr; }
  .member-add-controls button { width: 100%; min-height: 42px; }
}

@media (max-width: 420px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-item { min-height: 88px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
