:root {
  color-scheme: dark;
  --ink: #eef5ff;
  --muted: #91a3bc;
  --midnight: #050914;
  --navy: #091426;
  --panel: #0d192b;
  --panel-2: #111f35;
  --line: #22344d;
  --violet: #8458ff;
  --ultraviolet: #6540d9;
  --cyan: #48d6e8;
  --teal: #37b8b3;
  --warning: #f1bd70;
  --danger: #ff7f98;
  --radius: 8px;
  font-family: "Aptos", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--midnight); scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at 18% 0%, rgba(72, 214, 232, .09), transparent 28rem), linear-gradient(145deg, #040812, #091224 55%, #070a16); }
button, input, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }

.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 20; background: var(--cyan); color: #031017; padding: .65rem 1rem; }
.skip-link:focus { top: 1rem; }
.shell { position: relative; width: min(1440px, calc(100% - 32px)); min-height: calc(100vh - 32px); margin: 16px auto; border: 1px solid transparent; border-radius: var(--radius); background: linear-gradient(var(--navy), var(--navy)) padding-box, linear-gradient(120deg, rgba(72,214,232,.65), rgba(132,88,255,.8), rgba(55,184,179,.55)) border-box; box-shadow: 0 24px 80px rgba(0,0,0,.38); }
.shell::before { content: ""; position: absolute; inset: -2px; z-index: -1; border-radius: 10px; background: linear-gradient(115deg, transparent 8%, rgba(72,214,232,.35), rgba(132,88,255,.45), transparent 72%); filter: blur(10px); opacity: .65; animation: shellGlow 12s ease-in-out infinite alternate; }
@keyframes shellGlow { from { transform: translateX(-1%); opacity: .4; } to { transform: translateX(1%); opacity: .75; } }

.masthead { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--line); }
.brand-block { display: flex; align-items: center; gap: .8rem; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid rgba(72,214,232,.55); border-radius: 50%; color: var(--cyan); font-family: Georgia, serif; font-size: 1.25rem; }
.brand-block strong, .brand-block span { display: block; }
.brand-block strong { font-family: Georgia, serif; font-size: 1.12rem; font-weight: 500; }
.brand-block div span { color: var(--muted); font-size: .78rem; margin-top: .15rem; }
.system-state { color: var(--teal); font-size: .82rem; }
.system-state.has-warning { color: var(--warning); }

.tabs { display: flex; gap: .25rem; padding: .65rem 1rem; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.tab { flex: 0 0 auto; border: 0; border-bottom: 2px solid transparent; background: transparent; padding: .68rem .82rem; color: var(--muted); cursor: pointer; }
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--cyan); border-bottom-color: var(--violet); }

main { min-height: 680px; }
.page { display: none; padding: clamp(1.25rem, 3vw, 2.6rem); }
.page.is-active { display: block; animation: reveal .38s ease-out both; }
@keyframes reveal { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
.page-heading { max-width: 760px; margin-bottom: 2rem; }
.page-heading p, .surface-heading p, .dialog-heading p { margin: 0 0 .45rem; color: var(--cyan); font-size: .72rem; text-transform: uppercase; letter-spacing: .11em; }
.page-heading h1 { margin: 0 0 .65rem; font: 500 clamp(1.8rem, 4vw, 3.4rem)/1.05 Georgia, serif; }
.page-heading span { color: var(--muted); line-height: 1.6; }
h2, h3 { font-family: Georgia, serif; font-weight: 500; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 1.2rem; }
.metric { min-width: 0; padding: 1.2rem; background: rgba(13,25,43,.76); border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong { display: block; margin: .6rem 0 .35rem; font: 500 1.65rem Georgia, serif; overflow-wrap: anywhere; }
.metric small { font-size: .72rem; }
.split-layout { display: grid; grid-template-columns: 1.15fr .85fr; gap: 1.2rem; }
.surface { padding: 1.3rem; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(13,25,43,.68); }
.surface-heading { border-bottom: 1px solid var(--line); padding-bottom: .85rem; margin-bottom: 1rem; }
.surface-heading h2 { margin: 0; font-size: 1.25rem; }
.evidence-block p, .empty-state p, .state-message p, .status-card p { color: var(--muted); line-height: 1.55; }
.evidence-block small { color: var(--muted); }
.review-list { margin: 0; padding-left: 1.2rem; color: var(--warning); line-height: 1.8; }

.badge { display: inline-block; max-width: 100%; padding: .27rem .48rem; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: .68rem; text-transform: uppercase; overflow-wrap: anywhere; }
.badge.ready { color: var(--cyan); border-color: rgba(72,214,232,.42); }
.badge.blocked { color: var(--danger); border-color: rgba(255,127,152,.42); }
.badge.watched { color: #c3afff; border-color: rgba(132,88,255,.45); margin-right: .4rem; }

.state-surface { min-height: 280px; display: grid; align-items: center; }
.state-message { max-width: 760px; }
.state-message h2 { margin: 1rem 0 .5rem; font-size: 1.55rem; }
.state-message dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-top: 1.5rem; background: var(--line); border: 1px solid var(--line); }
.state-message dl div { padding: 1rem; background: var(--panel); }
.state-message dt { color: var(--muted); font-size: .72rem; }
.state-message dd { margin: .5rem 0 0; overflow-wrap: anywhere; }

.table-tools { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(180px, .45fr) auto; gap: .65rem; align-items: end; margin-bottom: 1rem; }
.table-tools label { grid-column: 1 / -1; color: var(--muted); font-size: .78rem; }
.table-tools input, .table-tools select { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 4px; background: #091427; color: var(--ink); padding: .65rem .75rem; }
.result-count { color: var(--muted); padding: .65rem; white-space: nowrap; }
.company-list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.company-list-head, .company-row { display: grid; grid-template-columns: minmax(180px, 1.3fr) minmax(130px, .7fr) minmax(220px, 1fr) 110px; gap: 1rem; align-items: center; width: 100%; min-height: 62px; padding: .75rem 1rem; }
.company-list-head { min-height: 42px; color: var(--muted); background: #0a1425; font-size: .7rem; text-transform: uppercase; }
.company-row { border: 0; border-top: 1px solid var(--line); text-align: left; background: rgba(13,25,43,.72); cursor: pointer; }
.company-row:hover { background: var(--panel-2); }
.company-identity strong, .company-identity small { display: block; }
.company-identity small { margin-top: .25rem; color: var(--muted); }
.row-action { color: var(--cyan); text-align: right; font-size: .78rem; }
.section-status { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; color: var(--muted); }

.status-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.status-card { min-height: 150px; padding: 1rem; border-top: 2px solid var(--ultraviolet); background: var(--panel); }
.status-card > div { display: flex; justify-content: space-between; gap: .75rem; align-items: start; }
.status-card > div > span:first-child { font-family: Georgia, serif; font-size: 1.08rem; }

.about-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); }
.about-layout section { min-height: 190px; padding: 1.25rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.about-layout section:nth-child(2n) { border-right: 0; }
.about-layout section:nth-last-child(-n+2) { border-bottom: 0; }
.about-layout h2 { margin-top: 0; }
.about-layout p { color: var(--muted); line-height: 1.6; }

footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem 1.4rem; color: var(--muted); border-top: 1px solid var(--line); font-size: .72rem; }
.company-dialog { position: fixed; inset: 0; width: min(920px, calc(100vw - 24px)); min-width: 0; max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); margin: auto; padding: 0; overflow-x: hidden; border: 1px solid #41577b; border-radius: var(--radius); color: var(--ink); background: #081224; box-shadow: 0 30px 90px rgba(0,0,0,.7); }
.company-dialog * { min-width: 0; overflow-wrap: anywhere; }
.company-dialog::backdrop { background: rgba(1,5,14,.8); backdrop-filter: blur(7px); }
.dialog-heading { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); background: #081224; }
.dialog-heading h2 { margin: 0; font-size: 1.35rem; }
.dialog-heading button { border: 1px solid var(--line); border-radius: 4px; background: transparent; padding: .55rem .75rem; cursor: pointer; }
.dialog-body { padding: 1.2rem; }
.dialog-body > section { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.dialog-body > section p { color: var(--muted); line-height: 1.6; }
.dialog-body > section small { color: var(--muted); }
.detail-meta { display: flex; flex-wrap: wrap; gap: .5rem; }
.detail-meta span, .detail-governance { padding: .5rem .65rem; background: var(--panel); color: var(--muted); font-size: .75rem; }
.detail-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.detail-title h3 { margin: 0; }
.detail-governance { margin-top: 1rem; border-left: 2px solid var(--cyan); }
.muted { color: var(--muted); }
.loading-state, .empty-state { padding: 1rem 0; }

@media (max-width: 900px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .split-layout, .status-grid { grid-template-columns: 1fr; }
  .company-list-head { display: none; }
  .company-row { grid-template-columns: 1fr 1fr; }
  .row-action { text-align: left; }
}

@media (max-width: 640px) {
  .shell { width: calc(100% - 12px); margin: 6px auto; min-height: calc(100vh - 12px); }
  .masthead { align-items: flex-start; padding: 1rem; }
  .system-state { max-width: 42%; text-align: right; }
  .page { padding: 1.1rem; }
  .page-heading h1 { font-size: 2rem; }
  .metric-grid, .about-layout, .state-message dl, .table-tools { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .about-layout section { border-right: 0; border-bottom: 1px solid var(--line) !important; }
  .about-layout section:last-child { border-bottom: 0 !important; }
  .company-row { grid-template-columns: 1fr; gap: .55rem; }
  .section-status, footer { flex-direction: column; }
  .dialog-heading { align-items: flex-start; }
  .company-dialog { inset: 12px; width: auto; max-width: none; max-height: none; margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .shell::before { display: none; }
}