:root {
  --ink: #153244;
  --ink-soft: #375566;
  --okta: #087db9;
  --coral: #ff5a47;
  --paper: #f5f7f8;
  --white: #ffffff;
  --line: #cfdae0;
  --line-strong: #91a8b5;
  --yellow: #fff3a6;
  --green: #16856b;
  --green-soft: #dff4ec;
  --orange: #c66b18;
  --orange-soft: #fff0dc;
  --red: #b23838;
  --red-soft: #fee9e7;
  --shadow: 0 12px 35px rgba(21, 50, 68, .08);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Aptos, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(8, 125, 185, .35); outline-offset: 3px; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 100; background: var(--ink); color: white; padding: .7rem 1rem; }
.skip-link:focus { top: 1rem; }

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2.2rem;
  color: white;
  background: var(--ink);
  border-bottom: 4px solid var(--coral);
}
.brand { display: flex; align-items: center; gap: .8rem; text-decoration: none; }
.brand strong { display: block; font-family: "Arial Narrow", Aptos, sans-serif; font-size: 1.25rem; letter-spacing: .04em; text-transform: uppercase; }
.brand small { display: block; color: #bcd0da; font-size: .72rem; letter-spacing: .08em; }
.brand-mark { position: relative; width: 42px; height: 28px; display: block; background: #1d485e; overflow: hidden; }
.brand-mark i { position: absolute; width: 18px; height: 42px; background: var(--coral); transform: rotate(-45deg); left: -5px; top: -15px; }
.brand-mark b { position: absolute; width: 18px; height: 42px; background: white; transform: rotate(-45deg); left: 10px; top: -22px; opacity: .9; }
.topnav { display: flex; align-items: center; gap: .35rem; }
.topnav a { color: #e8f0f3; text-decoration: none; padding: .65rem .9rem; border-radius: 4px; }
.topnav a:hover { background: rgba(255,255,255,.1); }
.topnav form { margin: 0; }
.topnav button { color: #bcd0da; background: transparent; border: 0; padding: .65rem .9rem; cursor: pointer; }
.topnav button:hover { color: white; background: rgba(255,255,255,.1); }

.app-shell { display: grid; grid-template-columns: 96px minmax(0, 1fr); min-height: calc(100vh - 76px); }
.audit-rail { background: #e9eff2; border-right: 1px solid var(--line); padding: 1.5rem .75rem; }
.rail-label { margin: 0 0 1.25rem; font-family: ui-monospace, Consolas, monospace; font-size: .64rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-soft); text-align: center; }
.audit-rail ol { list-style: none; padding: 0; margin: 0; position: sticky; top: 1.5rem; }
.audit-rail li { position: relative; display: grid; place-items: center; padding-bottom: 2rem; color: #6b818d; }
.audit-rail li:not(:last-child)::after { content: ""; position: absolute; width: 1px; height: 25px; bottom: .2rem; background: var(--line-strong); }
.audit-rail li span { display: grid; place-items: center; width: 42px; height: 31px; border: 1px solid var(--line-strong); background: var(--paper); font-family: ui-monospace, Consolas, monospace; font-size: .72rem; font-weight: 800; }
.audit-rail li small { margin-top: .35rem; font-size: .66rem; }
.audit-rail li.is-current { color: var(--ink); }
.audit-rail li.is-current span { color: white; background: var(--okta); border-color: var(--okta); box-shadow: 4px 4px 0 var(--coral); }
.audit-rail-muted { opacity: .45; }

.main-content { width: min(1500px, 100%); min-width: 0; max-width: 100%; margin: 0 auto; padding: 3rem clamp(1.25rem, 3vw, 3.5rem) 7rem; }
.page-heading { margin-bottom: 2rem; }
.page-heading h1 { margin: .15rem 0 .5rem; font-family: "Arial Narrow", Aptos, sans-serif; font-size: clamp(2.15rem, 4vw, 4rem); line-height: .96; letter-spacing: -.035em; text-transform: uppercase; }
.page-heading p:not(.eyebrow) { max-width: 760px; margin: 0; color: var(--ink-soft); }
.compact-heading { max-width: 870px; }
.heading-with-action { display: flex; align-items: end; justify-content: space-between; gap: 2rem; }
.eyebrow { margin: 0; color: var(--okta); font-family: ui-monospace, Consolas, monospace; font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 3px; padding: .72rem 1.15rem; font-weight: 800; text-decoration: none; cursor: pointer; }
.button-primary { color: white; background: var(--okta); box-shadow: 4px 4px 0 var(--ink); }
.button-primary:hover { background: #066fa5; transform: translate(1px, 1px); box-shadow: 3px 3px 0 var(--ink); }
.button-secondary { color: var(--ink); background: white; border-color: var(--line-strong); }
.text-link { color: var(--okta); font-weight: 800; text-decoration: none; }

.card { min-width: 0; max-width: 100%; background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow); }
.card-heading, .period-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.2rem 1.4rem; border-bottom: 1px solid var(--line); }
.card-heading h2, .period-heading h2 { margin: 0; font-family: "Arial Narrow", Aptos, sans-serif; font-size: 1.3rem; text-transform: uppercase; letter-spacing: .01em; }
.count { color: var(--ink-soft); font-family: ui-monospace, Consolas, monospace; font-size: .75rem; }
.table-card { overflow: hidden; }
.table-scroll { display: block; width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
table { width: 100%; border-collapse: collapse; }
th { padding: .8rem 1rem; color: #eaf4f7; background: var(--ink); font-size: .72rem; letter-spacing: .05em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: .9rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f7fafb; }
code { font-family: ui-monospace, Consolas, monospace; color: var(--ink); font-weight: 800; }
.status, .type-chip { display: inline-flex; padding: .22rem .48rem; border-radius: 2px; background: #e6edf0; font-family: ui-monospace, Consolas, monospace; font-size: .68rem; font-weight: 800; }
.status-generated { color: #075c49; background: var(--green-soft); }

.empty-state { max-width: 760px; padding: 4.2rem; background: white; border: 1px solid var(--line); border-left: 9px solid var(--okta); box-shadow: var(--shadow); }
.empty-state h2 { margin: .5rem 0; font-size: 2rem; }
.empty-state p { color: var(--ink-soft); margin-bottom: 1.5rem; }
.empty-code { color: var(--coral); font-family: ui-monospace, Consolas, monospace; font-weight: 900; letter-spacing: .12em; }

.login-shell { min-height: min(680px, calc(100vh - 160px)); display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, 480px); align-items: center; gap: clamp(2rem, 7vw, 8rem); max-width: 1180px; margin: 0 auto; }
.login-copy h1 { max-width: 760px; margin: .4rem 0 1rem; font-family: "Arial Narrow", Aptos, sans-serif; font-size: clamp(3.4rem, 7.2vw, 7rem); line-height: .82; letter-spacing: -.055em; text-transform: uppercase; }
.login-copy > p:not(.eyebrow) { max-width: 570px; color: var(--ink-soft); font-size: 1.05rem; }
.login-sequence { display: flex; align-items: center; gap: .65rem; margin-top: 2.2rem; }
.login-sequence span { display: grid; place-items: center; width: 58px; height: 42px; color: white; background: var(--ink); font-family: ui-monospace, Consolas, monospace; font-size: .74rem; font-weight: 900; }
.login-sequence span:last-child { background: var(--okta); box-shadow: 4px 4px 0 var(--coral); }
.login-sequence i { width: 42px; height: 1px; background: var(--line-strong); }
.login-card { position: relative; padding: 2rem; border-top: 7px solid var(--coral); }
.login-card h2 { margin: .25rem 0 1.6rem; font-family: "Arial Narrow", Aptos, sans-serif; font-size: 2rem; text-transform: uppercase; }
.login-card label { margin-top: 1rem; color: var(--ink); }
.login-card input { margin-top: .35rem; }
.login-card .button { width: 100%; margin: 1.5rem 0 1rem; }
.login-card small { display: block; color: var(--ink-soft); text-align: center; }
.login-index { color: var(--okta); font-family: ui-monospace, Consolas, monospace; font-size: .7rem; font-weight: 900; letter-spacing: .12em; }

.upload-card { max-width: 950px; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
.drop-zone { min-height: 330px; display: grid; place-items: center; align-content: center; gap: .55rem; padding: 3rem; border: 3px dashed #9bb3bf; margin: 1.2rem; cursor: pointer; text-align: center; background: repeating-linear-gradient(0deg, #fbfcfc, #fbfcfc 29px, #edf2f4 30px); }
.drop-zone:hover { border-color: var(--okta); }
.drop-zone strong { font-size: 1.3rem; }
.drop-zone span:not(.pdf-stamp) { color: var(--ink-soft); }
.drop-zone input { width: min(420px, 100%); margin-top: .8rem; padding: .7rem; background: white; border: 1px solid var(--line-strong); }
.pdf-stamp { display: grid; place-items: center; width: 68px; height: 82px; color: white; background: var(--coral); font-family: ui-monospace, Consolas, monospace; font-size: 1.2rem; font-weight: 900; clip-path: polygon(0 0, 75% 0, 100% 20%, 100% 100%, 0 100%); }
.form-actions, .sticky-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.2rem; }
.privacy-note, .blocked-note { color: var(--ink-soft); font-size: .8rem; }
.process-note { max-width: 950px; margin-top: 2rem; }
.process-note h2 { font-family: "Arial Narrow", Aptos, sans-serif; text-transform: uppercase; }
.check-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.check-grid span { padding: .8rem; background: white; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.check-grid span::before { content: "✓"; color: var(--green); font-weight: 900; margin-right: .55rem; }

.alert { display: flex; gap: 1rem; padding: 1rem 1.2rem; margin-bottom: 1.5rem; border: 1px solid; }
.alert-error { color: #7f2323; background: var(--red-soft); border-color: #e5a6a0; }
.quote-summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-bottom: 1.5rem; }
.quote-summary-grid > * { min-height: 95px; padding: 1rem; border-right: 1px solid var(--line); }
.quote-summary-grid > *:last-child { border-right: 0; }
.quote-summary-grid span, label { display: block; color: var(--ink-soft); font-size: .75rem; font-weight: 700; }
.quote-summary-grid strong { display: block; margin-top: .55rem; font-size: 1.05rem; }
input, select, textarea { width: 100%; min-height: 40px; border: 1px solid var(--line-strong); border-radius: 2px; padding: .55rem .65rem; color: var(--ink); background: white; }
input:focus, select:focus, textarea:focus { border-color: var(--okta); outline: 3px solid rgba(8,125,185,.14); }
.quote-summary-grid input { margin-top: .35rem; background: var(--yellow); }
.period-card { width: 100%; min-width: 0; max-width: 100%; margin-bottom: 1.5rem; overflow: hidden; }
.period-heading { background: #edf4f7; }
.period-heading strong { font-family: ui-monospace, Consolas, monospace; font-size: 1.15rem; }
.review-table { min-width: 1240px; }
.review-table input, .review-table select { min-width: 90px; background: var(--yellow); border-color: #dec954; }
.review-table .description-input { min-width: 290px; }
.review-table .sku-input { min-width: 110px; font-family: ui-monospace, Consolas, monospace; font-weight: 800; }
.confidence-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: .3rem; }
.confidence-high { background: var(--green); }
.confidence-key { font-size: .78rem; color: var(--ink-soft); }
.rule-cell { min-width: 155px; }
.rule-cell label { display: flex; gap: .35rem; align-items: center; color: var(--ink); }
.rule-cell input[type="checkbox"] { width: auto; min-height: auto; }
.rule-cell input:not([type="checkbox"]) { margin-top: .35rem; }
.sticky-actions { position: sticky; z-index: 10; bottom: 1rem; margin-top: 1.5rem; padding: 1rem 1.2rem; background: rgba(255,255,255,.96); border: 1px solid var(--line-strong); box-shadow: 0 12px 30px rgba(21,50,68,.18); }

.commercial-layout { max-width: 980px; display: grid; gap: 1.4rem; }
.form-card { display: grid; grid-template-columns: 68px 1fr; padding: 1.5rem; gap: 1.2rem; }
.form-card h2 { margin: .15rem 0 1.2rem; font-family: "Arial Narrow", Aptos, sans-serif; text-transform: uppercase; }
.section-number { display: grid; place-items: center; align-self: start; width: 52px; height: 52px; color: white; background: var(--ink); font-family: ui-monospace, Consolas, monospace; font-size: 1.2rem; font-weight: 900; }
.margin-card .section-number { background: var(--coral); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid label { color: var(--ink); }
.form-grid input, .form-grid textarea { margin-top: .35rem; }
.span-2 { grid-column: 1 / -1; }
.margin-input { max-width: 220px; }
.margin-input div { display: flex; align-items: center; margin-top: .35rem; border: 2px solid var(--coral); background: white; }
.margin-input div input { margin: 0; border: 0; font-family: ui-monospace, Consolas, monospace; font-size: 1.45rem; font-weight: 900; }
.margin-input div span { padding: 0 1rem; color: var(--coral); font-size: 1.2rem; font-weight: 900; }

.approval-seal { width: 92px; height: 92px; display: grid; place-items: center; text-align: center; color: var(--green); border: 3px double var(--green); border-radius: 50%; font-family: ui-monospace, Consolas, monospace; font-size: .72rem; font-weight: 900; transform: rotate(-7deg); }
.seal-blocked { color: var(--red); border-color: var(--red); }
.issue-strip { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.2rem; }
.issue { padding: .35rem .55rem; font-family: ui-monospace, Consolas, monospace; font-size: .68rem; border: 1px solid; }
.issue b { margin-right: .25rem; }
.issue-info { color: var(--green); background: var(--green-soft); }
.issue-warning { color: var(--orange); background: var(--orange-soft); }
.issue-error { color: var(--red); background: var(--red-soft); }
.simulation-table { min-width: 1180px; }
.simulation-table td { vertical-align: middle; white-space: nowrap; }
.simulation-table td:first-child { min-width: 310px; white-space: normal; }
.simulation-table td:first-child small { display: block; margin: .25rem 0 .45rem; color: var(--ink-soft); }
.simulation-table .margin-ok { color: var(--green); font-weight: 900; }
details { min-width: 95px; }
details summary { color: var(--okta); font-weight: 800; cursor: pointer; }
details ol { min-width: 380px; padding-left: 1.3rem; white-space: normal; font-family: ui-monospace, Consolas, monospace; font-size: .72rem; }
.totals-panel { display: grid; grid-template-columns: repeat(3, 1fr); margin: 2rem 0; border: 1px solid var(--line-strong); background: white; }
.totals-panel div { padding: 1.2rem; border-right: 1px solid var(--line); }
.totals-panel div:last-child { border: 0; }
.totals-panel span { display: block; color: var(--ink-soft); font-size: .75rem; text-transform: uppercase; }
.totals-panel strong { display: block; margin-top: .25rem; font-family: ui-monospace, Consolas, monospace; font-size: 1.35rem; }
.totals-panel .grand-total { color: white; background: var(--ink); }
.totals-panel .grand-total span { color: #bed0d9; }
.generated-files { padding: 1.2rem; }
.generated-files h2 { margin-top: 0; }
.generated-files a { display: grid; grid-template-columns: 1fr auto; gap: .15rem 1rem; padding: .9rem; border: 1px solid var(--line); text-decoration: none; }
.generated-files a small { color: var(--ink-soft); }
.generated-files a b { grid-row: 1 / 3; grid-column: 2; align-self: center; color: var(--okta); }

.rule-form-card { padding: 1.4rem; margin-bottom: 1.5rem; }
.rule-form-card h2 { margin-top: 0; }
.rule-form { display: grid; grid-template-columns: 1fr 2fr 1fr 1fr 1fr 2fr auto; align-items: end; gap: .7rem; }
.rule-form input, .rule-form select { margin-top: .35rem; }

@media (max-width: 900px) {
  .topbar { padding: 0 1rem; }
  .topnav a { padding: .5rem; font-size: .78rem; }
  .app-shell { grid-template-columns: 1fr; }
  .audit-rail { position: sticky; z-index: 20; top: 0; padding: .55rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-label { display: none; }
  .audit-rail ol { display: flex; justify-content: center; gap: .4rem; }
  .audit-rail li { padding: 0; }
  .audit-rail li:not(:last-child)::after, .audit-rail li small { display: none; }
  .audit-rail li span { width: 48px; height: 30px; }
  .main-content { padding: 2rem 1rem 6rem; }
  .heading-with-action { align-items: flex-start; flex-direction: column; }
  .quote-summary-grid, .totals-panel { grid-template-columns: 1fr 1fr; }
  .check-grid { grid-template-columns: 1fr 1fr; }
  .rule-form { grid-template-columns: 1fr 1fr; }
  .rule-form .button { grid-column: 1 / -1; }
  .sticky-actions { position: static; }
  .login-shell { min-height: auto; grid-template-columns: 1fr; gap: 2rem; }
  .login-copy h1 { font-size: clamp(3rem, 13vw, 5rem); }
}

@media (max-width: 560px) {
  .brand small { display: none; }
  .topnav a:last-child { display: none; }
  .topnav button { max-width: 105px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-heading h1 { font-size: 2.4rem; }
  .empty-state, .drop-zone { padding: 2rem 1rem; }
  .quote-summary-grid, .form-grid, .totals-panel, .check-grid { grid-template-columns: 1fr; }
  .quote-summary-grid > * { border-right: 0; border-bottom: 1px solid var(--line); }
  .form-card { grid-template-columns: 1fr; }
  .sticky-actions { align-items: stretch; flex-direction: column; }
  .sticky-actions .button, .sticky-actions form, .sticky-actions form button { width: 100%; }
  .approval-seal { width: 76px; height: 76px; }
}

@media (prefers-reduced-motion: no-preference) {
  .button, .drop-zone { transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease; }
}
