/*
 * FeeMatch design system — light, neo-brutalist, HR-friendly.
 * Structure comes from ink borders and solid offset shadows, not soft shadows.
 * Yellow = your range + primary actions. Green = overlap/match only.
 * Instrument Sans for text, IBM Plex Mono for figures. See DESIGN_PROMPT.md.
 */
:root {
  --ink: #0A0B0E;
  --paper: #F1F5F9;
  --sheet: #FFFFFF;
  --sunk: #E6EBF1;
  --accent: #FFD23F;
  --accent-soft: #FFF6D1;
  --accent-ink: #8A5A00;
  --signal: #34D399;
  --signal-soft: #E3F8EF;
  --signal-ink: #047857;
  --warn-soft: #FFF1DD;
  --warn-ink: #9A4A00;
  --danger: #C8321E;
  --danger-soft: #FDECEA;
  --danger-ink: #9B2414;
  --muted: #526071;
  --rule: #CBD3DD;
  --grid: #E2E8EF;
  --r: 6px;
  --sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}

body.fm { background: var(--paper); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
.fm h1, .fm h2, .fm h3 { text-wrap: balance; }
.fm :focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.fm-wrap { max-width: 1120px; margin-inline: auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.fm-narrow { max-width: 760px; margin-inline: auto; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* Type */
.h1 { font-size: clamp(30px, 4vw, 44px); line-height: 1.06; font-weight: 700; letter-spacing: -.03em; }
.h2 { font-size: 20px; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
.lead { font-size: 17px; color: #2E3A48; line-height: 1.55; }
.muted { color: var(--muted); }
.eyebrow { font-size: 14px; font-weight: 600; color: var(--accent-ink); }
.link { color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.link:hover { background: var(--accent-soft); }
.page-head { display: grid; gap: 8px; margin-bottom: 32px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--sans); font-weight: 600; font-size: 15px; line-height: 1; padding: 12px 18px; border: 1.5px solid var(--ink); border-radius: var(--r); background: var(--sheet); color: var(--ink); text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color .12s, color .12s, box-shadow .12s, transform .06s; }
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--accent); box-shadow: 3px 3px 0 var(--ink); }
.btn-primary:hover { background: var(--ink); color: var(--paper); }
.btn-primary:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.btn-danger:hover { background: var(--ink); color: #fff; }
.btn-danger-ghost { color: var(--danger-ink); border-color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { font-size: 13px; padding: 8px 12px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { background: var(--sunk); color: var(--muted); border-color: var(--rule); box-shadow: none; cursor: not-allowed; transform: none; }
.btn-text { background: none; border: 0; padding: 0; font: 600 14px var(--sans); color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; cursor: pointer; }
.btn-text:hover { background: var(--accent-soft); }

/* Panels */
.panel { background: var(--sheet); border: 1.5px solid var(--ink); border-radius: var(--r); }
.panel-pad { padding: 24px; }
@media (min-width: 640px) { .panel-pad { padding: 28px 32px; } }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; border-bottom: 1.5px solid var(--ink); }
.panel-body { padding: 24px; }
.panel-rows > * + * { border-top: 1px solid var(--rule); }
.panel-raised { box-shadow: 6px 6px 0 var(--ink); }
.panel-match { border-color: var(--signal-ink); box-shadow: 6px 6px 0 var(--signal); }
.panel-danger { border-color: var(--danger); }
.panel-danger > .panel-head { border-color: var(--danger); background: var(--danger-soft); color: var(--danger-ink); }
.panel-accent { border-color: var(--ink); background: var(--accent-soft); }
.stack > * + * { margin-top: 24px; }

/* Forms */
.field { display: grid; gap: 6px; }
.field-label { font-size: 14px; font-weight: 600; color: var(--ink); }
.field-label .req { color: var(--danger); margin-left: 2px; }
.field-hint { font-size: 13px; color: var(--muted); }
.field-error { font-size: 13px; font-weight: 500; color: var(--danger-ink); }
.input { display: block; width: 100%; font: 400 15px var(--sans); color: var(--ink); background: var(--sheet); border: 1.5px solid var(--ink); border-radius: var(--r); padding: 10px 12px; transition: box-shadow .12s; }
.input::placeholder { color: #8893A2; }
.input:focus { outline: none; box-shadow: 0 0 0 3px var(--accent); }
.input[type="number"], .input.input-num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.input[readonly] { background: var(--paper); }
.input-error, .input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.input-error:focus { box-shadow: 0 0 0 3px #F6B8AF; }
textarea.input { resize: vertical; line-height: 1.5; }
.select-wrap { position: relative; }
.select { appearance: none; padding-right: 36px; cursor: pointer; }
.select-wrap::after { content: ""; position: absolute; right: 14px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.range-box { border: 1.5px solid var(--ink); border-radius: var(--r); background: var(--accent-soft); padding: 18px 18px 20px; }
.range-box legend { padding: 0 6px; margin-left: -6px; font-size: 15px; font-weight: 600; }
.range-box.is-error { border-color: var(--danger); background: var(--danger-soft); }

/* Callouts */
.callout { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1.5px solid var(--ink); border-radius: var(--r); font-size: 15px; background: var(--sheet); }
.callout svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.callout-info { background: var(--accent-soft); }
.callout-success { background: var(--signal-soft); border-color: var(--signal-ink); color: #064E3B; }
.callout-warn { background: var(--warn-soft); border-color: #D98A1E; color: #5C2E00; }
.callout-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger-ink); }
.callout ul { margin: 0; padding-left: 18px; list-style: disc; }
.callout li + li { margin-top: 4px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font: 600 12px var(--sans); line-height: 1; padding: 5px 9px; border-radius: 99px; border: 1px solid var(--ink); background: var(--sheet); color: var(--ink); white-space: nowrap; }
.badge svg { width: 12px; height: 12px; }
.badge-match { background: var(--signal-soft); border-color: var(--signal-ink); color: var(--signal-ink); }
.badge-wait { background: var(--accent-soft); border-color: var(--accent-ink); color: var(--accent-ink); }
.badge-warn { background: var(--warn-soft); border-color: #D98A1E; color: var(--warn-ink); }
.badge-muted { background: var(--sunk); border-color: var(--rule); color: var(--muted); }
.badge-ink { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* Tables and lists */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; text-align: left; }
.table th { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 12px 10px 0; border-bottom: 1.5px solid var(--ink); white-space: nowrap; }
.table td { padding: 14px 12px 14px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; }
.stat { padding: 20px 24px; display: grid; gap: 4px; align-content: start; }
.stat-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.stat-value { font: 600 26px var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.meter { height: 10px; border: 1.5px solid var(--ink); border-radius: 99px; background: var(--sheet); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-right: 1.5px solid var(--ink); }
.meter.is-full > span { background: #F59E0B; }
.meter.is-ok > span { background: var(--signal); }
.meter-sm { height: 8px; }

/* Numbered steps (a real sequence) */
.steps-list { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid; gap: 18px; }
.steps-list > li { counter-increment: step; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 14px; align-items: start; }
.steps-list > li::before { content: counter(step); display: grid; place-items: center; width: 30px; height: 30px; border: 1.5px solid var(--ink); border-radius: var(--r); background: var(--accent); font: 600 14px var(--mono); }
.steps-list p { margin: 0; }

/* Outcome screens */
.outcome { display: grid; justify-items: center; text-align: center; gap: 12px; margin-bottom: 32px; }
.outcome-icon { display: grid; place-items: center; width: 56px; height: 56px; border: 1.5px solid var(--ink); border-radius: var(--r); background: var(--sheet); box-shadow: 4px 4px 0 var(--ink); }
.outcome-icon svg { width: 26px; height: 26px; }
.outcome-icon.is-match { background: var(--signal); }
.outcome-icon.is-accent { background: var(--accent); }
.outcome-icon.is-muted { background: var(--sunk); }
.outcome p { max-width: 52ch; }
.shared-range { display: grid; gap: 10px; justify-items: center; text-align: center; padding: 28px 24px; }
.shared-range .value { font: 600 clamp(26px, 4.5vw, 40px) var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.shared-range .label { font-size: 14px; font-weight: 600; color: var(--signal-ink); }
.range-cell { font: 600 15px var(--mono); font-variant-numeric: tabular-nums; color: var(--signal-ink); white-space: nowrap; }

/* Header */
.fm-top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; background: var(--paper); border-bottom: 1.5px solid var(--ink); }
.fm-top-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 700; font-size: 19px; letter-spacing: -.02em; color: var(--ink); }
.brand-mark { width: 22px; height: 14px; position: relative; flex: none; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; top: 0; bottom: 0; width: 14px; border: 1.5px solid var(--ink); border-radius: 3px; }
.brand-mark::before { left: 0; background: var(--accent); }
.brand-mark::after { right: 0; background: rgba(52, 211, 153, .6); }
.beta-tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border: 1px solid var(--accent-ink); color: var(--accent-ink); border-radius: 99px; text-decoration: none; }
.beta-tag:hover { background: var(--accent-soft); }
.nav { display: flex; align-items: center; gap: 22px; font-size: 15px; font-weight: 500; }
.nav-link { color: var(--muted); text-decoration: none; }
.nav-link:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.nav .btn { padding: 9px 14px; font-size: 14px; }
.nav .btn-primary { box-shadow: 2px 2px 0 var(--ink); }
.menu { position: absolute; right: 0; margin-top: 8px; width: 210px; background: var(--sheet); border: 1.5px solid var(--ink); border-radius: var(--r); box-shadow: 4px 4px 0 var(--ink); padding: 6px; z-index: 50; }
.menu-item { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 4px; font: 500 14px var(--sans); color: var(--ink); text-decoration: none; background: none; border: 0; cursor: pointer; text-align: left; }
.menu-item svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.menu-item:hover, .menu-item:focus { background: var(--accent-soft); outline: none; }
.menu-sep { margin: 6px 0; border-top: 1px solid var(--rule); }

/* Footer */
.fm-foot { border-top: 1.5px solid var(--ink); padding-block: 22px; font-size: 14px; color: var(--muted); margin-top: 64px; }
.fm-foot-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.fm-foot a { text-decoration: none; }
.fm-foot a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }

/* Legal / prose */
.prose-fm h2 { font-size: 19px; font-weight: 600; margin: 0 0 10px; }
.prose-fm p, .prose-fm li { font-size: 16px; line-height: 1.6; color: #2E3A48; }
.prose-fm ul { margin: 0; padding-left: 20px; list-style: disc; display: grid; gap: 8px; }
.prose-fm section { padding: 24px 0; border-top: 1px solid var(--rule); display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
@media (min-width: 768px) { .prose-fm section { grid-template-columns: 240px minmax(0, 1fr); gap: 32px; } }

details.panel > summary { list-style: none; cursor: pointer; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary .chev { transition: transform .15s; }
details.panel[open] > summary .chev { transform: rotate(90deg); }

@media (prefers-reduced-motion: reduce) {
  .fm *, .fm *::before, .fm *::after { animation: none !important; transition: none !important; }
}
