/* nymbra portal — dark-only, mobile-first shell.
 *
 * Phone-first: a single centred column capped at ~28rem, widening on
 * larger screens. Large type, high contrast, one accent. System font
 * stack (no web fonts — self-contained asset rule). No JavaScript.
 */

:root {
  /* Dark theme tokens. Near-black background, high-contrast text, one
     accent used sparingly for emphasis / links. */
  --bg: #0d0f12;
  --surface: #171a1f;
  --border: #2a2f37;
  --text: #f2f4f7;
  --text-muted: #a7afba;
  --accent: #5aa9ff;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;

  --shell-max: 28rem;
  --space: 1rem;
  --radius: 0.75rem;
}

* {
  box-sizing: border-box;
}

html {
  /* Comfortable base type for phone reading; scales the rem-based layout. */
  font-size: 112.5%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.shell {
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: calc(var(--space) * 1.5) var(--space);
}

/* Let the column breathe on tablet / desktop. */
@media (min-width: 40rem) {
  :root {
    --shell-max: 34rem;
  }

  .shell {
    padding: calc(var(--space) * 2);
  }
}

h1, h2, h3 {
  line-height: 1.2;
  margin: 0 0 var(--space);
}

a {
  color: var(--accent);
}

.muted {
  color: var(--text-muted);
}

/* --- Auth forms (login / new-password / MFA) --- */

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space);
  margin-top: calc(var(--space) * 1.5);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field > span {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.auth-form input {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.auth-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.auth-form button {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.form-error {
  padding: 0.75rem var(--space);
  color: var(--text);
  background: rgba(255, 90, 90, 0.12);
  border: 1px solid rgba(255, 90, 90, 0.5);
  border-radius: var(--radius);
}

/* --- Participant surface (home / history / holdings) --- */

.note {
  font-size: 0.85rem;
  margin: 0.35rem 0;
}

/* Hero balance — the big number the family opens the app to see. */
.hero {
  text-align: center;
  margin: calc(var(--space) * 1.5) 0;
}

.hero-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  margin: 0 0 0.25rem;
}

.hero-balance {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.1;
  margin: 0;
  word-break: break-word;
}

@media (min-width: 40rem) {
  .hero-balance {
    font-size: 3.75rem;
  }
}

/* Server-rendered SVG balance chart (no JS chart lib). */
.chart {
  margin: var(--space) 0 calc(var(--space) * 1.5);
}

.chart svg {
  display: block;
  width: 100%;
  height: 7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

.chart-empty {
  padding: calc(var(--space) * 2) var(--space);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin: var(--space) 0 calc(var(--space) * 1.5);
}

/* Currency selector. */
.currency-form {
  margin: var(--space) 0;
}

.currency-form select {
  width: 100%;
  padding: 0.65rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Navigation links block. */
.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space);
  margin-top: calc(var(--space) * 1.5);
  padding-top: var(--space);
  border-top: 1px solid var(--border);
}

.inline-form {
  display: inline;
  margin: 0;
}

.linkish {
  padding: 0;
  font: inherit;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
}

/* History ledger list. */
.ledger {
  list-style: none;
  padding: 0;
  margin: var(--space) 0;
}

.ledger-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15rem 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.ledger-kind {
  font-weight: 600;
}

.ledger-money {
  text-align: right;
  font-weight: 600;
}

.ledger-units {
  text-align: right;
  font-size: 0.85rem;
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: var(--space);
  margin: var(--space) 0;
}

/* Holdings proportion bars. */
.bars {
  list-style: none;
  padding: 0;
  margin: var(--space) 0;
}

.bar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.25rem 0.75rem;
  margin-bottom: 0.9rem;
}

.bar-name {
  font-weight: 600;
}

.bar-pct {
  font-size: 0.85rem;
  text-align: right;
}

.bar-track {
  grid-column: 1 / -1;
  height: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
}

.bar-cash .bar-fill {
  background: var(--text-muted);
}

/* --- Admin surface (desktop-first: dense tables, stat tiles) --- */

/* The admin panel wants room to breathe; widen the shell on desktop. */
@media (min-width: 40rem) {
  .shell:has(.admin-nav) {
    max-width: 60rem;
  }
}

.admin-nav {
  flex-wrap: wrap;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--space);
  margin: var(--space) 0 calc(var(--space) * 1.5);
}

.stat {
  padding: var(--space);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  margin: 0 0 0.2rem;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0;
  word-break: break-word;
}

.stat-sub {
  font-size: 0.78rem;
  margin: 0.15rem 0 0;
}

/* Horizontal-scroll wrapper so wide tables never break the page width. */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  margin: var(--space) 0;
}

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  white-space: nowrap;
}

table.grid th,
table.grid td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.grid th {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table.grid td.num,
table.grid th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  font-size: 0.7rem;
  color: var(--bg);
  background: var(--accent);
  border-radius: 0.4rem;
}

.warn {
  color: #ffb454;
}

.ok {
  color: #6ee7a8;
}

.detail {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1rem;
  margin: var(--space) 0;
}

.detail dt {
  color: var(--text-muted);
}

.detail dd {
  margin: 0;
}

.admin-action {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: var(--space);
  margin: var(--space) 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.admin-action input[type="text"],
.admin-action select {
  width: 100%;
  padding: 0.6rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.admin-action button {
  align-self: flex-start;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.secret-box {
  padding: var(--space);
  margin: var(--space) 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.secret-code {
  font-size: 1.2rem;
  word-break: break-all;
}

.checkbox-field span {
  color: var(--text);
}
