/* ---- Themes. Dark is the default. Pick one in Settings; theme.js sets <html data-theme="..."> ---- */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220; --bg-2: #111a2e; --surface: #161f33; --surface-2: #1d2840; --border: #2a3652;
  --text: #e8ecf5; --muted: #94a0ba; --accent: #f5b301; --accent-ink: #1a1400; --link: #f5b301; --danger: #ff6b6b;
  --bg-glow: #1a2542; --topbar-bg: rgba(11, 18, 32, .85); --shadow: 0 12px 32px rgba(0, 0, 0, .45); --overlay: rgba(2, 6, 16, .68);
  --focus: rgba(245, 179, 1, .2); --accent-soft: rgba(245, 179, 1, .1); --warn-border: #6b5200;
  --ok: #4ade80; --ok-border: #1f6b3a; --ok-soft: rgba(74, 222, 128, .1); --ok-text: #b7f2cd;
  --danger-soft: rgba(255, 107, 107, .12); --danger-text: #ffb3b3; --danger-border: #7a2d2d; --expense: #6d7fa8;
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb; --bg-2: #eaeef7; --surface: #ffffff; --surface-2: #eef1f8; --border: #d3d9e8;
  --text: #172033; --muted: #56627b; --accent: #f5b301; --accent-ink: #1a1400; --link: #8f6300; --danger: #c93434;
  --bg-glow: #ffffff; --topbar-bg: rgba(255, 255, 255, .9); --shadow: 0 12px 28px rgba(20, 30, 60, .16); --overlay: rgba(20, 30, 60, .45);
  --focus: rgba(245, 179, 1, .4); --accent-soft: rgba(245, 179, 1, .18); --warn-border: #d9ad3f;
  --ok: #15803d; --ok-border: #86d0a1; --ok-soft: rgba(21, 128, 61, .08); --ok-text: #14532d;
  --danger-soft: rgba(201, 52, 52, .08); --danger-text: #8f1f1f; --danger-border: #e59a9a; --expense: #7a8bb0;
}
:root[data-theme="slate"] {
  color-scheme: dark;
  --bg: #17181c; --bg-2: #1e2025; --surface: #24262c; --surface-2: #2d3038; --border: #3a3e48;
  --text: #ececf0; --muted: #9a9eab; --link: #f5b301; --bg-glow: #2a2c34; --topbar-bg: rgba(23, 24, 28, .88); --expense: #8a90a3;
}
:root[data-theme="ocean"] {
  color-scheme: dark;
  --bg: #06151c; --bg-2: #0b1f2a; --surface: #0f2a38; --surface-2: #153646; --border: #1f4658;
  --text: #e4f3f8; --muted: #8fb0be; --accent: #22d3ee; --accent-ink: #02262e; --link: #22d3ee;
  --bg-glow: #0d3446; --topbar-bg: rgba(6, 21, 28, .88); --focus: rgba(34, 211, 238, .25); --accent-soft: rgba(34, 211, 238, .1);
  --warn-border: #0e7490; --expense: #6b9db3;
}
:root[data-theme="forest"] {
  color-scheme: dark;
  --bg: #0a1510; --bg-2: #101f17; --surface: #14281d; --surface-2: #1b3626; --border: #29483a;
  --text: #e6f2ea; --muted: #8fae9b; --accent: #a3e635; --accent-ink: #1a2400; --link: #a3e635;
  --bg-glow: #163524; --topbar-bg: rgba(10, 21, 16, .88); --focus: rgba(163, 230, 53, .25); --accent-soft: rgba(163, 230, 53, .1);
  --warn-border: #4d7c0f; --expense: #7a9a86;
}
:root[data-theme="rose"] {
  color-scheme: light;
  --bg: #fbf3f5; --bg-2: #f5e8ec; --surface: #ffffff; --surface-2: #f7ebef; --border: #ebd2da;
  --text: #2a1620; --muted: #74545f; --accent: #e11d63; --accent-ink: #ffffff; --link: #be123c; --danger: #b91c1c;
  --bg-glow: #ffffff; --topbar-bg: rgba(255, 255, 255, .9); --shadow: 0 12px 28px rgba(80, 20, 40, .14); --overlay: rgba(60, 20, 35, .4);
  --focus: rgba(225, 29, 99, .25); --accent-soft: rgba(225, 29, 99, .08); --warn-border: #e8a0b4;
  --ok: #15803d; --ok-border: #86d0a1; --ok-soft: rgba(21, 128, 61, .08); --ok-text: #14532d;
  --danger-soft: rgba(185, 28, 28, .08); --danger-text: #8f1f1f; --danger-border: #e59a9a; --expense: #a98a97;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, var(--bg-glow) 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
}
h1, h2 { line-height: 1.2; margin: 0 0 .5rem; }
a { color: var(--link); }
.muted { color: var(--muted); }
.accent { color: var(--link); }
.spacer { flex: 1; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 800; letter-spacing: .08em; color: var(--text); text-decoration: none; }
.brand-lg { font-size: 1.25rem; margin-bottom: 1.5rem; }
.logo { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 900; }

.btn { display: inline-block; border: 1px solid transparent; border-radius: 10px; padding: .7rem 1.2rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: filter .15s, background .15s; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; margin-top: 1rem; }
.btn-sm { padding: .4rem .8rem; font-size: .9rem; }
.btn[disabled] { opacity: .6; cursor: wait; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }

/* Landing */
.hero { max-width: 720px; margin: 0 auto; padding: 18vh 1.25rem 4rem; text-align: center; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.25rem); }
.lead { color: var(--muted); font-size: 1.1rem; margin: 1rem auto 2rem; max-width: 56ch; }
.actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { margin-bottom: 1rem; }
.tabs { display: flex; gap: .25rem; background: var(--bg-2); padding: .25rem; border-radius: 10px; margin-bottom: 1rem; }
.tabs button { flex: 1; background: transparent; border: 0; color: var(--muted); padding: .55rem; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--text); }
label { display: block; margin: .9rem 0 .3rem; font-size: .9rem; color: var(--muted); }
input { width: 100%; padding: .7rem .8rem; background: var(--bg-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; font: inherit; }
input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--focus); }
.hint { display: block; margin-top: .3rem; color: var(--muted); font-size: .8rem; }
.alert { background: var(--danger-soft); border: 1px solid var(--danger); color: var(--danger-text); padding: .7rem .9rem; border-radius: 10px; margin: 0 0 .5rem; font-size: .92rem; }

/* App shell (mobile-first) */
.app { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; background: var(--topbar-bg); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.icon-btn { background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 8px; width: 2.4rem; height: 2.4rem; font-size: 1.1rem; cursor: pointer; }
.sidebar { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(84vw, 300px); display: flex; flex-direction: column; gap: .25rem; padding: 1rem; background: var(--bg-2); border-right: 1px solid var(--border); box-shadow: var(--shadow); overflow-y: auto; transform: translateX(-102%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; }
.sidebar.open { transform: none; visibility: visible; transition: transform .25s ease, visibility 0s; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 .75rem; padding: 0 .25rem 0 .35rem; }
.scrim { position: fixed; inset: 0; z-index: 35; background: var(--overlay, rgba(2, 6, 16, .68)); opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility 0s linear .25s; }
.scrim.show { opacity: 1; visibility: visible; transition: opacity .25s ease; }
body.nav-open { overflow: hidden; }
.nav-link { display: block; padding: .65rem .85rem; border-radius: 10px; color: var(--text); text-decoration: none; }
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: var(--surface-2); color: var(--link); }
.nav-link.disabled { color: var(--muted); cursor: not-allowed; }
.nav-link.disabled:hover { background: transparent; }
.nav-link em { font-size: .7rem; font-style: normal; border: 1px solid var(--border); border-radius: 999px; padding: .05rem .45rem; margin-left: .4rem; }
.content { align-content: start; padding: 1.25rem; max-width: 1100px; margin: 0 auto; display: grid; gap: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.stat { display: flex; flex-direction: column; gap: .35rem; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: clamp(1.1rem, 1.75vw, 1.6rem); font-weight: 800; white-space: nowrap; }

@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; }
  .icon-btn { display: none; }
  .sidebar { position: static; z-index: auto; width: auto; transform: none; visibility: visible; box-shadow: none; overflow: visible; transition: none; min-height: calc(100vh - 57px); }
  .drawer-head, .scrim { display: none; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Account menu (topbar) */
.account { position: relative; }
.account-btn { display: flex; align-items: center; gap: .6rem; background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: .25rem .7rem .25rem .25rem; font: inherit; cursor: pointer; }
.account-btn:hover, .account-btn[aria-expanded="true"] { background: var(--surface-2); }
.avatar { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: .8rem; }
.account-who { display: none; flex-direction: column; text-align: left; line-height: 1.2; max-width: 12rem; }
.account-name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-biz { color: var(--muted); font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { color: var(--muted); font-size: .75rem; }
.account-menu { position: absolute; right: 0; top: calc(100% + .5rem); min-width: 15rem; max-width: calc(100vw - 2rem); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .4rem; box-shadow: var(--shadow); z-index: 30; display: flex; flex-direction: column; }
.account-menu[hidden] { display: none; }
.account-menu-head { display: flex; flex-direction: column; gap: .1rem; padding: .6rem .7rem .7rem; margin-bottom: .3rem; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.menu-item { display: block; width: 100%; text-align: left; padding: .6rem .7rem; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: inherit; text-decoration: none; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }
.menu-danger { color: var(--danger); }
@media (min-width: 640px) { .account-who { display: flex; } }

/* ---- Shared components (clients module onward) ---- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: .85rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.toolbar { display: flex; gap: .75rem; }
.btn-danger { background: var(--danger); color: #2a0000; }
.danger-text { color: var(--danger); }
textarea { width: 100%; padding: .7rem .8rem; background: var(--bg-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; font: inherit; resize: vertical; }
textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--focus); }

.table-card { padding: 0; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.table td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.actions-col { text-align: right; }
.actions-col .btn { margin: .15rem 0 .15rem .25rem; }
.empty { padding: 2rem 1rem; text-align: center; margin: 0; }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; }

/* Table rows become stacked cards on phones */
@media (max-width: 639px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: .75rem 1.25rem; border-bottom: 1px solid var(--border); }
  .table tbody td:first-child, .table tbody td:last-child { padding-left: 0; padding-right: 0; }
  .table td { border: 0; padding: .2rem 0; }
  .table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  .table .num, .actions-col { text-align: left; }
  .actions-col { margin-top: .5rem; }
}

dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; width: min(92vw, 460px); }
dialog::backdrop { background: var(--overlay, rgba(2, 6, 16, .68)); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.25rem; }

/* ---- Invoices ---- */
select { width: 100%; padding: .7rem .8rem; background: var(--bg-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; font: inherit; }
select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--focus); }
.toolbar select { max-width: 200px; }
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 700; border: 1px solid var(--border); color: var(--muted); }
.badge-paid { color: var(--ok); border-color: var(--ok-border); background: var(--ok-soft); }
.badge-unpaid, .badge-partial { color: var(--link); border-color: var(--warn-border); background: var(--accent-soft); }
.badge-overdue { color: var(--danger); border-color: var(--danger-border); background: var(--danger-soft); }
.badge-void { text-decoration: line-through; }
.alert-info { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin: 0 0 .75rem; }
.table-card > .card-head { padding: 1.1rem 1.25rem .6rem; margin: 0; }
.table th:first-child, .table td:first-child { padding-left: 1.25rem; }
.table th:last-child, .table td:last-child { padding-right: 1.25rem; }
.card-head h2 { margin: 0; font-size: 1.05rem; }
.form-grid { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 2fr 1fr 1fr 1fr; } }
.section-title { margin: 1.5rem 0 .5rem; font-size: 1.05rem; }
.items { display: grid; gap: .6rem; margin-bottom: .75rem; }
.item-row { display: grid; gap: .5rem; grid-template-columns: 1fr 1fr; align-items: center; }
.item-row .it-desc { grid-column: 1 / -1; }
.item-row .it-amt { font-variant-numeric: tabular-nums; text-align: right; }
@media (min-width: 640px) { .item-row { grid-template-columns: 3fr 90px 130px 130px 40px; } .item-row .it-desc { grid-column: auto; } }
.totals-wrap { display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: space-between; align-items: flex-start; margin-top: 1rem; }
.tax-field { width: 160px; }
.totals { margin: 0; min-width: 240px; }
.totals div { display: flex; justify-content: space-between; gap: 2rem; padding: .25rem 0; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 1px solid var(--border); margin-top: .35rem; padding-top: .6rem; font-size: 1.2rem; font-weight: 800; }
.totals .grand dt { color: var(--text); }
.totals .grand dd { color: var(--accent); }

/* ---- Sharing, settings, public invoice ---- */
.center { text-align: center; }
.copy-row { display: flex; gap: .5rem; }
.alert-ok { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok-text); }
.form-grid-2 { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid-2 { grid-template-columns: 1fr 1fr; } }
.pre { white-space: pre-wrap; margin: .25rem 0 0; }
.public-wrap { max-width: 820px; margin: 0 auto; padding: 1.25rem; }
.sheet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.sheet-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 3px solid var(--accent); padding-bottom: 1rem; margin-bottom: 1rem; }
.sheet-head h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
.sheet-title { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; }
.sheet-title .accent { font-size: 1.6rem; font-weight: 800; }
.sheet-meta { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.sheet-meta > div { display: grid; gap: .15rem; align-content: start; }
.label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; margin-top: .4rem; }
.sheet-table { margin-bottom: 1rem; }
.sheet-totals { margin-left: auto; max-width: 320px; }
.sheet-extra { display: grid; gap: 1rem; margin-top: 1.5rem; }
.sheet-actions { display: flex; gap: .75rem; justify-content: center; margin: 1.5rem 0 .75rem; flex-wrap: wrap; }

@media print {
  body { background: #fff !important; color: #000 !important; }
  .no-print { display: none !important; }
  .sheet { border: 0; background: #fff; color: #000; padding: 0; }
  .sheet .muted, .sheet .label, .sheet .totals dt, .sheet .table th { color: #444 !important; }
  .sheet .accent, .sheet .totals .grand dd { color: #b57f00 !important; }
  .sheet .table td, .sheet .table th { border-color: #ccc !important; }
}

/* ---- Subscription ---- */
.plans { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .plans { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .plans { grid-template-columns: repeat(4, 1fr); } }
.plan-card { display: flex; flex-direction: column; gap: .5rem; }
.plan-card h3 { margin: 0; }
.plan-card.picked { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.plan-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.plan-price strong { font-size: 1.7rem; }
.plan-features { list-style: none; margin: .5rem 0 1rem; padding: 0; display: grid; gap: .35rem; flex: 1; font-size: .92rem; }
.plan-features li::before { content: "✓ "; color: var(--accent); font-weight: 700; }
.plan-card .btn-block { margin-top: auto; }
.cycle-toggle { display: inline-flex; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: .2rem; gap: .2rem; }
.cycle-toggle button { background: transparent; border: 0; color: var(--muted); padding: .45rem .8rem; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.cycle-toggle button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.cycle-toggle em { font-style: normal; font-size: .7rem; color: var(--accent); margin-left: .25rem; }
.usage { display: grid; gap: .5rem; min-width: 220px; }
.usage-row { display: flex; justify-content: space-between; gap: 1.5rem; }

/* ---- Expenses + charts ---- */
.grid-3 { grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.stat-value.pos { color: var(--ok); }
.stat-value.neg { color: var(--danger); }
.breakdown { display: grid; gap: .6rem; margin-top: .75rem; }
.bd-row { display: grid; grid-template-columns: 110px 1fr auto; gap: .75rem; align-items: center; }
.bd-label { font-size: .9rem; }
.bd-track { background: var(--bg-2); border-radius: 999px; height: 10px; overflow: hidden; }
.bd-bar { background: var(--accent); height: 100%; border-radius: 999px; }
.bd-amt { font-variant-numeric: tabular-nums; font-size: .9rem; min-width: 7rem; text-align: right; }
@media (max-width: 479px) { .bd-row { grid-template-columns: 1fr auto; } .bd-track { grid-column: 1 / -1; order: 3; } }
.chart-head { padding: 0 0 .5rem; flex-wrap: wrap; gap: .5rem; }
.legend { display: flex; gap: 1rem; font-size: .85rem; color: var(--muted); }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-right: .35rem; vertical-align: middle; }
.dot.income, .bar.income { background: var(--accent); }
.dot.expense, .bar.expense { background: var(--expense); }
.chart { display: flex; gap: .5rem; align-items: flex-end; height: 180px; padding-top: .5rem; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .4rem; height: 100%; justify-content: flex-end; }
.bars { display: flex; gap: 4px; align-items: flex-end; height: calc(100% - 1.5rem); width: 100%; justify-content: center; }
.bar { width: min(18px, 40%); border-radius: 4px 4px 0 0; min-height: 0; }
.chart-label { font-size: .75rem; color: var(--muted); }

/* ---- Admin ---- */
.kv { display: grid; gap: .4rem; margin: 0 0 1rem; }
.kv div { display: flex; justify-content: space-between; gap: 1.5rem; border-bottom: 1px solid var(--border); padding: .35rem 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; word-break: break-word; }
code { background: var(--bg-2); padding: .1rem .35rem; border-radius: 6px; font-size: .85em; }

/* ---- Email verification ---- */
.verify-banner { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 10px; padding: .65rem 1rem; font-size: .92rem; }

/* ---- Boxed links: View all, Back, Forgot password, empty-state actions ---- */
.link-btn { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .9rem; border: 1px solid var(--accent); border-radius: 999px; background: var(--accent-soft); color: var(--link); font-weight: 600; font-size: .9rem; line-height: 1.3; text-decoration: none; transition: background .15s, color .15s; }
.link-btn:hover { background: var(--accent); color: var(--accent-ink); }
.empty .link-btn, .hint .link-btn { margin: 0 .15rem; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-top: 1rem; }

/* ---- Notifications bell ---- */
.bell { position: relative; }
.bell-btn { position: relative; background: transparent; border: 1px solid var(--border); color: var(--text); border-radius: 50%; width: 2.4rem; height: 2.4rem; cursor: pointer; display: inline-grid; place-items: center; }
.bell-btn:hover, .bell-btn[aria-expanded="true"] { background: var(--surface-2); }
.bell-btn svg { width: 1.15rem; height: 1.15rem; }
.bell-badge { position: absolute; top: -.3rem; right: -.3rem; min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem; border-radius: 999px; background: var(--danger); color: #fff; font-size: .68rem; font-weight: 800; display: grid; place-items: center; }
.notif-menu { position: absolute; right: -3.2rem; top: calc(100% + .5rem); width: 22rem; max-width: calc(100vw - 1.5rem); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 30; display: flex; flex-direction: column; overflow: hidden; }
.notif-menu[hidden] { display: none; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: .7rem .9rem; border-bottom: 1px solid var(--border); }
.notif-list { max-height: 24rem; overflow-y: auto; }
.notif-item { display: block; width: 100%; text-align: left; padding: .7rem .9rem; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font: inherit; text-decoration: none; cursor: pointer; }
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--accent-soft); }
.notif-item strong { display: block; font-size: .92rem; }
.notif-item span { display: block; color: var(--muted); font-size: .84rem; overflow-wrap: anywhere; }
.notif-item time { display: block; color: var(--muted); font-size: .74rem; margin-top: .15rem; }
.notif-empty { padding: 1.5rem .9rem; text-align: center; color: var(--muted); }

/* ---- Theme picker ---- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .75rem; margin-top: .5rem; }
.theme-opt { position: relative; }
.theme-opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.theme-card { display: flex; flex-direction: column; gap: .5rem; padding: .6rem; border: 2px solid var(--border); border-radius: 10px; background: var(--bg-2); }
.theme-opt input:checked + .theme-card { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.theme-opt input:focus-visible + .theme-card { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-sw { display: grid; grid-template-columns: 1.4fr 1fr; grid-template-rows: 1.3rem 1.3rem; gap: 3px; border-radius: 6px; overflow: hidden; }
.theme-sw i { display: block; }
.theme-name { font-weight: 600; font-size: .9rem; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain legend { padding: 0; font-weight: 700; font-size: 1.05rem; margin-bottom: .25rem; }
.check-row { display: flex; gap: .6rem; align-items: flex-start; margin-top: 1rem; }
.check-row input { width: auto; margin-top: .25rem; }
.check-row label { margin: 0; color: var(--text); }

/* ---- Support tickets ---- */
.thread { display: flex; flex-direction: column; gap: .75rem; }
.msg { max-width: 85%; padding: .7rem .9rem; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.mine { align-self: flex-end; background: var(--accent-soft); border-color: var(--accent); }
.msg .who { display: block; font-size: .76rem; color: var(--muted); margin-bottom: .25rem; white-space: normal; }
.badge-open { color: var(--link); border-color: var(--warn-border); background: var(--accent-soft); }
.badge-answered { color: var(--ok); border-color: var(--ok-border); background: var(--ok-soft); }
.badge-closed { color: var(--muted); }
.ticket-row { cursor: pointer; }
.ticket-row:hover td { background: var(--surface-2); }

/* ---- Admin sub-navigation and messaging ---- */
.subnav { display: flex; flex-wrap: wrap; gap: .5rem; }
.link-btn[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.check-grid { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .3rem; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip span { display: inline-block; padding: .4rem .9rem; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-2); font-size: .9rem; }
.chip input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--link); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Bills & payroll ---- */
.check-col { width: 2rem; }
.check-col input { width: auto; }
dialog table.table { min-width: 0; }
#hist-dialog, #bill-dialog { width: min(94vw, 560px); }
#hist-dialog { width: min(94vw, 680px); }
#bill-dialog form { max-height: 80vh; overflow-y: auto; padding-right: .25rem; }
.content { min-width: 0; }
.table-card { overflow-x: auto; }
@media (min-width: 900px) { .actions-col { width: 15.5rem; max-width: 15.5rem; } }

/* Dashboard "Get started" checklist */
.onboard { border-color: var(--accent); }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2, var(--border)); overflow: hidden; margin: .25rem 0 .75rem; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.step { display: flex; align-items: center; gap: .75rem; padding: .6rem .5rem; border-radius: 10px; }
.step.next { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.step-mark { flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.step.done .step-mark { background: var(--success, #22c55e); border-color: var(--success, #22c55e); color: #052e16; }
.step.done .step-body strong { text-decoration: line-through; opacity: .65; }
.step-body { flex: 1; min-width: 0; display: grid; gap: .1rem; }

/* Dashboard upcoming bills widget */
.bw-summary { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 .75rem; }
.bw-flag { font-size: .85rem; padding: .25rem .65rem; border-radius: 99px; background: var(--surface-2); color: var(--text); }
.bw-flag.overdue { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); font-weight: 600; }
.bw-list { list-style: none; margin: 0; padding: 0; }
.bw-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .7rem 0; border-top: 1px solid var(--border); }
.bw-main { display: grid; gap: .1rem; min-width: 0; }
.bw-main strong, .bw-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bw-side { display: grid; justify-items: end; gap: .25rem; flex: none; }
.bw-amount { font-weight: 600; font-variant-numeric: tabular-nums; }

.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Admin analytics */
.dot.signup, .bar.signup { background: var(--success, #22c55e); }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Feedback button + dialog */
.fb-btn { position: fixed; right: 1rem; bottom: 1rem; z-index: 30; padding: .6rem 1.05rem; border-radius: 99px; border: 1px solid var(--accent); background: var(--surface); color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
.fb-btn:hover { background: var(--accent); color: var(--accent-ink); }
.content { padding-bottom: 5rem; } /* room so the button never covers the last row */
#fb-dialog { width: min(94vw, 480px); }
.fb-kinds { border: 0; padding: 0; margin: 1rem 0 .5rem; display: grid; gap: .5rem; }
.fb-kinds legend { font-weight: 600; margin-bottom: .5rem; padding: 0; }
.fb-kinds input { position: absolute; opacity: 0; pointer-events: none; }
.fb-kinds label { color: var(--text); display: grid; gap: .1rem; margin: 0; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.fb-kinds input:checked + label { border-color: var(--accent); background: var(--accent-soft); }
.fb-kinds input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
@media print { .fb-btn { display: none; } }

/* ---- Dashboard ---- */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.dash-head h1 { font-size: clamp(1.4rem, 4.5vw, 1.9rem); margin: 0; }
.dash-sub { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: .35rem 0 0; color: var(--muted); font-size: .92rem; }
.plan-pill { display: inline-block; padding: .1rem .6rem; border-radius: 999px; border: 1px solid var(--warn-border); background: var(--accent-soft); color: var(--link); font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; text-decoration: none; }
.dash-actions { display: flex; gap: .5rem; }
@media (max-width: 639px) { .dash-actions { width: 100%; } .dash-actions .btn { flex: 1; text-align: center; } }

.dash-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.dash-stats .stat { padding: 1rem 1.1rem; gap: .3rem; }
.dash-stats .stat-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.dash-stats .stat-value { font-size: 1.45rem; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; }
.dash-stats .stat.wide { grid-column: 1 / -1; }
@media (min-width: 900px) {
  .dash-stats { gap: 1rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dash-stats .stat.wide { grid-column: auto; }
  .dash-stats .stat-value { font-size: clamp(1.15rem, 1.7vw, 1.55rem); }
}

.dash-split { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1200px) {
  .dash-split { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: stretch; }
  .dash-split > .card:not([hidden]) { display: flex; flex-direction: column; }
  .dash-split .chart { flex: 1; height: auto; min-height: 180px; }
}
.bw-row:first-of-type { border-top: 0; }

/* Feedback button: icon only on phones */
.fb-btn { display: inline-flex; align-items: center; gap: .5rem; }
.fb-btn svg { width: 1.15rem; height: 1.15rem; flex: none; }
@media (max-width: 639px) {
  .fb-btn { width: 3rem; height: 3rem; padding: 0; justify-content: center; right: .85rem; bottom: .85rem; }
  .fb-btn .fb-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
