/* ============================================================================
   Survista Experience — design system
   Brand: crimson #C1002C on warm paper. Type: Fira Sans (UI/numbers, the FF Meta
   Pro lineage) + Spectral (headings). Metaphor: a precise private-bank statement,
   not a dashboard. Crimson is a scalpel — wordmark, active nav, primary action,
   the headline rule. Everything else is warm ink on paper.
   ========================================================================== */

:root {
  --paper:      #fbfaf8;
  --surface:    #ffffff;
  --surface-2:  #f6f3ee;
  --ink:        #211d1b;
  --ink-soft:   #403a36;
  --slate:      #6e6a66;
  --line:       #e7e3dc;
  --line-soft:  #f0ede7;
  --crimson:    #c1002c;
  --crimson-deep:#8e0020;
  --crimson-tint:#fbeef0;
  --ok:         #2f6b4f;
  --warn:       #9a6a12;

  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --sans:  "Fira Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --r-lg: 5px;   /* panels */
  --r-sm: 3px;   /* buttons, inputs */
  --wrap: 1040px;
  --bar-h: 60px;

  color-scheme: light;
}

/* Dark tokens: applied by OS preference unless the viewer forced light, or
   forced explicitly via data-theme="dark". */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:      #1a1715;
    --surface:    #221e1b;
    --surface-2:  #272320;
    --ink:        #ece8e2;
    --ink-soft:   #d6d0c8;
    --slate:      #a49e97;
    --line:       #352f2a;
    --line-soft:  #2b2622;
    --crimson:    #f0486a;
    --crimson-deep:#f26d87;
    --crimson-tint:#2a1a1d;
    --ok:         #6bbd93;
    --warn:       #d6a24b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper:      #1a1715;
  --surface:    #221e1b;
  --surface-2:  #272320;
  --ink:        #ece8e2;
  --ink-soft:   #d6d0c8;
  --slate:      #a49e97;
  --line:       #352f2a;
  --line-soft:  #2b2622;
  --crimson:    #f0486a;
  --crimson-deep:#f26d87;
  --crimson-tint:#2a1a1d;
  --ok:         #6bbd93;
  --warn:       #d6a24b;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  font-feature-settings: "kern" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }

a { color: var(--crimson); text-decoration: none; }
a:hover { color: var(--crimson-deep); }

p { margin: 0 0 1rem; max-width: 68ch; }

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

/* numbers: tabular, grouped — quiet precision */
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ---- top bar ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.1) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--wrap); margin: 0 auto;
  min-height: var(--bar-h);
  padding: 0 24px; position: relative;
  display: flex; align-items: center; gap: 16px;
}
.wordmark { display: inline-flex; align-items: center; padding: 4px 0; color: var(--ink); }
.sx-logo { height: 26px; width: auto; display: block; }
.sx-word { fill: var(--ink); }
.sx-dot { fill: var(--crimson); }

/* hamburger — shown on phones only (see media query) */
.hamburger {
  display: none; margin-left: auto; flex: none;
  width: 42px; height: 38px;
  flex-direction: column; justify-content: center; align-items: center; gap: 4px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); cursor: pointer;
}
.hamburger span { display: block; width: 18px; height: 2px; background: var(--ink); border-radius: 2px;
  transition: transform .2s, opacity .2s; }
.topbar.open .hamburger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.topbar.open .hamburger span:nth-child(2) { opacity: 0; }
.topbar.open .hamburger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.menu { display: flex; flex: 1 1 auto; align-items: center; gap: 20px; }
.nav { display: flex; gap: 4px; align-items: center; }
.nav a {
  color: var(--ink-soft); font-size: 0.94rem; font-weight: 500;
  padding: 8px 12px; border-radius: var(--r-sm);
  border-bottom: 2px solid transparent;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { color: var(--ink); border-bottom-color: var(--crimson); border-radius: 0; }

.menu-user { display: flex; align-items: center; gap: 10px; margin-left: auto; white-space: nowrap; }
.menu-user .who { display: flex; flex-direction: column; line-height: 1.1; }
.avatar {
  width: 30px; height: 30px; border-radius: 999px; flex: none;
  background: var(--crimson); color: #fff;
  display: grid; place-items: center; font-size: 0.8rem; font-weight: 600;
  font-family: var(--sans);
}
.who-name { font-size: 0.9rem; font-weight: 500; line-height: 1.1; }
.who-sub { font-size: 0.76rem; color: var(--slate); line-height: 1.1; }

/* ---- notification bell -------------------------------------------------- */
.bell { position: relative; flex: none; }
.bell-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 38px; height: 38px; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); cursor: pointer;
  transition: border-color .12s, color .12s;
}
.bell-btn:hover { border-color: var(--slate); color: var(--ink); }
.bell-btn svg { width: 18px; height: 18px; display: block; }
.bell-badge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--crimson); color: #fff;
  font-size: 0.68rem; font-weight: 600; line-height: 18px; text-align: center;
  font-variant-numeric: tabular-nums; box-shadow: 0 0 0 2px var(--paper);
}
.bell-badge[hidden] { display: none; }
.bell-menu {
  position: absolute; top: calc(100% + 10px); right: 0; width: 324px; max-width: 86vw;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 14px 34px rgba(0,0,0,.14); overflow: hidden; display: none; z-index: 40;
}
.bell.open .bell-menu { display: block; }
.bell-head { padding: 12px 16px; font-weight: 600; font-size: 0.9rem;
  border-bottom: 1px solid var(--line); background: var(--surface-2); }
.bell-list { max-height: min(60vh, 420px); overflow-y: auto; }
.bell-item { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft); color: var(--ink); }
.bell-item:last-child { border-bottom: 0; }
.bell-item:hover { background: var(--surface-2); color: var(--ink); }
.bell-item.unread { background: var(--crimson-tint); }
.bell-dot { width: 7px; height: 7px; border-radius: 999px; background: transparent; flex: none; margin-top: 6px; }
.bell-item.unread .bell-dot { background: var(--crimson); }
.bell-title { font-weight: 500; font-size: 0.9rem; display: block; }
.bell-sub { color: var(--slate); font-size: 0.78rem; }
.bell-empty { padding: 28px 16px; color: var(--slate); text-align: center; font-size: 0.9rem; }

/* ---- layout ------------------------------------------------------------- */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 36px 24px 72px; }
.section { margin: 40px 0 0; }
.section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { font-size: 1.15rem; }
.eyebrow { font-size: 0.85rem; color: var(--slate); font-family: var(--sans); font-weight: 500; }

/* ---- statement masthead (hero) ----------------------------------------- */
.masthead { padding: 8px 0 28px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.masthead .greet { font-family: var(--serif); font-size: 1.5rem; font-weight: 500; color: var(--ink); }
.masthead .asof { color: var(--slate); font-size: 0.9rem; margin-top: 2px; }
.total { margin-top: 22px; display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.total .fig {
  font-family: var(--sans); font-weight: 600; font-size: clamp(2.4rem, 7vw, 3.4rem);
  line-height: 1; letter-spacing: -0.02em;
}
.total .fig .ccy { color: var(--slate); font-size: 0.42em; font-weight: 500; margin-right: 0.35em; letter-spacing: 0; }
.total .cap { color: var(--slate); font-size: 0.92rem; padding-bottom: 6px; }
.rule-crimson { height: 2px; width: 54px; background: var(--crimson); margin: 16px 0 0; border: 0; }
.tagline { font-family: var(--serif); font-style: italic; color: var(--ink-soft); font-size: 1.02rem; margin-top: 14px; }

/* ---- panel / ledger ----------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.panel + .panel { margin-top: 14px; }

.ledger { width: 100%; border-collapse: collapse; }
.ledger th, .ledger td { text-align: left; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.ledger thead th { font-size: 0.78rem; font-weight: 600; color: var(--slate); background: var(--surface-2); letter-spacing: 0.01em; }
.ledger tbody tr:last-child td { border-bottom: 0; }
.ledger tbody tr:hover td { background: var(--surface-2); }
.ledger td.r, .ledger th.r { text-align: right; }
.ledger .pf-name { font-weight: 600; }
.ledger .sub { color: var(--slate); font-size: 0.86rem; }
.ledger .hold-line { display: flex; justify-content: space-between; gap: 16px; padding: 2px 0; }
.ledger .hold-line .nm { color: var(--ink-soft); }

/* ---- tags / pills ------------------------------------------------------- */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.78rem; font-weight: 500; font-family: var(--sans);
  padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line);
}
.tag.crimson { background: var(--crimson-tint); color: var(--crimson-deep); border-color: color-mix(in srgb, var(--crimson) 25%, var(--line)); }
.tag.muted { color: var(--slate); }

/* module tiles */
.modules { display: flex; flex-wrap: wrap; gap: 10px; }
.module {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); font-weight: 500; font-size: 0.95rem;
}
.module .mi { width: 8px; height: 8px; border-radius: 999px; background: var(--crimson); flex: none; }
.module.off { color: var(--slate); background: transparent; border-style: dashed; }
.module.off .mi { background: var(--line); }

/* ---- buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-size: 0.94rem; font-weight: 500;
  padding: 9px 16px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: border-color .12s, background .12s;
}
.btn:hover { border-color: var(--slate); color: var(--ink); }
.btn.primary { background: var(--crimson); border-color: var(--crimson); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--crimson-deep); border-color: var(--crimson-deep); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 0.86rem; }
.btn.block { width: 100%; justify-content: center; }
.ms-logo { width: 16px; height: 16px; display: inline-grid; grid-template-columns: 1fr 1fr; gap: 1.5px; flex: none; }
.ms-logo i { display: block; }
.ms-logo i:nth-child(1){ background:#f25022 } .ms-logo i:nth-child(2){ background:#7fba00 }
.ms-logo i:nth-child(3){ background:#00a4ef } .ms-logo i:nth-child(4){ background:#ffb900 }

/* ---- documents ---------------------------------------------------------- */
.doc-row { display: flex; align-items: center; gap: 16px; padding: 15px 18px; border-bottom: 1px solid var(--line-soft); }
.doc-row:last-child { border-bottom: 0; }
.doc-ic {
  width: 38px; height: 46px; flex: none; border-radius: 3px; position: relative;
  background: var(--surface-2); border: 1px solid var(--line);
}
.doc-ic::after { content: ""; position: absolute; left: 7px; right: 7px; top: 12px; height: 2px;
  background: var(--line); box-shadow: 0 6px 0 var(--line), 0 12px 0 var(--line), 0 18px 0 var(--crimson); }
.doc-main { flex: 1 1 auto; min-width: 0; }
.doc-title { font-weight: 600; }
.doc-meta { color: var(--slate); font-size: 0.85rem; margin-top: 1px; }
.doc-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.new-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--crimson); display: inline-block; }

/* ---- messages ----------------------------------------------------------- */
.thread-layout { display: grid; grid-template-columns: 290px 1fr; gap: 16px; align-items: start; }
.thread-list .panel { padding: 0; }
.thread-item { display: block; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); color: var(--ink); }
.thread-item:last-child { border-bottom: 0; }
.thread-item:hover { background: var(--surface-2); color: var(--ink); }
.thread-item.active { background: var(--crimson-tint); box-shadow: inset 3px 0 0 var(--crimson); }
.thread-item .t-subj { font-weight: 600; font-size: 0.95rem; }
.thread-item .t-snip { color: var(--slate); font-size: 0.84rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-item .t-when { color: var(--slate); font-size: 0.76rem; margin-top: 3px; }

.convo { display: flex; flex-direction: column; min-height: 360px; }
.convo-head { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.convo-head h3 { font-size: 1.05rem; }
.convo-head .sub { color: var(--slate); font-size: 0.85rem; margin-top: 2px; }
.convo-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; flex: 1 1 auto; }
.msg { max-width: 76%; }
.msg .bubble { padding: 11px 15px; border-radius: 12px; font-size: 0.95rem; line-height: 1.5; }
.msg .meta { font-size: 0.74rem; color: var(--slate); margin-top: 5px; }
.msg.them { align-self: flex-start; }
.msg.them .bubble { background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg.me { align-self: flex-end; }
.msg.me .bubble { background: var(--crimson); color: #fff; border-bottom-right-radius: 3px; }
.msg.me .meta { text-align: right; }
.convo-compose { border-top: 1px solid var(--line); padding: 14px 16px; display: flex; gap: 10px; align-items: flex-end; }
.convo-compose textarea {
  flex: 1 1 auto; resize: vertical; min-height: 44px; max-height: 160px;
  font-family: var(--sans); font-size: 0.95rem; line-height: 1.45;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
}
.convo-compose textarea:focus { border-color: var(--crimson); outline: none; }

/* ---- forms / inputs (login etc.) --------------------------------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.86rem; color: var(--ink-soft); font-weight: 500; margin-bottom: 5px; }
.input {
  width: 100%; font-family: var(--sans); font-size: 0.95rem;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
}
.input:focus { border-color: var(--crimson); outline: none; }
select.input { appearance: auto; }

/* ---- staff upload form -------------------------------------------------- */
.upload-form { padding: 18px 18px 16px; }
.uf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; }
.upload-form .field { margin-bottom: 12px; }
.upload-form .field span { display: block; font-size: 0.86rem; color: var(--ink-soft); font-weight: 500; margin-bottom: 5px; }
.uf-actions { display: flex; justify-content: flex-end; margin-top: 2px; }
@media (max-width: 680px) { .uf-grid { grid-template-columns: 1fr; } }

/* ---- empty / notice ----------------------------------------------------- */
.empty { text-align: center; color: var(--slate); padding: 48px 24px; }
.empty .big { font-family: var(--serif); font-size: 1.2rem; color: var(--ink-soft); margin-bottom: 6px; }
.notice { padding: 14px 16px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft); font-size: 0.92rem; }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); background: color-mix(in srgb, var(--warn) 8%, var(--surface)); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; background: var(--surface-2); padding: 2px 6px; border-radius: 3px; }

/* ---- footer ------------------------------------------------------------- */
.foot { max-width: var(--wrap); margin: 0 auto; padding: 24px; color: var(--slate); font-size: 0.82rem;
  border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.foot .sig { font-family: var(--serif); font-style: italic; }

/* ---- login / landing ---------------------------------------------------- */
.landing { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.hero {
  display: grid; grid-template-columns: 1.1fr 0.9fr; align-items: center; gap: 48px;
  max-width: var(--wrap); margin: 0 auto; padding: 64px 24px; width: 100%;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); line-height: 1.08; letter-spacing: -0.02em; }
.hero .lede { font-size: 1.1rem; color: var(--ink-soft); margin-top: 18px; max-width: 46ch; }
.hero .tag-de { font-family: var(--serif); font-style: italic; color: var(--crimson-deep); font-size: 1.15rem; margin-bottom: 18px; }
.signin-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 28px; }
.signin-card h2 { font-size: 1.15rem; margin-bottom: 4px; }
.signin-card .sub { color: var(--slate); font-size: 0.9rem; margin-bottom: 20px; }
.hairline { height: 1px; background: var(--line); border: 0; margin: 18px 0; }

/* ---- responsive --------------------------------------------------------- */
@media (max-width: 860px) {
  .thread-layout { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; padding: 40px 24px; gap: 28px; }
}
@media (max-width: 680px) {
  body { font-size: 15px; }
  .topbar-inner { padding: 10px 16px; }
  .hamburger { display: inline-flex; }
  .menu {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: 8px; box-shadow: 0 10px 28px rgba(0,0,0,.10);
  }
  .topbar.open .menu { display: flex; }
  .nav { flex-direction: column; align-items: stretch; gap: 2px; }
  .nav a { padding: 12px; border-bottom: 0; border-radius: var(--r-sm); }
  .nav a.active { background: var(--crimson-tint); color: var(--ink); border-bottom: 0;
    box-shadow: inset 3px 0 0 var(--crimson); }
  .menu-user { margin-left: 0; width: 100%; gap: 12px; flex-wrap: wrap;
    border-top: 1px solid var(--line-soft); margin-top: 6px; padding: 12px 6px 4px; }
  .menu-user .who { flex: 1 1 auto; }
  .wrap { padding: 24px 16px 56px; }
  .ledger th, .ledger td { padding: 11px 12px; }
  .ledger .hide-sm { display: none; }
  .doc-row { flex-wrap: wrap; }
  .total { flex-direction: column; align-items: flex-start; gap: 4px; }
  .total .cap { padding-bottom: 0; }
  .section-head { flex-wrap: wrap; }
  .doc-actions { width: 100%; justify-content: flex-end; }
  /* portfolios become a stacked block list on phones — no table can overflow */
  .ledger, .ledger tbody, .ledger tr, .ledger td { display: block; width: 100%; }
  .ledger thead { display: none; }
  .ledger tr { padding: 13px 15px; border-bottom: 1px solid var(--line-soft); }
  .ledger tbody tr:last-child { border-bottom: 0; }
  .ledger td { border: 0; padding: 2px 0; }
  .ledger td.r { text-align: left; }
  .ledger td.r.num { font-weight: 600; margin-top: 2px; }
  .ledger .hold-line { flex-direction: column; align-items: flex-start; gap: 0; }
  .sx-logo { height: 23px; }
  .section-head .eyebrow { display: none; }
  .modules { flex-wrap: wrap; }
  .module { flex: 1 1 140px; }
  .wrap { overflow-x: hidden; }
}
@media (max-width: 680px) { html { overflow-x: hidden; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- document viewer (a statement sheet) -------------------------------- */
.doc-paper { max-width: 760px; margin: 0 auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 48px 56px; }
.doc-paper .dp-brand { font-family: var(--sans); font-weight: 600; letter-spacing: 0.22em;
  text-transform: uppercase; font-size: 0.95rem; color: var(--ink); }
.doc-paper .dp-rule { height: 2px; width: 54px; background: var(--crimson); margin: 10px 0 30px; }
.doc-paper h1 { font-size: 1.7rem; margin-bottom: 6px; }
.doc-paper .dp-meta { color: var(--slate); font-size: 0.9rem; margin-bottom: 28px; }
.doc-paper .dp-body { font-size: 1.02rem; line-height: 1.7; color: var(--ink-soft); }
.doc-paper .dp-body p { max-width: none; }
.doc-toolbar { max-width: 760px; margin: 0 auto 18px; display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap; }

@media print {
  .topbar, .foot, .doc-toolbar, .noprint { display: none !important; }
  body { background: #fff; }
  .wrap { padding: 0; }
  .doc-paper { border: 0; border-radius: 0; padding: 0; max-width: none; }
}
