/* ==========================================================================
   SCT design system — vanilla CSS, no build step, no framework.
   Light is the default; dark comes from [data-theme="dark"] (the toggle) or
   prefers-color-scheme when the visitor has not chosen. Every colour is a token:
   never hard-code a hex in a page.
   ========================================================================== */

:root {
  /* brand */
  --crimson:      #C8102E;
  --crimson-dark: #A50D26;
  --leaf:         #2E8B57;
  --gold:         #D4AF37;
  --ink:          #0A0A0C;
  --paper:        #FFFFFF;
  --slate:        #86868b;

  /* surfaces */
  --bg:           #FFFFFF;
  --bg-soft:      #F5F5F7;
  --bg-sunken:    #EFEFF2;
  --surface:      #FFFFFF;
  --surface-2:    #FAFAFC;
  --glass:        rgba(255,255,255,.72);

  /* text */
  --text:         #0A0A0C;
  --text-2:       #3A3A3E;
  --text-muted:   #86868b;
  --text-invert:  #FFFFFF;

  /* lines */
  --border:       #E5E5EA;
  --border-soft:  #EFEFF2;

  /* status */
  --ok:           #2E8B57;
  --ok-bg:        #E8F5EE;
  --warn:         #B47B00;
  --warn-bg:      #FDF3E0;
  --err:          #C8102E;
  --err-bg:       #FCEBEE;
  --gold-bg:      #FBF4DF;

  /* shape + depth */
  --r-sm: 8px;  --r: 12px;  --r-lg: 16px;  --r-xl: 24px;  --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(10,10,12,.06), 0 1px 3px rgba(10,10,12,.04);
  --sh-2: 0 4px 12px rgba(10,10,12,.08);
  --sh-3: 0 12px 32px rgba(10,10,12,.12);

  /* type */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fs-xs: .75rem;  --fs-sm: .8125rem;  --fs-base: .9375rem;  --fs-md: 1rem;
  --fs-lg: 1.125rem; --fs-xl: 1.375rem; --fs-2xl: 1.75rem; --fs-3xl: 2.25rem; --fs-4xl: 3rem;

  /* layout */
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --maxw: 1200px;

  /* motion — entrances are ease-out, UI stays under 300ms */
  --ease-out: cubic-bezier(.16,1,.3,1);
  --dur: 240ms;

  color-scheme: light;
}

/* dark by system preference, unless the visitor explicitly chose light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0A0A0C;
    --bg-soft:     #131316;
    --bg-sunken:   #08080A;
    --surface:     #141417;
    --surface-2:   #1B1B1F;
    --glass:       rgba(20,20,23,.72);
    --text:        #F5F5F7;
    --text-2:      #C7C7CC;
    --text-muted:  #8E8E93;
    --text-invert: #0A0A0C;
    --border:      #2C2C2E;
    --border-soft: #232326;
    --ok-bg:       #10251A;
    --warn-bg:     #2A2109;
    --err-bg:      #2A0F14;
    --gold-bg:     #2A2410;
    --sh-1: 0 1px 2px rgba(0,0,0,.5);
    --sh-2: 0 4px 12px rgba(0,0,0,.55);
    --sh-3: 0 12px 32px rgba(0,0,0,.65);
    color-scheme: dark;
  }
}

/* explicit toggle always wins, both ways */
:root[data-theme="dark"] {
  --bg:          #0A0A0C;
  --bg-soft:     #131316;
  --bg-sunken:   #08080A;
  --surface:     #141417;
  --surface-2:   #1B1B1F;
  --glass:       rgba(20,20,23,.72);
  --text:        #F5F5F7;
  --text-2:      #C7C7CC;
  --text-muted:  #8E8E93;
  --text-invert: #0A0A0C;
  --border:      #2C2C2E;
  --border-soft: #232326;
  --ok-bg:       #10251A;
  --warn-bg:     #2A2109;
  --err-bg:      #2A0F14;
  --gold-bg:     #2A2410;
  --sh-1: 0 1px 2px rgba(0,0,0,.5);
  --sh-2: 0 4px 12px rgba(0,0,0,.55);
  --sh-3: 0 12px 32px rgba(0,0,0,.65);
  color-scheme: dark;
}

/* --------------------------------------------------------------- reset */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, video { max-width: 100%; height: auto; display: block; }
a { color: var(--crimson); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4,h5 { margin: 0 0 .5em; line-height: 1.2; font-weight: 700; letter-spacing: -.015em; }
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
p  { margin: 0 0 1em; }
small, .small { font-size: var(--fs-sm); }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .875em; }

:focus-visible { outline: 2px solid var(--crimson); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------ utilities */

.wrap      { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.wrap-tight{ width: 100%; max-width: 880px; margin: 0 auto; padding: 0 20px; }
.stack > * + * { margin-top: 16px; }
.row       { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row > .input, .row > .select, .row-between > .input, .row-between > .select { width: auto; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid      { display: grid; gap: 16px; }
.grid-2    { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3    { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4    { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0,1fr); } }

.muted     { color: var(--text-muted); }
.strong    { font-weight: 600; }
.center    { text-align: center; }
.right     { text-align: right; }
.nowrap    { white-space: nowrap; }
.mt-0{margin-top:0}.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}.mt-4{margin-top:32px}
.mb-0{margin-bottom:0}.mb-1{margin-bottom:8px}.mb-2{margin-bottom:16px}.mb-3{margin-bottom:24px}
.hide { display: none !important; }
.eyebrow {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--crimson);
}

/* --------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card-pad-lg { padding: 28px; }
.card-soft  { background: var(--surface-2); }
.card-title { font-size: var(--fs-md); font-weight: 700; margin: 0 0 12px; }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 600; }
.stat-value { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.02em; }
.stat-sub   { font-size: var(--fs-sm); color: var(--text-muted); }

/* ------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: var(--fs-base); font-weight: 600; line-height: 1;
  padding: 11px 18px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out),
              background-color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.btn:hover { text-decoration: none; background: var(--bg-soft); }
.btn:active { transform: scale(.98); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }

.btn-primary { background: var(--crimson); border-color: var(--crimson); color: #fff; }
.btn-primary:hover { background: var(--crimson-dark); border-color: var(--crimson-dark); }
.btn-outline { background: transparent; border-color: var(--crimson); color: var(--crimson); }
.btn-outline:hover { background: var(--err-bg); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #241d05; }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-pill { border-radius: var(--r-pill); padding-left: 22px; padding-right: 22px; }
.btn-sm { padding: 7px 12px; font-size: var(--fs-sm); }
.btn-lg { padding: 15px 26px; font-size: var(--fs-md); }
.btn-block { display: flex; width: 100%; }

/* --------------------------------------------------------------- forms */

.field { display: block; margin-bottom: 16px; }
.field > label, .label {
  display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin-bottom: 6px;
}
.input, .select, .textarea, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; font: inherit; font-size: var(--fs-base); color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 11px 13px; transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.input:focus, .select:focus, .textarea:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--crimson); box-shadow: 0 0 0 3px rgba(200,16,46,.16);
}
.input::placeholder, textarea::placeholder { color: var(--text-muted); }
.textarea, textarea { min-height: 110px; resize: vertical; }
select, .select { appearance: none; background-image: none; padding-right: 34px; cursor: pointer; }
.hint { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 6px; }
.field-err .input, .field-err input { border-color: var(--err); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs-sm); }
.check input { width: auto; margin-top: 3px; flex: none; }
/* honeypot for public forms (D25) — visually gone, still submitted by bots */
.hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

/* -------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-lg); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); font-weight: 700; background: var(--surface-2); white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-empty { padding: 36px 16px; text-align: center; color: var(--text-muted); }

/* -------------------------------------------------------------- badges */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em;
  padding: 3px 9px; border-radius: var(--r-pill); white-space: nowrap;
  background: var(--bg-soft); color: var(--text-2);
}
.badge-ok   { background: var(--ok-bg);   color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err  { background: var(--err-bg);  color: var(--err); }
.badge-gold { background: var(--gold-bg); color: #8A6D12; }
:root[data-theme="dark"] .badge-gold { color: var(--gold); }

/* -------------------------------------------------------------- alerts */

.flashes { display: grid; gap: 10px; margin-bottom: 20px; }
.alert {
  border: 1px solid var(--border); border-left: 3px solid var(--slate);
  border-radius: var(--r); padding: 12px 16px; font-size: var(--fs-base); background: var(--surface);
}
.alert-ok   { border-left-color: var(--ok);   background: var(--ok-bg);   color: var(--ok); }
.alert-warn { border-left-color: var(--warn); background: var(--warn-bg); color: var(--warn); }
.alert-err  { border-left-color: var(--err);  background: var(--err-bg);  color: var(--err); }

/* ------------------------------------------------------ public nav/foot */

.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50; height: var(--topbar-h);
  display: flex; align-items: center;
  background: var(--glass); backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--border);
}
.navbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand img { height: 30px; width: auto; }
.nav-links { display: flex; align-items: center; gap: 26px; }
.nav-links a { color: var(--text-2); font-size: var(--fs-base); font-weight: 500; }
.nav-links a:hover, .nav-links a.is-active { color: var(--text); text-decoration: none; }
.nav-right { display: flex; align-items: center; gap: 10px; }
body.has-navbar { padding-top: var(--topbar-h); }

.site-foot { border-top: 1px solid var(--border); background: var(--bg-soft); padding: 48px 0 32px; margin-top: 64px; }
.site-foot .cols { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 32px; }
.site-foot h5 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); margin-bottom: 12px; }
.site-foot a, .site-foot p, .site-foot li { color: var(--text-muted); font-size: var(--fs-sm); }
.site-foot a:hover { color: var(--text); }
.site-foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.site-foot .copyright { border-top: 1px solid var(--border); margin-top: 32px; padding-top: 20px; font-size: var(--fs-xs); color: var(--text-muted); }
@media (max-width: 800px) { .site-foot .cols { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 480px) { .site-foot .cols { grid-template-columns: 1fr; } }

/* -------------------------------------------------------- portal shell */

.portal { min-height: 100vh; background: var(--bg-soft); }

.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40; height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  background: var(--glass); backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand img { height: 26px; }
.topbar-spacer { flex: 1; }
.topbar-wallets { display: flex; gap: 18px; align-items: center; }
.topbar-wallet { display: flex; flex-direction: column; line-height: 1.15; }
.topbar-wallet span { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 700; }
.topbar-wallet strong { font-size: var(--fs-base); font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .topbar-wallets { display: none; } }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--r); border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 16px; line-height: 1;
}
.icon-btn:hover { background: var(--bg-soft); }

.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w); z-index: 35;
  background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 16px 12px 40px;
  transition: transform var(--dur) var(--ease-out);
}
.sidebar .nav-group { margin-bottom: 18px; }
.sidebar .nav-group > h6 {
  margin: 0 0 6px; padding: 0 10px;
  font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted);
}
.sidebar a {
  display: block; padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: var(--fs-base); font-weight: 500;
}
.sidebar a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.sidebar a.is-active { background: var(--err-bg); color: var(--crimson); font-weight: 600; }

.portal-main { padding: calc(var(--topbar-h) + 24px) 24px 64px; margin-left: var(--sidebar-w); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: var(--fs-2xl); margin: 0; }
.page-head .sub { color: var(--text-muted); font-size: var(--fs-sm); margin: 4px 0 0; }

.sidebar-scrim {
  position: fixed; inset: 0; z-index: 34; background: rgba(0,0,0,.4);
  opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease-out);
}
@media (max-width: 1000px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--sh-3); }
  body.drawer-open .sidebar { transform: translateX(0); }
  body.drawer-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  .portal-main { margin-left: 0; padding-left: 16px; padding-right: 16px; }
}
@media (min-width: 1001px) { .drawer-toggle { display: none; } }

.impersonation-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  background: var(--gold); color: #241d05; padding: 8px 16px;
  font-size: var(--fs-sm); font-weight: 600; display: flex; gap: 12px;
  align-items: center; justify-content: center;
}
.impersonation-bar a { color: #241d05; text-decoration: underline; }

/* -------------------------------------------------------------- toasts */

.toast-host { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: grid; gap: 8px; }
.toast {
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--r);
  font-size: var(--fs-sm); box-shadow: var(--sh-3); max-width: 340px;
  animation: toast-in var(--dur) var(--ease-out) both;
}
.toast-ok  { background: var(--ok); }
.toast-err { background: var(--err); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* -------------------------------------------------------------- reveal */

[data-reveal] {
  opacity: 0; transform: translateY(12px);
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
  will-change: opacity, transform;
}
[data-reveal].is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
                           transition-duration: .01ms !important; scroll-behavior: auto !important; }
  [data-reveal] { opacity: 1; transform: none; }
}

/* --------------------------------------------------------- auth screens */

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background: var(--bg-soft); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
             border-radius: var(--r-xl); padding: 32px; box-shadow: var(--sh-2); }
.auth-card .brand { justify-content: center; margin-bottom: 20px; }
.auth-card .brand img { height: 36px; margin: 0 auto; }
.auth-card h1 { font-size: var(--fs-xl); text-align: center; margin-bottom: 4px; }
.auth-card .sub { text-align: center; color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: 24px; }
.auth-alt { text-align: center; font-size: var(--fs-sm); color: var(--text-muted); margin-top: 20px; }

/* Public navbar — mobile: keep brand + primary actions, drop the link row (no JS needed). */
@media (max-width: 760px) {
  .navbar .wrap { gap: 10px; }
  .navbar .nav-links { display: none; }
  .navbar .brand img { height: 24px; }
  .navbar .nav-right { gap: 6px; }
  .navbar .nav-right .btn { padding-left: 12px; padding-right: 12px; }
}

/* ------------------------------------------------------- progress meter */
/* Used by the QV-maintenance gate on the member dashboard and Bonus History. */
.progress { height: 8px; border-radius: var(--r-pill); background: var(--bg-sunken); overflow: hidden; }
.progress > span { display: block; height: 100%; min-width: 2px; border-radius: var(--r-pill);
                   background: linear-gradient(90deg, var(--crimson), var(--gold));
                   transition: width .3s var(--ease-out); }
.progress.is-done > span { background: var(--leaf); }
@media (prefers-reduced-motion: reduce) { .progress > span { transition: none; } }

/* Brand lockup: colour on light surfaces, white transparent on dark (toggle + system). */
.brand-dark { display: none; }
:root[data-theme="dark"] .brand-light { display: none; }
:root[data-theme="dark"] .brand-dark { display: inline-block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-light { display: none; }
  :root:not([data-theme="light"]) .brand-dark { display: inline-block; }
}
