/* Family Financial Planner – single stylesheet with design tokens.
   Palette: pine green (trust, Islamic finance), gold accent (wakaf gold), cool paper background. */

:root {
  --pine: #0f5447;
  --pine-dark: #0a3a31;
  --pine-deep: #072a24;
  --mint: #e6f0ed;
  --gold: #c39322;
  --gold-soft: #f6ecd2;
  --ink: #18232a;
  --ink-2: #44535b;
  --muted: #6b7a81;
  --paper: #f4f6f5;
  --white: #ffffff;
  --line: #d9e1de;
  --ok: #1f7a4d;   --ok-bg: #e3f3ea;
  --warn: #8a5a00; --warn-bg: #fbf0d6;
  --bad: #b42318;  --bad-bg: #fbe7e5;
  --info: #1d5fb8; --info-bg: #e5eefb;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(10, 58, 49, .06), 0 4px 16px rgba(10, 58, 49, .05);
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --topbar-h: 60px;
  --sidebar-w: 264px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--paper); }
a { color: var(--pine); text-underline-offset: 2px; }
a:hover { color: var(--pine-dark); }
img { max-width: 100%; height: auto; object-fit: contain; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .9em; max-width: 78ch; }
code, pre { font-family: var(--mono); font-size: .86em; }
pre.code { background: var(--pine-deep); color: #e8f3ef; padding: .75rem 1rem; border-radius: var(--radius-sm); overflow-x: auto; white-space: pre; }
code.wrap { word-break: break-all; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--white); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.tiny { font-size: .75rem; }
.center { text-align: center; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 1.25rem; }
.bad { color: var(--bad); }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 1rem; padding: 0 1rem;
  background: var(--white); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-logo { height: 34px; width: auto; }
.brand-name { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-site { flex: 1; min-width: 0; }
.top-site select { max-width: 280px; min-width: 140px; font-weight: 600; background-color: var(--mint); border-color: transparent; }
.lang-form select { width: auto; min-width: 64px; }
.top-right { display: flex; align-items: center; gap: .6rem; }
.top-user { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); line-height: 1.2; text-align: right; }
.top-user-name { font-weight: 600; font-size: .9rem; }
.top-user-role { font-size: .75rem; color: var(--muted); }
.top-msg { position: relative; display: inline-flex; padding: .45rem; border-radius: 50%; color: var(--ink-2); }
.top-msg:hover { background: var(--mint); }
.top-msg .count { position: absolute; top: -2px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--gold); color: var(--white); font-size: .7rem; font-weight: 700; display: grid; place-items: center; }
.lang-form select, .site-form select { padding: .35rem .5rem; font-size: .88rem; }
.btn-exit { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--line); background: var(--white); color: var(--ink); padding: .4rem .7rem; border-radius: 999px; font: inherit; font-size: .88rem; cursor: pointer; }
.btn-exit:hover { border-color: var(--bad); color: var(--bad); }
.icon-btn { border: 0; background: none; padding: .4rem; color: var(--ink); cursor: pointer; border-radius: var(--radius-sm); }
.menu-toggle { display: none; }

/* ---------- Shell & sidebar ---------- */
.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); width: var(--sidebar-w); flex: none;
  display: flex; flex-direction: column; background: var(--pine-dark); color: #d6e7e1;
}
.sidebar a { color: inherit; text-decoration: none; }
.nav-dashboard, .nav-item, .nav-credits {
  display: flex; align-items: center; gap: .7rem; padding: .55rem 1rem .55rem 1.1rem; border-left: 3px solid transparent; font-size: .92rem;
}
.nav-dashboard { margin-top: .6rem; font-weight: 700; color: var(--white); }
.nav-dashboard:hover, .nav-item:hover, .nav-credits:hover { background: rgba(255, 255, 255, .06); color: var(--white); }
.sidebar .active { border-left-color: var(--gold); background: rgba(195, 147, 34, .16); color: var(--white); font-weight: 600; }
.nav-scroll { flex: 1; overflow-y: auto; padding: .3rem 0 1rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
.nav-top { padding-bottom: .4rem; margin-bottom: .4rem; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.nav-top .nav-item { font-size: .86rem; color: #b9d2c9; }
.nav-group summary {
  list-style: none; cursor: pointer; padding: .7rem 1.1rem .35rem; font-size: .78rem; font-weight: 700; color: #9fc0b5; display: flex; justify-content: space-between; align-items: center;
}
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.nav-group[open] summary::after { transform: rotate(45deg); }
.nav-group summary:hover { color: var(--white); }
.nav-credits { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: .7rem; padding-bottom: .8rem; font-size: .86rem; color: #b9d2c9; }
.scrim { position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(7, 42, 36, .45); z-index: 25; }

/* ---------- Content ---------- */
.content { flex: 1; min-width: 0; padding: 1.5rem clamp(1rem, 3vw, 2.2rem) 3rem; }
.page-head { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; justify-content: space-between; margin-bottom: 1.2rem; }
.page-head h1 { margin: 0; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.page-actions form { margin: 0; }
.foot { padding: 1rem; text-align: center; color: var(--muted); font-size: .78rem; }

.panel, .card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.card { box-shadow: var(--shadow); }
.card.narrow { max-width: 560px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; }
details.panel > summary { cursor: pointer; font-weight: 600; }
details.panel[open] > summary { margin-bottom: .8rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: .75rem; align-items: end; }
.dash-grid { gap: 1.25rem; }
.dash-grid > .panel { margin: 0; }

/* Welcome + stats */
.welcome { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; padding-bottom: 1rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.welcome-hi { font-size: 1.35rem; font-weight: 700; margin: 0; }
.welcome .muted { margin: 0; }
.welcome-date { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.stat { display: flex; flex-direction: column; gap: .15rem; padding: .9rem 1rem; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
a.stat:hover { border-color: var(--pine); }
.stat-n { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-l { font-size: .85rem; color: var(--ink-2); }
.stat-has { border-left: 4px solid var(--gold); }
.stat-ok .stat-n { color: var(--ok); }
.stat-bad .stat-n { color: var(--bad); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list a, .list li > span { display: flex; flex-direction: column; padding: .6rem 0; text-decoration: none; color: var(--ink); }
.list .list-title { font-weight: 500; }
.list .unread .list-title { font-weight: 700; }
.list .unread a { box-shadow: inset 3px 0 0 var(--gold); padding-left: .7rem; }
.list-meta { font-size: .8rem; color: var(--muted); }
.list-snippet { font-size: .86rem; color: var(--ink-2); }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: .6rem; padding: .4rem 0; }
.checklist .tick { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; border: 2px solid var(--line); flex: none; }
.checklist .done .tick { background: var(--ok); border-color: var(--ok); color: var(--white); }
.checklist .done a { color: var(--ink-2); }
.checklist .fail .tick { background: var(--bad); border-color: var(--bad); color: var(--white); }
.checklist .todo .tick { border-color: var(--gold); color: var(--warn); }
.plain { padding-left: 1.2rem; }
ol.steps { padding-left: 1.2rem; }
ol.steps li { margin-bottom: 1rem; }
.secret { font-family: var(--mono); font-size: 1.2rem; letter-spacing: .08em; background: var(--mint); padding: .6rem .8rem; border-radius: var(--radius-sm); margin: .4rem 0; display: inline-block; }

dl.dl { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: .45rem 1rem; margin: 0 0 1rem; }
dl.dl dt { color: var(--muted); font-size: .88rem; }
dl.dl dd { margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
.panel .table-wrap, .card .table-wrap { border: 0; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table thead th { font-size: .8rem; font-weight: 700; color: var(--ink-2); background: #f8faf9; position: sticky; top: 0; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafcfb; }
.table .group-row th { background: var(--mint); color: var(--pine-dark); font-size: .82rem; }
.matrix td.center input { width: 18px; height: 18px; accent-color: var(--pine); }
.matrix .tiny { display: block; }
.actions-cell { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: wrap; align-items: flex-start; }
.actions-cell form { margin: 0; }
.inline-details { position: relative; }
.inline-details > summary { list-style: none; }
.inline-details > summary::-webkit-details-marker { display: none; }
.inline-details[open] > form { position: absolute; right: 0; top: 110%; z-index: 5; width: 280px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; box-shadow: var(--shadow); text-align: left; }
.changes { list-style: none; padding: 0; margin: .3rem 0 0; font-size: .82rem; }
.changes .field { font-weight: 600; }
.changes .old { color: var(--bad); text-decoration: line-through; text-decoration-color: rgba(180, 35, 24, .4); word-break: break-word; }
.changes .new { color: var(--ok); word-break: break-word; }
.tests td { font-size: .86rem; }
.test-form { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .4rem; }
.test-form input { width: 140px; }

/* Badges */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; text-decoration: none; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: #edf0ef; color: var(--ink-2); }

/* Forms */
.form label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 600; color: var(--ink-2); margin-bottom: .9rem; }
.form label small { font-weight: 400; color: var(--muted); }
.form label.check, label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=number], input:not([type]), select, textarea {
  font: inherit; font-size: .95rem; color: var(--ink); background: var(--white); border: 1px solid #c3cfcb; border-radius: var(--radius-sm); padding: .55rem .7rem; width: 100%; min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--pine); outline: 2px solid rgba(15, 84, 71, .18); outline-offset: 0; }
input[readonly], input:disabled, select:disabled, textarea:disabled { background: #f1f4f3; color: var(--muted); }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--pine); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem .2rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .3rem; }
fieldset.radios { display: flex; gap: 1rem; flex-wrap: wrap; padding-bottom: .6rem; }
.form-row { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; }
.form-row label { margin-bottom: 0; flex: 1 1 200px; }
.form-row label.check { flex: 0 0 auto; }
.form-inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.form-inline label { margin: 0; }
.form-inline input { width: auto; flex: 1 1 140px; }
.action-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-bottom: .7rem; }
.action-form label { display: flex; flex-direction: column; font-size: .85rem; gap: .25rem; flex: 1 1 180px; }
.action-form input { flex: 1 1 180px; width: auto; }
.action-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-start; margin-bottom: .6rem; }
.action-row .action-form { margin: 0; }
.w-sm { max-width: 90px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .35rem 1rem; margin-bottom: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem .9rem; align-items: flex-end; margin-bottom: 1rem; }
.filters label { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.filters input, .filters select { width: auto; min-width: 150px; }
.settings .setting { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: .4rem 1.5rem; padding: .7rem 0; border-bottom: 1px solid var(--line); align-items: center; }
.settings .setting:last-of-type { border-bottom: 0; margin-bottom: 1rem; }
.setting-label { display: flex; flex-direction: column; gap: .1rem; }
.setting-label > label { font-weight: 600; color: var(--ink); }
.setting-input input[type=checkbox] { width: 20px; height: 20px; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--paper) 30%); padding: 1rem 0 .5rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-size: .9rem; font-weight: 600; padding: .5rem 1rem; border-radius: var(--radius-sm); border: 1px solid #c3cfcb; background: var(--white); color: var(--ink); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--pine); color: var(--pine-dark); }
.btn-primary { background: var(--pine); border-color: var(--pine); color: var(--white); }
.btn-primary:hover { background: var(--pine-dark); border-color: var(--pine-dark); color: var(--white); }
.btn-danger { background: var(--white); border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: var(--white); border-color: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-block { width: 100%; }

/* Messages & banners */
.flash { padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid transparent; }
.flash ul { margin: 0; padding-left: 1.1rem; }
.flash-ok { background: var(--ok-bg); color: #155a39; border-color: #b8e0c9; }
.flash-error { background: var(--bad-bg); color: #8e1c13; border-color: #f2c3be; }
.flash-warn { background: var(--warn-bg); color: #6b4600; border-color: #efd9a2; }
.banner { padding: .65rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 600; }
.banner-freeze { background: #e8eef7; color: #1b3e73; border-left: 4px solid var(--info); }
.banner-warn { background: var(--warn-bg); color: #6b4600; border-left: 4px solid var(--gold); }
.note { background: var(--gold-soft); border-left: 4px solid var(--gold); padding: .65rem .9rem; border-radius: var(--radius-sm); font-size: .9rem; }
.empty { text-align: center; padding: 2.5rem 1rem; background: var(--white); border: 1px dashed #c3cfcb; border-radius: var(--radius); color: var(--ink-2); }
.success-box { text-align: center; }
.regno { font-size: 1.6rem; font-weight: 700; letter-spacing: .04em; color: var(--pine); font-variant-numeric: tabular-nums; }
.danger-zone { border-color: #f2c3be; }
.danger-zone h2 { color: var(--bad); }
.freeze-card.is-frozen { border-color: var(--info); background: #f4f8fd; }
.freeze-state { font-size: 1rem; }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a { padding: .5rem .9rem; text-decoration: none; color: var(--ink-2); border-bottom: 3px solid transparent; margin-bottom: -1px; font-weight: 600; font-size: .9rem; }
.tabs a.on { color: var(--pine-dark); border-bottom-color: var(--gold); }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin-top: .5rem; }

/* Threads */
.thread { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1.25rem; }
.thread-item { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; max-width: 820px; }
.thread-item.mine, .thread-item.staff { border-left: 4px solid var(--pine); }
.thread-item header { margin-bottom: .4rem; }
.thread-body { white-space: normal; overflow-wrap: anywhere; }
.attachments { list-style: none; padding: 0; margin: .6rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .86rem; }
.attachments a::before { content: "📎 "; }
.meta-line { color: var(--ink-2); }

/* Documents (manual, guide) */
.doc { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem clamp(1rem, 3vw, 2.5rem); max-width: 900px; }
.doc h2 { margin-top: 1.6rem; padding-top: .4rem; border-top: 1px solid var(--line); }
.doc h2:first-child { margin-top: 0; border-top: 0; }
.doc li { margin-bottom: .35rem; }
.doc table { border-collapse: collapse; width: 100%; font-size: .9rem; margin-bottom: 1rem; }
.doc th, .doc td { border: 1px solid var(--line); padding: .45rem .6rem; text-align: left; vertical-align: top; }
.doc th { background: var(--mint); }

/* Credits */
.credits { text-align: center; padding: 2rem 1rem; }
.credits-logo { height: 72px; width: auto; margin-bottom: .8rem; }
.credits h2 { font-size: 1.5rem; }
.credit-list { list-style: none; padding: 0; margin: 1.5rem auto 0; max-width: 480px; }
.credit-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.credit-name { font-weight: 600; }
.credit-role { color: var(--ink-2); }
.credit-edit input { flex: 1 1 140px; width: auto; }

/* Public pages (login, register) */
body.public { background: radial-gradient(1200px 500px at 10% -10%, #dcebe6 0%, transparent 60%), var(--paper); }
.public-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; }
.public-card { width: 100%; max-width: 460px; background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 1.6rem clamp(1.1rem, 4vw, 2rem); box-shadow: var(--shadow); }
.public-wrap.wide .public-card { max-width: 760px; }
.public-card h1 { font-size: 1.35rem; margin: 1.2rem 0 1rem; }
.public-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.public-top .brand-name { white-space: normal; }
.public-lang select { padding: .3rem .4rem; font-size: .85rem; width: auto; }
.public-foot { color: var(--muted); font-size: .78rem; margin-top: 1rem; }
.brand-dark .brand-name { color: var(--pine-dark); }
.divider { display: flex; align-items: center; gap: .8rem; color: var(--muted); font-size: .85rem; margin: 1.1rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.g_id_signin { display: flex; justify-content: center; }

/* Date picker */
.dp { position: absolute; z-index: 60; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(10, 58, 49, .18); padding: .6rem; width: 264px; font-size: .85rem; }
.dp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; font-weight: 700; }
.dp-head button, .dp-foot button { border: 0; background: none; cursor: pointer; padding: .3rem .5rem; border-radius: var(--radius-sm); font: inherit; color: var(--pine); }
.dp-head button:hover, .dp-foot button:hover { background: var(--mint); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.dp-grid span { color: var(--muted); font-size: .72rem; padding: .2rem 0; }
.dp-grid button { border: 0; background: none; padding: .35rem 0; border-radius: var(--radius-sm); cursor: pointer; font: inherit; color: var(--ink); font-variant-numeric: tabular-nums; }
.dp-grid button:hover { background: var(--mint); }
.dp-grid button.sel { background: var(--pine); color: var(--white); }
.dp-grid button.today { box-shadow: inset 0 0 0 1px var(--gold); }
.dp-foot { display: flex; justify-content: space-between; margin-top: .4rem; }

/* ---------- External sign-in ---------- */
.oauth-buttons { display: flex; flex-direction: column; align-items: center; gap: .7rem; margin-bottom: 1rem; }
.btn-apple { display: inline-flex; align-items: center; justify-content: center; gap: .55rem; width: 300px; max-width: 100%; height: 40px; border-radius: 999px;
  background: #000; color: #fff; text-decoration: none; font-weight: 600; font-size: .95rem; font-family: -apple-system, "SF Pro Text", var(--font); }
.btn-apple:hover, .btn-apple:focus { background: #222; color: #fff; }
.child-row + .child-row { border-top: 1px dashed var(--line); padding-top: .6rem; }

/* ---------- Phase 2: household finance ---------- */
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.lead { font-size: 1.02rem; color: var(--ink-2); }
.tag { display: inline-block; font-size: .68rem; font-weight: 700; color: var(--pine); background: var(--mint); border-radius: 4px; padding: 0 .3rem; vertical-align: middle; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--white); }
.btn-gold:hover { background: #a87c18; border-color: #a87c18; color: var(--white); }
.btn-lg { padding: .75rem 1.6rem; font-size: 1rem; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.list li.row-between { padding: .4rem 0; }
.bar { display: block; height: 8px; border-radius: 99px; background: #e6ece9; overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--ok); }
.bar-warn > span { background: #d29a1e; }
.bar-over > span { background: var(--bad); }
.bar-gold > span { background: var(--gold); }
.bar-lg { height: 12px; margin: .8rem 0 .3rem; }
.stat .bar { margin-top: .4rem; }
.w-bar { width: 110px; }

.month-card { background: var(--pine-dark); color: #e8f3ef; border-radius: 14px; padding: 1.2rem 1.4rem; margin-bottom: 1rem; }
.month-card h2 { color: var(--white); margin: 0; font-size: 1.15rem; }
.month-card .muted { color: #a9c7bc; }
.month-card-head { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; justify-content: space-between; margin-bottom: .9rem; }
.month-card-head select { background: rgba(255,255,255,.1); color: var(--white); border-color: rgba(255,255,255,.25); width: auto; }
.month-card-head select option { color: var(--ink); }
.month-figures { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 1rem; }
.month-figures > div { display: flex; flex-direction: column; }
.fig-l { font-size: .82rem; color: #a9c7bc; }
.fig-n { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--white); white-space: nowrap; }
.fig-main .fig-n { font-size: 1.7rem; color: var(--gold); }
.month-card .pos { color: #7fd9a9; }
.month-card .neg { color: #ffb4ab; }
.month-card .fig-main .neg { color: #ffb4ab; }
.month-card .bar { background: rgba(255,255,255,.15); }
.month-card a { color: var(--gold-soft); }
.alerts { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.25rem; }
.alert { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem .9rem; background: var(--white); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: var(--radius-sm); }
.cta { border-left: 5px solid var(--gold); }
.list li.is-overdue .list-title { color: var(--bad); }
.goal-list .bar { margin: .3rem 0; }

.budget-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.month-nav { display: flex; align-items: center; gap: .7rem; }
.month-nav strong { min-width: 9.5rem; text-align: center; font-size: 1.05rem; }
.num-input { text-align: right; max-width: 150px; padding: .35rem .5rem; font-variant-numeric: tabular-nums; }
.num-input.sm { max-width: 110px; font-size: .85rem; }
.budget-table td { vertical-align: middle; }
.year-grid th, .year-grid td { padding: .4rem .45rem; white-space: nowrap; }
.year-grid .sticky-col { position: sticky; left: 0; background: var(--white); z-index: 1; min-width: 170px; }
.year-grid .group-row .sticky-col { background: var(--mint); }
.year-grid tfoot th { background: #f8faf9; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: #f3f6f5; margin-bottom: 1rem; }
.segmented .seg { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: .4rem 1rem; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.segmented input:checked + span { background: var(--white); color: var(--pine-dark); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.segmented input:focus-visible + span { outline: 3px solid var(--gold); }
.amount-field input.big { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; padding: .6rem .8rem; }
.txn-form[data-dir="out"] .for-transfer:not(.for-out),
.txn-form[data-dir="in"] .for-transfer:not(.for-in),
.txn-form[data-dir="in"] .for-out:not(.for-in),
.txn-form[data-dir="transfer"] .for-in:not(.for-transfer),
.txn-form[data-dir="transfer"] .for-out:not(.for-transfer) { display: none; }
details.more { margin: .3rem 0 1rem; }
details.more > summary { cursor: pointer; color: var(--pine); font-weight: 600; font-size: .9rem; margin-bottom: .6rem; }
.wakaf-opt { border-left: 3px solid var(--gold); padding-left: .8rem; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.txn-table td { vertical-align: middle; }

.agenda-item { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .55rem 0; }
.agenda-main { flex: 1; display: flex; flex-direction: column; min-width: 180px; }
.agenda-date { font-size: .8rem; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.agenda-overdue { border-left: 4px solid var(--bad); }
.agenda-overdue .agenda-date { color: var(--bad); }
.agenda-due { border-left: 4px solid var(--gold); }
.agenda-item form { margin: 0; }

.goal-grid, .program-grid, .template-grid, .member-grid { display: grid; gap: 1rem; margin-bottom: 1.25rem; }
.goal-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.program-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.template-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.member-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.goal-card { display: flex; flex-direction: column; gap: .35rem; padding: 1rem 1.1rem; background: var(--white); border: 1px solid var(--line); border-top: 4px solid var(--ok); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.goal-card:hover { border-color: var(--pine); }
.goal-behind { border-top-color: #d29a1e; }
.goal-achieved { border-top-color: var(--gold); }
.goal-type { font-size: .78rem; color: var(--ink-2); font-weight: 600; }
.goal-name { font-size: 1.05rem; font-weight: 700; }
.goal-amounts { font-variant-numeric: tabular-nums; font-size: .92rem; }
.template { display: flex; flex-direction: column; gap: .3rem; padding: .9rem 1rem; border: 1px dashed #b9c8c3; border-radius: var(--radius); text-decoration: none; color: var(--ink); background: #fbfdfc; }
.template:hover { border-color: var(--pine); border-style: solid; }
.program h2 { font-size: 1.05rem; margin-bottom: .2rem; }
.program form { margin-top: .6rem; }
.wkf-progress .bar { margin: .5rem 0 .3rem; }
.gold-card { border-top: 4px solid var(--gold); max-width: 760px; }
.gold-links { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1rem; }
.gold-link { display: flex; flex-direction: column; padding: .8rem 1.1rem; border: 1px solid var(--gold); border-radius: var(--radius); text-decoration: none; color: var(--ink); min-width: 200px; background: var(--gold-soft); }
.member { display: flex; gap: .8rem; padding: 1rem; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.member h3 { margin: 0; }
.member p { margin: .15rem 0; }
.avatar { width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--mint); color: var(--pine-dark); display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; }
.member-body { flex: 1; min-width: 0; }
.member-edit summary { cursor: pointer; color: var(--pine); }
.member-edit form { margin-top: .5rem; }
.family-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.wizard .step h2 { display: flex; align-items: center; gap: .6rem; }
.step-n { width: 28px; height: 28px; border-radius: 50%; background: var(--pine); color: var(--white); display: grid; place-items: center; font-size: .9rem; flex: none; }
.report { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem clamp(1rem, 3vw, 2rem); }
.report-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; border-bottom: 2px solid var(--pine); padding-bottom: .8rem; }
.report-head h2 { margin: 0; }
.report-head p { margin: 0; }
.report-logo { height: 46px; width: auto; }
.report h3 { margin-top: 1.4rem; }
@media (max-width: 767px) {
  .month-figures { grid-template-columns: 1fr 1fr; gap: .8rem; }
  .fig-n { font-size: 1.02rem; }
  .fig-main .fig-n { font-size: 1.45rem; }
  .fig-main { grid-column: 1 / -1; }
  .alert { flex-direction: column; align-items: flex-start; }
  .num-input { max-width: 110px; }
}
@media print {
  .no-print, .flash, .banner { display: none !important; }
  .report { border: 0; padding: 0; }
  body { background: #fff; }
}

/* ---------- v1.4: budget copy, sign-out, responsive tables ---------- */
.copy-offer { border-left: 5px solid var(--gold); }
.alert.alert-bad { border-left-color: var(--bad); margin-bottom: 1rem; }
.copy-offer h2 { margin-bottom: .3rem; }
.copy-offer form { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; }
.auto-copy { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0 1.5rem; color: var(--ink-2); }
.nav-signout { margin: 0; }
.nav-signout button { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .55rem 1rem .9rem; background: none; border: 0;
  color: #f2c6bf; font: inherit; font-size: .86rem; cursor: pointer; text-align: left; }
.nav-signout button:hover, .nav-signout button:focus-visible { color: var(--white); background: rgba(255, 255, 255, .06); }
.stat-n { white-space: nowrap; }
.year-grid .num-input.sm { min-width: 92px; }

/* Phones: wide tables become cards (labels come from the table header, set by app.js). */
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .stat { padding: .7rem .8rem; }
  .stat-n { font-size: clamp(1rem, 4.6vw, 1.3rem); }
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable tr { padding: .55rem .8rem; border-bottom: 1px solid var(--line); }
  .rtable tbody tr:last-child { border-bottom: 0; }
  .rtable td { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .2rem 0; border: 0; text-align: right; }
  .rtable td::before { content: attr(data-label); font-size: .78rem; font-weight: 600; color: var(--ink-2); text-align: left; flex: none; max-width: 45%; }
  .rtable td[data-label=""]::before { display: none; }
  .rtable td:empty { display: none; }
  .rtable td:first-child { font-weight: 600; text-align: left; justify-content: flex-start; }
  .rtable td:first-child::before { display: none; }
  .rtable td.actions-cell, .rtable td.right { justify-content: flex-end; flex-wrap: wrap; }
  .rtable .group-row th { display: block; padding: .5rem .8rem; }
  .rtable tbody tr:hover td { background: none; }
  .rtable .num-input { max-width: none; width: 55%; }
  .budget-table td:last-child .bar { width: 100%; }
  .sticky-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom));
    background: var(--white); border-top: 1px solid var(--line); box-shadow: 0 -4px 12px rgba(0, 0, 0, .06); }
  .sticky-actions .btn { width: 100%; }
  form:has(.sticky-actions) { padding-bottom: 4.5rem; }
  .page-head { flex-wrap: wrap; }
  .page-actions { flex-wrap: wrap; }
  .filters { grid-template-columns: 1fr 1fr; }
  .month-nav strong { min-width: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .topbar .brand-name { display: none; }
}
@media (max-width: 1023px) and (min-width: 600px) {
  :root { --sidebar-w: 220px; }
  .top-user-role { display: none; }
}
@media (max-width: 860px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .settings .setting { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .menu-toggle { display: inline-flex; }
  .sidebar { position: fixed; left: 0; top: var(--topbar-h); z-index: 26; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 4px 0 24px rgba(0, 0, 0, .2); width: min(82vw, 300px); }
  body.nav-open .sidebar { transform: translateX(0); }
  .topbar .brand-name { display: none; }
  .top-user { display: none; }
  .btn-exit span { display: none; }
  .btn-exit { padding: .4rem; }
  .top-site select { max-width: 40vw; min-width: 0; }
  .topbar { gap: .5rem; padding: 0 .6rem; }
  .content { padding-top: 1rem; }
  h1 { font-size: 1.3rem; }
  .welcome { flex-direction: column; align-items: flex-start; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  dl.dl { grid-template-columns: 1fr; gap: .1rem; }
  dl.dl dd { margin-bottom: .5rem; }
  .filters input, .filters select { min-width: 0; width: 100%; }
  .filters label { flex: 1 1 140px; }
  .inline-details[open] > form { position: static; width: auto; margin-top: .4rem; }
  .actions-cell { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media print {
  .topbar, .sidebar, .foot, .page-actions, .sticky-actions { display: none !important; }
  .content { padding: 0; }
}
