@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --ink: #10100f;
  --paper: #f5f3eb;
  --white: #fffef8;
  --orange: #ff5a1f;
  --green: #8cff60;
  --blue: #245dff;
  --line: #cbc7b8;
  --muted: #6b695f;
  font-family: Outfit, Arial, sans-serif;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--ink); color: var(--paper); overflow-x: hidden; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, label:focus-within { outline: 3px solid var(--blue); outline-offset: 3px; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 99; background: var(--green); color: var(--ink); padding: .8rem 1rem; }
.skip-link:focus { top: 1rem; }
main { width: 100%; max-width: 100%; overflow-x: hidden; }

.command-nav { min-height: 68px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding: .7rem clamp(1rem, 3vw, 3.5rem); border-bottom: 1px solid #373733; position: sticky; top: 0; z-index: 30; background: rgba(16,16,15,.96); backdrop-filter: blur(12px); }
.brand { color: var(--paper); text-decoration: none; display: flex; align-items: center; gap: .75rem; font-weight: 600; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; background: var(--orange); color: var(--ink); font-weight: 700; }
.runtime { display: flex; gap: .55rem; align-items: center; font-size: .78rem; color: #a7a59c; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.runtime-light { width: 8px; height: 8px; border-radius: 50%; background: #f0b22d; box-shadow: 0 0 16px currentColor; }
.runtime.ready .runtime-light { background: var(--green); }
.runtime.failed .runtime-light { background: var(--orange); }
.nav-actions { justify-self: end; display: flex; align-items: center; gap: .6rem; }
.icon-button, .nav-export { min-height: 44px; border: 1px solid #4c4b47; background: transparent; color: var(--paper); padding: 0 .9rem; }
.icon-button { width: 44px; padding: 0; font-size: 1.35rem; }
.nav-export { background: var(--paper); color: var(--ink); border-color: var(--paper); font-weight: 600; }

.tool-heading { padding: clamp(3rem, 7vw, 7rem) clamp(1rem, 5vw, 5.5rem) clamp(2.5rem, 5vw, 5rem); background: radial-gradient(circle at 82% 30%, rgba(255,90,31,.16), transparent 28%), var(--ink); }
.kicker, .eyebrow { margin: 0 0 1rem; text-transform: uppercase; font-size: .72rem; font-weight: 700; letter-spacing: .14em; color: var(--orange); }
.eyebrow.dark { color: #7d3f27; }
.tool-heading h1 { margin: 0; max-width: 72rem; font-size: clamp(3rem, 7vw, 6.8rem); line-height: .92; font-weight: 600; letter-spacing: 0; }
.lede { max-width: 55rem; margin: 1.5rem 0 0; font-size: clamp(1.05rem, 2vw, 1.45rem); line-height: 1.45; color: #bdbab0; }
.assumption-line { margin-top: 1.5rem; display: inline-flex; gap: .4rem; padding: .75rem 1rem; border-left: 4px solid var(--green); background: #1f201d; color: #d7d5cc; font-size: .9rem; }

.audit-bench { display: grid; grid-template-columns: minmax(290px, 4fr) minmax(0, 8fr); min-height: 760px; border-top: 1px solid #363530; border-bottom: 1px solid #363530; }
.inputs-panel { padding: clamp(1.2rem, 3vw, 2.5rem); background: #181816; border-right: 1px solid #3b3a35; }
.panel-heading, .ledger-head, .rates-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.panel-heading h2, .ledger-head h2, .rates-heading h3 { margin: 0; }
.local-badge { border: 1px solid #4a4a42; color: var(--green); padding: .35rem .55rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .68rem; }
.source-controls { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 2px; margin: 1.6rem 0 1rem; background: #3b3a35; border: 1px solid #3b3a35; }
.source-button { border: 0; min-height: 48px; padding: .6rem; background: #20201d; color: #cbc8be; text-align: center; display: grid; place-items: center; }
.source-button:hover, .source-button.active { background: var(--green); color: var(--ink); }
#file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.field-label { display: block; margin: 1rem 0 .55rem; font-size: .85rem; color: #c5c2b8; }
#csv-input { width: 100%; min-height: 196px; resize: vertical; border: 1px solid #4a4942; border-radius: 0; background: #0f0f0e; color: #e9e5d9; padding: .9rem; font: .7rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.schema-note { margin: .5rem 0 1.4rem; color: #7e7b73; font: .63rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.rates-heading { margin-bottom: .7rem; }
.rates-heading span { color: #7e7b73; font-size: .74rem; }
.rate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.rate-grid label, .tolerance-label { color: #9e9b92; font-size: .72rem; }
.rate-grid input, .tolerance-label input { width: 100%; min-height: 46px; margin-top: .32rem; border: 1px solid #4a4942; border-radius: 0; background: #242420; color: var(--paper); padding: .6rem .7rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.tolerance-label { display: block; margin-top: .65rem; }
.run-button { width: 100%; min-height: 56px; display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; border: 0; background: var(--orange); color: var(--ink); padding: 0 1rem; font-weight: 700; }
.run-button:hover { background: #ff7445; }
.run-button kbd { border: 1px solid rgba(0,0,0,.35); padding: .25rem .45rem; background: transparent; }
.error-box { margin-top: .8rem; border: 1px solid var(--orange); background: #2b1610; color: #ffc0a9; padding: .8rem; font: .78rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }

.ledger-panel { min-width: 0; padding: clamp(1.2rem, 3vw, 2.6rem); background-color: var(--paper); color: var(--ink); background-image: repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(16,16,15,.035) 28px); }
.ledger-head h2 { font-size: clamp(1.4rem, 2.8vw, 2.5rem); }
.row-count { padding: .45rem .65rem; border: 1px solid var(--line); font: .74rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.totals { display: grid; grid-template-columns: repeat(4, 1fr); margin: 2rem 0 1.4rem; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--ink); }
.totals > div { padding: 1rem .8rem; border-right: 1px solid var(--line); }
.totals > div:last-child { border-right: 0; }
.totals span, .totals small { display: block; color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.totals strong { display: block; font: 600 clamp(1.55rem, 3vw, 3rem)/1 ui-monospace, SFMono-Regular, Menlo, monospace; margin: .45rem 0; }
.totals .excess strong { color: #d43a00; }
.burn-rail { margin: 1.4rem 0; }
.rail-labels { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .72rem; margin-bottom: .45rem; }
.rail-track { position: relative; display: flex; height: 18px; background: #dedbd0; overflow: hidden; }
.rail-expected, .rail-excess { display: block; height: 100%; width: 0; transition: width .7s cubic-bezier(.2,.7,.2,1); }
.rail-expected { background: var(--ink); }
.rail-excess { background: var(--orange); }
.table-wrap { width: 100%; overflow: auto; border-top: 1px solid var(--ink); max-height: 330px; }
table { width: 100%; min-width: 760px; border-collapse: collapse; font: .73rem/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; }
th { position: sticky; top: 0; z-index: 2; background: var(--paper); color: var(--muted); text-align: left; text-transform: uppercase; font-size: .62rem; padding: .75rem .55rem; border-bottom: 1px solid var(--line); }
td { padding: .75rem .55rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr { cursor: pointer; transition: background .2s ease; }
tbody tr:hover, tbody tr.selected { background: #e8e4d6; }
tbody tr.anomaly { background: #ffdfd1; }
tbody tr.anomaly:hover, tbody tr.anomaly.selected { background: #ffcab5; }
.finding { display: inline-block; padding: .25rem .4rem; border: 1px solid currentColor; font-size: .62rem; text-transform: uppercase; }
.finding.ok { color: #267216; }
.finding.warn { color: #a42f05; }
.detail-drawer { margin-top: 1.3rem; display: grid; grid-template-columns: minmax(100px, 150px) 1fr; gap: 1.1rem; padding: 1.1rem; border: 1px solid var(--ink); background: var(--white); }
.detail-index { font: 700 .75rem ui-monospace, SFMono-Regular, Menlo, monospace; color: #8a3720; }
.detail-drawer h3 { margin: 0; font-size: 1rem; }
.detail-drawer p { margin: .45rem 0 0; color: #59574f; font: .78rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.detail-guidance { border-left: 3px solid var(--orange); padding-left: .7rem; }

.reasoning-band { padding: clamp(5rem, 10vw, 10rem) clamp(1rem, 5vw, 5.5rem); background: var(--ink); display: grid; grid-template-columns: .85fr 1.4fr; gap: clamp(2rem, 7vw, 8rem); }
.reasoning-intro h2 { margin: 0; max-width: 28rem; font-size: clamp(2rem, 4vw, 4.5rem); line-height: 1; }
.reasoning-accordion { display: flex; min-height: 360px; border: 1px solid #41403b; }
.reason { flex: 1; min-width: 72px; border: 0; border-right: 1px solid #41403b; background: #181816; color: var(--paper); padding: 1.2rem; text-align: left; display: flex; flex-direction: column; gap: 1rem; transition: flex .45s ease, background .3s ease; overflow: hidden; }
.reason:last-child { border-right: 0; }
.reason:hover, .reason.active { flex: 2.2; background: #23231f; }
.reason span { color: var(--orange); font: .75rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.reason strong { max-width: 15rem; font-size: 1.15rem; }
.reason small { color: #a19e95; line-height: 1.45; }
.reason-explanation { grid-column: 2; padding: 1.2rem 0 0; border-top: 1px solid #4b4a44; color: #cac7bd; max-width: 50rem; font-size: 1.05rem; line-height: 1.55; }

.diagnosis { padding: clamp(4rem, 9vw, 9rem) clamp(1rem, 5vw, 5.5rem); background: var(--green); color: var(--ink); display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 6vw, 7rem); }
.diagnosis h2 { margin: 0; max-width: 45rem; font-size: clamp(2rem, 4vw, 4.4rem); line-height: 1; }
.diagnosis-options { display: grid; gap: 2px; align-content: start; background: var(--ink); border: 2px solid var(--ink); }
.diagnosis-options button { min-height: 66px; border: 0; background: var(--green); color: var(--ink); text-align: left; padding: 1rem; font-weight: 600; }
.diagnosis-options button:hover, .diagnosis-options button.selected { background: var(--ink); color: var(--green); }
.diagnosis-feedback { grid-column: 2; min-height: 82px; padding: 1rem; border: 2px solid var(--ink); font-weight: 500; line-height: 1.5; }
.diagnosis-feedback.correct { background: var(--ink); color: var(--green); }

footer { display: flex; justify-content: space-between; align-items: center; gap: 2rem; padding: 2rem clamp(1rem, 5vw, 5.5rem); background: var(--paper); color: var(--ink); }
footer div { display: grid; gap: .3rem; }
footer span { color: var(--muted); }
footer button { min-height: 52px; border: 0; background: var(--orange); color: var(--ink); padding: 0 1.2rem; font-weight: 700; }

@media (max-width: 900px) {
  .command-nav { grid-template-columns: 1fr auto; }
  .runtime { display: none; }
  .audit-bench { grid-template-columns: 1fr; }
  .inputs-panel { border-right: 0; border-bottom: 1px solid #3b3a35; }
  .reasoning-band, .diagnosis { grid-template-columns: 1fr; }
  .reason-explanation, .diagnosis-feedback { grid-column: 1; }
}

@media (max-width: 600px) {
  .command-nav { padding: .55rem .8rem; }
  .brand span:last-child, .nav-export { display: none; }
  .tool-heading { padding-top: 3rem; }
  .tool-heading h1 { font-size: clamp(2.8rem, 15vw, 4.5rem); }
  .assumption-line { display: block; }
  .source-controls { grid-template-columns: 1fr; }
  .rate-grid { grid-template-columns: 1fr 1fr; }
  .ledger-panel { padding: 1rem; }
  .ledger-head { align-items: flex-start; }
  .totals { grid-template-columns: 1fr 1fr; }
  .totals > div:nth-child(2) { border-right: 0; }
  .totals > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .totals strong { font-size: 1.65rem; }
  .detail-drawer { grid-template-columns: 1fr; }
  .reasoning-accordion { display: grid; min-height: 0; }
  .reason { min-height: 112px; border-right: 0; border-bottom: 1px solid #41403b; }
  .reason:hover, .reason.active { min-height: 155px; }
  footer { align-items: stretch; flex-direction: column; }
  footer button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
