/* Kas Masjid Al-Ikhlas — lihat design.md untuk token & komponen */

:root {
  --bg: #0e141b;
  --surface: #161e28;
  --surface-2: #1c2632;
  --surface-3: #232f3d;
  --border: #263241;
  --border-strong: #34424f;
  --text: #e6edf3;
  --text-muted: #8b9bab;
  --primary: #3ecf7a;
  --primary-strong: #2fb866;
  --primary-soft: rgba(62, 207, 122, .12);
  --on-primary: #06220f;
  --income: #3ecf7a;
  --income-soft: rgba(62, 207, 122, .12);
  --expense: #f25f5c;
  --expense-soft: rgba(242, 95, 92, .12);
  --transfer: #5aa9e6;
  --transfer-soft: rgba(90, 169, 230, .12);
  --opening: #a5b4fc;
  --opening-soft: rgba(165, 180, 252, .10);
  --warning: #f5b544;
  --warning-soft: rgba(245, 181, 68, .12);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .35);
  --sidebar-w: 248px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f0f3f6;
  --surface-3: #e6ebf0;
  --border: #dde3ea;
  --border-strong: #c9d2dc;
  --text: #17212b;
  --text-muted: #5b6b7b;
  --primary: #16a34a;
  --primary-strong: #15803d;
  --primary-soft: rgba(22, 163, 74, .10);
  --on-primary: #ffffff;
  --income: #15803d;
  --income-soft: rgba(22, 163, 74, .10);
  --expense: #dc2626;
  --expense-soft: rgba(220, 38, 38, .08);
  --transfer: #2563eb;
  --transfer-soft: rgba(37, 99, 235, .08);
  --opening: #4f46e5;
  --opening-soft: rgba(79, 70, 229, .07);
  --warning: #b45309;
  --warning-soft: rgba(245, 158, 11, .12);
  --shadow: 0 8px 28px rgba(15, 23, 42, .12);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
p { margin: 0 0 .75rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.i-sm { width: 16px; height: 16px; }
.i-lg { width: 24px; height: 24px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.text-income { color: var(--income); }
.text-expense { color: var(--expense); }
.text-transfer { color: var(--transfer); }
.text-opening { color: var(--opening); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

/* ------------------------------------------------------------ Shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: grid; place-items: center; overflow: hidden;
  background: var(--primary-soft); color: var(--primary);
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.brand-name { font-weight: 700; color: var(--primary); font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--text-muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); padding: 16px 12px 6px; }
.nav a, .nav button {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500; font-size: 14px;
  background: none; border: 0; width: 100%; text-align: left; cursor: pointer; font-family: inherit;
}
.nav a:hover, .nav button:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav-cta { margin: 4px 0 8px; }
.nav-cta a { background: var(--primary); color: var(--on-primary) !important; justify-content: center; font-weight: 600; }
.nav-cta a:hover { background: var(--primary-strong); }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 28px; min-height: 68px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; font-weight: 700; }
.topbar .greet { font-size: 13px; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.role-chip { font-size: 12px; color: var(--text-muted); padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; }
.content { width: 100%; max-width: 1240px; padding: 24px 28px 48px; }

/* ------------------------------------------------------------ Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-head { padding: 18px 20px 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-7-5 { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; }

.stat { position: relative; padding: 18px 20px; }
.stat-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 12px; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat.opening .stat-icon { background: var(--opening-soft); color: var(--opening); }
.stat.opening .stat-value { color: var(--opening); }
.stat.income .stat-icon { background: var(--income-soft); color: var(--income); }
.stat.income .stat-value { color: var(--income); }
.stat.expense .stat-icon { background: var(--expense-soft); color: var(--expense); }
.stat.expense .stat-value { color: var(--expense); }
.stat.closing { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 55%, transparent); }
.stat.closing .stat-icon { background: var(--primary); color: var(--on-primary); }
.stat.closing .stat-value { color: var(--primary); }

/* ------------------------------------------------------------ Page header / toolbar */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h2 { font-size: 18px; font-weight: 700; }
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav select { min-width: 170px; }

/* ------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  font: 600 14px var(--font); cursor: pointer; white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-danger { background: var(--expense); border-color: var(--expense); color: #fff; }
.btn-danger:hover { filter: brightness(.95); background: var(--expense); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-outline-primary { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary-soft); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.btn-lg { height: 48px; font-size: 15px; }

/* ------------------------------------------------------------ Forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field { margin-top: 16px; }
.label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.hint { font-size: 12px; color: var(--text-muted); }
.input, select.input, textarea.input {
  width: 100%; height: 44px; padding: 0 14px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: 14px var(--font);
  transition: border-color .15s, box-shadow .15s;
}
select.input {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238b9bab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
textarea.input { height: auto; min-height: 88px; padding: 12px 14px; resize: vertical; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input::placeholder { color: var(--text-muted); opacity: .8; }
.input-sm { height: 36px; font-size: 13px; }
.input-color { width: 44px; padding: 4px; cursor: pointer; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.form-row .field + .field { margin-top: 0; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); margin-top: 1px; flex: none; }

.amount-wrap { position: relative; }
.amount-wrap .prefix { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 20px; font-weight: 600; color: var(--text-muted); pointer-events: none; }
.input-amount { height: 60px; padding-left: 52px; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }

.password-wrap { position: relative; }
.password-wrap .input { padding-right: 48px; }
.password-wrap button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

/* Segmented control */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--text-muted);
  border: 1px solid transparent; transition: all .15s;
}
.segmented label:hover { color: var(--text); }
.segmented input:focus-visible + label { outline: 2px solid var(--primary); }
.segmented input[value="income"]:checked + label { background: var(--income-soft); color: var(--income); border-color: color-mix(in srgb, var(--income) 60%, transparent); }
.segmented input[value="expense"]:checked + label { background: var(--expense-soft); color: var(--expense); border-color: color-mix(in srgb, var(--expense) 60%, transparent); }
.segmented input[value="transfer"]:checked + label { background: var(--transfer-soft); color: var(--transfer); border-color: color-mix(in srgb, var(--transfer) 60%, transparent); }

/* Category chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips label {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px; cursor: pointer; font-weight: 500; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
  transition: all .15s;
}
.chips label:hover { border-color: var(--text-muted); }
.chips .dot { width: 8px; height: 8px; border-radius: 50%; }
.chips input:checked + label { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.chips input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Dropzone */
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 24px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  color: var(--text-muted); transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone-preview { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); margin-top: 10px; }
.dropzone-preview img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }

/* ------------------------------------------------------------ Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; line-height: 1.6; }
.badge-income { background: var(--income-soft); color: var(--income); }
.badge-expense { background: var(--expense-soft); color: var(--expense); }
.badge-transfer { background: var(--transfer-soft); color: var(--transfer); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-muted { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }

.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.delta.good { background: var(--income-soft); color: var(--income); }
.delta.bad { background: var(--expense-soft); color: var(--expense); }
.delta.flat { background: var(--surface-2); color: var(--text-muted); }

/* ------------------------------------------------------------ Alerts / flash */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid; font-size: 13px; margin-bottom: 16px; }
.alert .i { margin-top: 1px; }
.alert-success { background: var(--income-soft); border-color: color-mix(in srgb, var(--income) 45%, transparent); color: var(--text); }
.alert-success .i { color: var(--income); }
.alert-error { background: var(--expense-soft); border-color: color-mix(in srgb, var(--expense) 45%, transparent); color: var(--text); }
.alert-error .i { color: var(--expense); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 45%, transparent); color: var(--text); }
.alert-warning .i { color: var(--warning); }
.alert-info { background: var(--transfer-soft); border-color: color-mix(in srgb, var(--transfer) 40%, transparent); color: var(--text); }
.alert-info .i { color: var(--transfer); }
.flash-stack { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; width: min(520px, calc(100% - 32px)); }
.flash-stack .alert { box-shadow: var(--shadow); background: var(--surface); animation: flash-in .25s ease-out; }
.flash-stack .alert.out { opacity: 0; transform: translateY(-8px); transition: all .3s; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-8px); } }

/* ------------------------------------------------------------ Summary lines */
.lines > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.lines > div:last-child { border-bottom: 0; }
.lines .total { font-weight: 700; border-top: 1px solid var(--border-strong); border-bottom: 0; margin-top: 4px; }
.acc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: none; }
.acc-dot.primary { background: var(--primary); }

/* ------------------------------------------------------------ Transaction list */
.trx-list { display: flex; flex-direction: column; }
.trx {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--border);
}
.trx:last-child { border-bottom: 0; }
.trx-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; }
.trx-icon.income { background: var(--income-soft); color: var(--income); }
.trx-icon.expense { background: var(--expense-soft); color: var(--expense); }
.trx-icon.transfer { background: var(--transfer-soft); color: var(--transfer); }
.trx-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.trx-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trx-meta { font-size: 12px; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.trx-meta .i { width: 13px; height: 13px; }
.trx-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.trx-desc { font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trx-amount { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.trx-amount small { display: block; font-weight: 400; font-size: 11px; color: var(--text-muted); }
.trx-actions { display: flex; gap: 2px; }
.trx-list.compact .trx { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; padding: 10px 0; }
.trx-list.compact .trx-icon { width: 36px; height: 36px; }

.day-group + .day-group { margin-top: 12px; }
.day-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border-strong); }

/* ------------------------------------------------------------ Filters */
.filters { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) auto; gap: 10px; align-items: end; }
.filters .search { grid-column: span 2; }
.result-bar { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; padding: 12px 16px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 13px; margin: 16px 0; }
.result-bar strong { font-variant-numeric: tabular-nums; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets .btn.active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* ------------------------------------------------------------ Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-bottom: 0; }
.table .amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.table .desc { min-width: 220px; }

.bar { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; border-radius: 999px; }

/* ------------------------------------------------------------ Tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--text-muted); border: 1px solid var(--border); background: transparent; cursor: pointer; font-family: inherit; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.chart-box { position: relative; height: 300px; }

/* ------------------------------------------------------------ Master lists */
.item-list { display: flex; flex-direction: column; gap: 8px; }
.item { border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm); }
.item > summary, .item-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; list-style: none; cursor: pointer; }
.item > summary::-webkit-details-marker { display: none; }
.item-row { cursor: default; }
.item.archived { opacity: .6; }
.item-body { padding: 4px 14px 14px; border-top: 1px solid var(--border); }
.item .swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.item-name { font-weight: 600; }
.item-actions { display: flex; gap: 6px; margin-left: auto; align-items: center; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1; min-width: 160px; }
.inline-form .field + .field { margin-top: 0; }

/* ------------------------------------------------------------ Pagination */
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.pagination .current { padding: 0 12px; font-size: 13px; color: var(--text-muted); }

/* ------------------------------------------------------------ Empty */
.empty { text-align: center; padding: 40px 16px; color: var(--text-muted); }
.empty .i { width: 40px; height: 40px; margin-bottom: 8px; opacity: .6; }
.empty p { margin-bottom: 14px; }

/* ------------------------------------------------------------ Dialog */
dialog.modal { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 24px; width: min(420px, calc(100% - 32px)); box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px); }
dialog.modal h3 { font-size: 17px; margin-bottom: 8px; }
dialog.modal .form-actions { justify-content: flex-end; }

/* ------------------------------------------------------------ Bottom nav (mobile) */
.bottom-nav { display: none; }
.sheet { display: none; }

/* ------------------------------------------------------------ Auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); }
.auth-logo { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 16px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); overflow: hidden; }
.auth-logo img { width: 100%; height: 100%; object-fit: contain; }
.auth h1 { font-size: 20px; text-align: center; color: var(--primary); }
.auth .sub { text-align: center; color: var(--text-muted); margin: 4px 0 24px; font-size: 13px; }
.theme-float { position: fixed; top: 16px; right: 16px; }

/* ------------------------------------------------------------ Public page */
.public { max-width: 600px; margin: 0 auto; padding: 0 16px 48px; }
.public-hero { text-align: center; padding: 36px 16px 28px; }
.public-hero .logo { width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 20px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); overflow: hidden; }
.public-hero .logo img { width: 100%; height: 100%; object-fit: contain; }
.public-hero h1 { font-size: 24px; color: var(--primary); }
.public-hero p { color: var(--text-muted); margin: 6px 0 18px; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; margin: 28px 0 12px; }
.cat-row { padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.cat-row + .cat-row { margin-top: 8px; }
.donation { text-align: center; }
.acct-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin: 16px 0; }
.acct-number { font-size: 26px; font-weight: 800; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.qris { background: #fff; padding: 12px; border-radius: 12px; display: inline-block; max-width: 280px; border: 2px dashed var(--border-strong); }
.qris img { display: block; }
.public-foot { text-align: center; margin-top: 32px; padding-top: 20px; border-top: 1px dashed var(--border); }

/* ------------------------------------------------------------ Responsive */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters .search { grid-column: span 2; }
}

@media (max-width: 1023px) {
  :root { --sidebar-w: 76px; }
  .sidebar { padding: 16px 10px; align-items: center; }
  .brand { padding: 0 0 16px; }
  .brand-text, .nav-label, .nav-section { display: none; }
  .nav a, .nav button { justify-content: center; padding: 12px; }
  .nav-cta a { width: 48px; height: 48px; border-radius: 14px; }
  .grid-7-5, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 639px) {
  body { font-size: 14px; }
  .shell { display: block; }
  .sidebar { display: none; }
  .topbar { padding: 12px 16px; min-height: 60px; }
  .topbar h1 { font-size: 17px; }
  .topbar .greet, .role-chip { display: none; }
  .content { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  .card { padding: 16px; }
  .grid { gap: 12px; }
  .stat { padding: 14px; }
  .stat-icon { width: 30px; height: 30px; margin-bottom: 8px; }
  .stat-value { font-size: 18px; }
  .form-row { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .search { grid-column: 1 / -1; }
  .btn { height: 44px; }
  .btn-sm { height: 36px; }
  .btn-icon.btn-sm { width: 36px; }
  .chart-box { height: 240px; }
  .trx { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; }
  .trx-icon { width: 36px; height: 36px; }
  .trx-actions { grid-column: 2 / -1; justify-content: flex-end; margin-top: -4px; }
  .page-head { margin-bottom: 14px; }
  .month-nav { width: 100%; }
  .month-nav select { flex: 1; min-width: 0; }
  .item > summary, .item-row { flex-wrap: wrap; }

  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 0; font: 500 11px var(--font); color: var(--text-muted);
    background: none; border: 0; cursor: pointer;
  }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav .fab { margin-top: -22px; }
  .bottom-nav .fab span.fab-circle {
    width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
    background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 45%, transparent);
    border: 4px solid var(--surface);
  }
  .sheet { position: fixed; inset: 0; z-index: 60; }
  .sheet.open { display: block; }
  .sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); }
  .sheet-panel {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: var(--surface); border-radius: 20px 20px 0 0; padding: 12px 16px calc(20px + env(safe-area-inset-bottom));
    animation: sheet-up .2s ease-out;
  }
  .sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 0 auto 12px; }
  .sheet .nav a, .sheet .nav button { justify-content: flex-start; }
  @keyframes sheet-up { from { transform: translateY(100%); } }
}

@media print {
  .sidebar, .topbar, .bottom-nav, .no-print { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; }
}

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