/* ===================== धनसूत्र v2: auth, notifications, alarms, AI ===================== */
[hidden] { display: none !important; }
input[type=password], input[type=time], input[type=date], input[type=month] {
  width: 100%; min-height: 42px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--raised); font-size: 15px; outline: none;
}
code { font-size: 12.5px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }
h4.sub { font-size: 13px; color: var(--ink2); margin: 14px 0 4px; font-weight: 600; }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
a.btn { text-decoration: none; color: inherit; }
a.btn.primary { color: var(--accent-ink); }
.pill.sync b, .pill.ok b { color: var(--accent); }
.pill.offline b, .pill.err b { color: var(--crit-ink); }

/* bell */
.bell { position: relative; }
.bell-badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--crit); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }
.bell-badge[hidden] { display: none; }

/* notification panel */
.panel { position: fixed; z-index: 45; top: 0; right: 0; bottom: 0; width: min(400px, 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: -10px 0 30px rgba(0, 0, 0, .12); transform: translateX(105%); transition: transform .22s ease; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.panel.open { transform: none; }
.panel-h { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.panel-h b { font-size: 17px; margin-right: auto; }
#notifList { flex: 1; overflow-y: auto; padding: 8px; }
.panel-f { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.nf { display: flex; gap: 10px; width: 100%; text-align: left; background: none; border: 0; border-radius: 12px; padding: 10px; cursor: pointer; }
.nf:hover { background: var(--bg); }
.nf.unread { background: var(--accent-soft); }
.nf-i { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--bg); font-weight: 700; color: var(--accent); border: 1px solid var(--border); }
.nf-i.warn { color: #9a6700; }
.nf-i.crit { color: var(--crit-ink); }
.nf-b { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nf-b b { font-size: 14px; }
.nf-b span { font-size: 13px; color: var(--ink2); }
.nf-b small { font-size: 11.5px; color: var(--muted); }

/* alarms */
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.item.alarm.off { opacity: .6; }
.cal-link { display: flex; gap: 8px; margin: 8px 0; }
.cal-link input { font-size: 12.5px; }

/* auth */
.auth { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 20% 0%, var(--accent-soft), var(--bg)); }
.auth[hidden] { display: none; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .12); display: flex; flex-direction: column; gap: 16px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card form .ctl { flex: none; }
.auth-card .btn.primary { min-height: 48px; font-size: 15px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 12px; padding: 4px; border: 1px solid var(--border); }
.seg button { border: 0; background: none; border-radius: 9px; min-height: 38px; cursor: pointer; font-weight: 600; color: var(--ink2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.auth-err { color: var(--crit-ink); font-size: 13.5px; min-height: 1em; margin: 0; }

/* AI */
.ai-grid { align-items: start; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.chat-card { display: flex; flex-direction: column; }
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 56vh; min-height: 220px; overflow-y: auto; padding: 4px 2px 10px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere; }
.msg p { margin: 0 0 6px; }
.msg p:last-child { margin: 0; }
.msg ul { margin: 4px 0 6px; padding-left: 18px; }
.msg h4 { font-size: 14px; margin: 8px 0 4px; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.err { border-color: var(--crit); }
.typing { display: flex; gap: 4px; }
.typing span { width: 7px; height: 7px; border-radius: 99px; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chips-row { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0 10px; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.sug { flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.sug:hover { border-color: var(--accent); color: var(--accent); }
.ask { display: flex; gap: 8px; }
.ask input { flex: 1; }
.chat-card > .btn.sm { align-self: flex-start; margin-top: 8px; }
.review { font-size: 14px; line-height: 1.6; }
.review h4 { margin: 10px 0 4px; font-size: 14.5px; }
.review ul { padding-left: 18px; margin: 4px 0; }
.consent { border-left: 4px solid var(--accent); }

.score .chip, .ks .chip { align-self: flex-start; }

/* ===================== v3: review fixes ===================== */
#onboard:empty, #autoBanner:empty, #heroScore:empty { display: none; }
.hero { gap: 8px; }

/* type & targets: Devanagari needs a bit more size; touch targets ≥ 44px */

.fl, .kl, .ctl > span { font-size: 13px; }
.chip { font-size: 12px; }
.plot .tick { font-size: 12px; }
.nav-i { font-size: 12px; }
input[type=text], input[type=number], input[type=search], input[type=password], input[type=time], input[type=date], input[type=month], select { min-height: 44px; }
.btn, .btn.sm { min-height: 44px; }
.btn.sm { height: auto; white-space: normal; text-align: center; }
.icon-btn { width: 44px; height: 44px; }
.icon-btn.sm { width: 36px; height: 36px; }
.item .del { width: 44px; height: 44px; }
.amt { font-size: 12px; color: var(--accent); min-height: 1em; }
.kv small { font-size: 13px; font-weight: 500; }
.kpi .meter { margin: 4px 0 2px; }
.mj { grid-template-columns: 92px 1fr auto; }
.mj span { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.over { color: var(--crit-ink); font-weight: 700; }
.legend-note { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 12.5px; color: var(--ink2); margin: 10px 0 0; }
.legend-note .key.sq { margin-right: 4px; }
.danger-zone { border-top: 1px dashed var(--grid); margin-top: 16px; padding-top: 12px; }

/* toast follows the theme and can carry an action (undo) */
.toast { background: var(--raised); color: var(--ink); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0, 0, 0, .18); display: flex; align-items: center; gap: 12px; }
.toast.show { pointer-events: auto; }
.toast-act { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; padding: 6px 8px; min-height: 44px; }

/* floating "ask AI" button (phones) */
.fab { position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 31; display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 18px; border-radius: 99px; border: 0; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700; box-shadow: 0 8px 24px rgba(42, 120, 214, .35); cursor: pointer; }
body.on-ai .fab { display: none; }
@media (min-width: 960px) { .fab { display: none; } }

/* phones: tables become stacked cards; odd KPI tile spans the row */
@media (max-width: 599px) {
  .tbl.stack thead { display: none; }
  .tbl.stack, .tbl.stack tbody, .tbl.stack tr, .tbl.stack td { display: block; width: 100%; }
  .tbl.stack tr { border: 1px solid var(--border); border-radius: 12px; padding: 6px 12px; margin-bottom: 8px; background: var(--bg); }
  .tbl.stack tr.sel { border-color: var(--accent); background: var(--accent-soft); }
  .tbl.stack tr.sel td { background: none; }
  .tbl.stack td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 5px 0; text-align: right; white-space: normal; }
  .tbl.stack td::before { content: attr(data-label); color: var(--ink2); font-size: 12.5px; text-align: left; flex: none; max-width: 48%; }
  .tbl.stack td[data-label=""]::before { content: none; }
  .tbl.stack td:first-child { font-weight: 600; }
  .kpis > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .toast { bottom: calc(148px + env(safe-area-inset-bottom)); }
}

/* review fixes: one highlighted next step, collapsible routes, readable tips, full-width switches */
.now-step { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin: 12px 0 4px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); border: 1px solid var(--accent); }
.now-step small { flex-basis: 100%; color: var(--ink2); }
details.routes { margin: 12px 0; border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; }
details.routes > summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.swr-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
@media (max-width: 599px) {
  .tbl.stack td.note { display: block; text-align: left; }
  .tbl.stack td.note::before { display: block; max-width: none; margin-bottom: 2px; }
  .fld.chk { grid-column: 1 / -1; }
}

/* Phase 2 (ADR-0012): bottom-sheet editors + onboarding wizard. NB: .sheet / .sheet-bg belong to the "More" menu — editor sheets use .ed-sheet */
body.modal-open { overflow: hidden; }
.sheet-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-overlay[hidden] { display: none; }
.sheet-overlay.center { align-items: center; padding: 12px; }
.ed-sheet { background: var(--surface); color: var(--ink); width: 100%; max-width: 640px; max-height: 88vh; max-height: 88dvh; overflow-y: auto; border-radius: 18px 18px 0 0;
  padding: 6px 16px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0, 0, 0, .25); animation: sheetUp .18s ease-out; }
.ed-sheet::before { content: ''; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 4px auto 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: -6px; background: var(--surface); padding: 4px 0 8px; z-index: 1; }
.ed-sheet .item { border: 0; padding: 0; background: none; box-shadow: none; }
.sheet-foot { display: flex; gap: 10px; justify-content: space-between; margin-top: 14px; position: sticky; bottom: -12px; background: var(--surface); padding: 10px 0; }
.btn.del-txt { color: var(--crit-ink); }
@keyframes sheetUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ed-sheet { animation: none; } }
.item-sum { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; text-align: left; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; min-height: 56px; margin-bottom: 8px; cursor: pointer; color: inherit; font: inherit; }
.item-sum > span:first-child { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.item-sum b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sum small { color: var(--ink2); font-size: 13px; }
.item-sum .chev { font-size: 24px; color: var(--ink2); flex: none; }
.wizard { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; margin: 0; }
.wz-head h2 { margin: 2px 0 8px; }
.wz-dots { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 12px; }
.wz-dots li { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.wz-dots li.now { background: var(--accent); }
.wz-dots li.done { background: var(--accent); opacity: .45; }
.wz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.wz-grid .fld.wide { grid-column: 1 / -1; }
.wz-row { border: 1px solid var(--border); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.wz-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; }
.wz-err { color: var(--crit-ink); min-height: 1em; margin: 8px 0 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
/* while a sheet / wizard is open, messages appear at the top so they never cover the form */
body.modal-open .toast { top: calc(12px + env(safe-area-inset-top)); bottom: auto; z-index: 75; }
.wizard .wz-grid .fld .amt { min-height: 1em; }
#wizardOpen2 + small { display: block; margin-top: 4px; }

/* Phase 3: refinance what-if */
.refi-sug { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.refi-loans { border: 0; padding: 0; margin: 8px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.refi-loans legend { margin-bottom: 6px; }
.refi-l { display: flex; gap: 10px; align-items: center; border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; min-height: 48px; cursor: pointer; }
.refi-l input { width: 20px; height: 20px; flex: none; }
.refi-l span { display: flex; flex-direction: column; min-width: 0; }
.refi-l small { color: var(--ink2); }

/* Phase 3 review fixes */
@media (max-width: 599px) { .screen { padding-bottom: calc(96px + env(safe-area-inset-bottom)); } }   /* the floating AI button never covers numbers */
.card { scroll-margin-top: 72px; }
.refi-verdict { margin: 10px 0; }
.refi-out th:not(:first-child) { text-align: right; }
.btn.restore-btn { border: 1px solid var(--warn); background: transparent; }
details.hint-d > summary { cursor: pointer; color: var(--ink2); min-height: 44px; display: flex; align-items: center; }
.confirm-dlg { border: 1px solid var(--border); border-radius: 16px; padding: 18px; max-width: min(92vw, 440px); background: var(--surface); color: var(--ink); }
.confirm-dlg::backdrop { background: rgba(0, 0, 0, .45); }
.confirm-dlg .controls { justify-content: flex-end; }

/* Phase 3b: tax form, monthly report + print */
.chk-ctl { flex-direction: row !important; align-items: center; gap: 8px; min-height: 44px; }
.chk-ctl input { width: 20px; height: 20px; }
.report .rep-head { display: flex; justify-content: space-between; border-bottom: 2px solid var(--accent); padding-bottom: 8px; margin-bottom: 12px; }
.report .rep-head small { display: block; color: var(--ink2); }
.report h4 { margin: 16px 0 6px; }
.rep-list { padding-left: 20px; margin: 0; }
.rep-list li { margin-bottom: 4px; }
@media print {
  body.print-report .screen:not(.print-target), body.print-report .no-print, body.print-report .fab, body.print-report .toast { display: none !important; }
  body.print-report .screen.print-target { display: flex !important; padding: 0 !important; }
  body.print-report .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  body.print-report .tbl.stack thead { display: table-header-group !important; }
  body.print-report .tbl.stack { display: table !important; width: 100%; }
  body.print-report .tbl.stack tbody { display: table-row-group !important; }
  body.print-report .tbl.stack tr { display: table-row !important; border: 0; }
  body.print-report .tbl.stack td { display: table-cell !important; }
  body.print-report .tbl.stack td::before { content: none !important; }
}

/* Family accounts: viewers see, never change (ADR-0028) */
body.readonly [data-add], body.readonly [data-del], body.readonly .item .del, body.readonly #wizardOpen, body.readonly #wizardOpen2,
body.readonly #goalKidsBtn, body.readonly #autoLink, body.readonly #loadSample, body.readonly #resetAll, body.readonly #backupNow,
body.readonly [data-restore], body.readonly .file-btn, body.readonly #runAuto { display: none !important; }
body.notowner [data-restore], body.notowner #backupNow { display: none !important; }   /* owner-only on the server too */
.fam-code { display: inline-flex; flex-direction: column; gap: 2px; padding: 10px 14px; border: 2px dashed var(--accent); border-radius: 12px; margin: 8px 0; }
.fam-code b { font-size: 24px; letter-spacing: 2px; font-family: ui-monospace, Consolas, monospace; }

/* Phase 3b review fixes */
input[readonly] { background: var(--bg); color: var(--ink2); border-style: dashed; }
.amt.lock { color: var(--ink2); }
.fam-pill { background: var(--accent-soft); }
@page { size: A4; margin: 12mm; }
@media print {
  /* always print light, whatever theme is on screen */
  :root, :root[data-theme="dark"] { --bg: #ffffff; --surface: #ffffff; --raised: #ffffff; --ink: #0b0b0b; --ink2: #44433f; --muted: #66655f; --border: rgba(0, 0, 0, .15); color-scheme: light; }
  body.print-report { background: #fff !important; color: #0b0b0b !important; }
}

/* Phase 4: quick cash spend chips, 12-month table */
.chips-row.cash-cats { margin: 6px 0 2px; }
.chip-btn { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.chip-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#cashTable td small { display: inline-block; line-height: 1.4; }
.form-err { color: var(--crit-ink); margin: 4px 0; font-weight: 600; }
.cash-list { padding-bottom: 8px; }
body.readonly #cashQuickCard, body.readonly [data-biz-draft], body.readonly [data-cash-del] { display: none !important; }
.card.link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* 12-month view on phones: one compact block per month (UI review H4) */
.cal-list { list-style: none; margin: 0; padding: 0; }
.cal-list > li { border-bottom: 1px solid var(--border); padding: 10px 0; }
.cal-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cal-ev { margin-top: 4px; line-height: 1.5; }
.cal-list details summary { cursor: pointer; color: var(--accent); min-height: 44px; display: flex; align-items: center; }
.cal-dl { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 4px 0 0; }
.cal-dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.tot td { border-top: 2px solid var(--border); }
/* account security (ADR-0037) */
.sec-key { font-size: 1.05em; letter-spacing: .5px; word-break: break-all; user-select: all; }
.sec-codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.sec-codes code { display: block; padding: 6px 8px; border: 1px dashed var(--border); border-radius: 8px; text-align: center; font-size: 1.05em; }
/* CA print: headings stay with their table; app hints never print (UI review L17) */
@media print { body.print-report h4 { break-after: avoid; } body.print-report .no-print { display: none !important; } }

