:root {
  color-scheme: light;
  --page: #ffffff;
  --sidebar: #eaf6ff;
  --sidebar-strong: #dcefff;
  --top: #d7eef7;
  --text: #101820;
  --muted: #72808c;
  --line: #e5edf3;
  --field: #ffffff;
  --accent: #0b74de;
  --accent-dark: #075aaa;
  --danger: #b42318;
  --danger-bg: #fff2f0;
  --success: #087568;
  --code: #111820;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--sidebar);
  border-right: 1px solid #d7e9f6;
  padding: 14px 10px;
}

.brand {
  display: none;
  align-items: center;
  gap: 7px;
  height: 38px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  line-height: 1;
}

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

.side-nav p {
  padding: 0 8px 4px;
  color: #5f788b;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 28px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #243746;
  padding: 0 8px;
  text-align: left;
  text-decoration: none;
  font-size: 12px;
  font-weight: 650;
}

.side-link span {
  width: 8px;
  height: 8px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
}

.side-link.active,
.side-link:hover {
  background: #cfe7ff;
  color: #075aaa;
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding: 8px;
}

.settings-card {
  display: grid;
  gap: 5px;
  border-top: 1px solid #c7e0f4;
  padding-top: 10px;
}

.settings-card label {
  color: #5f788b;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.settings-card select {
  min-height: 30px;
  width: 100%;
  border: 1px solid #c7dceb;
  border-radius: 4px;
  background: #fff;
  color: #243746;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 750;
}

.sidebar-footer a {
  color: #405363;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

.main-view {
  min-width: 0;
  background: #fff;
}

.top-strip {
  height: 12px;
  background: var(--top);
}

.hero {
  width: min(760px, calc(100% - 36px));
  margin: 130px auto 18px;
  text-align: center;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  font-size: 20px;
  line-height: 1.25;
  font-weight: 800;
}

.hero-copy {
  width: min(620px, 100%);
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1080px);
  gap: 0;
  align-items: start;
  justify-content: center;
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto 42px;
}

.input-stack {
  display: grid;
  gap: 12px;
  width: 100%;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f7fafc;
  padding: 3px;
}

.mode-button,
.primary-button,
.secondary-button {
  min-height: 32px;
  border: 0;
  border-radius: 4px;
  transition: background 160ms ease, color 160ms ease, border 160ms ease;
}

.mode-button {
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mode-button.active {
  background: #111820;
  color: #fff;
}

.panel,
.json-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(28, 42, 55, 0.06);
}

.panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.test-data-select {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: #243746;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

h2 {
  font-size: 14px;
  font-weight: 800;
}

h3 {
  font-size: 13px;
  font-weight: 800;
}

.field-section + .field-section {
  margin-top: 20px;
}

.section-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.status-text,
.section-title span {
  color: var(--muted);
  font-size: 11px;
}

.status-text {
  margin-top: 4px;
  line-height: 1.35;
}

.status-text.success {
  color: var(--success);
}

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

.toggle-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  color: #243746;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

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

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

.field {
  min-width: 0;
}

.field label {
  display: block;
  min-height: 20px;
  margin-bottom: 5px;
  color: #243746;
  font-size: 12px;
  font-weight: 750;
}

.field strong {
  color: var(--danger);
  font-size: 13px;
  line-height: 1;
}

.field input,
.field select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--field);
  padding: 8px 10px;
  color: var(--text);
  outline: none;
  font-size: 13px;
}

.choice-with-custom {
  display: grid;
  gap: 8px;
}

.field select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 15px,
    calc(100% - 12px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 116, 222, 0.12);
}

.field .hint {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.primary-button {
  background: #111820;
  color: #fff;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 800;
}

.primary-button:hover {
  background: #25313b;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: #243746;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 800;
}

.secondary-button:hover {
  background: #f3f8fc;
}

.actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 176px;
  border: 1.5px dashed #bad0df;
  border-radius: 6px;
  background: #f8fbfd;
  padding: 24px;
  text-align: center;
  cursor: pointer;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.drop-title {
  display: block;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
}

.drop-copy {
  display: block;
  max-width: 420px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.upload-meta {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.errors {
  margin-top: 14px;
  border: 1px solid #ffc9c4;
  border-radius: 4px;
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
}

.rules-page {
  margin-top: 0;
}

.rules-editor {
  display: grid;
  gap: 20px;
}

.rule-group {
  display: grid;
  gap: 10px;
}

.rule-group h3 {
  color: var(--accent-dark);
}

.rules-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.rules-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px) 94px;
  border-top: 1px solid var(--line);
}

.rules-row:first-child {
  border-top: 0;
}

.rules-row-heading {
  background: #f5f9fc;
  color: #1d5f9e;
  font-size: 12px;
  font-weight: 800;
}

.rules-row > div,
.rules-row label {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 9px;
  border-left: 1px solid var(--line);
}

.rules-row > div:first-child,
.rules-row label:first-child {
  border-left: 0;
}

.rules-row label span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.rules-row input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
}

.rule-row-actions {
  display: grid;
  align-items: end;
}

.delete-rule-button {
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 32px;
  border: 1px solid #ffc9c4;
  border-radius: 4px;
  background: #fff;
  color: var(--danger);
  padding: 0;
}

.delete-rule-button:hover {
  background: var(--danger-bg);
}

.delete-rule-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.add-rule-button {
  justify-self: start;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: #243746;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.add-rule-button:hover {
  background: #f3f8fc;
}

.json-panel {
  overflow: hidden;
  background: #f8fafc;
}

.json-panel .panel-heading {
  margin: 0;
  padding: 14px 14px 12px;
  background: #fff;
}

.result-output {
  min-height: 620px;
  overflow: auto;
  padding: 0;
}

.result-page {
  width: min(850px, calc(100% - 48px));
  margin: 10px auto 56px;
}

.result-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.result-page .json-panel {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.result-page .json-panel > .panel-heading {
  display: none;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 557px) 267px;
  gap: 24px;
  align-items: start;
}

.result-main-column {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.input-review-card,
.estimate-card,
.confidence-card,
.providers-card,
.empty-result {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 26px 23px 24px;
}

.input-review-card summary,
.estimate-card h2,
.confidence-card h2,
.providers-card h2,
.empty-result h2 {
  color: #172033;
  font-size: 24px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: 0;
}

.input-review-card {
  padding: 0;
}

.input-review-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 0 23px;
  list-style: none;
  cursor: pointer;
}

.input-review-card summary::-webkit-details-marker {
  display: none;
}

.input-review-chevron {
  color: #64748b;
  font-size: 18px;
  transform: rotate(0deg);
  transition: transform 160ms ease;
}

.input-review-card[open] .input-review-chevron {
  transform: rotate(180deg);
}

.input-review-body {
  padding: 0 23px 24px;
}

.input-review-id {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-bottom: 16px;
  border-radius: 3px;
  background: #f1f5f9;
  color: #64748b;
  padding: 0 9px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.input-review-list {
  display: grid;
  margin: 0;
}

.input-review-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.9fr) minmax(0, 1.4fr);
  gap: 18px;
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 0;
}

.input-review-row:last-child {
  border-bottom: 0;
}

.input-review-row dt {
  color: #64748b;
  font-size: 12px;
}

.input-review-row dd {
  margin: 0;
  color: #172033;
  font-size: 14px;
  line-height: 1.35;
  text-align: right;
  overflow-wrap: anywhere;
}

.estimate-subcopy,
.providers-subcopy,
.empty-result p {
  margin-top: 8px;
  color: #718096;
  font-size: 13px;
  line-height: 1.35;
}

.estimate-list {
  display: grid;
  margin-top: 10px;
}

.estimate-item {
  border-bottom: 1px solid #e2e8f0;
}

.estimate-item[open] {
  padding-bottom: 16px;
}

.estimate-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  min-height: 50px;
  padding: 13px 0 12px;
  cursor: pointer;
  list-style: none;
}

.estimate-row::-webkit-details-marker {
  display: none;
}

.estimate-row span:first-child {
  color: #536174;
  font-size: 13px;
}

.estimate-right {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-width: 210px;
}

.estimate-value {
  color: #172033;
  font-size: 17px;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.estimate-feedback {
  display: inline-flex;
  gap: 10px;
}

.estimate-feedback button {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  background: transparent;
  color: #111827;
  padding: 0;
}

.range-chart {
  width: 235px;
  margin: 10px auto 0;
  color: #111827;
  text-align: center;
}

.range-title {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 600;
}

.range-plot {
  position: relative;
  height: 205px;
  border: 1px solid #111;
  background: #fff;
}

.range-bar {
  position: absolute;
  top: 96px;
  height: 14px;
  background: #1f77b4;
}

.range-value {
  position: absolute;
  top: 68px;
  transform: translateX(-50%);
  font-size: 14px;
  white-space: nowrap;
}

.range-marker {
  position: absolute;
  top: 86px;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 9px solid #111;
}

.range-axis {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 23px;
  height: 1px;
  background: #111;
}

.range-axis span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
}

.range-axis i {
  display: block;
  width: 1px;
  height: 8px;
  background: #111;
}

.range-axis b {
  position: absolute;
  top: 9px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}

.range-currency {
  margin-top: 4px;
  font-size: 13px;
}

.range-chart-empty {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.estimate-feedback svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.estimate-feedback button:last-child svg {
  transform: rotate(180deg);
}

.estimate-delta {
  color: #008cff;
  font-size: 12px;
  font-weight: 500;
}

.estimate-note {
  margin-top: 16px;
  border: 1px solid #cfe3ff;
  border-radius: 6px;
  background: #edf6ff;
  padding: 19px 22px 18px;
}

.estimate-note-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 500;
}

.estimate-note-title span {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 2px solid #0b64ff;
  border-radius: 50%;
  color: #0b64ff;
  font-size: 12px;
  font-weight: 800;
}

.estimate-note ul {
  display: grid;
  gap: 6px;
  margin: 14px 0 0;
  padding-left: 18px;
  color: #475569;
  font-size: 13px;
  line-height: 1.35;
}

.confidence-card {
  align-self: start;
  padding: 24px 23px 25px;
}

.confidence-ring {
  --score: 0%;
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  margin: 18px auto 22px;
  border-radius: 50%;
  background: conic-gradient(#08a045 var(--score), #e5e7eb 0);
}

.confidence-ring-inner {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #fff;
  color: #172033;
  font-size: 32px;
  font-weight: 400;
}

.confidence-badge {
  width: fit-content;
  margin: 0 auto 18px;
  border-radius: 999px;
  background: #dffbea;
  color: #09a34a;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
}

.confidence-copy {
  color: #475569;
  font-size: 15px;
  line-height: 1.35;
}

.result-link {
  display: inline-block;
  margin-top: 14px;
  color: #0b64ff;
  font-size: 14px;
  text-decoration: underline;
}

.confidence-explain {
  position: relative;
  width: fit-content;
  margin-top: 14px;
}

.confidence-explain summary {
  list-style: none;
  color: #0b64ff;
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
}

.confidence-explain summary::-webkit-details-marker {
  display: none;
}

.confidence-popover {
  position: absolute;
  z-index: 5;
  left: 0;
  top: calc(100% + 8px);
  width: min(260px, calc(100vw - 48px));
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
  padding: 12px 14px;
  color: #1f2937;
}

.confidence-popover p {
  color: #1f2937;
  font-size: 13px;
  line-height: 1.35;
}

.confidence-popover ul {
  display: grid;
  gap: 4px;
  margin: 8px 0 0;
  padding-left: 14px;
}

.confidence-popover li {
  color: #64748b;
  font-size: 12px;
  line-height: 1.35;
}

.confidence-popover strong {
  margin-left: 4px;
  color: #ef4444;
  font-weight: 500;
}

.next-steps {
  margin-top: 20px;
  border-top: 1px solid #e2e8f0;
  padding-top: 24px;
}

.next-steps p {
  color: #475569;
  font-size: 13px;
}

.next-step {
  display: flex;
  gap: 12px;
  margin-top: 13px;
  color: #334155;
  font-size: 17px;
  line-height: 1.35;
}

.next-step span {
  color: #0b64ff;
}

.providers-card {
  margin-top: 0;
}

.provider-list {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.provider-row {
  display: grid;
  gap: 8px;
}

.provider-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: #172033;
  font-size: 17px;
}

.provider-percent {
  color: #475569;
  font-size: 14px;
}

.provider-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.provider-fill {
  height: 100%;
  border-radius: inherit;
  background: #175cff;
}

.raw-details {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 14px;
}

.raw-details summary {
  cursor: pointer;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.raw-details pre {
  max-height: 260px;
  overflow: auto;
  margin: 12px 0 0;
  border-radius: 4px;
  background: var(--code);
  color: #d7f7ea;
  padding: 14px;
  font: 12px/1.6 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.hidden {
  display: none;
}

@media (max-width: 1120px) {
  .hero {
    margin-top: 72px;
  }

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

  .providers-card {
    grid-column: auto;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    min-height: 0;
  }

  .side-nav,
  .sidebar-footer {
    display: none;
  }

  .hero {
    width: min(100% - 28px, 760px);
    margin-top: 46px;
  }

  .workspace {
    width: min(100% - 28px, 760px);
  }

  .result-page {
    width: min(100% - 28px, 760px);
  }

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