/* Soft Sand (default) — warm cream + muted teal */
:root,
[data-theme="sand"] {
  --bg: #f4efe6;
  --bg2: #ebe4d8;
  --card: #fffcf7;
  --text: #1c1917;
  --muted: #78716c;
  --accent: #0d9488;
  --accent2: #0f766e;
  --good: #15803d;
  --good-soft: #166534;
  --warn: #a16207;
  --bad: #b91c1c;
  --border: #e0d6c8;
  --input-bg: #ffffff;
  --header-bg: #fffcf7ee;
  --secondary: #e7dfd2;
  --hover: #efe8dc;
  --active-bg: #ccfbf155;
  --active-fg: #0f766e;
  --active-border: #5eead480;
  --danger-bg: #9f1239;
  --danger-fg: #9f1239;
  --avatar-from: #14b8a6;
  --avatar-to: #0f766e;
  --brand-from: #0d9488;
  --brand-to: #15803d;
  --shadow: #1c191722;
  --overlay: #1c191799;
  --auth-glow-1: #99f6e455;
  --auth-glow-2: #fde68a44;
  --grade-b: #16a34a;
  --badge-on-fg: #166534;
  --badge-on-bg: #dcfce7;
  --badge-off-fg: #9f1239;
  --badge-off-bg: #ffe4e6;
  --badge-admin-fg: #0f766e;
  --badge-admin-bg: #ccfbf1;
  --pillar-bar: #e7dfd2;
  --chart-tick: #78716c;
  --chart-grid: #e0d6c888;
  --chart-accent: #0d9488;
  --chart-good: #16a34a;
  --header-h: 100px;
  --sidebar-w: 260px;
}

/* Classic dark navy (previous default) */
[data-theme="dark"] {
  --bg: #0b1220;
  --bg2: #111a2b;
  --card: #162033;
  --text: #e8eef8;
  --muted: #8fa0b8;
  --accent: #3b82f6;
  --accent2: #2563eb;
  --good: #22c55e;
  --good-soft: #86efac;
  --warn: #eab308;
  --bad: #ef4444;
  --border: #243247;
  --input-bg: #0d1524;
  --header-bg: #0e1728ee;
  --secondary: #243247;
  --hover: #1c2a42;
  --active-bg: #1d4ed833;
  --active-fg: #93c5fd;
  --active-border: #1d4ed855;
  --danger-bg: #7f1d1d;
  --danger-fg: #fca5a5;
  --avatar-from: #3b82f6;
  --avatar-to: #1d4ed8;
  --brand-from: #2563eb;
  --brand-to: #16a34a;
  --shadow: #0008;
  --overlay: #000a;
  --auth-glow-1: #1e3a5f55;
  --auth-glow-2: #14532d33;
  --grade-b: #86efac;
  --badge-on-fg: #86efac;
  --badge-on-bg: #14532d44;
  --badge-off-fg: #fca5a5;
  --badge-off-bg: #450a0a44;
  --badge-admin-fg: #93c5fd;
  --badge-admin-bg: #1e3a8a44;
  --pillar-bar: #243247;
  --chart-tick: #8fa0b8;
  --chart-grid: #24324755;
  --chart-accent: #3b82f6;
  --chart-good: #22c55e;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a { color: var(--accent); }
button, input, select, textarea {
  font: inherit;
  color: var(--text);
}
button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  padding: 0.5rem 0.9rem;
  font-weight: 600;
}
button.secondary { background: var(--secondary); color: var(--text); }
button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
button.danger { background: var(--danger-bg); color: #fff; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
input, select, textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  color: var(--text);
}
label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.45rem 0 0.25rem;
}
.hidden { display: none !important; }

.env-banner {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.75rem;
  background: #b45309;
  color: #fff7ed;
}
.env-banner.sandbox { background: #b45309; }
.env-banner.beta { background: #1d4ed8; }

.example-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.45rem 1rem;
  background: #7c2d12;
  color: #fff7ed;
  border-bottom: 1px solid #9a3412;
}
.example-banner-text {
  max-width: 820px;
  line-height: 1.35;
}
.example-banner-btn {
  background: #fff7ed;
  color: #7c2d12;
  border: 0;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}
.example-banner-btn:hover { background: #ffedd5; }
.example-banner-exit {
  background: #fff7ed;
  color: #7c2d12;
  border: 1px solid #fed7aa;
}
#btn-exit-demo-header {
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.example-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #7c2d12;
  color: #fff7ed;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  vertical-align: middle;
}
.example-export-note {
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #7c2d12;
  font-size: 0.82rem;
  line-height: 1.4;
}
[data-theme="dark"] .example-export-note {
  background: #431407;
  border-color: #9a3412;
  color: #fed7aa;
}
.signed-out-contact-bar {
  display: none;
  margin: 0 0 1rem;
}
body.signed-out-contact .signed-out-contact-bar {
  display: block;
}
body.signed-out-contact .sidebar,
body.signed-out-contact .app-header,
body.signed-out-contact .example-banner,
body.signed-out-contact .side-actions {
  display: none !important;
}
body.signed-out-contact #app-shell {
  display: block;
}
body.signed-out-contact .app-body {
  display: block;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
}
body.signed-out-contact .content {
  margin: 0 auto;
  max-width: 52rem;
  padding: 1.25rem 1rem 2.5rem;
}

body.example-mode .table-wrap {
  position: relative;
}
body.example-mode .table-wrap::before {
  content: "EXAMPLE DATA";
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #7c2d12;
  padding: 0.25rem 0.15rem 0.35rem;
}
[data-theme="dark"] body.example-mode .table-wrap::before {
  color: #fdba74;
}

.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--overlay);
  display: grid;
  place-items: end center;
  padding: 1.25rem;
}
.tour-card {
  width: min(520px, 100%);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem 1.2rem 1rem;
  box-shadow: 0 16px 40px var(--shadow);
  margin-bottom: 1.5rem;
}
.tour-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9a3412;
}
.tour-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
}
.tour-card p {
  margin: 0 0 0.65rem;
  color: var(--muted);
  line-height: 1.45;
}
.tour-step {
  font-size: 0.78rem;
}
.tour-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Signed-out landing */
#signed-out-landing {
  min-height: 100vh;
  padding: 0.75rem 1.25rem 1.75rem;
  background:
    radial-gradient(1000px 500px at 10% -10%, var(--auth-glow-1), transparent),
    radial-gradient(800px 400px at 100% 0%, var(--auth-glow-2), transparent),
    var(--bg);
}
.signed-out-main {
  width: min(1100px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 460px);
  grid-template-areas:
    "copy auth"
    "details details";
  gap: 1rem 2rem;
  align-items: start;
}
.signed-out-copy {
  grid-area: copy;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
#signed-out-title { order: 1; }
.signed-out-lead { order: 2; }
.signed-out-legal-lead { order: 3; }
#signed-out-hero-cta { order: 4; }
#landing-example-preview { order: 5; }
#signed-out-landing #auth-screen {
  grid-area: auth;
  min-height: 0;
  padding: 0;
  display: block;
  background: none;
  place-items: unset;
}
.signed-out-details {
  grid-area: details;
  min-width: 0;
}
#signed-out-landing .home-banner-title {
  color: var(--text);
  text-shadow: none;
  font-size: clamp(1.35rem, 3.1vw, 1.85rem);
  line-height: 1.22;
  max-width: 18em;
}
.signed-out-lead {
  margin: 0.4rem 0 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.signed-out-legal-lead {
  margin: 0.45rem 0 0;
  max-width: 38rem;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text);
}
.landing-example-preview {
  margin: 0.85rem 0 0;
  max-width: 100%;
}
.landing-example-job {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.75rem;
  margin: 0.75rem 0 0;
}
.landing-example-job .landing-example-card {
  margin: 0;
  display: flex;
  flex-direction: column;
}
.landing-example-job img {
  max-height: 200px;
  object-fit: cover;
  object-position: top;
}
.landing-example-job figcaption {
  padding: 0.45rem 0.65rem 0.6rem;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--muted);
}
.landing-example-eyebrow {
  margin: 0 0 0.4rem;
}
.landing-example-badge {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: #7c2d12;
  color: #fff7ed;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.landing-example-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px var(--shadow);
  overflow: hidden;
}
.landing-example-card img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  object-position: top;
}
.landing-example-captions {
  margin: 0.45rem 0 0;
  max-width: 36rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}
.landing-example-captions p {
  margin: 0 0 0.2rem;
}
.landing-example-captions p:last-child {
  margin-bottom: 0;
}
.signed-out-hero-cta {
  margin: 0.65rem 0 0;
}
#btn-demo-hero {
  font-size: 1.05rem;
  padding: 0.7rem 1.35rem;
  font-weight: 700;
}
.signed-out-hero-hint {
  margin: 0.35rem 0 0;
  max-width: 28rem;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--muted);
}
.signed-out-steps {
  margin: 0.45rem 0 0;
  max-width: 36rem;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--muted);
}
#btn-demo-login {
  font-size: 1.02rem;
  padding: 0.62rem 1.15rem;
  font-weight: 700;
}
.example-job-line {
  margin: 0 0 0.75rem;
  max-width: 40rem;
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--muted);
}
.income-grades-cta {
  margin: 0 0 0.85rem;
}
.fidelity-howto a {
  color: inherit;
}
#signed-out-landing #auth-api-status.hidden {
  display: none !important;
  margin: 0;
}
.signed-out-about {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}
.signed-out-howto-heading {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
#signed-out-landing .auth-card {
  width: 100%;
  padding: 0.7rem 1rem 0.8rem;
}
#signed-out-landing .auth-logo {
  width: auto;
  max-width: min(200px, 70%);
  max-height: 36px;
  object-fit: contain;
}
#signed-out-landing .auth-brand {
  margin: 0 0 0.2rem;
}
#signed-out-landing .auth-tagline {
  margin-bottom: 0.35rem !important;
  font-size: 0.88rem !important;
}
#signed-out-landing .auth-beta-note {
  margin-bottom: 0.35rem;
  padding: 0.4rem 0.55rem;
  font-size: 0.74rem;
  line-height: 1.3;
}
#signed-out-landing .auth-card .sub {
  margin-bottom: 0.25rem;
}
#signed-out-landing .auth-register-notice,
#signed-out-landing .auth-upload-reassure {
  font-size: 0.72rem;
  line-height: 1.3;
  margin-bottom: 0.35rem;
}
#signed-out-landing .auth-register-legal {
  margin-top: 0.45rem;
}
#signed-out-landing .auth-actions {
  margin-top: 0.45rem;
}
#signed-out-landing .auth-forgot-row {
  margin: 0.15rem 0 0.35rem;
}
#signed-out-landing label {
  margin: 0.2rem 0 0.1rem;
}
#signed-out-landing input {
  padding: 0.38rem 0.55rem;
}
#signed-out-landing .legal-footer {
  margin-top: 0.65rem;
  padding-top: 0.45rem;
}
.export-page-wrap {
  min-height: 100vh;
  padding: 1.25rem 1.25rem 3rem;
  background:
    radial-gradient(1000px 500px at 10% -10%, var(--auth-glow-1), transparent),
    radial-gradient(800px 400px at 100% 0%, var(--auth-glow-2), transparent),
    var(--bg);
}
.export-page {
  width: min(720px, 100%);
  margin: 0 auto;
}
.export-page h1 {
  margin: 0.35rem 0 0.75rem;
  font-size: clamp(1.35rem, 3.1vw, 1.85rem);
  line-height: 1.25;
}
.export-page h2 {
  margin: 1.35rem 0 0.45rem;
  font-size: 1.05rem;
}
.export-page h3 {
  margin: 1rem 0 0.35rem;
  font-size: 0.95rem;
}
.export-page p,
.export-page li {
  line-height: 1.45;
}
.export-page .export-back {
  margin: 0 0 0.75rem;
}
.export-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 1rem 0 0.5rem;
}
.export-cta a {
  display: inline-block;
  border-radius: 8px;
  padding: 0.65rem 1.2rem;
  font-weight: 700;
  text-decoration: none;
}
.export-cta-primary {
  background: var(--accent);
  color: #fff !important;
}
.export-cta-secondary {
  background: var(--secondary);
  color: var(--text) !important;
}
.export-todo {
  margin: 0.65rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
@media (max-height: 720px) {
  #signed-out-landing {
    padding: 0.4rem 1rem 1.1rem;
  }
  #signed-out-landing .home-banner-title {
    font-size: clamp(1.15rem, 2.3vw, 1.4rem);
  }
  .signed-out-lead {
    margin-top: 0.2rem;
    font-size: 0.92rem;
  }
  .signed-out-main {
    gap: 0.5rem 1.25rem;
  }
  #signed-out-landing .auth-card {
    padding: 0.5rem 0.85rem 0.6rem;
  }
  #signed-out-landing .auth-logo {
    max-height: 28px;
    max-width: min(170px, 60%);
  }
  #signed-out-landing .auth-field-hint {
    font-size: 0.74rem;
  }
}
.auth-upload-reassure {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
}

/* Auth */
#auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(1000px 500px at 10% -10%, var(--auth-glow-1), transparent),
    radial-gradient(800px 400px at 100% 0%, var(--auth-glow-2), transparent),
    var(--bg);
}
.auth-card {
  width: min(460px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 20px 50px var(--shadow);
}
.auth-beta-note {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #7c2d12;
  font-size: 0.8rem;
  line-height: 1.45;
}
[data-theme="dark"] .auth-beta-note {
  background: #431407;
  border-color: #9a3412;
  color: #fed7aa;
}
.auth-brand {
  display: flex;
  justify-content: center;
  margin: 0.25rem 0 1rem;
}
.auth-logo {
  display: block;
  width: min(440px, 94%);
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}
.auth-logo-dark { display: none; }
[data-theme="dark"] .auth-logo-light { display: none; }
[data-theme="dark"] .auth-logo-dark { display: block; }
.auth-card h1 { margin: 0 0 0.25rem; font-size: 1.35rem; }
.auth-card .sub { color: var(--muted); margin-bottom: 1rem; font-size: 0.9rem; }
.auth-tagline {
  text-align: center;
  font-weight: 600;
  color: var(--text) !important;
  font-size: 0.95rem !important;
}
.auth-register-legal { margin: 0.85rem 0 0; }
.auth-register-notice {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
}
.auth-agree-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
}
.auth-agree-row input { width: auto; margin: 0; }
.auth-card .auth-field-hint {
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.auth-actions { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }
.auth-actions button { min-width: 0; }
.auth-forgot-row { margin: 0.35rem 0 0.75rem; text-align: right; }
button.linkish,
.linkish {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent, #1d4ed8);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
button.linkish:hover { opacity: 0.85; }
.auth-msg { margin-top: 0.75rem; font-size: 0.88rem; color: var(--muted); min-height: 1.2em; }
.auth-msg.err { color: var(--bad); }
.auth-msg.ok { color: var(--good); }
.legal-footer {
  margin-top: 1.1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.85rem;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.75rem;
}
.legal-footer a,
.legal-footer span {
  color: var(--muted);
  text-decoration: none;
}
.legal-footer a:hover { color: var(--accent); text-decoration: underline; }
.sidebar-legal {
  justify-content: flex-start;
  margin: 0.75rem 0.85rem 0;
  padding-top: 0.65rem;
}

/* Shell */
#app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: var(--header-h) 1fr;
}
.app-header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  display: grid;
  /* Right column never narrower than its controls (one row, no wrap); the brand stays centred when there is room. */
  grid-template-columns: minmax(0, 1fr) auto minmax(max-content, 1fr);
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 40;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  justify-self: start;
  min-width: 0;
  width: 100%; /* stay inside its column; the loaded/status text ellipsizes instead of running under the brand */
}
.header-loaded {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 28vw;
}
.brand-center {
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}
.brand-wordmark-lg {
  display: block;
  height: 72px;
  width: auto;
  max-width: min(520px, 62vw);
  object-fit: contain;
  object-position: center;
}
.brand-wordmark-dark { display: none; }
[data-theme="dark"] .brand-wordmark-light { display: none; }
[data-theme="dark"] .brand-wordmark-dark { display: block; }
.brand-badge { display: none; }
.header-right {
  justify-self: end;
}

/* Home */
.home-banner {
  position: relative;
  width: 100%;
  /* Roughly half the stacked left column (welcome + steps) */
  min-height: clamp(150px, 28vh, 240px);
  height: clamp(150px, 28vh, 240px);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  background:
    #0f766e
    url("/static/brand/home-banner.jpg") center / cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.home-banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(15, 23, 42, 0.55) 0%,
    rgba(15, 118, 110, 0.35) 45%,
    rgba(28, 25, 23, 0.45) 100%
  );
  pointer-events: none;
}
.home-banner-content {
  position: relative;
  z-index: 1;
  padding: 1rem 1.5rem;
  max-width: 820px;
}
.home-banner-title {
  margin: 0 0 0.35rem;
  font-size: clamp(1.85rem, 4vw, 2.75rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #fff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
}
.home-banner-tagline {
  margin: 0;
  font-size: clamp(0.95rem, 1.6vw, 1.15rem);
  color: rgba(255, 255, 255, 0.92);
  font-weight: 500;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .home-banner-overlay {
  background: linear-gradient(
    90deg,
    rgba(11, 18, 32, 0.65) 0%,
    rgba(37, 99, 235, 0.28) 50%,
    rgba(11, 18, 32, 0.55) 100%
  );
}

.home-top {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(240px, 0.9fr);
  grid-template-rows: auto 1fr;
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 1rem;
}
.home-hero {
  grid-column: 1;
  grid-row: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.35rem 1.4rem 1.25rem;
  margin: 0;
}
.home-steps-card {
  grid-column: 1;
  grid-row: 2;
  margin: 0 !important;
  display: flex;
  flex-direction: column;
}
.home-steps-card .home-steps {
  flex: 1;
}
.home-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}
.home-hero h2 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  line-height: 1.25;
}
.home-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}
.home-steps {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.home-steps li { margin-bottom: 0.55rem; }
.home-steps strong { color: var(--text); }
.home-aside {
  grid-column: 2;
  grid-row: 1 / span 2;
  padding: 1.15rem 1.15rem 1.2rem;
  margin: 0 !important;
  height: auto;
  min-height: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-self: stretch;
}
.home-aside-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.home-aside-img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  flex-shrink: 0;
}
.home-trust {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 1rem;
}
.home-trust-item {
  display: grid;
  gap: 0.15rem;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.35;
}
.home-trust-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
}
.home-aside-actions {
  display: grid;
  gap: 0.45rem;
  margin-top: auto;
}
.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.home-tile ul {
  margin: 0.35rem 0 1rem;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.home-tile li { margin-bottom: 0.35rem; }
.home-tile p { margin: 0; color: var(--muted); font-size: 0.9rem; }
@media (max-width: 1000px) {
  .home-top {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
  .home-hero,
  .home-aside,
  .home-steps-card {
    grid-column: 1;
    grid-row: auto;
  }
  .home-aside-actions { margin-top: 1rem; }
  .home-grid { grid-template-columns: 1fr; }
}

/* Support pages */
.help-card h3 { margin-top: 0; }
.help-list {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 0.65rem 1rem;
}
.help-list dt {
  font-weight: 700;
  color: var(--text);
}
.help-list dd {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.help-bullets {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.help-bullets li { margin-bottom: 0.45rem; }
.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.7rem;
  cursor: help;
  vertical-align: middle;
  margin-left: 0.25rem;
}
.help-tip:hover { color: var(--accent); border-color: var(--accent); }
.help-glossary details {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.45rem;
  background: var(--input-bg);
}
.help-glossary summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--text);
}
.help-glossary p {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
@media (max-width: 700px) {
  .help-list { grid-template-columns: 1fr; gap: 0.2rem 0; }
  .help-list dt { margin-top: 0.55rem; }
}
.theme-select {
  font-size: 0.78rem;
  width: auto;
  min-width: 7.5rem;
  padding: 0.3rem 0.5rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
}
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 0.72rem; }

.header-right { display: flex; align-items: center; gap: 0.75rem; flex-wrap: nowrap; justify-content: flex-end; }
.header-right > * { flex-shrink: 0; }
.chip.theme-chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.15rem 0.35rem 0.15rem 0.6rem; border: none; }
.chip.theme-chip > span { font-size: 0.72rem; color: var(--muted); }
/* Theme, then the Plan chip, move into the profile menu when they do not fit beside the centred brand (app.js placeHeaderItems). */
.app-header.header-compact .profile-meta { display: none; }
.profile-menu-slot:empty { display: none; }
.profile-menu-slot { border-bottom: 1px solid var(--border); margin-bottom: 0.3rem; padding-bottom: 0.3rem; }
.profile-menu-slot .theme-chip { display: flex; justify-content: space-between; min-height: 44px; padding: 0 0.7rem; }
.profile-menu-slot .theme-select { min-height: 44px; }
.profile-menu-slot .chip#plan-chip { display: block; border: none; border-radius: 8px; padding: 0.55rem 0.7rem; font-size: 0.78rem; }
@media (max-width: 900px) {
  .app-header { height: 88px; }
  .brand-wordmark-lg { height: 56px; max-width: min(360px, 58vw); }
}
@media (max-width: 700px) {
  .app-header { height: 78px; }
  .brand-wordmark-lg { height: 48px; max-width: min(260px, 55vw); }
  .header-loaded { display: none; }
  .brand-center { padding: 0.15rem 0.45rem; }
}
/* App header brand: full wordmark above 640px; square plate icon (36px) 12px right of the menu button at 640px and below */
.app-header .brand-icon-sm { display: none; }
@media (max-width: 640px) {
  .app-header { grid-template-columns: auto auto 1fr; gap: 12px; }
  .app-header .brand-center { justify-self: start; padding: 0; }
  .app-header .brand-wordmark-lg,
  [data-theme="dark"] .app-header .brand-wordmark-dark { display: none; }
  .app-header .brand-icon-sm { display: block; width: 36px; height: 36px; }
}
.chip {
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
}

/* Profile */
.profile-wrap { position: relative; }
.profile-btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 0.5rem;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.55rem 0.3rem 0.35rem;
  color: var(--text);
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--avatar-from), var(--avatar-to));
  display: grid; place-items: center;
  font-size: 0.8rem; font-weight: 700;
  color: #fff;
}
.profile-meta { text-align: left; line-height: 1.15; }
.profile-meta .name { font-size: 0.82rem; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-meta .role { font-size: 0.7rem; color: var(--muted); }
.profile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 240px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px var(--shadow);
  padding: 0.4rem;
  z-index: 50;
}
.profile-menu button, .profile-menu .mi {
  width: 100%;
  text-align: left;
  background: transparent;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-weight: 500;
  color: var(--text);
}
.profile-menu button:hover, .profile-menu .mi:hover { background: var(--hover); }
.profile-menu .sep { height: 1px; background: var(--border); margin: 0.3rem 0; }
.profile-menu .danger { color: var(--danger-fg); }

/* Layout body: fixed nav column + fluid main pane */
.app-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: calc(100vh - var(--header-h));
  width: 100%;
  align-items: stretch;
}
@media (max-width: 900px) {
  #signed-out-landing {
    padding: 0.85rem 0.85rem 1.75rem;
  }
  .signed-out-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "copy"
      "auth"
      "details";
    gap: 0.85rem;
  }
  #signed-out-landing .home-banner-title {
    max-width: none;
    font-size: clamp(1.28rem, 6.2vw, 1.7rem);
  }
  #landing-example-preview { order: 4; }
  #signed-out-hero-cta { order: 5; }
  .landing-example-job {
    grid-template-columns: minmax(0, 1fr);
  }
  .landing-example-job img {
    max-height: 180px;
    object-fit: cover;
    object-position: top;
  }
  .landing-example-card-holdings {
    max-height: 250px;
  }
  .landing-example-card-holdings img {
    width: 100%;
    height: 250px;
    max-height: 250px;
    object-fit: cover;
    object-position: top;
  }
  #btn-demo-hero,
  #btn-demo-login {
    width: 100%;
  }
  .auth-actions button {
    flex: 1 1 auto;
  }
  .app-body { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    display: none;
  }
  .sidebar.open {
    display: block;
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: min(var(--sidebar-w), 86vw);
    z-index: 30;
    box-shadow: 8px 0 32px var(--shadow);
  }
}

.sidebar {
  grid-column: 1;
  border-right: 1px solid var(--border);
  background: var(--bg2);
  padding: 0.55rem 0.65rem 0.85rem;
  overflow-y: auto;
  /* Do not apply .hidden to #sidebar on desktop — it collapses the main column */
}
.sidebar h3 {
  margin: 0.55rem 0 0.2rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.sidebar h3:first-of-type {
  margin-top: 0.35rem;
}
.nav-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  padding: 0.32rem 0.55rem;
  margin-bottom: 0.06rem;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.25;
}
.nav-btn:hover { background: var(--hover); }
.nav-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.nav-btn:disabled:hover { background: transparent; }
#nav-empty-hint { color: var(--warn); font-weight: 600; }
.nav-btn.active {
  background: var(--active-bg);
  color: var(--active-fg);
  border: 1px solid var(--active-border);
}
.side-note {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.45rem;
  line-height: 1.3;
}
.sidebar .side-actions {
  margin-top: 0.55rem;
  display: grid;
  gap: 0.25rem;
}

/* Main content pane — always the wide right column */
.content {
  grid-column: 2;
  min-width: 0;
  width: 100%;
  max-width: none;
  padding: 1.25rem 1.75rem 2.75rem;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg);
}
@media (max-width: 900px) {
  .content { grid-column: 1; padding: 1rem 1rem 2.5rem; }
}
.page {
  display: none;
  width: 100%;
  max-width: 1200px;
}
.page.active { display: block; }
.page h2 { margin: 0 0 0.35rem; font-size: 1.35rem; }
.page .lead { color: var(--muted); margin: 0 0 1.15rem; font-size: 0.92rem; }

body.workspace-empty .dash-has-data { display: none; }
.empty-dash {
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 1.35rem 1.25rem 1.2rem;
  margin: 0 0 1.25rem;
  max-width: 720px;
}
.empty-dash h2,
.empty-dash h3 {
  margin: 0 0 0.45rem;
  font-size: 1.2rem;
}
.empty-dash p {
  margin: 0 0 0.75rem;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
}
.empty-dash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.fidelity-howto {
  margin: 0 0 1rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
}
.empty-dash .fidelity-howto { margin: 0 0 0.9rem; }
.fidelity-howto h4 {
  margin: 0 0 0.4rem;
  font-size: 0.88rem;
}
.fidelity-howto ul {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.45;
}
.fidelity-howto li { margin: 0.2rem 0; }
.empty-placeholders { margin: 0 0 0.9rem; }
.empty-kpis .kpi.ghost {
  background: var(--bg2);
  border-style: dashed;
}
.empty-kpis .kpi.ghost .v { color: var(--muted); }
.empty-chart-ph {
  min-height: 140px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 8px,
    var(--bg2) 8px,
    var(--bg2) 16px
  );
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 0.75rem;
  text-align: center;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
}
.kpi .v { font-size: 1.25rem; font-weight: 700; }
.kpi .l { font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; }
.kpi .v.kpi-up { color: var(--good); }
.kpi .v.kpi-down { color: var(--bad); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.05rem;
  margin-bottom: 1rem;
}
.card h3 { margin: 0 0 0.75rem; font-size: 1rem; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.85rem;
}
.toolbar .field { min-width: 140px; flex: 1; }
.msg { font-size: 0.88rem; color: var(--muted); white-space: pre-wrap; }
.msg.ok { color: var(--good); }
.msg.err { color: var(--bad); }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--card); }
.table-wrap { overflow: auto; max-height: 480px; border-radius: 8px; }
.grade-A { color: var(--good); font-weight: 700; }
.grade-B { color: var(--grade-b); font-weight: 700; }
.grade-C { color: var(--warn); font-weight: 700; }
.grade-D { color: var(--bad); font-weight: 700; }
.chart-box { height: 320px; position: relative; }
.chart-box.sm { height: 260px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .row-2 { grid-template-columns: 1fr; } }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: var(--overlay);
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal {
  width: min(480px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.15rem;
}
.modal h3 { margin: 0 0 0.75rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge.on { color: var(--badge-on-fg); border-color: var(--badge-on-fg); background: var(--badge-on-bg); }
.badge.off { color: var(--badge-off-fg); border-color: var(--badge-off-fg); background: var(--badge-off-bg); }
.badge.admin { color: var(--badge-admin-fg); border-color: var(--badge-admin-fg); background: var(--badge-admin-bg); }

.menu-toggle { display: none; }
@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
  .profile-meta { display: none; }
}

/* —— Upload & analyze page —— */
.data-page {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
  max-width: 100%;
}
.data-step {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 0.85rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.15rem 1.2rem 1.25rem;
}
.data-step-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--active-bg);
  border: 1px solid var(--active-border);
  color: var(--active-fg);
  font-weight: 700;
  font-size: 0.95rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.data-step-body { min-width: 0; }
.data-step-title {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 650;
}
.data-step-desc {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.data-step-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}
.data-step-head-row .data-step-desc { margin-bottom: 0.85rem; }

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 720px) {
  .upload-grid { grid-template-columns: 1fr; }
  .data-step { grid-template-columns: 1fr; }
  .data-step-num { margin-bottom: 0.15rem; }
}

.upload-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  min-height: 168px;
}
.upload-card-head {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.upload-kind {
  font-weight: 650;
  font-size: 0.95rem;
}
.upload-hint {
  font-size: 0.75rem;
  color: var(--muted);
  word-break: break-all;
}

.file-drop {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 52px;
  margin: 0;
  padding: 0.65rem 0.85rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.file-drop:hover {
  border-color: var(--accent);
  background: var(--hover);
}
.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
}
.file-drop-label {
  font-size: 0.88rem;
  color: var(--muted);
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}
.file-drop-label.has-file {
  color: var(--text);
  font-weight: 500;
}
.upload-btn {
  width: 100%;
  margin-top: auto;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 220px;
  overflow-y: auto;
}
.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.88rem;
}
.file-list li .fname {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.file-list li .fmeta {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.file-list-empty {
  color: var(--muted);
  border-style: dashed !important;
  justify-content: center;
}

.analyze-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1.25rem;
}
.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
}
.check-inline input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}
.data-status {
  margin: 0.9rem 0 0;
  min-height: 1.25em;
}

/* Grade hero (ownership-period A–D) */
.quality-hero {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1.25rem;
  align-items: center;
}
@media (max-width: 700px) {
  .quality-hero { grid-template-columns: 1fr; text-align: center; }
}
.quality-hero-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem;
  background: var(--input-bg);
  border-radius: 14px;
  border: 1px solid var(--border);
}
.quality-letter {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
}
.quality-score {
  font-size: 1.5rem;
  font-weight: 700;
}
.quality-score small { font-size: 0.9rem; color: var(--muted); font-weight: 500; }
.quality-type {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pillar-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1rem;
}
.pillar-card {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}
.pillar-card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.35rem;
}
.pillar-card-head strong { font-size: 0.98rem; }
.pillar-pts { font-weight: 700; color: var(--active-fg); }
.pillar-bar {
  height: 8px;
  background: var(--pillar-bar);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.45rem 0 0.55rem;
}
.pillar-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--good));
  border-radius: 999px;
}
.pillar-summary { font-size: 0.86rem; color: var(--muted); margin: 0 0 0.5rem; }
.pillar-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.35rem 0.75rem;
  font-size: 0.8rem;
}
.pillar-metrics span { color: var(--muted); }
.pillar-metrics b { color: var(--text); font-weight: 600; }

.pq-row input { width: 100%; }
