:root {
  color-scheme: dark;
  --bg: #0b1117;
  --bg-elevated: #101923;
  --surface: rgba(16, 25, 35, 0.84);
  --surface-strong: rgba(19, 31, 43, 0.96);
  --surface-soft: rgba(30, 43, 57, 0.72);
  --text: #edf3f9;
  --muted: #98a8ba;
  --line: rgba(137, 169, 201, 0.18);
  --line-strong: rgba(137, 169, 201, 0.26);
  --accent: #3fd0c9;
  --accent-strong: #22b8b0;
  --accent-soft: rgba(63, 208, 201, 0.14);
  --accent-glow: rgba(63, 208, 201, 0.22);
  --warning: #ff9f7f;
  --warning-soft: rgba(133, 45, 24, 0.28);
  --success: #8de3a9;
  --success-soft: rgba(26, 82, 48, 0.32);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 47px,
      rgba(115, 149, 185, 0.05) 47px,
      rgba(115, 149, 185, 0.05) 48px
    ),
    linear-gradient(180deg, rgba(12, 18, 25, 0.12), rgba(12, 18, 25, 0.6)),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.45;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1320px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.topbar,
.workbench {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 28px;
  margin-bottom: 20px;
  align-items: end;
  background:
    linear-gradient(135deg, rgba(63, 208, 201, 0.1), rgba(63, 208, 201, 0)),
    var(--surface-strong);
  border-color: var(--line-strong);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.title-block h1,
.section-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.title-block h1 {
  font-size: clamp(1.95rem, 2vw, 2.7rem);
  line-height: 1.05;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 12px;
  min-width: min(480px, 100%);
}

.status-cell,
.metric {
  background: linear-gradient(180deg, rgba(18, 28, 38, 0.96), rgba(15, 23, 33, 0.92));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  min-height: 74px;
  padding: 12px 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.status-label,
.metric dt,
.meta-line,
.file-name {
  color: var(--muted);
  font-size: 0.88rem;
}

.status-cell strong,
.metric dd {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(340px, 0.85fr);
  gap: 20px;
}

.inputs,
.query {
  padding: 22px 22px 24px;
}

.results {
  grid-column: 1 / -1;
  padding: 22px;
}

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

.field-block + .field-block {
  margin-top: 18px;
}

.field-label-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.field-label {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(9, 14, 20, 0.58);
}

.segment {
  background: transparent;
  border: 0;
  min-height: 42px;
  padding: 0 16px;
  color: var(--muted);
}

.segment.is-active {
  background: linear-gradient(180deg, rgba(63, 208, 201, 0.3), rgba(63, 208, 201, 0.18));
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(63, 208, 201, 0.24);
}

.meta-line {
  margin-top: 8px;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  min-height: 42px;
}

textarea,
.number-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 20, 0.76);
  color: var(--text);
}

textarea {
  min-height: 154px;
  padding: 12px 14px;
  resize: vertical;
}

textarea::placeholder,
.number-input::placeholder {
  color: #657487;
}

textarea:focus,
.number-input:focus {
  outline: none;
  border-color: rgba(63, 208, 201, 0.56);
  box-shadow: 0 0 0 4px rgba(63, 208, 201, 0.12);
}

#rovText {
  min-height: 116px;
}

.number-input {
  min-height: 48px;
  padding: 0 14px;
}

.query-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: end;
}

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

.metrics dt {
  margin: 0;
}

.metrics dd {
  margin: 6px 0 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.primary,
.secondary,
.ghost {
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #062328;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(34, 184, 176, 0.24);
}

.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(34, 184, 176, 0.3);
}

.secondary {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-color: var(--line);
}

.secondary:hover:not(:disabled),
.ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

.error-banner {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 159, 127, 0.26);
  background: var(--warning-soft);
  color: var(--warning);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9, 14, 20, 0.82);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

thead th {
  background: rgba(17, 27, 37, 0.98);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: left;
  padding: 12px 14px;
}

tbody td {
  border-top: 1px solid rgba(137, 169, 201, 0.12);
  padding: 13px 14px;
  vertical-align: top;
  word-break: break-word;
}

tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.path-cell {
  font-family: "Cascadia Code", Consolas, "SFMono-Regular", monospace;
  font-size: 0.92rem;
  color: #d6e2ed;
}

.rov-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--success-soft);
  color: var(--success);
  font-size: 0.86rem;
}

.rov-pill.is-invalid {
  background: var(--warning-soft);
  color: var(--warning);
}

.result-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(63, 208, 201, 0.22);
  background: rgba(63, 208, 201, 0.08);
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state {
  margin-top: 16px;
  min-height: 56px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 8px;
  background: rgba(17, 27, 37, 0.92);
  color: var(--muted);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(63, 208, 201, 0.14);
}

.is-hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .status-grid {
    min-width: 0;
  }

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

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 18px, 1320px);
    padding-top: 10px;
  }

  .topbar,
  .inputs,
  .query,
  .results {
    padding: 16px;
  }

  .status-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .segmented {
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .section-head {
    flex-wrap: wrap;
  }
}
