:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --line: #d5e0ec;
  --line-strong: #c3d0df;
  --ink: #27405d;
  --muted: #6e8196;
  --navy: #1f4c7a;
  --navy-soft: #ecf4fb;
  --success: #2d7f53;
  --success-soft: #edf8f1;
  --warning: #a76f00;
  --warning-soft: #fff7e3;
  --neutral-soft: #eef3f8;
  --shadow: 0 8px 22px rgba(27, 49, 74, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Aptos", "Segoe UI", "Calibri", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(31, 76, 122, 0.05), transparent 80px),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
}

.app-shell {
  width: min(1340px, calc(100% - 18px));
  margin: 0 auto;
  padding: 10px 0 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.topbar-copy {
  min-width: 0;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(1.3rem, 2.5vw, 1.8rem);
  line-height: 1.06;
}

h2 {
  font-size: 0.98rem;
  margin-bottom: 3px;
}

.subheading,
.panel-header p,
.small-note,
.empty-panel p,
.empty-state,
.meta-chip,
.helper-chip,
.results-meta-secondary,
.token-pill span,
.result-section-header span {
  color: var(--muted);
  line-height: 1.35;
}

.topbar-meta,
.helper-list,
.form-actions,
.sample-row,
.export-form,
.results-filters,
.token-strip,
.results-meta-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-chip,
.helper-chip,
.token-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  font-size: 0.76rem;
}

.layout,
.result-sections {
  display: grid;
  gap: 10px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 9px;
}

.search-form {
  display: grid;
  gap: 9px;
}

.mode-switch {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 7px;
}

.mode-option {
  cursor: pointer;
}

.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-option span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 114px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 600;
  transition: 0.18s ease;
}

.mode-option input:checked + span {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.field-label {
  font-weight: 700;
  font-size: 0.88rem;
}

textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font: inherit;
  line-height: 1.45;
  padding: 10px 12px;
}

textarea:focus {
  outline: none;
  border-color: rgba(31, 76, 122, 0.65);
  box-shadow: 0 0 0 3px rgba(31, 76, 122, 0.1);
}

.form-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.button,
.sample-button,
.filter-button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 7px 11px;
  text-decoration: none;
  transition: 0.18s ease;
}

.button:hover,
.sample-button:hover,
.filter-button:hover {
  transform: translateY(-1px);
}

.button-primary {
  background: var(--navy);
  color: #fff;
}

.button-secondary,
.sample-button,
.filter-button {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--ink);
}

.error-panel {
  background: #fff7f7;
  border-color: #efcdcd;
}

.results-topbar {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.results-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.results-meta-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.results-meta-main strong {
  font-size: 1.2rem;
  color: var(--navy);
}

.results-meta-secondary span {
  padding: 3px 0;
}

.results-filters {
  align-items: center;
}

.filter-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
}

.filter-button span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(39, 64, 93, 0.08);
  font-size: 0.72rem;
}

.filter-button.is-active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.filter-button.is-active span {
  background: rgba(255, 255, 255, 0.18);
}

.compact-export {
  gap: 6px;
}

.token-strip {
  margin-bottom: 8px;
}

.token-pill {
  padding: 4px 8px;
  max-width: 100%;
}

.token-pill strong {
  color: var(--ink);
}

.token-pill-matched {
  background: var(--success-soft);
  border-color: #cfe9d9;
}

.token-pill-not_found {
  background: var(--warning-soft);
  border-color: #eedfb4;
}

.token-pill-invalid {
  background: var(--neutral-soft);
}

.result-type-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fcfdff;
  overflow: hidden;
}

.result-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(31, 76, 122, 0.06), rgba(31, 76, 122, 0.02));
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow: hidden;
}

.compact-table-wrap {
  overflow-x: auto;
}

.result-table,
.detail-table {
  width: 100%;
  border-collapse: collapse;
}

.result-table {
  table-layout: fixed;
}

.result-table th,
.result-table td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 0.84rem;
}

.result-table th {
  background: var(--navy);
  color: #fff;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.summary-row {
  cursor: pointer;
}

.summary-row td {
  background: #fff;
}

.summary-row:nth-child(4n + 1) td {
  background: #fbfdff;
}

.summary-row:hover td {
  background: #f1f7fd;
}

.summary-row.is-open td {
  background: #eef5fb;
}

.result-table th:nth-child(1),
.result-table td:nth-child(1) {
  width: 12%;
}

.result-table th:nth-child(2),
.result-table td:nth-child(2) {
  width: 12%;
}

.result-table th:nth-child(3),
.result-table td:nth-child(3) {
  width: 11%;
}

.result-table th:nth-child(4),
.result-table td:nth-child(4) {
  width: 32%;
}

.result-table th:nth-child(5),
.result-table td:nth-child(5) {
  width: 11%;
}

.result-table th:nth-child(6),
.result-table td:nth-child(6) {
  width: 12%;
}

.result-table th:nth-child(7),
.result-table td:nth-child(7) {
  width: 10%;
}

.truncate-cell {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  white-space: normal;
  line-height: 1.35;
}

.detail-row[hidden] {
  display: none;
}

.detail-row td {
  padding: 0;
  background: #fff;
}

.detail-panel {
  padding: 10px;
  background: #f7fbff;
}

.detail-table th,
.detail-table td {
  border: 1px solid var(--line);
  padding: 7px 9px;
  text-align: left;
  vertical-align: top;
  font-size: 0.82rem;
}

.detail-table th {
  width: 210px;
  background: #f0f5fa;
  color: var(--navy);
  font-weight: 700;
}

.empty-state,
.empty-panel {
  text-align: center;
}

.empty-state {
  padding: 18px;
  background: var(--panel-soft);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
}

@media (max-width: 980px) {
  .topbar,
  .panel-header,
  .form-footer,
  .results-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-meta,
  .compact-export,
  .results-filters,
  .results-meta-secondary {
    width: 100%;
  }

  .detail-table th {
    width: 150px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 10px, 100%);
    padding-top: 8px;
  }

  .panel {
    padding: 10px;
  }

  .mode-option span,
  .button,
  .sample-button,
  .filter-button {
    width: 100%;
    justify-content: center;
  }

  .form-actions,
  .sample-row,
  .compact-export {
    width: 100%;
  }

  .result-table {
    min-width: 760px;
  }
}
