:root {
  color-scheme: dark;
  --bg: #101313;
  --panel: #171c1b;
  --panel-2: #1e2523;
  --line: #303a37;
  --text: #f2f3ec;
  --muted: #a5b0aa;
  --green: #5fe09b;
  --yellow: #f4c95d;
  --red: #ff7474;
  --accent: #d7ff63;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { max-width: 100%; width: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); overflow-wrap: break-word; }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
img, video, svg, canvas { height: auto; max-width: 100%; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.topbar {
  align-items: center; background: rgba(16, 19, 19, .96); border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; min-height: 64px; padding: 10px 20px;
  position: sticky; top: 0; z-index: 10;
}
.brand { align-items: center; display: flex; gap: 10px; min-width: 0; text-decoration: none; }
.brand strong { overflow-wrap: anywhere; }
.brand span { align-items: center; background: var(--accent); border-radius: 9px; color: #111; display: flex; font-weight: 900; height: 36px; justify-content: center; width: 36px; }
.top-status { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; min-width: 0; }
.top-status form { margin: 0; }
.header-status-row { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; max-width: 100%; min-width: 0; }
.header-state { border: 1px solid var(--line); border-radius: 999px; font-size: .78rem; font-weight: 800; padding: 6px 10px; text-transform: uppercase; }
.header-state.critical { background: #492020; border-color: var(--red); }
.header-state.inactive { color: var(--muted); }
.header-state.ok { color: var(--green); }
.founder { color: var(--muted); font-size: .86rem; }
.link-button { background: none; border: 0; color: var(--text); padding: 4px; text-decoration: underline; }

.language-selector { align-items: center; border: 1px solid var(--line); border-radius: 8px; display: flex; flex: 0 0 auto; padding: 2px; }
.language-selector form { display: flex; }
.language-selector > span { color: var(--line); }
.language-selector button { background: transparent; border: 0; border-radius: 5px; color: var(--muted); min-height: 30px; min-width: 38px; padding: 4px 8px; }
.language-selector button.active { background: var(--panel-2); color: var(--text); font-weight: 900; }

.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); max-width: 100%; min-height: calc(100vh - 98px); min-width: 0; }
.nav-panel { border-right: 1px solid var(--line); min-width: 0; }
.nav-panel > summary { display: none; }
.sidebar { border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; padding: 18px 10px; }
.nav-panel .sidebar { border-right: 0; }
.sidebar a { border-radius: 8px; color: var(--muted); font-size: .9rem; min-width: 0; overflow-wrap: anywhere; padding: 9px 12px; text-decoration: none; }
.sidebar a:hover, .sidebar a.active { background: var(--panel-2); color: var(--text); }
.sidebar a.active { box-shadow: inset 3px 0 var(--accent); }
.workspace { max-width: 100%; min-width: 0; padding: 24px; }
.workspace > *, .card, .card > *, section, article, form { min-width: 0; }
footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .75rem; max-width: 100%; overflow-wrap: anywhere; padding: 10px 20px; text-align: right; }

.page-heading, .pair-header, .card header { align-items: flex-start; display: flex; flex-wrap: wrap; gap: 18px; justify-content: space-between; min-width: 0; }
.page-heading { margin-bottom: 18px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.45rem, 3vw, 2.35rem); letter-spacing: -.035em; }
h2 { font-size: 1.05rem; }
h3 { color: var(--muted); font-size: .9rem; margin-top: 20px; }
.eyebrow { color: var(--accent); font-size: .7rem; font-weight: 900; letter-spacing: .12em; margin-bottom: 5px; text-transform: uppercase; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); max-width: 100%; padding: 18px; }
.card-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); margin-bottom: 18px; min-width: 0; }
.metric-grid { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.metric-grid.compact { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
.metric { display: block; min-height: 122px; text-decoration: none; }
.metric:hover { border-color: #56645f; transform: translateY(-1px); }
.metric-label { color: var(--muted); font-size: .8rem; }
.metric-value { font-size: 1.65rem; font-weight: 800; margin-bottom: 5px; }
.metric-support { color: var(--muted); font-size: .72rem; overflow-wrap: anywhere; }
.inline-stats { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 12px; }
.text-link { color: var(--accent); font-weight: 700; }

.pair-header { margin-bottom: 18px; }
.pair-meta { align-items: flex-end; display: flex; flex-direction: column; gap: 6px; text-align: right; }
.pair-meta span { color: var(--muted); font-size: .79rem; max-width: 100%; overflow-wrap: anywhere; }
.pair-meta b { color: var(--text); }
.badge { border: 1px solid currentColor; border-radius: 999px; display: inline-block; font-size: .65rem; font-weight: 900; letter-spacing: .04em; padding: 4px 7px; text-transform: uppercase; }
.badge.good { color: var(--green); }
.badge.warn { color: var(--yellow); }
.badge.bad { color: var(--red); }

.artifact-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 14px; min-width: 0; }
.artifact { min-width: 0; }
.artifact h2 { overflow-wrap: anywhere; }
.artifact .version { color: var(--accent); font-family: ui-monospace, monospace; }
.preview { align-items: center; background: #0b0d0d; border-radius: 10px; display: flex; justify-content: center; margin: 12px 0; min-height: 260px; overflow: hidden; }
.preview video, .preview img { display: block; height: auto; max-height: 520px; max-width: 100%; object-fit: contain; width: auto; }
.preview-missing { color: var(--muted); font-size: .82rem; }
.copy-block { background: var(--panel-2); border-radius: 9px; margin: 8px 0; padding: 12px; }
.copy-block b { color: var(--accent); font-size: .75rem; text-transform: uppercase; }
.copy-block p { margin: 5px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.facts { display: grid; font-size: .82rem; grid-template-columns: minmax(0, 110px) minmax(0, 1fr); }
.facts dt { color: var(--muted); padding: 5px 0; }
.facts dd { margin: 0; overflow-wrap: anywhere; padding: 5px 0; }
.decision-grid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; margin-top: 14px; }
.decision-grid form { background: var(--panel-2); border-radius: 9px; padding: 10px; }
.artifact-tabs { display: none; }

label { color: var(--muted); display: flex; flex-direction: column; font-size: .78rem; font-weight: 700; gap: 5px; margin-bottom: 10px; }
input, textarea, select { background: #0d1110; border: 1px solid #3a4642; border-radius: 7px; color: var(--text); max-width: 100%; min-width: 0; padding: 9px; width: 100%; }
textarea { min-height: 76px; resize: vertical; }
.button { background: var(--panel-2); border: 1px solid #53615c; border-radius: 8px; color: var(--text); display: inline-block; font-weight: 800; max-width: 100%; overflow-wrap: anywhere; padding: 9px 12px; text-decoration: none; white-space: normal; }
.button.primary, .button.approve { background: var(--accent); border-color: var(--accent); color: #111; }
.button.reject { border-color: var(--red); color: var(--red); }
.button.small { font-size: .75rem; padding: 6px 8px; }
.action-row { margin-top: 14px; }
.governance-form { border-top: 1px solid var(--line); margin-top: 15px; padding-top: 15px; }

.table-card { margin-bottom: 18px; max-width: 100%; min-width: 0; }
.table-scroll { max-width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-inline: contain; width: 100%; }
table { border-collapse: collapse; font-size: .78rem; min-width: 100%; width: max-content; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .67rem; letter-spacing: .06em; text-transform: uppercase; }
td { overflow-wrap: anywhere; }
pre { background: #0c0f0e; border-radius: 8px; color: #cbd4cf; font-size: .72rem; max-height: 480px; max-width: 100%; overflow: auto; overflow-wrap: anywhere; padding: 12px; white-space: pre-wrap; }
details { margin-top: 10px; }
summary { cursor: pointer; font-weight: 800; }
.alert { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; padding: 10px; }
.alert.error { border-color: var(--red); color: var(--red); }
.alert.warning { border-color: var(--yellow); color: var(--yellow); }
.alert.info { border-color: #72a8ff; color: #b9d4ff; }
.critical-panel { border-color: #673737; margin-bottom: 18px; }
.money { font-size: 2rem; font-weight: 900; }
.label { color: var(--yellow); font-size: .6rem; font-weight: 900; }
.empty { color: var(--muted); text-align: center; }
.inventory-list { color: var(--muted); padding-left: 20px; }

.login-page { align-items: center; display: flex; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; max-width: 440px; padding: 32px; width: 100%; }
.login-card .button { width: 100%; }
.login-language { display: flex; justify-content: flex-end; margin-bottom: 18px; }
.security-note { color: var(--muted); font-size: .72rem; margin: 15px 0 0; }
#toast { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; bottom: 18px; display: none; max-width: 360px; padding: 12px; position: fixed; right: 18px; z-index: 20; }
#toast.visible { display: block; }
#toast.failed { border-color: var(--red); }

@media (max-width: 1080px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shell { grid-template-columns: 1fr; }
  .nav-panel { background: var(--bg); border-bottom: 1px solid var(--line); border-right: 0; }
  .nav-panel > summary { color: var(--text); cursor: pointer; display: list-item; font-weight: 800; min-height: 44px; padding: 12px 18px; }
  .sidebar { border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); padding: 8px; }
}

@media (min-width: 1081px) {
  .nav-panel:not([open]) > .sidebar { display: flex; }
}

@media (max-width: 820px) {
  .artifact-grid { display: block; }
  .artifact-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
  .artifact-tabs button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; color: var(--text); min-height: 44px; padding: 8px 12px; }
  [data-artifact-tab] { display: none; }
  [data-artifact-tab="REEL"] { display: block; }
  .artifact-grid.show-carousel [data-artifact-tab="REEL"] { display: none; }
  .artifact-grid.show-carousel [data-artifact-tab="CAROUSEL"] { display: block; }
}

@media (max-width: 700px) {
  .topbar { align-items: flex-start; }
  .brand strong, .founder { display: none; }
  .workspace { padding: 14px; }
  .metric-grid, .metric-grid.compact { grid-template-columns: 1fr 1fr; }
  .pair-header { flex-direction: column; }
  .pair-meta { align-items: flex-start; text-align: left; }
  .decision-grid { grid-template-columns: 1fr; }
  .preview { min-height: 180px; }
}

@media (max-width: 430px) {
  .metric-grid, .metric-grid.compact { grid-template-columns: 1fr; }
  .top-status { justify-content: flex-end; }
  .topbar { padding-inline: 12px; }
  .header-state { max-width: 150px; overflow-wrap: anywhere; text-align: center; }
  .login-card { padding: 22px; }
}
