:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #071117;
  --surface: #0d1b22;
  --surface-2: #11252d;
  --line: #203942;
  --text: #edf7f5;
  --muted: #8fa7aa;
  --accent: #55e6c1;
  --accent-strong: #79f3d3;
  --danger: #ff7b82;
  --warning: #ffc46b;
  --shadow: 0 28px 70px rgb(0 0 0 / 24%);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 80% -20%, #123f45 0, transparent 35%), var(--bg); color: var(--text); }
button, input, select { font: inherit; }
a { color: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 100; top: 10px; left: 10px; transform: translateY(-150%); padding: 10px 14px; border-radius: 8px; background: var(--accent); color: #04110e; font-weight: 800; }
.skip-link:focus { transform: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.app-shell { display: grid; grid-template-columns: 258px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 26px 18px 18px; border-right: 1px solid var(--line); background: rgb(6 17 22 / 86%); backdrop-filter: blur(22px); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 0 8px; }
.brand-mark { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border-radius: 13px 13px 13px 4px; background: linear-gradient(145deg, var(--accent-strong), #31bca9); color: #05211c; font-size: 21px; font-weight: 900; box-shadow: 0 10px 28px rgb(85 230 193 / 22%); }
.brand strong, .brand small, .profile strong, .profile small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .01em; }
.brand small, .profile small { margin-top: 2px; color: var(--muted); font-size: 12px; text-transform: capitalize; }
.sidebar nav { display: grid; gap: 7px; margin-top: 48px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 1px solid transparent; border-radius: 11px; color: var(--muted); font-size: 14px; font-weight: 650; text-decoration: none; transition: 160ms ease; }
.sidebar nav a:hover { color: var(--text); background: var(--surface); }
.sidebar nav a[aria-current="page"] { border-color: #24524f; background: linear-gradient(90deg, rgb(85 230 193 / 13%), rgb(85 230 193 / 3%)); color: var(--accent-strong); }
.nav-icon { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 8px; background: #11252b; color: #8ccfc1; font-size: 9px; letter-spacing: .07em; }
.profile { display: grid; grid-template-columns: 36px 1fr 32px; gap: 10px; align-items: center; margin-top: auto; padding: 14px 10px 4px; border-top: 1px solid var(--line); min-width: 0; }
.profile > span:nth-child(2) { min-width: 0; }
.profile strong { overflow: hidden; text-overflow: ellipsis; font-size: 13px; white-space: nowrap; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid #2b5c59; border-radius: 50%; background: #12302f; color: var(--accent); font-size: 11px; font-weight: 800; }
.icon-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }

.content { width: 100%; max-width: 1480px; margin: 0 auto; padding: 54px clamp(26px, 5vw, 74px) 80px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 30px; margin-bottom: 32px; }
.page-header h1, .error-state h1 { margin: 5px 0 7px; font-size: clamp(30px, 4vw, 47px); line-height: 1.03; letter-spacing: -.045em; }
.page-header p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 15px; }
.eyebrow { margin: 0; color: var(--accent); font-size: 11px; font-weight: 850; letter-spacing: .16em; text-transform: uppercase; }
.live-chip { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; padding: 8px 11px; border: 1px solid #21443f; border-radius: 999px; background: #0c201f; color: #a9d9cf; font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.live-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgb(85 230 193 / 11%); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric, .panel, .health-card { border: 1px solid var(--line); background: linear-gradient(145deg, rgb(16 36 44 / 96%), rgb(11 26 33 / 96%)); box-shadow: var(--shadow); }
.metric { display: flex; flex-direction: column; min-height: 175px; padding: 22px; border-radius: 15px; }
.metric > span { color: #afc2c3; font-size: 13px; font-weight: 650; }
.metric strong { margin: 19px 0 auto; font-size: 41px; line-height: 1; letter-spacing: -.04em; }
.metric small { color: var(--muted); font-size: 11px; line-height: 1.45; }
.panel { margin-top: 18px; padding: 26px; border-radius: 16px; }
.panel h2, .health-card h2 { margin: 5px 0 9px; font-size: 20px; letter-spacing: -.02em; }
.panel p:not(.eyebrow) { max-width: 720px; color: #a6b8ba; line-height: 1.65; }
.split-panel { display: grid; grid-template-columns: 1fr minmax(300px, .6fr); align-items: center; gap: 40px; }
.compact-stats { display: grid; gap: 1px; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.compact-stats div { display: flex; justify-content: space-between; gap: 20px; padding: 13px 15px; background: #0c1a21; }
.compact-stats dt { color: var(--muted); font-size: 12px; }
.compact-stats dd { margin: 0; font-size: 12px; font-weight: 750; text-transform: capitalize; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 20px; }
.section-title h2 { margin-bottom: 0; }
.count-badge { display: grid; place-items: center; min-width: 31px; height: 27px; padding: 0 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; }

.activity { display: grid; gap: 0; margin: 4px 0 0; padding: 0; list-style: none; }
.activity li { position: relative; display: grid; grid-template-columns: 18px 1fr; gap: 12px; padding: 10px 0; }
.activity li:not(:last-child)::after { content: ""; position: absolute; left: 5px; top: 27px; bottom: -3px; width: 1px; background: var(--line); }
.activity-dot { position: relative; z-index: 1; width: 11px; height: 11px; margin-top: 4px; border: 2px solid #28615a; border-radius: 50%; background: var(--accent); }
.activity strong, .activity span { display: block; }
.activity strong { font-size: 13px; text-transform: capitalize; }
.activity div > span { margin-top: 3px; color: var(--muted); font-size: 11px; }

.service-banner { display: flex; align-items: center; gap: 13px; padding: 15px 18px; border: 1px solid; border-radius: 12px; }
.service-banner.ready { border-color: #28554d; background: rgb(24 74 63 / 30%); }
.service-banner.unready { border-color: #6b4545; background: rgb(96 40 44 / 24%); }
.service-banner strong, .service-banner span { display: block; }
.service-banner strong { font-size: 13px; }
.service-banner div > span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.health-light { display: block; width: 11px; height: 11px; border-radius: 50%; }
.health-light.good { background: var(--accent); box-shadow: 0 0 0 5px rgb(85 230 193 / 10%); }
.health-light.bad { background: var(--danger); box-shadow: 0 0 0 5px rgb(255 123 130 / 10%); }
.endpoint-list { display: grid; gap: 9px; margin: 22px 0; }
.endpoint-list > div { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 15px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #09171d; }
.endpoint-list span { color: var(--muted); font-size: 12px; }
.endpoint-list code { overflow-wrap: anywhere; color: #c2d4d4; font-size: 12px; }
.endpoint-list b { margin-right: 8px; color: var(--accent); }
.muted { color: var(--muted) !important; font-size: 12px; }
.rule-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin: 20px 0; }
.rule-grid div { padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: #09171d; }
.rule-grid span, .rule-grid strong { display: block; }
.rule-grid span { margin-bottom: 7px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.rule-grid strong { font-size: 13px; }

.table-panel { padding: 0; overflow: hidden; }
.table-panel .section-title { padding: 25px 26px 3px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 11px 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #0a171d; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .09em; }
td { padding: 15px 18px; border-bottom: 1px solid rgb(32 57 66 / 65%); color: #cedcdb; font-size: 12px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td strong, .subline { display: block; }
.subline { margin-top: 4px; color: var(--muted); font-size: 10px; }
code { font-family: "SFMono-Regular", Consolas, monospace; }
.pill, .state { display: inline-flex; align-items: center; width: fit-content; padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; background: #11242a; color: #b5c8c8; font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; }
.state.positive { border-color: #28564f; background: #102c29; color: #8de1cc; }
.state.neutral { color: #a2aeaf; }
.scope-list { display: flex; flex-wrap: wrap; gap: 5px; min-width: 180px; }
.empty { display: grid; place-items: center; min-height: 155px; padding: 24px; color: var(--muted); text-align: center; }
.empty span { font-size: 28px; color: #42616a; }

label { display: grid; gap: 7px; color: #b7c8c8; font-size: 11px; font-weight: 700; }
input, select { min-width: 0; height: 43px; padding: 0 12px; border: 1px solid #29434b; border-radius: 9px; background: #08151b; color: var(--text); }
input::placeholder { color: #61757a; }
input:hover, select:hover { border-color: #3b5c64; }
.inline-form { display: grid; grid-template-columns: minmax(180px, 1.6fr) minmax(130px, .7fr) minmax(130px, .7fr) auto; gap: 12px; align-items: end; }
.library-form { grid-template-columns: minmax(155px, 1.1fr) repeat(3, minmax(105px, .7fr)) auto; margin-top: 22px; }
.stack-form { display: grid; gap: 18px; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 9px; color: #b7c8c8; font-size: 11px; font-weight: 700; }
.check-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.check-grid label { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #09171d; cursor: pointer; }
.check-grid input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.button { min-height: 40px; padding: 0 15px; border: 1px solid transparent; border-radius: 9px; font-size: 11px; font-weight: 800; cursor: pointer; transition: 150ms ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: wait; }
.button.primary { background: var(--accent); color: #06201b; box-shadow: 0 9px 24px rgb(85 230 193 / 14%); }
.button.ghost { background: transparent; }
.button.danger { border-color: #6f3e44; color: var(--danger); }
.button.wide { width: 100%; min-height: 47px; }
.secret-result { display: grid; gap: 12px; margin-top: 18px; padding: 16px; border: 1px solid #8b6c2e; border-radius: 10px; background: rgb(93 68 19 / 25%); }
.secret-result strong, .secret-result span { display: block; }
.secret-result strong { color: #ffdc98; font-size: 12px; }
.secret-result span { margin-top: 4px; color: #bba77e; font-size: 10px; }
.secret-result code { overflow-wrap: anywhere; padding: 11px; border-radius: 7px; background: #080e11; color: #fff1cf; font-size: 11px; user-select: all; }
.catalog-result { margin-top: 20px; padding: 19px; border: 1px solid #28554d; border-radius: 12px; background: rgb(24 74 63 / 20%); }
.catalog-result h3 { margin: 5px 0 0; font-size: 22px; }
.catalog-result dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--line); }
.catalog-result dl div { min-width: 0; padding: 12px; background: #09171d; }
.catalog-result dt { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.catalog-result dd { margin: 6px 0 0; overflow-wrap: anywhere; color: #cfdddc; font-size: 11px; }
.catalog-actions { display: flex; align-items: center; gap: 10px; }
.player-panel { padding: 0; overflow: hidden; }
.player-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding: 24px 26px; }
.player-heading h2 { margin-bottom: 5px; }
.player-status { margin: 0 !important; color: var(--muted) !important; font-size: 11px; }
.player-close { border-color: var(--line); color: var(--muted); }
.player-panel video { display: block; width: 100%; max-height: min(72vh, 820px); background: #000; }
.player-panel audio { display: none; }
.player-controls { display: grid; grid-template-columns: minmax(190px, 1.2fr) repeat(3, minmax(150px, 1fr)); gap: 1px; border-top: 1px solid var(--line); background: var(--line); }
.player-controls > div, .player-controls > label { min-width: 0; padding: 15px 17px; background: #09171d; }
.player-controls > div span, .player-controls > div strong, .player-controls > div code { display: block; }
.player-controls > div span { margin-bottom: 7px; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.player-controls > div strong, .player-controls > div code { overflow-wrap: anywhere; color: #cfdddc; font-size: 11px; }
.player-controls select { width: 100%; }
.manual-intro code, .manual-section p code, .manual-list code { padding: 2px 5px; border: 1px solid var(--line); border-radius: 5px; background: #08151b; color: #bce9df; font-size: .9em; }
.manual-section { scroll-margin-top: 24px; }
.manual-code { margin: 18px 0 0; padding: 18px; overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; background: #061015; color: #c8d9d7; font-size: 12px; line-height: 1.65; white-space: pre; }
.manual-code code { font: inherit; }
.manual-list { display: grid; gap: 11px; margin: 18px 0 0; padding-left: 20px; color: #a6b8ba; font-size: 13px; line-height: 1.65; }
.manual-status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin: 20px 0; }
.manual-status-grid div { padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: #09171d; }
.manual-status-grid span, .manual-status-grid strong { display: block; }
.manual-status-grid span { margin-bottom: 7px; color: var(--accent); font-size: 11px; font-weight: 850; }
.manual-status-grid strong { color: #becdcc; font-size: 11px; line-height: 1.4; }
.ingest-title { padding-right: 26px !important; }
.ingest-title label { min-width: 160px; }

.health-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.health-card { padding: 23px; border-radius: 15px; }
.health-card > div { display: flex; align-items: center; gap: 14px; }
.health-card h2 { margin: 0; }
.health-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 22px 0 0; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--line); }
.health-card dl div { padding: 12px; background: #09171d; }
.health-card dt { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.health-card dd { margin: 5px 0 0; font-size: 12px; font-weight: 750; }

.auth-layout { display: grid; grid-template-columns: minmax(320px, 1.1fr) minmax(420px, .9fr); min-height: 100vh; }
.auth-brand { display: flex; flex-direction: column; justify-content: space-between; padding: clamp(32px, 6vw, 76px); background: radial-gradient(circle at 40% 38%, rgb(34 110 102 / 35%), transparent 37%), linear-gradient(155deg, #0b1e25, #071117 65%); border-right: 1px solid var(--line); }
.auth-brand .brand { padding: 0; }
.auth-brand h1 { max-width: 660px; margin: 13px 0 22px; font-size: clamp(44px, 6.2vw, 82px); line-height: .94; letter-spacing: -.065em; }
.auth-brand div > p:not(.eyebrow) { max-width: 540px; color: #9eb3b5; line-height: 1.7; }
.security-note { color: #6f898d; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.auth-card { align-self: center; width: min(100% - 48px, 490px); margin: 40px auto; padding: 34px; border: 1px solid var(--line); border-radius: 19px; background: rgb(13 27 34 / 94%); box-shadow: var(--shadow); }
.auth-card h2 { margin: 8px 0; font-size: 30px; letter-spacing: -.04em; }
.auth-card > div:first-child > p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 13px; }
.auth-form { display: grid; gap: 16px; margin-top: 28px; }
.auth-form input { height: 49px; }
.auth-footnote { margin: 20px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; text-align: center; }
.notice { display: flex; gap: 10px; margin-top: 22px; padding: 13px; border: 1px solid #69562d; border-radius: 9px; background: rgb(100 75 24 / 19%); }
.notice strong, .notice span { display: block; }
.notice strong { flex: 0 0 auto; color: var(--warning); font-size: 10px; text-transform: uppercase; }
.notice span { color: #b7a98c; font-size: 10px; line-height: 1.5; }
.form-error { padding: 11px 12px; border: 1px solid #74434a; border-radius: 8px; background: rgb(105 42 50 / 22%); color: #ffb4b9; font-size: 11px; }

.boot-screen, .loading, .error-state { display: grid; place-items: center; align-content: center; min-height: 60vh; text-align: center; }
.boot-screen { min-height: 100vh; gap: 14px; }
.boot-screen p, .loading p, .error-state p, .error-state small { color: var(--muted); }
.loading { gap: 14px; }
.spinner { width: 25px; height: 25px; border: 2px solid #29434a; border-top-color: var(--accent); border-radius: 50%; animation: spin 800ms linear infinite; }
.error-state { gap: 9px; }
.error-state > span { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid #6e4046; border-radius: 50%; color: var(--danger); font-weight: 900; }
.error-state .button { margin-top: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; transition-duration: 1ms !important; } }

@media (max-width: 1050px) {
  .metric-grid, .rule-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-form, .library-form { grid-template-columns: 1fr 1fr; }
  .auth-layout { grid-template-columns: 1fr; }
  .player-controls { grid-template-columns: 1fr 1fr; }
  .manual-status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-brand { display: none; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; padding-bottom: 76px; }
  .sidebar { position: fixed; z-index: 20; top: auto; right: 0; bottom: 0; left: 0; display: block; width: auto; height: 70px; padding: 8px; border: 1px solid var(--line); background: rgb(6 17 22 / 96%); }
  .sidebar > .brand, .profile { display: none; }
  .sidebar nav { display: flex; justify-content: space-around; gap: 2px; margin: 0; overflow-x: auto; }
  .sidebar nav a { flex: 0 0 auto; display: grid; justify-items: center; gap: 3px; padding: 5px 8px; font-size: 8px; }
  .nav-icon { width: 26px; height: 26px; }
  .content { padding: 34px 18px 48px; }
  .page-header { align-items: flex-start; }
  .live-chip { display: none; }
  .split-panel, .health-grid { grid-template-columns: 1fr; }
  .endpoint-list > div { grid-template-columns: 1fr; gap: 7px; }
  .auth-card { width: min(100% - 28px, 490px); padding: 25px 20px; }
}

@media (max-width: 520px) {
  .metric-grid, .rule-grid, .inline-form { grid-template-columns: 1fr; }
  .catalog-result dl { grid-template-columns: 1fr; }
  .metric { min-height: 145px; }
  .panel { padding: 21px 18px; }
  .table-panel { padding: 0; }
  .health-card dl { grid-template-columns: 1fr; }
  .player-heading { display: grid; padding: 21px 18px; }
  .player-controls, .manual-status-grid { grid-template-columns: 1fr; }
  .catalog-actions { align-items: flex-end; flex-direction: column; }
}
