:root {
  --ink: #16211d;
  --muted: #66736e;
  --paper: #f4f3ee;
  --panel: #fcfbf7;
  --line: #dcded7;
  --forest: #173f34;
  --mint: #bce2ce;
  --acid: #d8ee72;
  --orange: #d66a3a;
  --shadow: 0 14px 40px rgba(28, 52, 44, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.hidden { display: none !important; }
.auth-view { width: 100%; min-height: 100vh; padding: 24px; display: grid; place-items: center; background: var(--forest); }
.auth-card { width: 100%; max-width: 420px; padding: 36px; display: grid; gap: 17px; text-align: left; border-radius: 12px; background: var(--panel); box-shadow: 0 24px 80px rgba(0,0,0,.3); }
.auth-card h1 { margin: 0; font: 500 38px/1 Georgia, serif; }
.auth-card > p:not(.eyebrow) { margin: 0 0 8px; color: var(--muted); line-height: 1.5; }
.auth-card label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.auth-card .auth-brand { color: var(--ink); margin-bottom: 18px; }
.auth-card .button { width: 100%; margin-top: 4px; }
.form-error { min-height: 18px; color: #9b3327; font-size: 12px; }
.user-chip { padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: rgba(255,255,255,.5); font-size: 12px; }
.read-only #trade-form, .read-only #reconciliation-form, .read-only .settle { display: none !important; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 30px 24px; display: flex; flex-direction: column; color: #eef5f1; background: var(--forest); }
.brand { display: flex; align-items: center; gap: 12px; color: white; text-decoration: none; font-size: 22px; letter-spacing: -.03em; }
.brand em { color: var(--acid); font-style: normal; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; color: var(--forest); background: var(--acid); border-radius: 50%; font-family: Georgia, serif; font-weight: 700; }
.eyebrow { margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.sidebar > .eyebrow { margin-top: 40px; color: #8eb0a4; }
.sidebar nav { display: grid; gap: 7px; margin-top: 10px; }
.sidebar nav a { display: flex; gap: 12px; padding: 11px 10px; color: #c4d4ce; border-radius: 8px; text-decoration: none; font-size: 14px; }
.sidebar nav a span { color: #6e9487; font: 11px/1.7 ui-monospace, SFMono-Regular, monospace; }
.sidebar nav a:hover, .sidebar nav a.active { color: white; background: rgba(255, 255, 255, .08); }
.sidebar-foot { margin-top: auto; color: #aabeb7; }
.sidebar-foot small { display: block; margin-top: 7px; font-size: 11px; }
.status-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #c89047; box-shadow: 0 0 0 4px rgba(200, 144, 71, .14); }
.status-dot.online { background: #7de3aa; box-shadow: 0 0 0 4px rgba(125, 227, 170, .12); }

main { min-width: 0; padding: 0 48px; }
.topbar { min-height: 104px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 20px; font-weight: 620; }
.topbar .eyebrow { color: var(--muted); }
.top-actions { display: flex; gap: 10px; }
.button { min-height: 42px; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--forest); border-radius: 6px; color: white; background: var(--forest); cursor: pointer; text-decoration: none; font-weight: 700; font-size: 13px; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); background: #245848; }
.button.secondary { color: var(--forest); background: transparent; }
.button.small { min-height: 30px; padding: 0 10px; font-size: 11px; }

.section { padding: 72px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 20px; }
.hero { padding-top: 64px; }
.hero-copy { max-width: 820px; }
.hero h2 { max-width: 760px; margin: 0; font: 500 clamp(42px, 5vw, 72px)/.98 Georgia, "Times New Roman", serif; letter-spacing: -.045em; }
.hero-copy > p:last-child { max-width: 710px; margin: 26px 0 0; color: var(--muted); font-size: 17px; line-height: 1.65; }
.accent { color: var(--orange); }
.flow-map { margin-top: 46px; padding: 22px; display: grid; grid-template-columns: repeat(7, auto); align-items: center; gap: 14px; color: white; background: var(--forest); border-radius: 10px; box-shadow: var(--shadow); }
.flow-map div { display: grid; gap: 3px; }
.flow-map b { font-size: 14px; }
.flow-map small { color: #9db8af; }
.flow-map i { color: var(--acid); font-style: normal; }

.metric-grid { padding: 24px 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; border-bottom: 1px solid var(--line); }
.metric { min-height: 128px; padding: 18px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.4); }
.metric span, .metric small { color: var(--muted); font-size: 12px; }
.metric strong { margin: auto 0 3px; font: 500 38px/1 Georgia, serif; }
.metric.warning strong { color: var(--orange); }

.two-column { display: grid; grid-template-columns: minmax(260px, .75fr) minmax(520px, 1.25fr); gap: 64px; align-items: start; }
.section-number { color: var(--orange); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.section h2 { margin: 6px 0 16px; font: 500 38px/1.05 Georgia, serif; letter-spacing: -.025em; }
.section-copy > p:not(.section-number), .section-heading > p { color: var(--muted); line-height: 1.6; }
.logic-note { margin-top: 34px; padding: 18px; border-left: 3px solid var(--orange); background: rgba(255,255,255,.38); }
.logic-note p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.section-heading { margin-bottom: 28px; display: flex; justify-content: space-between; align-items: end; gap: 30px; }
.section-heading h2 { margin-bottom: 0; }
.section-heading > p { max-width: 480px; margin: 0; }

.panel { padding: 24px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.form-grid label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.form-grid .wide { grid-column: 1 / -1; }
input, select { width: 100%; min-height: 43px; padding: 0 12px; color: var(--ink); border: 1px solid #ced2cb; border-radius: 5px; outline: none; background: white; }
input:focus, select:focus { border-color: #4e8875; box-shadow: 0 0 0 3px rgba(78,136,117,.12); }
.check { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 8px !important; }
.check input { width: 17px; min-height: 17px; }
.subform { padding: 17px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; border: 1px dashed #c8cec6; border-radius: 6px; background: #f7f7f2; }
.subform.hidden { display: none; }
.two-panel { display: grid; grid-template-columns: 1.15fr .85fr; gap: 20px; align-items: start; }
.explanation { position: sticky; top: 24px; min-height: 280px; color: white; background: var(--forest); border-color: var(--forest); }
.explanation h3 { margin: 4px 0 16px; font: 500 28px Georgia, serif; }
.explanation p:not(.eyebrow) { color: #b9cec7; line-height: 1.6; }
.explanation .button { border-color: var(--acid); color: var(--acid); }
.mini-output { max-height: 320px; margin-top: 18px; padding-top: 16px; overflow: auto; border-top: 1px solid rgba(255,255,255,.15); font: 11px/1.55 ui-monospace, SFMono-Regular, monospace; }
.muted { color: var(--muted); }

.trade-form { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.trade-form .button { align-self: end; }
.table-panel { margin-top: 20px; padding: 0; overflow: hidden; }
.two-panel .table-panel { margin-top: 0; }
.panel-title { padding: 20px 22px 14px; display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.panel-title h3 { margin: 0; font-size: 15px; }
.panel-title small { color: var(--muted); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 10px 16px; color: var(--muted); background: #f0f1eb; text-align: left; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
td { padding: 13px 16px; border-top: 1px solid #e4e6df; white-space: nowrap; }
td.number { font-variant-numeric: tabular-nums; text-align: right; }
.empty { color: var(--muted); text-align: center; padding: 26px; }
.state { padding: 4px 7px; border-radius: 20px; color: #346b58; background: #ddede6; font-size: 10px; font-weight: 800; }
.state.confirmed { color: #8b5e1f; background: #f3e7c8; }
.inline-date { display: grid; gap: 5px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.inline-date input { min-width: 170px; }
.steps { margin-top: 25px; padding: 0; list-style: none; counter-reset: steps; }
.steps li { padding: 12px 0; border-bottom: 1px solid var(--line); counter-increment: steps; }
.steps li::before { content: "0" counter(steps); margin-right: 12px; color: var(--orange); font: 11px ui-monospace, monospace; }

.fiscal-section { border-bottom: 0; }
.badge { padding: 7px 11px; border: 1px solid #9ecab8; border-radius: 20px; color: #2e6f59; background: #e0f0e9; font-size: 11px; font-weight: 800; }
.tax-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; }
.policy-list { display: grid; gap: 10px; }
.policy-item { padding: 12px 0; display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); }
.policy-item b { color: var(--ink); font-size: 12px; }
.policy-item span { max-width: 60%; text-align: right; font-size: 12px; }
.calculator { color: white; background: var(--forest); border-color: var(--forest); }
.calculator label { display: grid; gap: 8px; color: #abc0b8; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.calculator .button { margin-top: 14px; border-color: var(--acid); color: var(--forest); background: var(--acid); }
.calculator output { margin-top: 24px; display: block; color: var(--acid); font: 500 42px Georgia, serif; }
.calculator small { color: #9eb6ad; }
footer { padding: 30px 0 44px; display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }

#toast { position: fixed; right: 24px; bottom: 24px; max-width: 420px; padding: 14px 18px; color: white; background: var(--forest); border-radius: 7px; box-shadow: 0 16px 50px rgba(0,0,0,.22); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; font-size: 13px; }
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: #8b3528; }

@media (max-width: 1050px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .sidebar nav { grid-template-columns: repeat(3, 1fr); }
  .sidebar-foot { margin-top: 24px; }
  main { padding: 0 24px; }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .two-column, .two-panel, .tax-grid { grid-template-columns: 1fr; }
  .explanation { position: relative; top: 0; }
  .trade-form { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 650px) {
  .auth-view { padding: 16px; }
  .auth-card { max-width: 380px; padding: 28px 22px; }
  .auth-card h1 { font-size: 32px; }
  .sidebar nav { grid-template-columns: 1fr 1fr; }
  .topbar, .section-heading { align-items: flex-start; flex-direction: column; padding: 22px 0; }
  .hero h2 { font-size: 42px; }
  .flow-map { grid-template-columns: 1fr; }
  .flow-map i { transform: rotate(90deg); justify-self: center; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .form-grid, .trade-form, .subform { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  footer { flex-direction: column; gap: 8px; }
}
