/* Member portal + admin dashboard components */
body.app { background: var(--paper); color: var(--ink); }
.app .muted { color: #55627a; }
.app h1, .app h2, .app h3 { color: var(--ink); }

/* ---------- top bar ---------- */
.bar { background: var(--ink); color: #fff; }
.bar__row { display: flex; align-items: center; gap: 1rem; min-height: 72px; }
.bar__row img { height: 48px; width: auto; }
.bar__who { margin-left: auto; text-align: right; line-height: 1.15; }
.bar__who strong { display: block; font-family: var(--font-display); font-weight: 400; font-size: 1.15rem; }
.bar__who span { font-size: 1rem; color: #CFC6BD; }
.bar a.home { text-decoration: none; display: flex; }

/* ---------- auth ---------- */
.auth { min-height: calc(100svh - 72px); display: grid; grid-template-columns: 1fr 1fr; }
.auth__side { position: relative; overflow: hidden; background: var(--ink); color: #fff; padding: clamp(2rem, 6vw, 5rem); display: flex; flex-direction: column; justify-content: flex-end; }
.auth__side::before { content: ''; position: absolute; inset: 0 0 0 auto; width: 33%; background: var(--mariner); }
.auth__side img.mark { position: absolute; right: 8%; top: 12%; width: min(34vw, 340px); filter: drop-shadow(0 24px 30px rgba(0, 0, 0, .55)); }
.auth__side h1 { position: relative; color: #fff; font-size: clamp(2.4rem, 5vw, 4.2rem); margin-bottom: 1rem; }
.auth__side p { position: relative; color: #E8DFD6; font-size: 1.3rem; max-width: 26ch; }
.auth__panel { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth__card { width: min(440px, 100%); }
.tabs { display: flex; gap: .4rem; margin-bottom: 1.6rem; border-bottom: 2px solid var(--line); overflow-x: auto; }
.tabs [role="tab"] { font-family: var(--font-display); font-size: 1.1rem; padding: .7rem 1.1rem; background: none; border: 0; border-bottom: 4px solid transparent; margin-bottom: -2px; color: #55627a; cursor: pointer; white-space: nowrap; }
.tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--gold); }
.tabs .count { display: inline-block; min-width: 1.5em; margin-left: .35rem; padding: 0 .4em; border-radius: 999px; background: var(--gold); color: var(--ink); font-size: .85em; text-align: center; }
.auth__card h2 { font-size: 2rem; margin-bottom: .4rem; }
.auth__card .sub { margin-bottom: 1.5rem; }
.auth__card .btn { width: 100%; }
.callout { border-left: 6px solid var(--gold); background: #fff; padding: 1rem 1.2rem; border-radius: 0 var(--r-md) var(--r-md) 0; margin-bottom: 1.2rem; }
.callout p { margin: 0; }
.callout--ok { border-left-color: var(--ok); }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth__side { min-height: 230px; padding: 1.6rem; justify-content: center; }
  .auth__side img.mark { width: 130px; top: 1rem; right: 12%; }
  .auth__side h1 { font-size: 2.2rem; }
}

/* ---------- dashboard layout ---------- */
.dash { padding: 1.6rem 0 4rem; }
.dash__hero { display: grid; grid-template-columns: 1.55fr 1fr; gap: 1.2rem; margin-bottom: 1.4rem; }
@media (max-width: 900px) { .dash__hero { grid-template-columns: 1fr; } }
.card { background: #fff; border-radius: var(--r-lg); padding: clamp(1.2rem, 3vw, 2rem); }
.card--ink { background: var(--ink); color: #fff; }
.card--ink h2, .card--ink h3 { color: #fff; }
.card--blue { background: var(--mariner); color: #fff; }
.card--blue h2, .card--blue h3 { color: #fff; }
.card h2 { font-size: 1.6rem; margin-bottom: 1rem; }
.card h3 { font-size: 1.3rem; }
.big { font-family: var(--font-display); font-size: clamp(2.6rem, 6vw, 4.4rem); line-height: 1; color: inherit; }
.card--ink .big { color: var(--gold); }
.label { font-size: 1.1rem; opacity: .85; display: block; margin-bottom: .3rem; }
.stack { display: grid; gap: 1.2rem; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.section-gap { margin-top: 1.4rem; }

/* ---------- progress bars ---------- */
.meter { position: relative; height: 16px; border-radius: 999px; background: rgba(12, 12, 12, .12); overflow: hidden; }
.card--ink .meter, .card--blue .meter { background: rgba(255, 255, 255, .22); }
.meter > i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--gold); border-radius: 999px; transition: width .9s cubic-bezier(.2, .8, .2, 1); }
.card--blue .meter > i { background: #fff; }
.meter--blue > i { background: var(--mariner); }
.meter--lg { height: 24px; }
.ticks { position: relative; height: 1.2em; margin-top: .25rem; font-size: .95rem; color: #55627a; }
.ticks span { position: absolute; transform: translateX(-50%); }
.ticks span:first-child { transform: none; }
.ticks span:last-child { transform: translateX(-100%); }
.card--ink .ticks, .card--blue .ticks { color: rgba(255, 255, 255, .8); }
.meter-row { display: grid; gap: .3rem; }
.meter-row header { display: flex; justify-content: space-between; gap: 1rem; font-size: 1.15rem; }
.meter-row header b { color: var(--ink); font-weight: 700; }

/* ---------- lists ---------- */
.accounts { display: grid; gap: 1rem; }
.pill { display: inline-block; padding: .1rem .7rem; border-radius: 999px; font-size: .98rem; font-weight: 700; background: var(--mariner-soft); color: var(--mariner-deep); white-space: nowrap; }
.pill--ok { background: #D7EFE2; color: #14553A; }
.pill--warn { background: #FBE5C2; color: #6E4100; }
.pill--bad { background: #F7D6D3; color: #7F1B14; }
.pill--gold { background: var(--gold-soft); color: #7A3508; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem 0; border-top: 1px solid var(--line); align-items: baseline; }
.list li:first-child { border-top: 0; }
.list .amt { font-weight: 700; color: var(--ink); white-space: nowrap; }
.amt.in { color: var(--ok); } .amt.out { color: var(--bad); }
.note-card { border-left: 6px solid var(--gold); padding: .2rem 0 .2rem 1rem; margin-bottom: 1rem; }
.note-card h3 { font-size: 1.25rem; margin-bottom: .2rem; }
.note-card p { margin: 0; }
.empty { text-align: center; padding: 2rem 1rem; color: #55627a; }
.empty h3 { margin-bottom: .4rem; }

/* ---------- goals ---------- */
.goal { border-top: 2px solid var(--line); padding: 1.3rem 0; }
.goal:first-child { border-top: 0; padding-top: 0; }
.goal header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; align-items: baseline; margin-bottom: .7rem; }
.goal h3 { font-size: 1.45rem; }
.goal .figs { display: flex; justify-content: space-between; gap: 1rem; font-size: 1.15rem; margin-top: .3rem; }
.plan { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: 1rem 0 .6rem; }
.plan div { background: var(--paper); border-radius: var(--r-md); padding: .6rem .8rem; }
.plan b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 1.25rem; color: var(--ink); }
.plan span { font-size: .98rem; color: #55627a; }
@media (max-width: 520px) { .plan { grid-template-columns: 1fr; } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--line); background: #fff; }
table.grid { width: 100%; border-collapse: collapse; font-size: 1.08rem; }
table.grid th { text-align: left; font-family: var(--font-display); font-weight: 400; font-size: .98rem; background: var(--mariner); color: #fff; padding: .7rem .8rem; white-space: nowrap; position: sticky; top: 0; }
table.grid td { padding: .6rem .8rem; border-top: 1px solid var(--line); vertical-align: top; color: var(--ink); }
table.grid tbody tr:nth-child(even) { background: #FBF7F3; }
table.grid td.num, table.grid th.num { text-align: right; white-space: nowrap; }
table.grid td .btn { margin: 0 .2rem .2rem 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: 1rem; align-items: center; }
.toolbar input, .toolbar select { min-height: 44px; padding: .4rem .8rem; font: inherit; font-size: 1.1rem; border: 2px solid rgba(12, 12, 12, .28); border-radius: var(--r-sm); background: #fff; color: var(--ink); }
.toolbar input[type="search"] { min-width: 240px; flex: 1; }
.toolbar .spacer { margin-left: auto; }

/* ---------- KPI tiles (admin) ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.kpi { background: #fff; border-radius: var(--r-md); padding: 1.1rem 1.2rem; border-top: 6px solid var(--gold); }
.kpi:nth-child(even) { border-top-color: var(--mariner); }
.kpi b { display: block; font-family: var(--font-display); font-weight: 400; font-size: 2.2rem; line-height: 1.05; color: var(--ink); }
.kpi span { font-size: 1.08rem; color: #55627a; }

/* ---------- dropzone ---------- */
.drop { border: 3px dashed var(--mariner); border-radius: var(--r-lg); padding: 2.5rem 1.2rem; text-align: center; background: #fff; cursor: pointer; }
.drop.over { background: var(--mariner-soft); }
.drop strong { font-family: var(--font-display); font-weight: 400; font-size: 1.4rem; display: block; color: var(--ink); margin-bottom: .3rem; }
.steps-log { font-size: 1.05rem; }
.warnings { background: #FFF5E0; border-left: 6px solid var(--warn); padding: .9rem 1.2rem; border-radius: 0 var(--r-md) var(--r-md) 0; margin: 1rem 0; }
.warnings ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* ---------- question threads ---------- */
.thread { border-top: 2px solid var(--line); padding: 1.1rem 0; }
.thread:first-child { border-top: 0; }
.thread .q { margin: 0 0 .6rem; white-space: pre-wrap; }
.thread .a { margin: 0; padding: .7rem 1rem; background: var(--mariner-soft); border-radius: var(--r-md); white-space: pre-wrap; color: var(--ink); }
.thread .meta { font-size: 1rem; color: #55627a; margin-bottom: .3rem; }
.inline-form { display: grid; gap: .6rem; margin-top: .8rem; }

/* ---------- wide tables: every account side by side ---------- */
.table-wrap--wide { max-height: 70vh; overflow: auto; }
table.grid--sticky th:first-child, table.grid--sticky td:first-child { position: sticky; left: 0; z-index: 1; background: #fff; box-shadow: 1px 0 0 var(--line); }
table.grid--sticky thead th:first-child { background: var(--mariner); z-index: 3; }
table.grid--sticky tbody tr:nth-child(even) td:first-child { background: #FBF7F3; }
table.grid td.zero { color: #9aa3b5; }
table.grid tfoot td { position: sticky; bottom: 0; background: var(--gold-soft); font-weight: 700; border-top: 2px solid var(--ink); color: var(--ink); }
table.grid tfoot td:first-child { z-index: 2; }
.toolbar label { display: inline-flex; align-items: center; gap: .4rem; font-size: 1.05rem; color: var(--ink); flex-wrap: wrap; }

table.grid--sticky td:last-child { white-space: nowrap; }
table.grid--sticky td:first-child { min-width: 11rem; }

/* =====================================================================
   GROUP DASHBOARD: a dark "stage" for one group's savings
   ===================================================================== */
.gv { background: var(--ink); color: #F6F1EC; border-radius: 28px; padding: clamp(.9rem, 2.5vw, 1.8rem); display: grid; gap: 1.2rem; }
.app .gv h2, .app .gv h3 { color: #fff; }
.gv-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.gv-bar label { font-size: 1.05rem; color: #CFC6BD; }
.gv select { min-height: 44px; padding: .3rem .9rem; font: inherit; font-size: 1.1rem; color: #fff; background: var(--ink-3); border: 1px solid rgba(255, 255, 255, .25); border-radius: 999px; }
.gv .btn--ghost { --bd: rgba(255, 255, 255, .5); }

.gv-hero { position: relative; isolation: isolate; overflow: hidden; border-radius: 22px; min-height: 340px; padding: clamp(1.4rem, 4vw, 3rem); display: grid; align-content: end;
  background: radial-gradient(55% 90% at 82% 45%, rgba(223, 109, 32, .38), transparent 70%), linear-gradient(135deg, #1d1610, #0C0C0C 62%); }
.gv-hero::before { content: ''; position: absolute; z-index: -3; inset: 0 0 0 auto; width: 33.333%; background: linear-gradient(165deg, var(--mariner), var(--mariner-deep) 65%, #1B3563); }
.gv-hero::after { content: ''; position: absolute; z-index: -2; inset: 0 0 0 auto; width: 40%; background: linear-gradient(90deg, rgba(12, 12, 12, .7), transparent); }
.gv-hero__beam { position: absolute; z-index: -2; top: -30%; right: 10%; width: 60%; height: 140%; mix-blend-mode: screen; filter: blur(14px); pointer-events: none;
  background: conic-gradient(from 196deg at 58% 0, transparent 0deg, rgba(255, 214, 170, .28) 9deg, transparent 20deg); animation: beam-in 2s .1s ease-out both; }
.gv-hero__mark { position: absolute; z-index: -1; right: 6%; bottom: 8%; width: min(34%, 340px); height: auto; filter: drop-shadow(0 26px 34px rgba(0, 0, 0, .6)); animation: rise 1s .1s cubic-bezier(.2, .8, .2, 1) both; }
.gv-hero__copy { max-width: min(640px, 100%); }
.gv-hero h2 { font-size: clamp(2.2rem, 5.5vw, 4rem); line-height: .98; margin-bottom: .4rem; }
.gv-sub { margin: 0 0 1.4rem; color: #E3DAD1; font-size: 1.2rem; }
.gv-label { font-size: 1.1rem; color: #CFC6BD; display: block; }
.gv-big { font-family: var(--font-display); font-size: clamp(2.6rem, 8vw, 5.6rem); line-height: 1; color: var(--gold); text-shadow: 0 8px 40px rgba(223, 109, 32, .35); overflow-wrap: anywhere; }
.gv-cycle { margin-top: 1.4rem; max-width: 460px; }
.gv-cycle__top { display: flex; justify-content: space-between; gap: 1rem; font-size: 1.02rem; color: #CFC6BD; }
.gv-cycle__top b { color: #fff; font-weight: 600; }
.gv-meter { height: 12px; margin: .35rem 0; border-radius: 999px; background: rgba(255, 255, 255, .16); overflow: hidden; }
.gv-meter > i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--gold); transition: width 1.1s cubic-bezier(.2, .8, .2, 1); }

.gv-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: .9rem; }
.gv-kpi { background: var(--ink-3); border-radius: 16px; padding: 1rem 1.1rem; border-top: 4px solid var(--gold); }
.gv-kpi:nth-child(even) { border-top-color: #6C93D6; }
.gv-kpi b { display: block; font-family: var(--font-display); font-weight: 400; font-size: clamp(1.4rem, 3vw, 1.9rem); line-height: 1.1; color: #fff; overflow-wrap: anywhere; }
.gv-kpi b small { font-size: .55em; color: #CFC6BD; }
.gv-kpi span { color: #CFC6BD; font-size: 1.05rem; }

.gv-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 1.2rem; }
.gv-card { background: var(--ink-2); border: 1px solid rgba(255, 255, 255, .08); border-radius: 22px; padding: clamp(1rem, 2.5vw, 1.6rem); min-width: 0; }
.gv-card--full { grid-column: 1 / -1; }
.gv-card h3 { font-size: 1.45rem; margin-bottom: .2rem; }
.gv-note { color: #CFC6BD; font-size: 1.05rem; margin: 0 0 1rem; max-width: none; }
.gv-chart { position: relative; height: 280px; }
.gv-chart--tall { height: 360px; }
.gv-donut { position: relative; height: 260px; margin-bottom: 1rem; }
.gv-donut__mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.gv-donut__mid b { font-family: var(--font-display); font-weight: 400; font-size: 2.2rem; color: #fff; line-height: 1; }
.gv-donut__mid span { color: #CFC6BD; }
.gv-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.gv-legend li { display: grid; grid-template-columns: 14px 1fr auto; gap: .6rem; align-items: center; font-size: 1.05rem; }
.gv-legend i { width: 14px; height: 14px; border-radius: 4px; }
.gv-legend b { color: #fff; font-weight: 600; }

.gv-rank { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; max-height: 560px; overflow: auto; padding-right: .4rem; }
.gv-rank li { display: grid; grid-template-columns: 1.8rem minmax(8.5rem, 12rem) 1fr minmax(6.5rem, auto); gap: .7rem; align-items: center; }
.gv-rank__n { font-family: var(--font-display); color: #CFC6BD; text-align: right; }
.gv-rank__name { line-height: 1.1; color: #fff; overflow-wrap: anywhere; }
.gv-rank__name small, .gv-goals small { display: block; color: #A99F95; font-size: .92rem; }
.gv-rank__bar { display: flex; height: 16px; border-radius: 999px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.gv-rank__bar i { display: block; height: 100%; width: 0; transition: width 1s cubic-bezier(.2, .8, .2, 1); border-right: 2px solid #17130F; }
.gv-rank__v { text-align: right; color: #fff; font-weight: 600; white-space: nowrap; }

.gv-goals { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.gv-goals li { display: grid; gap: .1rem; }
.gv-goals li > span { color: #CFC6BD; font-size: 1.02rem; }
.gv-goals b { color: #fff; }

.gv-heat { overflow-x: auto; display: grid; gap: 4px; padding-bottom: .4rem; max-height: 560px; overflow-y: auto; }
.gv-heat__row { display: grid; grid-template-columns: minmax(8.5rem, 11rem) repeat(10, minmax(28px, 1fr)); gap: 4px; align-items: center; min-width: 560px; }
.gv-heat__head { position: sticky; top: 0; background: var(--ink-2); z-index: 1; }
.gv-heat__head span { font-size: .85rem; color: #CFC6BD; text-align: center; }
.gv-heat__name { color: #fff; font-size: 1.02rem; line-height: 1.05; padding-right: .5rem; }
.gv-heat__cell { height: 26px; border-radius: 6px; background: rgba(255, 255, 255, .06); }

.gv-feed { list-style: none; margin: 0; padding: 0; }
.gv-feed li { display: grid; grid-template-columns: 9rem 1fr auto; gap: .8rem; padding: .6rem 0; border-top: 1px solid rgba(255, 255, 255, .08); }
.gv-feed li:first-child { border-top: 0; }
.gv-feed b.in { color: #7BD3A2; } .gv-feed b.out { color: #FF9C93; }

@media (max-width: 960px) {
  .gv-grid { grid-template-columns: 1fr; }
  .gv-hero::before { width: 24%; }
  .gv-hero__mark { opacity: .35; width: 52%; }
  .gv-rank li { grid-template-columns: 1.5rem 1fr; }
  .gv-rank__bar { grid-column: 2; } .gv-rank__v { grid-column: 2; text-align: left; }
}
@media print {
  .bar, #tabs, .gv-bar, .toast-host { display: none !important; }
  body.app { background: #fff; }
  .gv, .gv * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .gv-card { break-inside: avoid; } .gv-rank, .gv-heat { max-height: none; }
}
