:root {
  --accent: #2f6fed;
  --accent-strong: #1f57c7;
  --accent-soft: #eef5ff;
  --accent-line: #d8e7ff;
  --ink: #18212f;
  --muted: #657286;
  --soft: #8a95a6;
  --line: #dce2ea;
  --line-strong: #cbd4df;
  --panel: #ffffff;
  --page: #f6f8fb;
  --sidebar: #fbfcfe;
  --black: #0e1522;
  --radius: 8px;
  --shadow: 0 14px 34px rgba(24, 33, 47, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0;
}

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

[hidden] {
  display: none !important;
}

svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  stroke-width: 1.9;
}

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

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 8px;
}

.brand strong {
  display: block;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.1;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--soft);
  font-size: 0.72rem;
}

.side-nav {
  display: grid;
  gap: 4px;
}

.side-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 9px 10px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px;
}

.side-nav-item:hover,
.side-nav-item.is-active {
  color: var(--ink);
  background: #f0f4fa;
}

.side-nav-item.is-active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.side-nav-item svg {
  color: var(--accent);
}

.sidebar-section {
  display: grid;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.sidebar-heading,
.eyebrow,
.section-kicker,
.metric span,
.status-pill small,
.routing-label {
  color: var(--soft);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 54px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.status-pill svg {
  color: var(--soft);
}

.status-pill small,
.status-pill strong {
  display: block;
}

.status-pill strong {
  margin-top: 2px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.8rem;
  line-height: 1.25;
}

.status-pill[data-state="ready"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.status-pill[data-state="ready"] svg {
  color: var(--accent);
}

.status-pill[data-state="active"] {
  background: #f7f9fc;
  border-color: var(--line-strong);
}

.status-pill[data-state="attention"] {
  background: #f3f5f8;
  border-color: var(--line-strong);
}

.mini-output {
  margin: 0;
  padding: 10px;
  color: #334155;
  background: #f2f5f9;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: 600 0.72rem/1.5 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

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

.workspace-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.workspace-header h1 {
  margin: 3px 0 6px;
  color: var(--ink);
  font-size: 1.65rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.workspace-header p {
  max-width: 58rem;
  margin: 0;
  color: var(--muted);
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.soft-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 7px 10px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}

.soft-badge svg {
  color: var(--accent);
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 96px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric svg {
  width: 17px;
  height: 17px;
  color: var(--accent);
}

.metric strong {
  align-self: end;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.25;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.42fr);
  gap: 18px;
  align-items: start;
}

.primary-column,
.secondary-column {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.panel {
  min-width: 0;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  scroll-margin-top: 18px;
}

.compact-panel {
  padding: 16px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.compact-panel .panel-header {
  display: grid;
  gap: 6px;
}

.panel-header h2 {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.2;
}

.panel-header p {
  max-width: 34rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.section-kicker {
  color: var(--accent);
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-weight: 700;
}

.label-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.label-row svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

input,
textarea,
select {
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: 0;
}

input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 6px 10px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-weight: 700;
}

input::placeholder,
textarea::placeholder {
  color: #9aa5b5;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.12);
}

textarea {
  min-height: 118px;
  resize: vertical;
}

#review-corrections {
  min-height: 190px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.55;
}

.amount-field {
  max-width: 240px;
}

.api-key-field {
  margin-top: 16px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  min-height: 38px;
  max-width: 100%;
  padding: 9px 13px;
  color: #ffffff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 7px;
  cursor: pointer;
  font-weight: 750;
  line-height: 1.1;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

button:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  box-shadow: 0 8px 18px rgba(47, 111, 237, 0.16);
}

button:focus-visible {
  outline: 3px solid rgba(47, 111, 237, 0.18);
  outline-offset: 2px;
}

button:disabled {
  color: #ffffff;
  background: #9aa5b5;
  border-color: #9aa5b5;
  cursor: not-allowed;
}

.button-secondary {
  color: var(--ink);
  background: #ffffff;
  border-color: var(--line-strong);
}

.button-secondary:hover:not(:disabled) {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: var(--accent-line);
  box-shadow: none;
}

.button-secondary:disabled {
  color: var(--soft);
  background: #f4f6f9;
  border-color: var(--line);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 0;
}

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

.status-line {
  min-height: 1.25rem;
  margin: 14px 0 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

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

.routing-item {
  min-width: 0;
  padding: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 7px;
}

.routing-label {
  display: block;
  margin-bottom: 4px;
}

.routing-value {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
}

.output {
  width: 100%;
  min-height: 52px;
  max-height: 420px;
  margin: 14px 0 0;
  padding: 12px;
  overflow: auto;
  color: #273449;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: 600 0.78rem/1.55 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.compact-panel .output {
  max-height: 300px;
}

.use-case-list {
  display: grid;
  gap: 10px;
}

.use-case {
  display: flex;
  gap: 10px;
  padding: 11px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.use-case svg {
  margin-top: 2px;
  color: var(--accent);
}

.use-case h3 {
  margin: 0 0 3px;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.2;
}

.use-case p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

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

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

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

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

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

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

  .sidebar-section {
    padding-top: 12px;
  }

  .workspace {
    padding: 16px;
  }

  .workspace-header,
  .panel-header,
  .form-grid,
  .routing-summary {
    grid-template-columns: 1fr;
    display: grid;
  }

  .header-meta {
    justify-content: flex-start;
  }

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

  .amount-field {
    max-width: none;
  }

  .actions,
  button {
    width: 100%;
  }
}
