:root {
  color-scheme: dark;
  --bg: #080d12;
  --ink: #eef6f4;
  --muted: #8fa19d;
  --panel: #101820;
  --panel-soft: #151f29;
  --panel-strong: #1b2733;
  --line: #263746;
  --brand: #37c28a;
  --brand-dark: #20a874;
  --accent: #f2a65a;
  --blue: #78b7ff;
  --ok: #37c28a;
  --warn: #f2a65a;
  --danger: #ff6b6b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: 76px;
  background:
    radial-gradient(circle at 20% 0%, rgba(55, 194, 138, 0.13), transparent 32%),
    radial-gradient(circle at 90% 15%, rgba(120, 183, 255, 0.11), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 18px;
  background: rgba(7, 12, 17, 0.94);
  color: #eef5f3;
  border-right: 1px solid var(--line);
}

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

.brand__mark {
  display: grid;
  width: 46px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #06110d;
  font-weight: 800;
}

.brand h1,
.hero h2,
.section h3,
.review-panel h3,
.metric p,
.section-copy {
  margin: 0;
}

.brand h1 {
  max-width: 160px;
  font-size: 0.95rem;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.steps {
  display: grid;
  gap: 6px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #dbe8e4;
  text-decoration: none;
}

.step span {
  display: grid;
  width: 22px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.74rem;
}

.step.is-active,
.step:hover {
  background: rgba(55, 194, 138, 0.16);
  border-color: rgba(55, 194, 138, 0.42);
}

.side-action {
  display: grid;
  gap: 10px;
}

.system-card {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.system-card p:last-child {
  margin: 10px 0 0;
  color: #b8c9c4;
  line-height: 1.35;
  font-size: 0.78rem;
}

.status-dot {
  display: flex;
  align-items: center;
  gap: 9px;
}

.status-dot span {
  width: 10px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--warn);
}

.status-dot.is-ready span {
  background: #37c28a;
}

.workspace {
  display: grid;
  gap: 12px;
  width: min(100%, 1520px);
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  padding: 16px;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(55, 194, 138, 0.13), rgba(120, 183, 255, 0.05) 55%, transparent),
    var(--panel);
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}

.hero h2 {
  max-width: 870px;
  font-size: 1.22rem;
  line-height: 1.16;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.hero-actions,
.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.86rem;
  text-decoration: none;
}

.button--primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #04110d;
}

.button--quiet:hover,
.icon-button:hover {
  border-color: #3d5669;
  background: var(--panel-strong);
}

.button--primary:hover {
  background: var(--brand-dark);
}

.flow-strip {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.flow-strip div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 24, 32, 0.76);
}

.flow-strip span {
  display: grid;
  width: 28px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: rgba(55, 194, 138, 0.16);
  color: var(--brand);
  font-weight: 900;
}

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

.metric {
  min-height: 66px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric span {
  display: block;
  color: var(--blue);
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.metric p {
  margin-top: 5px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.76rem;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  align-items: start;
  gap: 12px;
}

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

.section {
  padding: 14px;
}

.section__header,
.review-panel__header,
.sql-preview__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section h3,
.review-panel h3 {
  font-size: 1rem;
}

.section-copy {
  max-width: 560px;
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.82rem;
}

.search {
  display: grid;
  gap: 6px;
  width: min(100%, 280px);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.search input,
.field input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #0b1219;
  color: var(--ink);
}

.field input[readonly] {
  border-color: rgba(55, 194, 138, 0.35);
  background: rgba(55, 194, 138, 0.08);
  color: var(--brand);
}

.segment-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.segment-card {
  display: grid;
  gap: 7px;
  min-height: 112px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  text-align: left;
  color: var(--ink);
}

.segment-card[aria-pressed="true"] {
  border-color: rgba(55, 194, 138, 0.7);
  background: linear-gradient(180deg, rgba(55, 194, 138, 0.14), rgba(21, 31, 41, 0.98));
}

.segment-card strong {
  line-height: 1.25;
  font-size: 0.9rem;
}

.segment-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.28;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.segment-card small {
  color: var(--blue);
  font-size: 0.7rem;
  line-height: 1.35;
}

.segment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.check-mark {
  display: grid;
  width: 22px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  border: 1px solid #3d5669;
  color: transparent;
}

.segment-card[aria-pressed="true"] .check-mark {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
}

.review-panel {
  position: sticky;
  top: 12px;
  padding: 12px;
}

.guide-panel {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.guide-panel a {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 800;
}

.guide-panel a:hover {
  border-color: rgba(55, 194, 138, 0.45);
  background: rgba(55, 194, 138, 0.08);
}

.guide-panel span {
  display: grid;
  width: 20px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: rgba(55, 194, 138, 0.14);
  color: var(--brand);
  font-size: 0.68rem;
}

.badge {
  padding: 5px 8px;
  border: 1px solid rgba(55, 194, 138, 0.36);
  border-radius: 999px;
  background: rgba(55, 194, 138, 0.12);
  color: var(--brand);
  font-size: 0.68rem;
  font-weight: 900;
}

.review-list {
  display: grid;
  gap: 7px;
  margin: 12px 0;
}

.review-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.review-item span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.review-item strong {
  text-align: right;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.sql-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #05080c;
  color: #d7e5df;
}

.sql-preview__header {
  padding: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sql-preview .icon-button {
  min-height: 32px;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

pre {
  min-height: 150px;
  max-height: 240px;
  margin: 0;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
  font: 0.72rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.review-actions {
  margin-top: 14px;
}

.review-actions .button {
  flex: 1 1 150px;
}

.split {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  align-items: start;
  gap: 12px;
}

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

.state-select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.state-select summary {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  list-style: none;
  cursor: pointer;
}

.state-select summary::-webkit-details-marker {
  display: none;
}

.state-select summary span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.state-select summary strong {
  font-size: 0.86rem;
}

.state-select summary small {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-select summary b {
  color: var(--brand);
  font-size: 0.76rem;
}

.state-select[open] summary {
  border-bottom: 1px solid var(--line);
}

.state-select .state-grid {
  max-height: 188px;
  overflow: auto;
  padding: 8px;
}

.state-chip {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 900;
  font-size: 0.8rem;
}

.state-chip[aria-pressed="true"] {
  border-color: var(--blue);
  background: rgba(120, 183, 255, 0.14);
  color: #b8dbff;
}

.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.settings {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 150px 150px;
  gap: 6px;
}

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

.field {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.7rem;
}

.toggle {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  font-weight: 800;
  font-size: 0.74rem;
}

.toggle input {
  width: 15px;
  height: 15px;
  accent-color: var(--brand);
}

.chip-list,
.cnae-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chip,
.cnae-option {
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 6px;
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 900;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.66rem;
  max-width: 100%;
  background: rgba(55, 194, 138, 0.12);
  border-color: rgba(55, 194, 138, 0.36);
  color: #c5f4de;
}

.chip span {
  overflow-wrap: anywhere;
}

.chip button {
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(13, 70, 62, 0.1);
  color: var(--brand);
  font-weight: 900;
}

.cnae-option[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand);
  color: #06110d;
}

.cnae-options {
  align-items: stretch;
  max-height: 94px;
  overflow: auto;
  padding-right: 2px;
}

.cnae-option {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1 1 220px;
  min-height: 30px;
  border-radius: 8px;
  padding: 6px;
  text-align: left;
}

.cnae-option strong {
  flex: 0 0 58px;
  font-size: 0.72rem;
  line-height: 1;
}

.cnae-option span {
  color: var(--ink);
  font-size: 0.66rem;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cnae-option[aria-pressed="true"] span,
.cnae-option[aria-pressed="true"] small {
  color: #06110d;
}

.result {
  padding: 20px;
}

.result h3,
.result p {
  margin: 0;
}

.result h3 {
  font-size: 1.2rem;
}

.result p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.result-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.result-box span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.result-box strong {
  display: block;
  margin-top: 6px;
}

.download-link {
  display: grid;
  min-height: 38px;
  margin-top: 12px;
  place-items: center;
  border: 1px solid rgba(55, 194, 138, 0.42);
  border-radius: 8px;
  background: rgba(55, 194, 138, 0.12);
  color: var(--brand);
  font-size: 0.86rem;
  font-weight: 900;
  text-decoration: none;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid rgba(55, 194, 138, 0.36);
  border-radius: 8px;
  background: #102018;
  color: var(--brand);
  box-shadow: var(--shadow);
  font-weight: 800;
}

.quick-dock {
  position: fixed;
  right: 10px;
  top: 50%;
  z-index: 20;
  display: grid;
  gap: 6px;
  transform: translateY(-50%);
}

.quick-dock a {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  width: 42px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 13, 18, 0.9);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: width 140ms ease, border-color 140ms ease, background 140ms ease;
}

.quick-dock span {
  display: grid;
  flex: 0 0 22px;
  width: 22px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: rgba(55, 194, 138, 0.16);
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 900;
}

.quick-dock strong {
  white-space: nowrap;
  font-size: 0.76rem;
}

.quick-dock a:hover,
.quick-dock a:focus-visible {
  width: 132px;
  border-color: rgba(55, 194, 138, 0.45);
  background: rgba(16, 24, 32, 0.98);
}

.action-bar {
  position: fixed;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(55, 194, 138, 0.32);
  border-radius: 8px;
  background: rgba(8, 13, 18, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.action-bar.is-busy {
  border-color: rgba(242, 166, 90, 0.55);
}

.action-bar.is-busy strong {
  color: var(--accent);
}

.action-bar.is-success {
  border-color: rgba(55, 194, 138, 0.72);
}

.action-bar.is-error {
  border-color: rgba(255, 107, 107, 0.72);
}

.action-bar.is-error strong {
  color: var(--danger);
}

.action-bar div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.action-bar strong,
.action-bar span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-bar strong {
  color: var(--brand);
  font-size: 0.82rem;
}

.action-bar span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

@media (min-width: 1181px) {
  .quick-dock {
    display: none;
  }

  .action-bar {
    left: 316px;
  }
}

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

  .sidebar {
    position: relative;
    height: auto;
    gap: 10px;
    padding: 10px;
  }

  .workspace {
    padding-right: 58px;
  }

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

  .brand__mark {
    width: 34px;
  }

  .brand h1 {
    max-width: none;
    font-size: 0.86rem;
  }

  .side-action {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .side-action .eyebrow {
    display: none;
  }

  .system-card {
    margin-top: 0;
    padding: 9px;
  }

  .system-card .eyebrow,
  .system-card p:last-child {
    display: none;
  }

  .status-dot strong {
    font-size: 0.82rem;
  }

}

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

  .hero,
  .section__header,
  .split {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .hero,
  .section__header {
    display: grid;
  }

  .hero h2 {
    font-size: 1.1rem;
    max-width: 100%;
  }

  .flow-strip {
    grid-template-columns: 1fr 1fr;
  }

  .metrics,
  .segment-grid,
  .state-grid,
  .result-grid {
    grid-template-columns: 1fr 1fr;
  }

  .settings {
    grid-template-columns: 1fr 1fr;
  }

  .steps {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .hero-actions,
  .review-actions {
    display: grid;
    width: 100%;
  }

  .hero-actions .button,
  .review-actions .button,
  .side-action .button {
    width: 100%;
  }

  .metrics,
  .segment-grid,
  .state-grid,
  .result-grid,
  .steps {
    grid-template-columns: 1fr;
  }

  .settings {
    grid-template-columns: 1fr;
  }

  .section,
  .hero {
    padding: 12px;
  }

  .workspace {
    padding-right: 48px;
  }

  .flow-strip {
    grid-template-columns: 1fr;
  }

  .action-bar {
    grid-template-columns: 1fr;
  }
}

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

  .review-panel {
    position: static;
  }
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.login-shell {
  width: min(100%, 420px);
}

.login-panel {
  display: grid;
  gap: 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 24, 32, 0.96);
  box-shadow: var(--shadow);
}

.login-brand h1 {
  max-width: none;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form .button {
  width: 100%;
}

.login-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}
