:root {
  --bg: #f4f6f0;
  --surface: #ffffff;
  --surface-alt: #eef6ee;
  --ink: #18201b;
  --muted: #647066;
  --line: #d2decf;
  --accent: #2f5d3a;
  --accent-2: #527f5b;
  --warning: #a86516;
  --danger: #853326;
  --shadow: 0 10px 28px rgba(24, 32, 27, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

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

h1 {
  margin-bottom: 0;
  font-size: 25px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 14px;
  font-size: 22px;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 240, 0.95);
  backdrop-filter: blur(10px);
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

nav a,
button,
.selected-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 11px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

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

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

#copyResult {
  margin-top: 16px;
  justify-self: start;
}

main {
  width: min(1220px, 100%);
  margin: 0 auto;
  padding: 22px 28px 56px;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel,
.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  margin-top: 18px;
  padding: 18px;
}

.lookup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.lookup-grid .panel {
  margin-top: 0;
}

.settlement-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

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

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.settlement-results {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
  margin: 12px 0 18px;
}

.settlement-results button {
  border-color: var(--line);
  background: #f7faf5;
  color: var(--ink);
}

.lookup-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.status-line {
  margin-top: 16px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfaf7;
  color: var(--muted);
  font-size: 13px;
}

.status-line[data-type="ok"] {
  border-color: #b7d4b4;
  background: #eff8ee;
  color: #24482d;
}

.status-line[data-type="error"] {
  border-color: #dfb7ae;
  background: #fff3f1;
  color: var(--danger);
}

.status-line[data-type="loading"] {
  border-color: #e3d0ad;
  background: #fff7e8;
  color: var(--warning);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.result-card {
  min-height: 150px;
  padding: 18px;
}

.result-card span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.result-card strong {
  display: block;
  margin: 9px 0 7px;
  font-size: 30px;
  line-height: 1.1;
}

.result-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.primary-result {
  border-color: #b8d2b5;
  background: #f7fbf5;
}

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

.details-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1.05fr);
  gap: 16px;
  align-items: stretch;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #cddbc8;
  border-radius: 8px;
  background: #fff;
}

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

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  background: var(--accent);
  color: #fff;
  font-size: 12px;
}

tbody tr:nth-child(even) {
  background: #f5f9f3;
}

.details-panel table {
  min-width: 0;
}

.details-panel th {
  width: 170px;
}

.outline-preview {
  display: grid;
  min-height: 260px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
  color: var(--muted);
  font-size: 13px;
}

.outline-preview svg {
  width: 100%;
  max-height: 250px;
}

.outline-preview path.raw-outline {
  fill: #dfeede;
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 5 4;
  fill-opacity: 0.55;
}

.outline-preview path.ideal-outline {
  fill: #ffffff;
  fill-opacity: 0.65;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: miter;
}

.outline-preview span {
  align-self: end;
  margin-bottom: 10px;
}

.outline-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.outline-legend i {
  display: inline-block;
  width: 18px;
  height: 0;
  vertical-align: middle;
}

.outline-legend .lg-raw {
  border-top: 2px dashed var(--muted);
}

.outline-legend .lg-ideal {
  border-top: 2px solid var(--accent);
}

code {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.92em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-alt);
  color: var(--accent);
}

.method-lead {
  max-width: 70ch;
  margin: 6px 0 18px;
  color: var(--muted);
}

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

.method-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfaf7;
}

.method-grid p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.method-proof {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.method-proof h3 {
  margin: 2px 0 10px;
}

.method-proof p {
  max-width: 70ch;
  color: var(--muted);
}

.proof-figure {
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfaf7;
}

.proof-figure svg {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  margin: 0 auto;
}

.proof-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}

.proof-legend .lg {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.proof-legend .lg::before {
  content: "";
  width: 14px;
  height: 0;
  border-top-width: 3px;
  border-top-style: solid;
}

.lg-outline::before { border-top-color: var(--warning); }
.lg-hole::before { border-top-color: var(--accent); }
.lg-gap::before { border-top-style: dashed; border-top-color: var(--muted); }

.proof-list {
  max-width: 70ch;
  margin: 14px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

@media (max-width: 980px) {
  .lookup-grid,
  .details-grid,
  .result-grid,
  .method-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar,
  .section-head {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    padding: 16px;
  }

  main {
    padding: 14px 12px 36px;
  }

  .settlement-row,
  .lookup-form {
    grid-template-columns: 1fr;
  }
}
