/* Money (Expenses + Club) page additions on top of pa.css / app.css.
   Only layout + small components the design boards use; colours always come from pa.css tokens. */

/* Links styled as chips / segments */
.pa a.chip { color: var(--text-2); text-decoration: none; }
.pa a.chip.active { color: var(--bg); }
.pa .seg a { text-decoration: none; }
.pa .seg a.on { color: var(--text); }
.money-nav { margin: 0 -16px; padding: 0 16px; }
@media (min-width: 900px) { .money-nav { margin: 0; padding: 0; flex-wrap: wrap; } }
.money-seg { padding: 0 16px 4px; }
@media (min-width: 900px) { .money-seg { padding: 12px 32px 0; max-width: 420px; } }

/* Segmented control driven by radio inputs (Expense / Income / Transfer) */
.seg.seg-radio label { height: 36px; border-radius: 9px; color: var(--text-2); font-size: 14px; font-weight: 500;
  display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.seg.seg-radio input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg.seg-radio label:has(input:checked) { background: var(--surface-3); color: var(--text); font-weight: 600; }
[data-theme="light"] .seg.seg-radio label:has(input:checked) { background: var(--surface); box-shadow: 0 1px 3px rgba(20,22,27,0.12); }
.seg.seg-radio label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Month switcher */
.month-switch { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.month-switch .t-h3 { text-align: center; }
.icon-btn[aria-disabled="true"] { opacity: .35; pointer-events: none; }

/* Floating add button (phones; desktop shows the header button) */
.pa a.pa-fab { position: fixed; right: 16px; bottom: calc(84px + var(--safe-bottom, 0px)); width: 56px; height: 56px;
  border-radius: 18px; padding: 0; box-shadow: var(--shadow-2); z-index: 31; }
.pa-fab .bi { font-size: 24px; }
@media (min-width: 900px) { .pa a.pa-fab { display: none; } }

/* Overview: budgets/subscriptions first on phones, beside the transactions on desktop */
@media (max-width: 899.98px) { .money-aside { order: -1; } }
.money-aside { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* Transactions grouped by day */
.tx-card { overflow: hidden; }
.tx-card .day-head { padding: 8px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.tx-card .li:last-child { border-bottom: 1px solid var(--border); }
.tx-card > .li:last-of-type { border-bottom: 0; }
.tx-col { display: none; font-size: 13px; color: var(--text-2); flex: 0 0 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .amt.ok { color: var(--success); }
@media (min-width: 900px) {
  .tx-card .tx-col { display: block; }
  .tx-card .tx-col.cat { width: 140px; }
  .tx-card .tx-col.acc { width: 120px; }
  .tx-card .li .sub.tx-sub { display: none; }
  .tx-card .li .amt { width: 110px; text-align: right; }
}

/* Budget rows */
.bud-row { display: flex; flex-direction: column; gap: 8px; color: inherit; text-decoration: none; }
.pa a.bud-row { color: var(--text); }

/* Add-transaction sheet (a page that looks like the sheet) */
.sheet-page { background: var(--surface); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow-2);
  padding: 16px; display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 560px; margin: 0 auto; }
@media (max-width: 899.98px) { .sheet-page { border-radius: 24px 24px 0 0; border-bottom: 0; box-shadow: var(--shadow-3); margin-bottom: -96px; padding-bottom: 32px; min-height: calc(100vh - 80px); } }
.amount-wrap { display: flex; align-items: center; justify-content: center; gap: 2px; padding: 4px 0; }
.amount-wrap .cur { font-family: var(--font-display); font-size: 36px; font-weight: 600; color: var(--text-2); }
.pa input.amount-field { width: 100%; max-width: 280px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text);
  outline: none; padding: 0; -moz-appearance: textfield; }
.pa input.amount-field:focus { border-bottom-color: var(--accent); }
.pa input.amount-field::-webkit-outer-spin-button, .pa input.amount-field::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pa input.amount-field::placeholder { color: var(--text-3); }

.cat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cat-opt { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 64px; padding: 10px 4px;
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 14px; color: var(--text-2); font-size: 12px;
  text-align: center; cursor: pointer; line-height: 1.2; }
.cat-opt span.n { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-opt .bi { font-size: 20px; }
.cat-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.cat-opt:has(input:checked) { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--text); font-weight: 600; padding: 9px 3px; }
.cat-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.cat-opt.more { font-family: inherit; }
.tone-c1 { color: var(--c1); } .tone-c2 { color: var(--c2); } .tone-c3 { color: var(--c3); }
.tone-c4 { color: var(--c4); } .tone-c5 { color: var(--c5); } .tone-c6 { color: var(--c6); }
.dot.c1 { background: var(--c1); } .dot.c2 { background: var(--c2); } .dot.c3 { background: var(--c3); }
.dot.c4 { background: var(--c4); } .dot.c5 { background: var(--c5); } .dot.c6 { background: var(--c6); }
.dot.ok { background: var(--success); } .dot.warn { background: var(--warning); } .dot.bad { background: var(--danger); }
.stack-bar span.c1 { background: var(--c1); } .stack-bar span.c2 { background: var(--c2); } .stack-bar span.c3 { background: var(--c3); }
.stack-bar span.c4 { background: var(--c4); } .stack-bar span.c5 { background: var(--c5); } .stack-bar span.c6 { background: var(--c6); }
.stack-bar span.other { background: var(--text-3); } .stack-bar span.rest { flex: 1; background: var(--surface-3); }
.stack-bar span.ok { background: var(--success); } .stack-bar span.warn { background: var(--warning); } .stack-bar span.bad-soft { flex: 1; background: var(--danger-soft); }
.stack-bar.lg { height: 12px; border-radius: 6px; }

/* Toggle switch on a real checkbox */
.pa input.pa-switch { appearance: none; -webkit-appearance: none; margin: 0; width: 48px; height: 28px; border-radius: 14px;
  background: var(--surface-3); position: relative; flex: 0 0 auto; cursor: pointer; border: 0; }
.pa input.pa-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 11px; background: var(--text-2); transition: left .15s ease; }
.pa input.pa-switch:checked { background: var(--accent); }
.pa input.pa-switch:checked::after { left: 23px; background: var(--accent-ink); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; cursor: pointer; }

/* Plain checkbox rows (alerts, members) */
.check-row { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.pa .check-row input[type="checkbox"], .pa .check-row input[type="radio"] { width: 20px; height: 20px; accent-color: var(--accent); flex: 0 0 auto; margin: 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.check-grid .check-row { padding: 0 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.check-grid .check-row:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* Form layout */
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 600px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid .full { grid-column: 1 / -1; } }
.form-card { max-width: 720px; width: 100%; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.form-actions .btn-pa { flex: 1 1 auto; }
@media (min-width: 600px) { .form-actions .btn-pa { flex: 0 0 auto; } }
.alert-pa { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.alert-pa.warn { background: var(--warning-soft); color: var(--warning); }
.alert-pa.info { background: var(--accent-soft); color: var(--accent-text); }
.pa .alert-pa ul { margin: 0; padding-left: 18px; }
.pa input[type="color"].input-pa { padding: 4px; width: 72px; cursor: pointer; }
.pa details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 14px; font-weight: 500; list-style: none; }
.pa details > summary::-webkit-details-marker { display: none; }
.pa details > summary::before { content: "\F285"; font-family: "bootstrap-icons"; font-size: 12px; transition: transform .15s ease; }
.pa details[open] > summary::before { transform: rotate(90deg); }

/* Icon picker (category form) */
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; max-height: 240px; overflow-y: auto; padding: 2px; }
.icon-opt { position: relative; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); font-size: 20px; cursor: pointer; }
.icon-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.icon-opt:has(input:checked) { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.icon-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Key/value rows */
.kv { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv > span:first-child { color: var(--text-2); }
.kv > span:last-child { text-align: right; min-width: 0; overflow-wrap: anywhere; }

/* Avatars + month history (Club) */
.avatar { border-radius: 50%; font-weight: 600; font-family: var(--font-display); font-size: 14px; }
.avatar.xl { width: 64px; height: 64px; font-size: 22px; }
.month-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; }
.month-grid span { height: 28px; border-radius: 6px; background: var(--surface-3); }
.month-grid span.ok { background: var(--success); } .month-grid span.warn { background: var(--warning); } .month-grid span.bad { background: var(--danger); }
.card-pa.danger-edge { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.wrap-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.li .actions { display: flex; gap: 4px; flex: 0 0 auto; }
.li.stack-sm { flex-wrap: wrap; }
@media (max-width: 599.98px) { .li.stack-sm .actions { width: 100%; padding-left: 44px; } }
.code-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; padding: 10px 12px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border); overflow-wrap: anywhere; color: var(--text-2); }
.pre-box { white-space: pre-wrap; font-family: inherit; font-size: 13px; margin: 0; padding: 12px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.pa .btn-wa { background: var(--success); color: var(--bg); }
.pa a.btn-wa { color: var(--bg); }

/* Simple data tables (statement, report) that collapse nicely on phones */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .7px; text-transform: uppercase; color: var(--text-3); padding: 10px 14px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }

/* Daily spend mini chart (monthly report) */
.daily { display: flex; align-items: flex-end; gap: 2px; height: 120px; }
.daily span { flex: 1; min-height: 2px; border-radius: 2px 2px 0 0; background: var(--accent); }
.daily span.zero { background: var(--surface-3); }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }

/* Public pages (no app navigation) */
.public-wrap { max-width: 720px; width: 100%; margin: 0 auto; }

@media print {
  .pa-side, .pa-tabbar, .no-print, .pa-fab, .pa-toasts { display: none !important; }
  .pa-content { padding: 0 !important; }
}
