:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-2: #eef5f3;
  --surface-3: #f7f1e6;
  --text: #202531;
  --muted: #667085;
  --line: #d8dee5;
  --accent: #087d75;
  --accent-2: #b9365e;
  --accent-3: #d18a00;
  --good: #18855d;
  --bad: #b42318;
  --shadow: 0 16px 40px rgba(23, 34, 48, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: #202531;
  color: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: #087d75;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

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

.nav-button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: transparent;
  color: rgba(255, 255, 255, 0.74);
  text-align: left;
}

.nav-button:hover,
.nav-button.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.sidebar-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(209, 138, 0, 0.38);
  border-radius: 8px;
  background: rgba(209, 138, 0, 0.12);
}

.sidebar-note span,
.sidebar-note strong {
  display: block;
}

.sidebar-note span {
  color: rgba(255, 255, 255, 0.64);
  font-size: 12px;
  text-transform: uppercase;
}

.sidebar-note strong {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.4;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-heading,
.preview-header,
.form-actions,
.section-actions,
.topbar-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 22px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 17px;
}

h4 {
  margin-bottom: 8px;
  font-size: 13px;
}

.lede,
.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.topbar-actions,
.section-actions,
.form-actions {
  gap: 10px;
  flex-wrap: wrap;
}

.lock-badge {
  display: inline-grid;
  min-height: 40px;
  place-items: center;
  border: 1px solid rgba(185, 54, 94, 0.26);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff3f6;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

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

.button.secondary {
  background: #ffffff;
  color: var(--accent);
}

.button.ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--text);
}

.button.danger {
  border-color: var(--bad);
  background: #fff7f6;
  color: var(--bad);
}

.command-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.command-strip article,
.unit-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.command-strip article {
  padding: 16px;
  border-top: 3px solid var(--accent);
}

.command-strip article:nth-child(2) {
  border-top-color: var(--accent-2);
}

.command-strip article:nth-child(3) {
  border-top-color: var(--accent-3);
}

.command-strip article:nth-child(4) {
  border-top-color: #315a9f;
}

.command-strip span,
.unit-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.command-strip strong {
  display: block;
  margin-top: 8px;
  font-size: 17px;
}

.command-strip p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.unit-section {
  margin-bottom: 22px;
}

.unit-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.unit-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.unit-card strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
}

.unit-card p {
  margin: 0;
  min-height: 44px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.unit-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.unit-card-meta span {
  min-height: 26px;
  border-radius: 99px;
  padding: 6px 10px;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 12px;
}

.metric-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-panel {
  padding: 16px;
}

.metric-panel span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-panel strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.section-heading {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.page-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(420px, 1.25fr) minmax(260px, 0.8fr);
  gap: 14px;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.inventory-panel,
.preview-panel {
  position: sticky;
  top: 20px;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
  margin-bottom: 12px;
}

label,
.schema-fieldset {
  display: grid;
  gap: 7px;
}

label span,
.schema-fieldset legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #ffffff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(8, 125, 117, 0.18);
  outline-offset: 1px;
}

.page-list {
  display: grid;
  gap: 8px;
  max-height: 68vh;
  overflow: auto;
  padding-right: 2px;
}

.page-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
}

.page-item:hover,
.page-item.is-selected {
  border-color: var(--accent);
  background: var(--surface-2);
}

.page-item strong,
.page-item span {
  display: block;
}

.page-item span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.page-item .page-meta-line {
  color: var(--accent);
  font-weight: 700;
}

.score-pill {
  display: inline-grid;
  min-width: 58px;
  min-height: 26px;
  place-items: center;
  margin-top: 10px;
  border-radius: 99px;
  background: #e9f6f0;
  color: var(--good);
  font-size: 12px;
  font-weight: 800;
}

.score-pill.warn {
  background: #fff4db;
  color: #9a6700;
}

.score-pill.bad {
  background: #fff0ef;
  color: var(--bad);
}

.gate-pill {
  display: inline-grid;
  min-width: 74px;
  min-height: 26px;
  place-items: center;
  margin-top: 10px;
  border-radius: 99px;
  background: #e9f6f0;
  color: var(--good);
  font-size: 12px;
  font-weight: 800;
}

.gate-pill.blocked {
  background: #fff0ef;
  color: var(--bad);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.choice-field {
  position: relative;
}

.choice-field select {
  min-height: 48px;
  border-color: rgba(8, 125, 117, 0.32);
  background:
    linear-gradient(90deg, rgba(8, 125, 117, 0.08), rgba(255, 255, 255, 0) 46%),
    #ffffff;
  color: var(--text);
  font-weight: 800;
}

.choice-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.type-choice-panel {
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
}

.choice-card {
  display: grid;
  min-height: 118px;
  gap: 7px;
  align-content: start;
  border: 1px solid rgba(8, 125, 117, 0.18);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  box-shadow: 0 1px 0 rgba(11, 18, 32, 0.04);
}

.choice-card:hover,
.choice-card.is-selected {
  border-color: var(--accent);
  background:
    linear-gradient(135deg, rgba(8, 125, 117, 0.1), rgba(255, 255, 255, 0) 54%),
    #ffffff;
}

.choice-card.is-selected {
  box-shadow: inset 0 0 0 2px rgba(8, 125, 117, 0.16);
}

.choice-card span,
.choice-card strong,
.choice-card em {
  display: block;
}

.choice-card span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.choice-card strong {
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.choice-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.routing-intelligence {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.routing-intelligence article {
  border: 1px solid rgba(8, 125, 117, 0.18);
  border-radius: 8px;
  padding: 13px;
  background: #f7fbfa;
}

.routing-intelligence article:nth-child(2) {
  border-color: rgba(185, 54, 94, 0.18);
  background: #fff8fa;
}

.routing-intelligence span,
.routing-intelligence strong,
.routing-intelligence em {
  display: block;
}

.routing-intelligence span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.routing-intelligence strong {
  margin-top: 6px;
  font-size: 15px;
}

.routing-intelligence p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.routing-intelligence em {
  margin-top: 8px;
  color: var(--accent);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.wide {
  grid-column: 1 / -1;
}

.schema-fieldset {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 16px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.schema-fieldset legend {
  padding: 0 6px;
}

.schema-fieldset label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}

.schema-fieldset input {
  width: auto;
}

.form-actions {
  margin-top: 16px;
}

.preview-header {
  justify-content: space-between;
  margin-bottom: 14px;
}

.preview-header span {
  display: inline-grid;
  min-width: 68px;
  min-height: 32px;
  place-items: center;
  border-radius: 99px;
  background: #e9f6f0;
  color: var(--good);
  font-weight: 800;
}

.serp-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.serp-preview span {
  display: block;
  color: var(--good);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.serp-preview strong {
  display: block;
  margin-top: 6px;
  color: #1a0dab;
  font-size: 18px;
  line-height: 1.3;
}

.serp-preview p {
  margin: 7px 0 0;
  color: #4d5156;
  line-height: 1.45;
}

.compact-block {
  margin-top: 14px;
}

.compact-block p,
.compact-block ul {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.compact-block ul {
  padding-left: 18px;
}

.code-output {
  min-height: 360px;
  max-height: 72vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #111827;
  color: #e5edf6;
  line-height: 1.55;
  white-space: pre-wrap;
}

.robots-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.robots-form {
  display: grid;
  gap: 12px;
}

.audit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.audit-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.audit-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.audit-card h3 {
  margin-bottom: 4px;
}

.audit-card p {
  margin-bottom: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.audit-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.5;
}

.audit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.rule-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 14px;
  margin-bottom: 22px;
}

.rule-hero {
  border: 1px solid rgba(8, 125, 117, 0.28);
  border-radius: 8px;
  padding: 22px;
  background: #e9f6f0;
  box-shadow: var(--shadow);
}

.rule-hero span {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.rule-hero strong {
  display: block;
  max-width: 820px;
  margin-top: 10px;
  font-size: 26px;
  line-height: 1.15;
}

.rule-hero p {
  max-width: 760px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.policy-list {
  margin: 12px 0 0;
  padding-left: 18px;
  line-height: 1.55;
}

.compact-heading {
  margin-top: 8px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 40px));
  border-radius: 8px;
  padding: 12px 14px;
  background: #202531;
  color: #ffffff;
  box-shadow: var(--shadow);
}

@media (max-width: 1320px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .page-layout {
    grid-template-columns: 1fr;
  }

  .command-strip,
  .unit-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .inventory-panel,
  .preview-panel {
    position: static;
  }

  .page-list {
    max-height: 340px;
  }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .workspace {
    padding: 18px;
  }

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

  .metrics-grid,
  .command-strip,
  .unit-board,
  .audit-grid,
  .rule-layout,
  .robots-layout,
  .form-grid,
  .choice-panel,
  .routing-intelligence,
  .schema-fieldset {
    grid-template-columns: 1fr;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }
}
