/* Household Expenses — same family as NAS100 Session Ledger:
   bold slate + signal palette, colorblind-aware win/loss coding. */

:root {
  --bg: #14171d;
  --panel: #1e232d;
  --panel-2: #262c39;
  --line: #333b4c;
  --line-soft: #2a3140;
  --text: #f0f3f8;
  --text-dim: #a7b0c0;
  --text-faint: #737d92;
  --brand: #ffce3d;
  --brand-ink: #1d1608;
  --win: #37d3bc;
  --win-dim: rgba(55, 211, 188, 0.14);
  --loss: #ff8e5e;
  --loss-dim: rgba(255, 142, 94, 0.14);
  --sans: "Satoshi", -apple-system, system-ui, sans-serif;
  --mono: "Satoshi", -apple-system, system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  background-image: radial-gradient(1100px 420px at 75% -10%, rgba(255, 206, 61, 0.05), transparent 60%);
}

.wrap { max-width: 1560px; margin: 0 auto; padding: 0 24px 96px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 26px 28px;
  margin-top: 18px;
}

/* ---------- masthead ---------- */
header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 26px 4px 6px;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.brand h1 {
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}
.brand h1 em { color: var(--brand); font-style: normal; }
.label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  font-weight: 700;
}
.appnav { display: flex; gap: 18px; flex-wrap: wrap; }
.appnav a { color: var(--brand); font-weight: 600; font-size: 0.9rem; text-decoration: none; }
.appnav a:hover { text-decoration: underline; }
.header-right { display: flex; align-items: center; gap: 14px; }
.dirty { font-family: var(--mono); font-size: 0.72rem; color: var(--loss); font-weight: 600; }

/* ---------- buttons / inputs ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: var(--brand-ink);
  font-family: var(--sans);
  font-weight: 800;
  font-size: 0.88rem;
  padding: 11px 22px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--line);
}
.btn.ghost:hover { color: var(--text); border-color: var(--text-faint); filter: none; }
.btn.small { padding: 8px 14px; font-size: 0.78rem; }

input, select, button {
  font-family: var(--sans);
}

input, select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 9px;
  border-radius: 8px;
  outline: none;
  min-width: 0;
  transition: border-color 0.15s ease;
}
input::placeholder { color: var(--text-faint); }
input:focus, select:focus { border-color: var(--brand); }

/* hide number-input spinners — they eat horizontal space */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.pos { color: var(--win); }
.neg { color: var(--loss); }

/* ---------- totals strip ---------- */
.totals-strip {
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
  padding: 18px 28px;
}
.totals-strip .totals-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.totals-strip .totals-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  font-weight: 700;
}
.totals-strip .totals-figure {
  font-family: var(--mono);
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.totals-strip .totals-figure .sep { color: var(--text-faint); font-weight: 500; margin: 0 8px; }
.totals-strip .totals-divider { width: 1px; align-self: stretch; background: var(--line); }
.totals-strip .totals-right {
  display: flex;
  align-items: center;
  gap: 32px;
  margin-left: auto;
  flex-wrap: wrap;
}
.totals-strip .leftover-figure { display: flex; flex-direction: column; gap: 2px; font-size: 0.94rem; }
.totals-strip .leftover-line { color: var(--text-dim); font-weight: 600; }
.totals-strip .leftover-line b { font-weight: 800; margin-left: 6px; }
.totals-strip .diff-note {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 600;
}

/* ---------- households grid ---------- */
.households {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
  margin-top: 18px;
}
.households .section-panel { margin-top: 0; }

/* ---------- expense sections ---------- */
.section-panel .section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}
.section-panel .section-title {
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.9rem;
}
.section-panel .section-subtotal {
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-dim);
}

.expense-table { width: 100%; }
.expense-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.6fr) minmax(90px, 0.95fr) minmax(120px, 1.1fr) minmax(90px, 0.9fr) auto;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
}
.expense-row:last-of-type { border-bottom: none; }
.expense-row.head {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.expense-row input[type="text"] { width: 100%; }
.expense-row input[type="number"] { width: 100%; }
.expense-row select { width: 100%; }
.computed {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.icon-btn {
  appearance: none;
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  justify-self: end;
}
.icon-btn:hover { color: var(--loss); }
.add-row-btn { margin-top: 12px; }

/* ---------- income panel ---------- */
.income-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 14px;
}
.income-block .field-row {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field .label { font-size: 0.62rem; }
.income-block .name { font-weight: 700; font-size: 0.92rem; margin-bottom: 8px; }
.income-total {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 4px;
}
.income-summary {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
}

/* ---------- token gate ---------- */
.gate {
  max-width: 470px;
  margin: 80px auto;
  padding: 36px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: var(--panel);
}
.gate h2 { font-weight: 800; margin-bottom: 10px; letter-spacing: -0.01em; }
.gate p { color: var(--text-dim); font-size: 0.88rem; margin-bottom: 10px; }
.gate ol { color: var(--text-dim); font-size: 0.85rem; padding-left: 20px; margin-bottom: 18px; }
.gate ol li { margin-bottom: 5px; }
.gate a { color: var(--brand); }
.gate input { width: 100%; margin-bottom: 12px; }
.gate .btn { width: 100%; }
.gate .error { color: var(--loss); font-size: 0.82rem; margin-top: 10px; font-weight: 600; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
  z-index: 50;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: var(--loss); }

/* ---------- load-in ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.totals-strip, .households, .section-panel, .income-panel { animation: rise 0.45s ease both; }

.hidden { display: none !important; }

/* ---------- phone ---------- */
@media (max-width: 720px) {
  .wrap { padding: 0 12px 72px; }
  .brand .label { display: none; }
  .brand h1 { font-size: 1.15rem; }
  .panel { padding: 18px 16px; }
  .households { grid-template-columns: 1fr; }
  .totals-strip { flex-direction: column; align-items: flex-start; gap: 16px; }
  .totals-strip .totals-divider { display: none; }
  .totals-strip .totals-right { margin-left: 0; flex-direction: column; align-items: flex-start; gap: 16px; }
  .income-grid { grid-template-columns: 1fr; }
  .expense-row { grid-template-columns: 1fr; gap: 4px; padding: 12px 0; }
  .expense-row.head { display: none; }
  .expense-row .computed::before { content: attr(data-label) " "; color: var(--text-faint); font-family: var(--sans); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em; }
  .expense-row .computed { text-align: left; }
  .icon-btn { justify-self: start; }
}
