:root {
  --ink: #171612;
  --muted: #69665f;
  --line: #e7e4dd;
  --paper: #f7f6f2;
  --surface: #fff;
  --coal: #0d0e0e;
  --coal-soft: #171817;
  --gold: #b67b24;
  --gold-light: #ddad65;
  --gold-wash: #fbf2e4;
  --green: #18794e;
  --green-wash: #eaf7f0;
  --red: #b42318;
  --red-wash: #fff0ee;
  --purple: #7652e8;
  --radius: 14px;
  --shadow: 0 20px 55px rgba(21, 20, 17, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid rgba(182, 123, 36, .48); outline-offset: 3px; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; top: 12px; left: 12px; padding: 10px 14px; transform: translateY(-180%); border-radius: 8px; background: #fff; color: #111; }
.skip-link:focus { transform: translateY(0); }
.eyebrow { margin: 0 0 6px; color: var(--gold); font-size: .72rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.brand-lockup { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; font-size: 1.35rem; letter-spacing: -.035em; }
.brand-symbol { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--gold-light); border-radius: 10px; color: var(--gold-light); font-family: Georgia, serif; }

.app-body { min-height: 100vh; background: var(--paper); }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; width: 244px; flex-direction: column; padding: 28px 18px 18px; overflow-y: auto; color: #f8f4e9; background: radial-gradient(circle at 50% 100%, rgba(221,173,101,.1), transparent 32%), var(--coal); }
.sidebar-brand { margin: 0 14px 29px; color: #fff; }
.agency-identity { display: flex; align-items: center; gap: 12px; margin-bottom: 19px; padding: 14px; border: 1px solid rgba(221,173,101,.35); border-radius: 12px; background: rgba(255,255,255,.025); }
.agency-identity small, .sidebar-footer small, .sidebar-footer span { display: block; color: #9d9d98; font-size: .72rem; }
.agency-identity strong { display: block; margin-top: 3px; font-size: .9rem; }
.agency-glyph { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 9px; color: var(--gold-light); background: rgba(221,173,101,.09); }
.agency-glyph svg { width: 21px; }
.nav-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.nav-list a { display: flex; min-height: 44px; align-items: center; gap: 12px; padding: 0 13px; border: 1px solid transparent; border-radius: 10px; color: #d9d9d3; text-decoration: none; font-size: .875rem; transition: background .18s ease, color .18s ease, border-color .18s ease; }
.nav-list a:hover { color: #fff; background: rgba(255,255,255,.045); }
.nav-list a.active { border-color: rgba(221,173,101,.42); color: #ffe1a8; background: linear-gradient(90deg, rgba(221,173,101,.17), rgba(221,173,101,.045)); }
.nav-list svg { width: 20px; height: 20px; }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding: 16px 12px 0; border-top: 1px solid rgba(255,255,255,.09); }
.sidebar-footer strong { display: block; max-width: 135px; overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer form { margin: 0; }
.icon-button { display: inline-grid; width: 40px; height: 40px; padding: 0; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: inherit; background: transparent; cursor: pointer; }
.sidebar .icon-button { border-color: rgba(255,255,255,.13); }
.icon-button svg { width: 19px; }
.mobile-menu-button { display: none; }
.main-content { min-height: 100vh; margin-left: 244px; padding: 42px clamp(24px, 3.5vw, 58px) 70px; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 30px; }
.page-heading h1 { margin: 0; font-size: clamp(2rem, 3vw, 2.9rem); line-height: .98; letter-spacing: -.055em; }
.page-heading p:last-child { margin: 9px 0 0; color: var(--muted); }
.period-picker { display: flex; align-items: center; gap: 10px; }
.period-picker label { font-size: .78rem; font-weight: 700; }
select, input, textarea { min-height: 44px; border: 1px solid #d9d6ce; border-radius: 9px; color: var(--ink); background: #fff; }
select, input { padding: 0 13px; }
textarea { padding: 12px 13px; resize: vertical; }
.period-picker select { min-width: 160px; }

.metric-strip { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
.metric-strip article { min-width: 0; padding: 21px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.metric-strip span, .metric-strip small { display: block; color: var(--muted); font-size: .75rem; }
.metric-strip strong { display: block; margin: 12px 0 8px; overflow: hidden; font-size: clamp(1.25rem, 2vw, 1.8rem); letter-spacing: -.045em; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .55fr); gap: 16px; }
.surface { min-width: 0; margin-bottom: 16px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 0 rgba(17,17,17,.02); }
.surface-wide { grid-row: span 2; }
.narrow-surface { max-width: 720px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading h2, .surface h2 { margin: 0; font-size: 1.08rem; letter-spacing: -.025em; }
.section-heading a, .text-link { color: #885514; font-size: .78rem; font-weight: 700; text-underline-offset: 4px; }
.breakdown-list { margin: 0 0 20px; }
.breakdown-list > div { display: flex; justify-content: space-between; gap: 20px; padding: 12px 0; border-bottom: 1px solid #f0eee9; }
.breakdown-list dt { color: var(--muted); }
.breakdown-list dd { margin: 0; font-weight: 720; font-variant-numeric: tabular-nums; }
.settlement-state > strong { display: block; margin: 15px 0 5px; font-size: 1.9rem; letter-spacing: -.04em; }
.settlement-state p { color: var(--muted); font-size: .84rem; }

.data-table-wrap { width: 100%; overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.data-table th { padding: 11px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .7rem; letter-spacing: .04em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 14px 10px; border-bottom: 1px solid #efede8; vertical-align: middle; }
.data-table tbody tr:hover { background: #fbfaf7; }
.data-table td strong, .data-table td small { display: block; }
.data-table td small { margin-top: 3px; color: var(--muted); }
.data-table .number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.status { display: inline-flex; min-height: 25px; align-items: center; padding: 0 9px; border: 1px solid #dfdcd4; border-radius: 999px; color: #625f58; background: #f7f6f2; font-size: .68rem; font-weight: 720; }
.status-success { border-color: #b9dfcb; color: var(--green); background: var(--green-wash); }
.table-filter { display: flex; gap: 9px; margin-bottom: 16px; }
.table-filter input { width: min(360px, 100%); }
.empty-state { display: grid; min-height: 190px; place-content: center; justify-items: start; padding: 28px; border: 1px dashed #dcd7ca; border-radius: 12px; color: var(--muted); background: #fbfaf7; }
.empty-state strong { color: var(--ink); }
.empty-state p { max-width: 550px; margin: 8px 0 18px; font-size: .86rem; line-height: 1.6; }
.empty-state.compact { min-height: 150px; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; padding: 0 16px; border: 1px solid transparent; border-radius: 9px; font-size: .8rem; font-weight: 750; text-decoration: none; cursor: pointer; }
.button-primary { border-color: #9a6419; color: #17130d; background: var(--gold-light); }
.button-primary:hover { background: #e8b96d; }
.button-quiet { border-color: #dcd8cf; color: var(--ink); background: #fff; }
.button-quiet:hover { border-color: #bcb7ac; background: #faf9f6; }
.button-wide { width: 100%; }
.alert { margin-bottom: 16px; padding: 13px 15px; border: 1px solid #d9d6ce; border-radius: 10px; color: #4b4944; background: #fff; font-size: .82rem; line-height: 1.5; }
.alert-info { border-color: #d7c4a0; background: #fff9ef; }
.alert-warning { border-color: #e8c16c; background: #fff8df; }
.alert-error { border-color: #f0b4ad; color: var(--red); background: var(--red-wash); }
.message-stack { position: relative; z-index: 4; }

.referral-banner { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; background: linear-gradient(110deg, #fff, #fff8eb); }
.referral-banner p:last-child { color: var(--muted); }
.copy-field { display: flex; width: min(550px, 50%); gap: 8px; }
.copy-field input { min-width: 0; flex: 1; }
.performance-list { display: grid; gap: 19px; }
.performance-list article { display: grid; grid-template-columns: minmax(170px,.25fr) minmax(0,.75fr); align-items: center; gap: 20px; }
.performance-person { display: flex; justify-content: space-between; gap: 12px; font-size: .8rem; }
.performance-person span { color: var(--muted); font-variant-numeric: tabular-nums; }
.stacked-bar { display: flex; height: 28px; overflow: hidden; border-radius: 6px; background: #eeeae2; }
.stacked-bar span { min-width: calc(var(--value) * .004px); flex-grow: var(--value); background: #6f38dd; }
.stacked-bar span:nth-child(2) { background: #db9e38; }
.stacked-bar span:nth-child(3) { background: #9b72ee; }
.stacked-bar span:nth-child(4) { background: #dc77ae; }
.stacked-bar span:nth-child(5) { background: #b59be8; }
.explanation-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.explanation-list li { padding: 15px; border: 1px solid var(--line); border-radius: 10px; }
.explanation-list strong, .explanation-list span { display: block; }
.explanation-list span { margin-top: 5px; color: var(--muted); font-size: .8rem; }
.level-track { display: grid; grid-template-columns: repeat(auto-fit,minmax(110px,1fr)); gap: 10px; }
.level-track > div { padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
.level-track .active { border-color: var(--purple); background: #f4f0ff; }
.level-index { display: block; margin-bottom: 17px; color: var(--purple); font-size: 1.5rem; font-weight: 800; }
.settings-tabs { display: flex; gap: 7px; margin-bottom: 18px; overflow-x: auto; }
.settings-tabs a { min-width: max-content; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: .78rem; text-decoration: none; }
.settings-tabs a.active { border-color: #b88437; color: #75480d; background: var(--gold-wash); }
.verification-layout, .totp-setup { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; }
.verification-upload { margin: 20px 0; }
.support-copy { color: var(--muted); font-size: .85rem; line-height: 1.65; }

.form-stack { display: grid; gap: 16px; }
.field-group { display: grid; gap: 7px; }
.field-group label { font-size: .76rem; font-weight: 720; }
.field-group input, .field-group select, .field-group textarea { width: 100%; }
.field-help, .field-error { margin: 0; font-size: .72rem; line-height: 1.45; }
.field-help { color: var(--muted); }
.field-error { color: var(--red); }
.recovery-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; margin: 20px 0; }
.recovery-grid code { padding: 11px; border: 1px solid var(--line); border-radius: 7px; background: #f7f5ef; text-align: center; }

.auth-body { color: var(--ink); background: #fff; }
.auth-layout { display: grid; min-height: 100vh; grid-template-columns: minmax(360px,.82fr) minmax(520px,1.18fr); }
.auth-brand { position: relative; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; padding: clamp(34px,5vw,80px); color: #f9f7ef; background: radial-gradient(circle at 65% 80%, rgba(221,173,101,.21), transparent 32%), var(--coal); }
.auth-brand::after { position: absolute; right: -8%; bottom: -20%; width: 78%; aspect-ratio: 1; border: 1px solid rgba(221,173,101,.16); border-radius: 50%; box-shadow: 0 0 0 60px rgba(221,173,101,.035), 0 0 0 120px rgba(221,173,101,.02); content: ""; }
.auth-brand-copy { position: relative; z-index: 1; max-width: 560px; }
.auth-brand-copy h1 { margin: 0; font-size: clamp(2.6rem,5.2vw,5.6rem); line-height: .92; letter-spacing: -.07em; }
.auth-brand-copy h1 span { color: var(--gold-light); }
.auth-brand-copy > p:last-child { max-width: 470px; margin-top: 28px; color: #bcbcb5; font-size: clamp(.95rem,1.5vw,1.2rem); line-height: 1.65; }
.auth-proof { position: relative; z-index: 1; display: flex; gap: 18px; color: #aaa9a2; font-size: .75rem; }
.auth-form-side { display: flex; min-height: 100vh; flex-direction: column; align-items: center; justify-content: center; padding: 45px 24px 24px; background: #fbfaf7; }
.auth-card { width: min(510px,100%); padding: clamp(26px,4vw,48px); border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow); }
.auth-card-heading { margin-bottom: 26px; text-align: center; }
.auth-card-heading h2 { margin: 0; font-size: 2rem; letter-spacing: -.045em; }
.auth-card-heading p { margin: 10px 0 0; color: var(--muted); }
.auth-footer { margin-top: 30px; color: #8a877f; font-size: .68rem; }

@media (max-width: 1080px) {
  .metric-strip { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .surface-wide { grid-row: auto; }
  .referral-banner { align-items: stretch; flex-direction: column; }
  .copy-field { width: 100%; }
}

@media (max-width: 760px) {
  .mobile-menu-button { position: fixed; z-index: 45; top: 13px; left: 13px; display: grid; width: 44px; height: 44px; place-items: center; border: 1px solid #d8d4ca; border-radius: 10px; color: var(--ink); background: #fff; box-shadow: 0 8px 22px rgba(0,0,0,.08); }
  .mobile-menu-button svg { width: 22px; }
  .sidebar { width: min(290px,88vw); transform: translateX(-104%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 86px 16px 45px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .period-picker { align-items: stretch; flex-direction: column; }
  .period-picker select { width: 100%; }
  .metric-strip { grid-template-columns: 1fr; }
  .surface { padding: 18px; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .data-table-wrap { overflow: visible; }
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; }
  .data-table tr { margin-bottom: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
  .data-table td { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 8px 0; border: 0; text-align: right; }
  .data-table td:first-child { align-items: flex-start; flex-direction: column; }
  .data-table .number { text-align: right; }
  .performance-list article { grid-template-columns: 1fr; gap: 7px; }
  .verification-layout, .totp-setup { grid-template-columns: 1fr; }
  .auth-layout { display: block; }
  .auth-brand { min-height: 360px; padding: 32px 24px; }
  .auth-form-side { min-height: auto; padding: 34px 16px; }
  .auth-proof { flex-wrap: wrap; }
}

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