:root {
  --bg: #eef2f1;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-strong: #ffffff;
  --line: rgba(15, 36, 41, 0.12);
  --text: #102126;
  --muted: #5f6f74;
  --accent: #126d79;
  --accent-strong: #0d5560;
  --accent-soft: rgba(18, 109, 121, 0.12);
  --danger: #b34d36;
  --success: #1a7f57;
  --warning: #9d6b16;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", Tahoma, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(18, 109, 121, 0.14), transparent 22%),
    radial-gradient(circle at top right, rgba(200, 166, 92, 0.14), transparent 18%),
    linear-gradient(180deg, #f6f8f7 0%, #e9efee 100%);
}
a { color: var(--accent-strong); text-decoration: none; }
button, input, select { font: inherit; }

.tool-shell {
  width: min(1320px, calc(100vw - 28px));
  margin: 16px auto 36px;
}

.tool-topbar, .card, .tabbar {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(18, 33, 38, 0.08);
}

.tool-topbar {
  padding: 22px 24px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.eyebrow, .card-eyebrow {
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

h1, h2, h3 { margin: 8px 0 0; }
h1 { font-size: clamp(2.1rem, 4vw, 3.2rem); line-height: 1.02; }
.subtle, .small-note, .minor, .table-note {
  color: var(--muted);
}

.status-strip, .inline-meta, .button-row, .tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-strip { align-items: center; justify-content: flex-end; }
.status-chip, .meta-pill, .status-link, .status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 8px 12px;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.8);
}

.status-link { background: transparent; }

.tabbar {
  margin-top: 14px;
  padding: 8px;
}

.tab {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab.is-active {
  background: var(--accent);
  color: #fff;
}

.tab-secondary {
  margin-left: auto;
}

.tab-panel {
  display: none;
  margin-top: 14px;
}

.tab-panel.is-active {
  display: block;
}

.panel-grid {
  display: grid;
  gap: 14px;
}

.upload-grid,
.export-grid {
  grid-template-columns: 1.05fr 0.95fr;
}

.fixture-grid {
  grid-template-columns: 0.88fr 1.12fr;
}

.card {
  padding: 20px;
}

.card-strong {
  background: var(--surface-strong);
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.stack { display: grid; gap: 14px; }
.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input, select {
  width: 100%;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

button, .button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid rgba(18, 109, 121, 0.18);
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  padding: 11px 15px;
  cursor: pointer;
}

.button-secondary, .table-action {
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  border: 1px solid var(--line);
}

.button-danger {
  background: rgba(179, 77, 54, 0.1);
  color: var(--danger);
  border: 1px solid rgba(179, 77, 54, 0.2);
}

.button-link, .table-link {
  background: rgba(18, 109, 121, 0.08);
  color: var(--accent-strong);
  border: 1px solid rgba(18, 109, 121, 0.18);
}

.button-row.compact { margin-top: 8px; }

.empty-state, .result-stack {
  border: 1px dashed rgba(18, 109, 121, 0.22);
  border-radius: 16px;
  background: rgba(18, 109, 121, 0.05);
  padding: 16px;
}

.result-stack {
  display: grid;
  gap: 8px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

th, td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(15, 36, 41, 0.08);
}

.empty-row { text-align: center; color: var(--muted); }
.action-cell { display: flex; flex-wrap: wrap; gap: 8px; }

.status-badge.completed { background: rgba(26, 127, 87, 0.14); color: var(--success); }
.status-badge.completed_with_warnings { background: rgba(157, 107, 22, 0.14); color: var(--warning); }
.status-badge.processing,
.status-badge.normalized { background: rgba(18, 109, 121, 0.12); color: var(--accent-strong); }
.status-badge.failed { background: rgba(179, 77, 54, 0.14); color: var(--danger); }

.fixture-list, .export-list, .review-list {
  display: grid;
  gap: 10px;
}

.fixture-item, .export-card {
  width: 100%;
  text-align: left;
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 14px 15px;
  background: rgba(255, 255, 255, 0.84);
}

.fixture-item {
  display: grid;
  gap: 5px;
  color: var(--text);
}

.fixture-item.is-active {
  border-color: rgba(18, 109, 121, 0.4);
  background: rgba(18, 109, 121, 0.1);
}

.export-card {
  display: grid;
  gap: 5px;
}

.review-header, .mode-head, .debug-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.editor-shell,
.editor-card,
.editor-grid,
.editor-status,
.mode-list,
.mode-item,
.mode-actions,
.editor-section-head,
.editor-action-bar,
.capability-editor,
.saved-exports {
  display: grid;
  gap: 12px;
}

.editor-status {
  margin-bottom: 14px;
}

.editor-message {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(18, 109, 121, 0.18);
  background: rgba(18, 109, 121, 0.08);
}

.editor-grid {
  grid-template-columns: 0.7fr 1.3fr;
}

.editor-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  padding: 16px;
}

.mode-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  padding: 12px;
}

.mode-item.is-active {
  border-color: rgba(18, 109, 121, 0.4);
  background: rgba(18, 109, 121, 0.1);
}

.mode-open {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 0;
}

.mode-open strong,
.mode-open span {
  display: block;
}

.mode-actions,
.editor-section-head,
.editor-action-bar {
  grid-auto-flow: column;
  justify-content: space-between;
  align-items: center;
}

.editor-action-bar {
  margin-top: 8px;
}

.editor-table table input,
.editor-table table select,
.capability-editor table input {
  min-width: 92px;
}

.row-selected {
  background: rgba(18, 109, 121, 0.07);
}

.validation-block {
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.validation-block.is-valid {
  border: 1px solid rgba(26, 127, 87, 0.18);
  background: rgba(26, 127, 87, 0.08);
}

.validation-block.is-invalid {
  border: 1px solid rgba(179, 77, 54, 0.18);
  background: rgba(179, 77, 54, 0.08);
}

.validation-block ul {
  margin: 10px 0 0;
  padding-left: 18px;
}

.validation-source {
  font-weight: 700;
}

.meta-pill-warning {
  color: var(--warning);
  background: rgba(157, 107, 22, 0.12);
}

.meta-pill-success {
  color: var(--success);
  background: rgba(26, 127, 87, 0.12);
}

.mode-block {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.7);
}

.compact-table table {
  min-width: 0;
}

.debug-block {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
  padding: 14px;
}

.debug-block summary {
  cursor: pointer;
  font-weight: 600;
}

.debug-row {
  margin: 12px 0;
}

pre {
  margin: 12px 0 0;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f5f8f8;
  color: var(--text);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.error-line {
  color: var(--danger);
}

.failure-details {
  border: 1px solid rgba(179, 77, 54, 0.18);
  border-radius: 14px;
  background: rgba(179, 77, 54, 0.06);
  padding: 10px 12px;
}

.failure-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--danger);
}

.failure-grid {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.failure-stack {
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.8);
}

@media (max-width: 1040px) {
  .upload-grid,
  .fixture-grid,
  .export-grid,
  .editor-grid,
  .grid-two,
  .tool-topbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .status-strip {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .tool-shell {
    width: min(100vw - 14px, 1320px);
    margin: 8px auto 24px;
  }

  .card,
  .tool-topbar {
    padding: 16px;
  }

  table { min-width: 720px; }
}
