:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #111827;
  --muted: #5f6b7a;
  --line: #d8dee8;
  --strong: #111827;
  --blue: #1f6feb;
  --green: #16855c;
  --red: #b42318;
  --amber: #9a6700;
  --shadow: 0 18px 48px rgba(17, 24, 39, 0.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101418;
  --surface: #171d23;
  --surface-2: #202832;
  --text: #eef2f6;
  --muted: #a8b3c2;
  --line: #33404d;
  --strong: #ffffff;
  --blue: #69a5ff;
  --green: #55c28f;
  --red: #ff8a7a;
  --amber: #f3c969;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand-row {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  align-items: center;
}

.brand-row h1,
.topbar h2,
.section-head h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand-map {
  width: 52px;
  height: 52px;
}

.eyebrow,
.label {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-button,
.icon-button,
.action-button,
.work-row {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.nav-button {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border-radius: 8px;
  text-align: left;
}

.nav-button:hover,
.nav-button.is-active {
  background: var(--surface-2);
  border-color: var(--line);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--bg);
  color: var(--blue);
  font-weight: 800;
}

.nav-count {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.sidebar-note p:last-child {
  margin: 0;
  font-size: 13px;
  color: var(--strong);
}

.workspace {
  padding: 24px;
  display: grid;
  align-content: start;
  gap: 18px;
}

.topbar,
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.topbar {
  min-height: 52px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--strong);
  font-weight: 800;
}

.icon-button:hover {
  background: var(--surface-2);
}

.action-button {
  width: fit-content;
  min-height: 40px;
  margin-top: 8px;
  padding: 0 14px;
  border-radius: 8px;
  border-color: var(--line);
  background: var(--blue);
  color: #ffffff;
  font-weight: 800;
}

.action-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.action-button:hover {
  filter: brightness(0.96);
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 10px;
  max-width: 420px;
}

.login-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-label input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  text-transform: none;
}

.login-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.secondary-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.secondary-link:hover {
  background: var(--surface-2);
}

.system-strip,
.metrics-grid,
.review-grid,
.automation-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.system-strip > div,
.metric,
.review-item,
.automation-item,
.focus-panel,
.view-panel,
.detail-surface,
.command-visual {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.system-strip > div,
.metric,
.review-item,
.automation-item {
  padding: 14px;
  min-height: 82px;
}

.system-strip strong,
.metric strong {
  display: block;
  color: var(--strong);
  font-size: 20px;
  line-height: 1.2;
}

.command-layout {
  display: grid;
  grid-template-columns: minmax(280px, 38%) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.command-visual {
  display: grid;
  place-items: center;
  min-height: 390px;
  padding: 24px;
  background: #101418;
}

.command-visual img {
  width: min(100%, 440px);
  height: auto;
}

.command-stack {
  display: grid;
  gap: 18px;
}

.focus-panel,
.view-panel {
  padding: 18px;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.state-pill.ok {
  color: var(--green);
  border-color: color-mix(in srgb, var(--green), var(--line) 55%);
}

.state-pill.review {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber), var(--line) 55%);
}

.next-action {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.next-action h4,
.review-item h4,
.automation-item h4 {
  margin: 0;
  font-size: 15px;
}

.next-action p,
.review-item p,
.automation-item p,
.work-row p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.split-layout {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 14px;
}

.list-surface {
  display: grid;
  gap: 8px;
}

.work-row {
  min-height: 86px;
  padding: 12px;
  border-color: var(--line);
  border-radius: 8px;
  background: var(--bg);
  text-align: left;
}

.work-row.is-selected {
  border-color: var(--blue);
  background: var(--surface-2);
}

.work-row strong {
  display: block;
  font-size: 14px;
}

.work-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.detail-surface {
  margin: 0;
  min-height: 380px;
  padding: 14px;
  overflow: auto;
  color: var(--text);
  white-space: pre-wrap;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  box-shadow: none;
}

.review-grid,
.automation-grid {
  margin-top: 18px;
}

.change-flow,
.evidence-list {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.flow-step,
.evidence-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 62px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.flow-step strong,
.evidence-row strong {
  color: var(--strong);
}

.flow-step p,
.evidence-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.is-hidden {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .command-layout,
  .split-layout {
    grid-template-columns: 1fr;
  }

  .system-strip,
  .metrics-grid,
  .review-grid,
  .automation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-list,
  .system-strip,
  .metrics-grid,
  .review-grid,
  .automation-grid {
    grid-template-columns: 1fr;
  }

  .flow-step,
  .evidence-row {
    grid-template-columns: 1fr;
  }
}
