:root {
  --bg: #fbf7f1;
  --surface: #ffffff;
  --ink: #2b1d09;
  --ink-soft: #6b5a41;
  --brand: #f7931a;
  --brand-dark: #d77b0c;
  --brand-tint: #fdefd9;
  --accent: #f8a33c;
  --border: #f0e4d2;
  --shadow: 0 10px 30px rgba(120, 74, 6, 0.10);
  --radius: 14px;
  --pos: #0c7d3f;
  --neg: #c0392b;
}
/* Dark theme — applied when <html data-theme="dark">. Overrides the same variables so every
   component that themes through them adapts automatically. */
[data-theme="dark"] {
  --bg: #17120b;
  --surface: #221a10;
  --ink: #f2e8d9;
  --ink-soft: #b6a488;
  --brand: #f7931a;
  --brand-dark: #ffb04d;
  --brand-tint: #3a2a12;
  --accent: #f8a33c;
  --border: #3a2e1e;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --pos: #45c47a;
  --neg: #e8695a;
}
/* Component tweaks for dark mode where a hardcoded color can't come from a variable. */
[data-theme="dark"] .topbar { background: rgba(23, 18, 11, 0.9); }
[data-theme="dark"] .error { background: #3a1f1c; border-color: #5a2e29; color: #f0b3ac; }
/* Landing page (shown when signed out) — fix its hardcoded light surfaces for dark mode. */
[data-theme="dark"] .landing header { background: rgba(23, 18, 11, 0.85); }
[data-theme="dark"] .landing .preview .bar { background: #2a2013; }
[data-theme="dark"] .landing .preview .bar span { background: #4a3a22; }
[data-theme="dark"] .landing .how { background: linear-gradient(180deg, #1c150d, #241a0f); }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.55; -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-dark); text-decoration: none; }
h1 { font-size: 1.6rem; letter-spacing: -0.02em; margin: 0 0 6px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }

.app-loading { min-height: 60vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--ink-soft); }
.app-loading img { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .8; } 50% { transform: scale(1.08); opacity: 1; } }

/* Shell */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; background: rgba(251,247,241,.9); backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-in { width: min(1160px, 94%); margin: 0 auto; display: flex; align-items: center; gap: 18px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.02em; }
.brand img { width: 30px; height: 30px; }
.nav { display: flex; gap: 4px; margin-left: 8px; flex: 1; overflow-x: auto; }
.nav a {
  padding: 8px 14px; border-radius: 999px; color: var(--ink-soft); font-weight: 500; font-size: .94rem; white-space: nowrap;
}
.nav a:hover { background: var(--brand-tint); color: var(--brand-dark); }
.nav a.active { background: var(--brand); color: #fff; }
.top-right { display: flex; align-items: center; gap: 10px; }
.profile-select select { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); font: inherit; }

.content { width: min(1160px, 94%); margin: 0 auto; padding: 26px 0 48px; flex: 1; }

/* Cards / grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 16px; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-2 { grid-template-columns: 1.4fr 1fr; }
.cols-2-even { grid-template-columns: 1fr 1fr; }
.stat .k { font-size: .72rem; color: var(--brand-dark); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 1.5rem; font-weight: 700; margin-top: 4px; }
.stat { background: var(--brand-tint); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--brand); color: #fff; border: none; font-weight: 600;
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-size: .92rem; }
.btn:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; color: var(--brand-dark); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--brand-tint); }
.btn.sm { padding: 5px 11px; font-size: .84rem; }
.btn.danger { background: transparent; color: var(--neg); border: 1px solid #f0d0cb; }
.btn.danger:hover { background: #fdecea; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: .92rem; }
th { color: var(--ink-soft); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); font-weight: 600; }
.neg { color: var(--neg); font-weight: 600; }
.muted { color: var(--ink-soft); }
.pill-tag { display: inline-block; font-size: .74rem; padding: 2px 9px; border-radius: 999px; background: var(--brand-tint); color: var(--brand-dark); font-weight: 600; }

/* Forms */
.form-row { display: grid; gap: 6px; margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { font-size: .82rem; color: var(--ink-soft); font-weight: 600; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; font: inherit; background: var(--surface); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-tint); border-color: var(--brand); }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.section-title { display: flex; align-items: center; gap: 8px; }
/* Collapsible section title (click to expand/collapse) with a rotating caret. */
h1.collapsible, h2.collapsible { cursor: pointer; display: inline-flex; align-items: center; gap: 8px; user-select: none; }
.collapsible .caret { display: inline-block; font-size: .7em; color: var(--ink-soft); transition: transform .15s ease; }
.collapsible .caret.open { transform: rotate(90deg); }
.toolbar { display: flex; gap: 10px; align-items: center; }

/* Custom date picker (DateBox): dd/MMM/yyyy display + calendar popup. */
.datebox { position: relative; min-width: 150px; }
.datebox-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; text-align: left; }
.datebox-field:hover { border-color: var(--brand); }
.datebox-field .datebox-ph { color: var(--ink-soft); }
.datebox-field svg { color: var(--ink-soft); flex: none; }
.datebox-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(43, 29, 9, .25); }
.datebox-pop { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 81; width: 288px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 14px; }
.datebox-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 600; text-transform: capitalize; }
.datebox-head button { background: transparent; border: none; cursor: pointer; font-size: 1.2rem; line-height: 1; color: var(--ink); padding: 2px 10px; border-radius: 8px; }
.datebox-head button:hover { background: var(--brand-tint); color: var(--brand-dark); }
.datebox-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.datebox-dow { text-align: center; font-size: .68rem; color: var(--ink-soft); padding: 4px 0; text-transform: uppercase; }
.datebox-day { aspect-ratio: 1; border: none; background: transparent; cursor: pointer; border-radius: 8px; font: inherit; font-size: .85rem; color: var(--ink); }
.datebox-day:hover { background: var(--brand-tint); }
.datebox-day.muted { color: var(--ink-soft); opacity: .45; }
.datebox-day.today { outline: 1px solid var(--brand); }
.datebox-day.sel { background: var(--brand); color: #fff; }
.datebox-foot { display: flex; justify-content: space-between; margin-top: 10px; }

/* Info icon + hover tooltip next to a section title. */
.info-hint { position: relative; display: inline-flex; align-items: center; color: var(--ink-soft); cursor: help; }
.info-hint:hover, .info-hint:focus { color: var(--brand-dark); outline: none; }
.info-tip { display: none; position: absolute; top: calc(100% + 8px); left: 0; z-index: 50; width: 270px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 12px; font-size: .82rem; font-weight: 400; line-height: 1.45; color: var(--ink); white-space: normal; text-transform: none; letter-spacing: normal; }
.info-hint:hover .info-tip, .info-hint:focus .info-tip { display: block; }

/* Dialog */
.modal-backdrop { position: fixed; inset: 0; background: rgba(43,29,9,.4); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 18px; padding: 22px; width: min(540px, 100%); box-shadow: var(--shadow); max-height: 90vh; overflow: auto; }
.modal h2 { margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* Inline checkbox + label inside a form row. */
.form-row label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-row label.check input { width: auto; margin: 0; }

/* User email hover menu (Settings + Sign out). */
.user-menu { position: relative; }
.user-trigger { display: flex; align-items: center; gap: 6px; background: transparent; border: 1px solid transparent; cursor: pointer; font: inherit; color: var(--ink-soft); padding: 6px 10px; border-radius: 10px; }
.user-trigger:hover { background: var(--brand-tint); border-color: var(--border); }
.user-trigger .user-email { font-size: .82rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-trigger .caret { font-size: .65rem; color: var(--ink-soft); }
.user-dropdown { display: none; position: absolute; right: 0; top: 100%; margin-top: 4px; min-width: 190px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 40; }
.user-menu.open .user-dropdown { display: block; }
/* Transparent catcher that closes the menu on an outside click (below the sticky topbar). */
.menu-backdrop { position: fixed; inset: 0; z-index: 20; background: transparent; }
.user-dropdown button { display: block; width: 100%; text-align: left; background: transparent; border: none; cursor: pointer; font: inherit; color: var(--ink); padding: 9px 12px; border-radius: 8px; }
.user-dropdown button:hover { background: var(--brand-tint); color: var(--brand-dark); }

/* Safe-to-spend card */
.safe-card { margin-top: 16px; }
.safe-card .k { font-size: .74rem; color: var(--brand-dark); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.safe-card .safe-amount { font-size: 2.1rem; font-weight: 700; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
.safe-card .safe-amount.neg { color: var(--neg); }
.safe-card .safe-amount.pos { color: var(--pos); }
.safe-card .safe-lines { color: var(--ink-soft); font-size: .9rem; display: grid; gap: 4px; }

.empty { text-align: center; color: var(--ink-soft); padding: 40px 10px; }
.error { background: #fdecea; border: 1px solid #f0d0cb; color: var(--neg); padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; font-size: .9rem; }
.progress { height: 8px; background: var(--brand-tint); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--brand)); }

/* Footer (matches landing) */
footer.site { background: #241a0b; color: #c3b291; padding: 26px 0; margin-top: auto; }
footer.site .foot-in { width: min(1160px, 94%); margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; font-size: .88rem; }
footer.site a { color: #fff; }

/* App-shell footer (the landing footer copied into MainLayout). Scoped to .shell so it stays
   self-contained and always wins over the generic footer/.foot rules. */
.shell footer#contact { background: #241a0b; color: #e8dcc7; padding: 54px 0 30px; margin-top: auto; }
.shell footer#contact a { color: #fff; }
.shell footer#contact .wrap { width: min(1120px, 92%); margin: 0 auto; }
.shell .foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 30px; flex-wrap: wrap; }
.shell .foot .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em; color: #fff; }
.shell .foot .logo img { width: 32px; height: 32px; display: block; }
.shell .foot > div > p { color: #c3b291; font-size: .95rem; max-width: 360px; margin-top: 12px; }
.shell .foot a.contact { color: #fff; font-weight: 600; }
.shell .foot a.contact:hover { color: var(--brand); }
.shell .foot-cols { display: flex; gap: 60px; flex-wrap: wrap; }
.shell .foot-cols h5 { color: #fff; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.shell .foot-cols a { display: block; color: #c3b291; font-size: .94rem; padding: 4px 0; }
.shell .foot-cols a:hover { color: #fff; }
.shell .copyright { border-top: 1px solid rgba(255,255,255,0.1); margin-top: 40px; padding-top: 22px; font-size: .86rem; color: #a4906c; text-align: center; }
.shell .copyright a { color: #c3b291; }
.shell .foot-cols .donate-list { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 2px; }
.shell .foot-cols .donate-btn { display: inline-flex; align-items: center; gap: 7px; background: var(--brand); color: #fff; font-weight: 600; font-size: .94rem; font-family: inherit; padding: 9px 16px; border: none; border-radius: 999px; cursor: pointer; transition: background .15s ease; }
.shell .foot-cols .donate-btn:hover { background: var(--brand-dark); color: #fff; }
.shell .foot-cols .donate-btn.kofi { background: #ff5e5b; }
.shell .foot-cols .donate-btn.kofi:hover { background: #e94b48; }

/* Pie charts (income/expense by category). */
.pie-block h2 { margin-bottom: 14px; }
.pie-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.pie-svg { width: 170px; height: 170px; flex: none; }
.pie-legend { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 8px; }
.pie-legend-row { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.pie-dot { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.pie-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pie-val { font-variant-numeric: tabular-nums; color: var(--ink); }
.pie-pct { font-variant-numeric: tabular-nums; color: var(--ink-soft); min-width: 48px; text-align: right; }

/* Install-app promo banner (PWA). Pinned bottom-left so it doesn't clash with the donation toast. */
.install-banner { position: fixed; left: 16px; bottom: 16px; z-index: 65; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; max-width: min(460px, 92%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 16px; }
.install-banner-text { display: flex; flex-direction: column; gap: 3px; font-size: .9rem; }
.install-banner-text strong { font-size: .96rem; }
.install-banner-text span { color: var(--ink-soft); }
.install-banner-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
@media (max-width: 560px) {
  .install-banner { left: 12px; right: 12px; max-width: none; }
}

/* Once-a-day donation reminder toast. */
.donate-toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; max-width: min(620px, 94%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 18px; }
.donate-toast-text { display: flex; flex-direction: column; gap: 3px; font-size: .9rem; }
.donate-toast-text strong { font-size: .96rem; }
.donate-toast-text span { color: var(--ink-soft); }
.donate-toast-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
@media (max-width: 560px) {
  .donate-toast { flex-direction: column; align-items: flex-start; }
  .donate-toast-actions { margin-left: 0; }
}

/* Center the PayPal hosted-button widget inside the donate modal. */
#paypal-container-B8XSUPA23UP7J { display: flex; flex-direction: column; align-items: center; }
#paypal-container-B8XSUPA23UP7J > * { width: 100%; max-width: 360px; margin-left: auto; margin-right: auto; }

/* ===== Landing page (scoped to .landing; overrides generic classes within it) ===== */
{ min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--ink); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
.wrap { width: min(1120px, 92%); margin: 0 auto; }
header { position: sticky; top: 0; z-index: 20; background: rgba(251,247,241,0.85); backdrop-filter: saturate(140%) blur(10px); border-bottom: 1px solid var(--border); }
.landing .nav { display: flex; align-items: center; justify-content: space-between; height: 68px; flex: none; gap: 0; overflow: visible; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em; }
.logo img { width: 32px; height: 32px; display: block; }
.nav-right { display: flex; align-items: center; gap: 16px; }
.nav-links { display: flex; gap: 22px; align-items: center; }
.nav-links a { color: var(--ink-soft); font-size: .95rem; font-weight: 500; }
.nav-links a:hover { color: var(--brand-dark); }
.btn { display: inline-block; background: var(--brand); color: #fff; font-weight: 600; padding: 11px 20px; border-radius: 999px; border: none; cursor: pointer; font-size: .95rem; transition: background .15s ease, transform .15s ease; }
.btn:hover { background: var(--brand-dark); transform: translateY(-1px); }
.btn.ghost { background: transparent; color: var(--brand-dark); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--brand-tint); }
.lang { padding: 8px 13px; font-size: .85rem; font-weight: 700; letter-spacing: .03em; }
.hero { padding: 76px 0 58px; text-align: center; }
.pill { display: inline-flex; align-items: center; gap: 8px; background: var(--brand-tint); color: var(--brand-dark); font-weight: 600; font-size: .82rem; padding: 7px 14px; border-radius: 999px; margin-bottom: 26px; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.08; letter-spacing: -0.03em; margin-bottom: 20px; }
.hero h1 .hl { color: var(--brand-dark); }
.hero p.lead { font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--ink-soft); max-width: 660px; margin: 0 auto 32px; }
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.preview { margin: 52px auto 0; max-width: 940px; }
.preview .frame { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.preview .bar { display: flex; gap: 7px; padding: 14px 16px; border-bottom: 1px solid var(--border); background: #fdf8f0; }
.preview .bar span { width: 11px; height: 11px; border-radius: 50%; background: #eeddc2; }
.dash { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; padding: 22px; text-align: left; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--brand-tint); border: none; border-radius: 12px; padding: 14px; }
.stat .k { font-size: .72rem; color: var(--brand-dark); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 1.25rem; font-weight: 700; margin-top: 4px; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 130px; padding-top: 8px; }
.bars .b { flex: 1; background: linear-gradient(180deg, var(--accent), var(--brand)); border-radius: 6px 6px 0 0; }
.list-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.list-row:last-child { border-bottom: none; }
.list-row .neg { color: #c0392b; font-weight: 600; }
.list-row .pos { color: var(--brand-dark); font-weight: 600; }
.muted { color: var(--ink-soft); }
section.block { padding: 72px 0; }
.landing .section-head { display: block; text-align: center; max-width: 660px; margin: 0 auto 48px; }
.landing .section-head h2 { font-size: clamp(1.7rem, 3.2vw, 2.4rem); letter-spacing: -0.02em; margin-bottom: 14px; }
.landing .section-head p { color: var(--ink-soft); font-size: 1.05rem; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; transition: transform .15s ease, box-shadow .15s ease; }
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.feature .ico { width: 46px; height: 46px; border-radius: 12px; background: var(--brand-tint); color: var(--brand-dark); display: grid; place-items: center; margin-bottom: 16px; }
.feature h3 { font-size: 1.12rem; margin-bottom: 8px; letter-spacing: -0.01em; }
.feature p { color: var(--ink-soft); font-size: .96rem; }
.how { background: linear-gradient(180deg, #ffffff, #fdf3e6); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.how-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.how-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px; }
.how-card .tag { display: inline-block; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--brand-dark); background: var(--brand-tint); padding: 5px 12px; border-radius: 999px; margin-bottom: 14px; }
.how-card h3 { font-size: 1.3rem; margin-bottom: 10px; }
.how-card p { color: var(--ink-soft); }
.how-card ul { list-style: none; margin-top: 16px; display: grid; gap: 10px; }
.how-card li { display: flex; gap: 10px; align-items: flex-start; font-size: .96rem; }
.how-card li svg { flex: none; margin-top: 3px; }
.trust { text-align: center; }
.trust .row { display: flex; justify-content: center; gap: 40px; flex-wrap: wrap; margin-top: 34px; }
.trust .item { max-width: 260px; }
.trust .item .ico { width: 44px; height: 44px; border-radius: 50%; background: var(--brand-tint); color: var(--brand-dark); display: grid; place-items: center; margin: 0 auto 14px; }
.trust .item h4 { margin-bottom: 6px; }
.trust .item p { color: var(--ink-soft); font-size: .94rem; }
footer { background: #241a0b; color: #e8dcc7; padding: 54px 0 30px; }
.foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 30px; flex-wrap: wrap; }
.foot .logo { color: #fff; }
.foot p { color: #c3b291; font-size: .95rem; max-width: 360px; margin-top: 12px; }
.foot a.contact { color: #fff; font-weight: 600; }
.foot a.contact:hover { color: var(--brand); }
.foot-cols { display: flex; gap: 60px; flex-wrap: wrap; }
.foot-cols h5 { color: #fff; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.foot-cols a { display: block; color: #c3b291; font-size: .94rem; padding: 4px 0; }
.foot-cols a:hover { color: #fff; }
.copyright { border-top: 1px solid rgba(255,255,255,0.1); margin-top: 40px; padding-top: 22px; font-size: .86rem; color: #a4906c; text-align: center; }

@media (max-width: 860px) {
    .nav-links { display: none; }
  .features { grid-template-columns: 1fr 1fr; }
  .how-grid { grid-template-columns: 1fr; }
  .dash { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .features { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

.landing-error { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 200; background: #fdecea; border: 1px solid #f0d0cb; color: var(--neg); padding: 12px 16px; border-radius: 12px; font-size: .9rem; box-shadow: var(--shadow); }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: #fff3cd; padding: 12px 20px; box-shadow: 0 -1px 6px rgba(0,0,0,.1); z-index: 100; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; top: 12px; }

@media (max-width: 900px) {
  .cols-3, .cols-4 { grid-template-columns: 1fr 1fr; }
  .cols-2, .cols-2-even { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .cols-3, .cols-4 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  html { font-size: 14px; }
}

/* On phones, collapse row action buttons (Edit/Delete/Enable/Disable) to icon-only to save width. */
@media (max-width: 560px) {
  .btn.sm.act-icon { font-size: 0; padding: 6px 9px; gap: 0; }
  .btn.sm.act-icon::before { font-size: .95rem; line-height: 1; }
  .act-edit::before { content: "✏️"; }
  .act-delete::before { content: "🗑️"; }
  .act-enable::before { content: "✅"; }
  .act-disable::before { content: "🚫"; }
  /* Keep the row action icons side by side (don't let them wrap onto stacked lines). */
  td.num { white-space: nowrap; }
  .btn.sm.act-icon { margin-left: 4px; }
}

/* Mobile top bar: keep the nav tabs visible on their own scrollable row. */
@media (max-width: 760px) {
  /* Slightly smaller base font so more fits on small screens (scales all rem-based text). */
  html { font-size: 15px; }
  .topbar-in { flex-wrap: wrap; height: auto; padding: 8px 0; gap: 8px 10px; }
  .brand span { display: none; }
  .top-right { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
  .top-right .profile-select select { max-width: 150px; }
  .top-right .muted { display: none; }              /* hide the email to save space */
  .user-trigger .user-email { display: none; }      /* collapse to just the ▾ menu on mobile */
  .user-trigger { padding: 6px 8px; }
  .nav { order: 3; flex-basis: 100%; margin-left: 0; padding-bottom: 2px; }
  .nav a { padding: 8px 12px; }
  .nav::-webkit-scrollbar { height: 4px; }
  .nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

  /* Prevent the page from scrolling sideways on small screens. */
  html, body { overflow-x: hidden; }
  .content { width: 100%; padding-left: 12px; padding-right: 12px; }

  /* Let section toolbars wrap instead of overflowing. */
  .section-head { flex-wrap: wrap; }
  .section-head .toolbar { flex-wrap: wrap; }
  .toolbar input[type="date"] { width: auto; flex: 1 1 auto; min-width: 0; }
  .toolbar .datebox { flex: 1 1 auto; min-width: 130px; }

  /* Wide tables scroll horizontally inside their card, not the whole page. */
  .card { overflow-x: auto; }
  .card table { min-width: 480px; }
}
