/* ==========================================================================
   Keuangan Masjid — design system
   ========================================================================== */

:root {
  --ink: #15261f;
  --ink-soft: #33473c;
  --muted: #6b7d73;
  --bg: #f4f6f1;
  --surface: #ffffff;
  --surface-muted: #f8faf6;
  --border: #e3e8df;
  --border-strong: #d3dbcf;
  --primary: #0f5c42;
  --primary-dark: #0a4733;
  --primary-soft: #e6f1ea;
  --gold: #b58a3c;
  --gold-soft: #f6efdf;
  --danger: #b23a3a;
  --danger-soft: #fbeceb;
  --success: #177a51;
  --success-soft: #e8f5ee;
  --info: #3a6ea5;
  --info-soft: #eaf1f9;
  --sidebar-from: #0c2f25;
  --sidebar-to: #071f18;
  --shadow-sm: 0 1px 2px rgba(15, 42, 32, .04), 0 1px 3px rgba(15, 42, 32, .06);
  --shadow-md: 0 12px 32px -18px rgba(15, 42, 32, .35), 0 4px 12px -6px rgba(15, 42, 32, .12);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-width: 264px;
  --page-max: 1240px;
  --font-sans: "Segoe UI", system-ui, -apple-system, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  overflow-x: clip;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.app-page {
  background:
    radial-gradient(1200px 620px at 88% -12%, #e9f1e5 0%, rgba(233, 241, 229, 0) 62%),
    var(--bg);
}

h1, h2, h3, h4, p, ul, ol, dl, dd {
  margin: 0;
}

ul, ol {
  padding: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

button {
  font-family: inherit;
}

img, svg {
  display: block;
  max-width: 100%;
}

code {
  font-family: var(--font-mono);
  font-size: .92em;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

::selection {
  background: #cfe6da;
  color: #0a3a29;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: 0 0 10px 10px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  transition: top .15s ease;
}

.skip-link:focus {
  top: 0;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.strong {
  font-weight: 700;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.in {
  color: var(--success);
}

.out {
  color: var(--danger);
}

/* ==========================================================================
   Shell
   ========================================================================== */

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  padding: 22px 16px 18px;
  color: #cfe2d8;
  background: linear-gradient(180deg, var(--sidebar-from) 0%, var(--sidebar-to) 100%);
  border-right: 1px solid rgba(255, 255, 255, .04);
  overflow-y: auto;
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, .09) 1px, transparent 1px);
  background-size: 20px 20px;
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, .7), transparent 65%);
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, .7), transparent 65%);
  opacity: .45;
}

.sidebar > * {
  position: relative;
  z-index: 1;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 13px;
  color: #ead9b3;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-mark.large {
  width: 60px;
  height: 60px;
  border-radius: 18px;
}

.brand-mark.large svg {
  width: 32px;
  height: 32px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text strong {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .01em;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-text small {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .42);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 30px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, .67);
  transition: background .15s ease, color .15s ease;
}

.nav-item .icon {
  width: 18px;
  height: 18px;
  opacity: .85;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, .06);
  text-decoration: none;
}

.nav-item.is-active {
  color: #fff;
  background: linear-gradient(90deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .05));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}

.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: #d8bd86;
  transform: translateY(-50%);
}

.nav-item.is-active .icon {
  color: #ead9b3;
  opacity: 1;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .18);
  border: 1px solid rgba(255, 255, 255, .05);
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #e9d8b0, #c9ae73);
  color: #3a2f14;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}

.avatar.xl {
  width: 56px;
  height: 56px;
  font-size: 18px;
}

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.user-meta strong {
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta small {
  font-size: 10.5px;
  color: rgba(255, 255, 255, .48);
}

.user-chip .user-meta {
  margin-right: auto;
}

.logout-form {
  display: flex;
}

.sidebar .icon-button {
  color: rgba(255, 255, 255, .55);
  background: transparent;
}

.sidebar .icon-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, .1);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(6, 25, 19, .5);
  backdrop-filter: blur(2px);
}

.app-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 32px 18px;
  background: rgba(244, 246, 241, .84);
  border-bottom: 1px solid rgba(227, 232, 223, .9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar-title {
  min-width: 0;
}

.topbar-title h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.2;
}

.topbar-title p {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.topbar .menu-toggle {
  display: none;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 24px 32px 56px;
}

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.segmented-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.segmented-note .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(181, 138, 60, .15);
}

.segmented-note strong {
  color: var(--ink);
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 16px;
  flex-wrap: wrap;
}

.card-head h2 {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.card-head p {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
  max-width: 620px;
}

.card-head code {
  font-size: .85em;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(280px, .72fr) minmax(0, 1.28fr);
  gap: 20px;
  align-items: start;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
}

.btn .icon {
  width: 17px;
  height: 17px;
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #11684b, #0d5139);
  box-shadow: 0 8px 18px -10px rgba(13, 81, 57, .8), inset 0 1px 0 rgba(255, 255, 255, .14);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #13744f, #0d5a3f);
  box-shadow: 0 10px 22px -10px rgba(13, 81, 57, .85), inset 0 1px 0 rgba(255, 255, 255, .14);
}

.btn-secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  border-color: #bfcabf;
  background: #fbfcf9;
}

.btn-ghost {
  color: var(--muted);
  background: transparent;
}

.btn-ghost:hover {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--border);
}

.btn-danger-ghost {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f2d3cf;
}

.btn-danger-ghost:hover {
  background: #f8e2df;
}

.btn-sm {
  height: 32px;
  padding: 0 11px;
  border-radius: 8px;
  font-size: 12.5px;
}

.btn-sm .icon {
  width: 15px;
  height: 15px;
}

.btn-block {
  width: 100%;
}

.btn.is-disabled {
  opacity: .45;
  pointer-events: none;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.icon-button:hover {
  color: var(--ink);
  background: var(--surface-muted);
  border-color: var(--border);
}

.icon-button.danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f2d3cf;
}

.icon-button .icon {
  width: 17px;
  height: 17px;
}

.icon-button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

.field input[type="text"],
.field input[type="password"],
.field input[type="search"],
.field input[type="number"],
.field input[type="date"],
.field select,
.inline-edit input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.field input::placeholder {
  color: #9daaa2;
}

.field input:hover,
.field select:hover,
.inline-edit input:hover {
  border-color: #bcc8bd;
}

.field input:focus,
.field select:focus,
.inline-edit input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 92, 66, .12);
}

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7d73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 34px;
  cursor: pointer;
}

.select-sm {
  height: 32px;
  padding: 0 28px 0 9px;
  font-size: 12.5px;
  border-radius: 8px;
  background-position: right 8px center;
  background-size: 13px;
  max-width: 100%;
}

.hint {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 6px 24px 24px;
}

.form-stack.inline {
  padding: 0;
}

.filter-card {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px 14px;
  align-items: end;
}

.field-search {
  grid-column: span 2;
}

.input-with-icon {
  position: relative;
}

.input-with-icon .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.input-with-icon input[type="search"] {
  padding-left: 36px;
}

.filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding-top: 3px;
  border-top: 1px solid #eef2ec;
  margin-top: 3px;
  padding-top: 14px;
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}

.check-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  margin: 0;
}

.inline-edit {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 12px 22px 16px;
  background: var(--surface-muted);
  border-top: 1px dashed var(--border);
}

.inline-edit input {
  flex: 1;
}

.inline-edit.wide {
  padding: 0;
  background: transparent;
  border: 0;
}

.inline-edit.wide .field {
  flex: 1;
}

.inline-edit .field.grow {
  flex: 1;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.checkbox-row input {
  accent-color: var(--primary);
}

/* ==========================================================================
   Badges, chips, tags
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .02em;
  white-space: nowrap;
}

.source-bsi {
  background: #e8f0fb;
  color: #255b96;
}

.source-qris {
  background: #f1eafb;
  color: #6a46a3;
}

.source-cash {
  background: #fbf2df;
  color: #8a6520;
}

.role-admin {
  background: var(--success-soft);
  color: #0f6544;
}

.role-editor {
  background: #eef0fa;
  color: #4a528f;
}

.role-user {
  background: #f1f4ef;
  color: #66756b;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.chip-warn {
  background: var(--gold-soft);
  border-color: #eadcbc;
  color: #7d5c1c;
}

.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 11.5px;
  font-weight: 600;
}

/* ==========================================================================
   Stats
   ========================================================================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.stat-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 21px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.stat-card.compact {
  padding: 17px 18px;
}

.stat-card.compact .stat-value {
  font-size: 21px;
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 13px;
}

.stat-icon .icon {
  width: 20px;
  height: 20px;
}

.tone-in {
  background: var(--success-soft);
  color: var(--success);
}

.tone-out {
  background: var(--danger-soft);
  color: var(--danger);
}

.tone-balance {
  background: rgba(255, 255, 255, .13);
  color: #ecd9b0;
}

.stat-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-label {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  margin: 3px 0 2px;
  font-size: clamp(20px, 2vw, 25px);
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  word-break: break-word;
}

.report-stats .stat-value {
  font-size: clamp(19px, 1.75vw, 24px);
  white-space: nowrap;
}

/* Long amounts shrink to keep the currency symbol on the same line. */
.report-stats .stat-value[data-len="lg"] {
  font-size: clamp(17px, 1.5vw, 21px);
}

.report-stats .stat-value[data-len="xl"] {
  font-size: clamp(15px, 1.25vw, 18px);
}

.stat-note {
  font-size: 11.5px;
  color: var(--muted);
}

.stat-note.link {
  color: var(--primary);
  font-weight: 600;
}

.stat-accent {
  color: #fff;
  background: linear-gradient(140deg, #0f5c42 0%, #0a3d2c 70%);
  border-color: transparent;
  box-shadow: 0 18px 36px -24px rgba(10, 61, 44, .9);
}

.stat-accent::after {
  content: "";
  position: absolute;
  top: -80px;
  right: -60px;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .14), transparent 68%);
  pointer-events: none;
}

.stat-accent .stat-label {
  color: rgba(255, 255, 255, .62);
}

.stat-accent .stat-value {
  color: #fff;
}

.stat-accent .stat-note {
  color: rgba(255, 255, 255, .62);
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  padding: 11px 20px;
  background: var(--surface-muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  padding: 13px 20px;
  border-bottom: 1px solid #eef2ec;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: #fafcf8;
}

.data-table tfoot th,
.data-table tfoot td {
  padding: 14px 20px;
  background: var(--surface-muted);
  border-top: 1px solid var(--border-strong);
  font-weight: 700;
  font-size: 13px;
}

.data-table tfoot th {
  text-align: left;
  color: var(--ink);
  letter-spacing: 0;
  text-transform: none;
  font-size: 13px;
}

.data-table .num {
  font-variant-numeric: tabular-nums;
}

.toggle-col {
  width: 44px;
  text-align: center !important;
  padding-left: 6px !important;
  padding-right: 12px !important;
}

.date-cell strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.date-cell small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
}

.desc-text {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  max-width: 560px;
}

.desc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.desc-meta .ref {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #87978d;
}

.amount-cell {
  font-weight: 650;
  white-space: nowrap;
}

.tag-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tag-form .select-sm {
  width: 230px;
  max-width: 100%;
}

.tx-table {
  min-width: 780px;
  table-layout: fixed;
}

.tx-table .category-cell {
  padding-left: 10px;
  padding-right: 8px;
}

.tx-table .tag-form .select-sm {
  width: 100%;
}

.tx-col-date {
  width: 132px;
}

.tx-col-source {
  width: 68px;
}

.tx-col-category {
  width: 210px;
}

.tx-col-amount {
  width: 96px;
}

.tx-col-note {
  width: 120px;
}

/* ---------------------------------------------------------- tx toolbar */
.tx-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.tx-search {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
  max-width: 620px;
  height: 44px;
  padding: 0 4px 0 40px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.tx-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.tx-search-icon {
  position: absolute;
  left: 13px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}

.tx-search-icon .icon {
  width: 17px;
  height: 17px;
}

.tx-search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0 6px 0 2px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
}

.tx-search-input::-webkit-search-cancel-button {
  display: none;
}

.tx-search-input::placeholder {
  color: #93a39a;
}

.tx-search-clear {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--muted);
}

.tx-search-clear:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.tx-search-clear .icon {
  width: 14px;
  height: 14px;
}

.tx-search-submit {
  flex: 0 0 auto;
  height: 34px;
  margin-left: 4px;
  padding: 0 14px;
  border: 1px solid var(--primary);
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}

.tx-search-submit:hover {
  background: var(--primary-dark);
}

.tx-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.tx-action-sep {
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: var(--border-strong);
}

.tx-filter-toggle {
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.tx-filter-toggle .icon {
  width: 16px;
  height: 16px;
}

.filter-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 2px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* --------------------------------------------------------- filter chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: -2px 0 14px;
}

.chips-label {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-right: 2px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 6px 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.chip:hover {
  border-color: #d9b4b0;
  background: var(--danger-soft);
  color: var(--danger);
}

.chip .chip-x {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: var(--muted);
}

.chip .chip-x .icon {
  width: 11px;
  height: 11px;
}

.chip:hover .chip-x {
  color: var(--danger);
}

.chip-danger {
  border-color: #e8c3c0;
  background: var(--danger-soft);
  color: var(--danger);
}

.chip-danger .chip-x {
  color: var(--danger);
}

.chips-clear {
  margin-left: 4px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: underline;
}

.chips-clear:hover {
  color: var(--danger);
}

/* -------------------------------------------------------- filter drawer */
.filter-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(9, 26, 20, .32);
  opacity: 0;
  backdrop-filter: blur(2px);
  transition: opacity .18s ease;
}

.filter-overlay[hidden] {
  display: none;
}

body.filter-open {
  overflow: hidden;
}

.filter-open .filter-overlay {
  opacity: 1;
}

.filter-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  display: flex;
  width: min(420px, 100vw);
  max-width: 100%;
  background: var(--surface);
  box-shadow: -18px 0 40px -24px rgba(9, 26, 20, .5);
  transform: translateX(20px);
  opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
}

.filter-drawer[hidden] {
  display: none;
}

.filter-drawer.is-visible {
  transform: translateX(0);
  opacity: 1;
}

.filter-form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.filter-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.filter-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: -.01em;
}

.filter-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.drawer-close {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.drawer-close:hover {
  border-color: var(--border-strong);
  background: var(--surface-muted);
  color: var(--ink);
}

.drawer-close .icon {
  width: 16px;
  height: 16px;
}

.filter-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 6px 20px 18px;
}

.filter-group {
  margin: 0;
  padding: 16px 0 4px;
  border: 0;
  border-bottom: 1px solid var(--border);
}

.filter-group:last-child {
  border-bottom: 0;
}

.filter-group > legend {
  padding: 0;
  margin-bottom: 10px;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.filter-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.filter-form .field {
  gap: 5px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

.filter-input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
}

.filter-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.money-input {
  position: relative;
  display: flex;
  align-items: center;
}

.money-prefix {
  position: absolute;
  left: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}

.field .money-input .filter-input {
  padding-left: 34px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.preset {
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.preset:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.preset.is-active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border-radius: 11px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.segment {
  position: relative;
  display: block;
}

.segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment span {
  display: block;
  padding: 7px 6px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.segment input:checked + span {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.segment input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.filter-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.filter-foot .btn {
  min-height: 40px;
}

.filter-foot .btn-primary {
  min-width: 132px;
}

.filter-input.is-untagged,
.select-sm.is-untagged {
  border-color: #e2b6b3;
  background: var(--danger-soft);
  color: var(--danger);
}

.option-untagged {
  color: var(--danger);
  font-weight: 600;
}

.tag-untagged {
  background: var(--danger-soft);
  color: var(--danger);
}

.note-form {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.note-input {
  width: 100%;
  min-width: 0;
  padding: 4px 26px 4px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 11.5px;
}

.note-input::placeholder {
  color: #9aaaa0;
}

.note-input:hover {
  border-color: var(--border);
  background: #fff;
}

.note-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.note-save {
  position: absolute;
  right: 2px;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease;
}

.note-save .icon {
  width: 13px;
  height: 13px;
}

.note-form:hover .note-save,
.note-form:focus-within .note-save {
  opacity: 1;
}

.note-text {
  display: inline-block;
  max-width: 230px;
  color: var(--ink-soft);
  font-size: 11.5px;
  word-break: break-word;
}

.note-text.is-empty {
  color: var(--muted);
}

.row-empty {
  opacity: .58;
}

.row-action {
  width: 54px;
  text-align: right;
}

.row-action form {
  display: inline-flex;
}

.row-delete {
  width: 32px;
  height: 32px;
  padding: 0;
  border-color: transparent;
}

.row-delete:hover {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f2d3cf;
}

.row-delete svg {
  width: 15px;
  height: 15px;
}

.report-category,
#bulanan {
  scroll-margin-top: 88px;
}

.report-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.report-filter {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 12px;
}

.month-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.month-cell-text {
  min-width: 0;
}

.month-download {
  width: 26px;
  height: 26px;
  flex: none;
  color: var(--primary);
}

.month-download .icon {
  width: 14px;
  height: 14px;
}

.month-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.report-filter .field-inline {
  gap: 6px;
}

.month-label {
  display: block;
  font-weight: 600;
  font-size: 13px;
}

.report-table td > small {
  color: var(--muted);
  font-size: 10.5px;
}

.row-toggle .icon {
  transition: transform .16s ease;
}

.row-toggle[aria-expanded="true"] .icon {
  transform: rotate(90deg);
}

.month-detail td {
  padding: 0 !important;
  background: var(--surface-muted);
}

.month-detail-inner {
  padding: 6px 0 8px;
  background: #fbfcf9;
  border-top: 1px dashed var(--border);
}

.mini-head {
  padding: 12px 24px 6px;
}

.mini-head h3 {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.page-indicator {
  font-size: 12px;
  color: var(--muted);
}

.page-indicator strong {
  color: var(--ink);
}

/* ==========================================================================
   Tree
   ========================================================================== */

.tree-head {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 150px 150px 150px;
  gap: 12px;
  padding: 10px 24px;
  background: var(--surface-muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.tree-head span:not(:first-child) {
  text-align: right;
}

.tree {
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}

.tree-details > summary {
  list-style: none;
}

.tree-details > .tree {
  margin-left: 22px;
  border-left: 1px solid var(--border);
}

.tree-details > summary::-webkit-details-marker {
  display: none;
}

.tree-row {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 150px 150px 150px;
  gap: 12px;
  align-items: center;
  padding: 8px 24px;
  font-size: 12.5px;
}

.tree-summary {
  cursor: pointer;
  transition: background .12s ease;
}

.tree-summary:hover,
.tree-leaf:hover {
  background: var(--surface-muted);
}

.tree-name {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-weight: 500;
}

.tree-caret {
  width: 0;
  height: 0;
  flex: none;
  margin: 0 2px 0 1px;
  border-left: 5px solid #8a9a90;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform .16s ease;
}

details[open] > summary .tree-caret {
  transform: rotate(90deg);
}

.tree-spacer {
  width: 5px;
  flex: none;
}

.tree-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-val {
  text-align: right;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tree-val.in {
  color: var(--success);
}

.tree-val.out {
  color: var(--danger);
}

.tree-val.strong {
  color: var(--ink);
  font-weight: 650;
}

.tree-sub {
  margin-left: 34px;
  border-left: 1px dashed var(--border-strong);
  padding-left: 4px;
}

.tree-sub .tree-row {
  padding-left: 12px;
}

.tree-untagged {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 150px 150px 150px;
  gap: 12px;
  align-items: center;
  margin: 8px 24px 10px;
  padding: 9px 12px;
  background: var(--gold-soft);
  border-radius: 9px;
  font-size: 12.5px;
}

.tree-untagged .tree-name {
  color: #7d5c1c;
  font-weight: 650;
}

.tree-untagged .tree-name small {
  font-weight: 500;
  color: #97804f;
}

.tree-untagged .tree-val {
  color: #6f551f;
}

.tree-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 12px 24px 20px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}

.tree-note .icon {
  width: 14px;
  height: 14px;
  margin-top: 1px;
}

.tree-note a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.tree-note a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Summary bar
   ========================================================================== */

.summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.summary-cluster {
  display: flex;
  gap: 12px 26px;
  flex-wrap: wrap;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.summary-item > span {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.summary-item strong {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}

.summary-item small {
  font-size: 10.5px;
  color: var(--muted);
}

/* ==========================================================================
   Tabs
   ========================================================================== */

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 4px;
  border-bottom: 1px solid var(--border);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: -1px;
  padding: 12px 14px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.tab .icon {
  width: 17px;
  height: 17px;
}

.tab:hover {
  color: var(--ink);
  text-decoration: none;
}

.tab.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-count {
  padding: 1px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 600;
}

/* ==========================================================================
   Upload
   ========================================================================== */

.upload-card {
  overflow: hidden;
}

.upload-head {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  padding: 21px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.upload-head h2 {
  font-size: 16px;
  font-weight: 650;
}

.upload-head p {
  margin-top: 3px;
  max-width: 620px;
  font-size: 12.5px;
  color: var(--muted);
}

.upload-head .chip {
  margin-left: auto;
}

.source-avatar {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 14px;
}

.source-avatar .icon {
  width: 21px;
  height: 21px;
}

.source-avatar.source-bsi {
  background: #e8f0fb;
  color: #255b96;
}

.source-avatar.source-qris {
  background: #f1eafb;
  color: #6a46a3;
}

.source-avatar.source-cash {
  background: #fbf2df;
  color: #8a6520;
}

.upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, .7fr);
  gap: 24px;
  padding: 24px;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 210px;
  padding: 30px 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 14px;
  background: var(--surface-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--primary);
  background: #f1f8f3;
}

.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 2px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary);
}

.drop-icon .icon {
  width: 20px;
  height: 20px;
}

.dropzone strong {
  font-size: 13.5px;
  font-weight: 650;
}

.dropzone small {
  font-size: 11.5px;
  color: var(--muted);
}

.file-name {
  max-width: 100%;
  margin-top: 5px;
  padding: 4px 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name.has-file {
  border-color: #c4dccf;
  background: var(--success-soft);
  color: var(--primary);
  font-weight: 600;
}

.upload-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.upload-guide {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-muted);
  align-self: start;
}

.upload-guide h3 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.upload-guide ul {
  display: flex;
  flex-direction: column;
  gap: 9px;
  list-style: none;
}

.upload-guide li {
  position: relative;
  padding-left: 15px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
}

.upload-guide li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .58em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
}

.upload-guide code {
  font-size: 10.5px;
  background: var(--surface);
}

.guide-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.guide-note .icon {
  width: 14px;
  height: 14px;
  margin-top: 1px;
}

.file-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.file-cell .icon {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--muted);
}

/* ==========================================================================
   Categories
   ========================================================================== */

.category-list,
.user-list {
  display: flex;
  flex-direction: column;
  list-style: none;
}

.category-item,
.user-row {
  border-top: 1px solid #eef2ec;
}

.category-item:first-child,
.user-row:first-child {
  border-top: 0;
}

.category-details > summary,
.user-details > summary {
  list-style: none;
}

.category-details > summary::-webkit-details-marker,
.user-details > summary::-webkit-details-marker {
  display: none;
}

.category-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  cursor: pointer;
  transition: background .12s ease;
}

.category-summary:hover,
details[open] > .category-summary {
  background: var(--surface-muted);
}

.category-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.category-name.indent-1 { padding-left: 30px; }
.category-name.indent-2 { padding-left: 56px; }
.category-name.indent-3 { padding-left: 82px; }
.category-name.indent-4 { padding-left: 108px; }
.category-name.indent-5 { padding-left: 134px; }
.category-name.indent-6 { padding-left: 160px; }

.category-group {
  background: #fbfcf9;
}

.category-group .category-summary {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  cursor: default;
}

.category-group .category-label {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
}

.group-mark {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  flex: none;
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.group-note {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.category-label {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-path {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.usage-count {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.category-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.category-actions form {
  display: flex;
}

.preview-box {
  padding: 11px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--surface-muted);
}

.preview-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.preview-tree {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
}

.preview-tree .preview-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-tree .preview-line::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
}

.preview-tree .preview-indent {
  width: 14px;
  flex: none;
}

/* ==========================================================================
   Users
   ========================================================================== */

.user-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  cursor: pointer;
  transition: background .12s ease;
}

.user-summary:hover,
details[open] > .user-summary {
  background: var(--surface-muted);
}

.user-summary .user-meta {
  margin-right: auto;
}

.user-summary .user-meta strong {
  color: var(--ink);
  font-size: 13.5px;
}

.user-summary .user-meta small {
  color: var(--muted);
  font-size: 11px;
}

.user-summary > .icon-button {
  color: var(--muted);
}

.user-details[open] > .user-summary > .icon-button .icon {
  transform: rotate(90deg);
}

.user-summary > .icon-button .icon {
  transition: transform .16s ease;
}

.user-editor {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 14px 20px 18px;
  background: var(--surface-muted);
  border-top: 1px dashed var(--border);
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 24px 20px;
  border-bottom: 1px solid var(--border);
}

.profile-hero > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.profile-hero strong {
  font-size: 15px;
  font-weight: 650;
}

.profile-hero small {
  color: var(--muted);
  font-size: 12px;
}

.profile-hero .badge {
  margin-left: auto;
}

.info-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 24px;
  padding: 8px 24px 18px;
}

.info-list > div {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #eef2ec;
  font-size: 12.5px;
}

.info-list dt {
  color: var(--muted);
}

.info-list dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.info-list .info-wide {
  grid-column: 1 / -1;
}

.info-list.info-single {
  grid-template-columns: 1fr;
}

.info-list .info-wide dd {
  text-align: right;
}

.info-list code {
  font-size: 10.5px;
  word-break: break-all;
  background: transparent;
  border: 0;
  padding: 0;
}

.info-roles {
  padding: 0 24px 22px;
}

.info-roles h3 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.role-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
  font-size: 12px;
  color: var(--ink-soft);
}

.role-list li {
  display: flex;
  align-items: center;
  gap: 9px;
}

/* ==========================================================================
   Empty states
   ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 52px 24px;
  text-align: center;
}

.empty-state.compact {
  padding: 34px 24px;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-muted);
  color: var(--muted);
}

.empty-icon .icon {
  width: 22px;
  height: 22px;
}

.empty-state h3 {
  font-size: 14px;
  font-weight: 650;
}

.empty-state p {
  max-width: 380px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ==========================================================================
   Alerts & toasts
   ========================================================================== */

.alert {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.5;
}

.alert-danger {
  border-color: #f0d2ce;
  background: var(--danger-soft);
  color: #8d2b2b;
}

.toast-region {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(420px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  line-height: 1.5;
  animation: toast-in .22s ease both;
}

.toast-danger {
  border-left-color: var(--danger);
}

.toast-info {
  border-left-color: var(--info);
}

.toast-message {
  flex: 1;
}

.toast-close {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* ==========================================================================
   Auth
   ========================================================================== */

body.auth-page {
  background: #f4f6f1;
}

.auth-layout {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  min-height: 100vh;
}

.auth-brand {
  position: relative;
  display: flex;
  align-items: center;
  padding: 56px clamp(32px, 5vw, 76px);
  overflow: hidden;
  color: #fff;
  background: linear-gradient(155deg, #0c3a2b 0%, #071f18 68%);
}

.auth-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .1) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(circle at 30% 30%, #000, transparent 72%);
  mask-image: radial-gradient(circle at 30% 30%, #000, transparent 72%);
  opacity: .5;
}

.auth-brand::after {
  content: "";
  position: absolute;
  right: -140px;
  bottom: -160px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(181, 138, 60, .22), transparent 68%);
}

.auth-brand-inner {
  position: relative;
  z-index: 1;
  max-width: 460px;
}

.auth-brand h1 {
  margin: 26px 0 16px;
  font-family: var(--font-display);
  font-size: clamp(34px, 4vw, 46px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -.01em;
}

.auth-brand p {
  max-width: 420px;
  color: rgba(255, 255, 255, .66);
  font-size: 14.5px;
  line-height: 1.75;
}

.auth-points {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 30px;
  list-style: none;
}

.auth-points li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, .78);
  font-size: 13px;
}

.auth-points .icon {
  width: 16px;
  height: 16px;
  color: #d8bd86;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 44px 24px;
}

.auth-card {
  width: 100%;
  max-width: 402px;
}

.auth-eyebrow {
  display: none;
  margin-bottom: 16px;
  color: var(--gold);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.auth-head h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.auth-head p {
  margin: 7px 0 24px;
  color: var(--muted);
  font-size: 13.5px;
}

.auth-card .form-stack {
  padding: 0;
}

.auth-card .alert {
  margin-bottom: 16px;
}

.auth-foot {
  margin-top: 22px;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
}

.auth-page .skip-link,
.error-page .skip-link {
  display: none;
}

/* ==========================================================================
   Error page
   ========================================================================== */

body.error-page {
  background:
    radial-gradient(900px 500px at 80% -10%, #e7f0e3 0%, transparent 60%),
    var(--bg);
}

.error-layout {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.error-card {
  width: 100%;
  max-width: 480px;
  padding: 44px 40px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.error-code {
  font-family: var(--font-display);
  font-size: 64px;
  font-weight: 600;
  line-height: 1;
  color: var(--gold);
}

.error-card h1 {
  margin: 10px 0;
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
}

.error-card p {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65;
}

.error-actions {
  margin-top: 24px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1180px) {
  .filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .field-search {
    grid-column: span 2;
  }

  .tree-head,
  .tree-row,
  .tree-untagged {
    grid-template-columns: minmax(150px, 1fr) 120px 120px 120px;
  }
}

@media (max-width: 1024px) {
  .split-layout,
  .upload-grid {
    grid-template-columns: 1fr;
  }

  .stat-value {
    font-size: 22px;
  }
}

@media (max-width: 960px) {
  .sidebar {
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 18px 0 40px -24px rgba(0, 0, 0, .5);
  }

  body.nav-open .sidebar {
    transform: none;
  }

  body.nav-open {
    overflow: hidden;
  }

  .app-main {
    margin-left: 0;
  }

  .topbar .menu-toggle {
    display: inline-grid;
  }

  .topbar {
    padding: 14px 18px;
    background: rgba(244, 246, 241, .92);
  }

  .topbar-title h1 {
    font-size: 18px;
  }

  .page {
    padding: 18px 18px 44px;
  }

  .stat-card {
    padding: 17px;
  }
}

@media (max-width: 820px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-search {
    grid-column: span 2;
  }

  .auth-layout {
    grid-template-columns: 1fr;
    background:
      radial-gradient(700px 380px at 85% -10%, #e6efe2 0%, transparent 60%),
      #f4f6f1;
  }

  .auth-brand {
    display: none;
  }

  .auth-panel {
    padding: 32px 18px;
  }

  .auth-eyebrow {
    display: block;
  }

  .auth-card {
    padding: 28px 24px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
  }

  .info-list {
    grid-template-columns: 1fr;
  }

  .tree-head {
    display: none;
  }

  .tree-row,
  .tree-untagged {
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 6px;
    padding: 8px 16px;
    font-size: 11.5px;
  }

  .tree-val {
    font-size: 11px;
  }

  .tree-untagged {
    margin: 8px 16px;
    padding: 8px 12px;
  }

  .tree-sub {
    margin-left: 18px;
  }

  .tree-sub .tree-row {
    padding-left: 8px;
  }

  .month-detail-inner .tree-row {
    padding-left: 16px;
    padding-right: 16px;
  }

  .data-table th,
  .data-table td {
    padding-left: 14px;
    padding-right: 14px;
  }

  .tree-note,
  .mini-head {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 620px) {
  .topbar-title p {
    display: none;
  }

  .page-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-actions {
    width: 100%;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .field-search {
    grid-column: auto;
  }

  .summary-cluster {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 12px 18px;
  }

  .summary-bar {
    padding: 14px;
  }

  .card-head {
    padding: 17px 17px 13px;
  }

  .form-stack {
    padding: 4px 17px 20px;
  }

  .upload-head,
  .upload-grid {
    padding: 17px;
  }

  .upload-head .chip {
    margin-left: 0;
  }

  .category-summary {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 11px 14px;
  }

  .category-path {
    display: none;
  }

  .usage-count {
    grid-column: 1;
    padding-left: 2px;
  }

  .category-actions {
    grid-row: 1 / span 2;
    grid-column: 2;
  }

  .user-summary {
    padding: 12px 14px;
  }

  .user-editor {
    padding: 12px 14px 16px;
  }

  .inline-edit {
    flex-direction: column;
    align-items: stretch;
  }

  .info-list,
  .profile-hero,
  .info-roles {
    padding-left: 17px;
    padding-right: 17px;
  }

  .stat-value {
    font-size: 20px;
  }

  .tree-row,
  .tree-untagged {
    grid-template-columns: minmax(0, 1fr) 72px 72px 72px;
    gap: 4px;
    padding: 8px 12px;
  }

  .tree-val {
    font-size: 9.5px;
    letter-spacing: -.01em;
  }

  .tree-label {
    font-size: 12px;
  }

  .pagination {
    gap: 8px;
  }

  .page-indicator {
    order: -1;
    width: 100%;
    text-align: center;
  }

  .tx-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .tx-search {
    max-width: none;
  }

  .tx-toolbar-actions {
    width: 100%;
    margin-left: 0;
  }

  .tx-filter-toggle {
    flex: 1 1 auto;
    height: 40px;
    justify-content: center;
  }

  .tx-action-sep {
    display: none;
  }

  .filter-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-bottom: 12px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .filter-chips::-webkit-scrollbar {
    display: none;
  }

  .chip,
  .chips-label,
  .chips-clear {
    flex: 0 0 auto;
  }

  .filter-drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    transform: translateY(24px);
  }

  .filter-drawer.is-visible {
    transform: translateY(0);
  }

  .filter-head {
    padding: 16px 16px 12px;
  }

  .filter-body {
    padding: 2px 16px 14px;
  }

  .filter-foot {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }

  .tx-table {
    display: block;
    min-width: 0;
  }

  .tx-table thead,
  .tx-table tbody {
    display: block;
  }

  .tx-table thead tr.tx-head {
    display: none;
  }


  .tx-table tr.tx-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "date amount"
      "desc desc"
      "cat cat"
      "note note";
    column-gap: 12px;
    row-gap: 7px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
  }

  .tx-table tr.tx-row:first-child {
    border-top: 0;
  }

  .tx-table tr.tx-row > td {
    display: block;
    width: auto;
    padding: 0;
    border: 0;
    vertical-align: baseline;
  }

  .tx-table .date-cell {
    grid-area: date;
  }

  .tx-table .desc-cell {
    grid-area: desc;
    padding-top: 1px;
  }

  .tx-table tbody td:nth-child(3) {
    display: none;
  }

  .tx-table .category-cell {
    grid-area: cat;
  }

  .tx-table .amount-cell {
    grid-area: amount;
    font-size: 13px;
  }

  .tx-table .note-cell {
    grid-area: note;
    padding-top: 5px;
    border-top: 1px dashed var(--border);
  }

  .tx-table .note-form {
    min-width: 0;
  }

  .tx-table .note-input {
    padding-top: 6px;
    padding-bottom: 6px;
    font-size: 12px;
  }

  .tx-table .note-save {
    width: 28px;
    height: 28px;
    opacity: 1;
  }

  .tx-table .desc-text {
    max-width: none;
    word-break: break-word;
  }

  .tx-table .tag-form .select-sm {
    width: 100%;
  }

  .report-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  .report-table th:nth-child(1) {
    width: 31%;
  }

  .report-table th:nth-child(n + 2) {
    width: 23%;
  }

  .report-table th:nth-child(5),
  .report-table td:nth-child(5),
  .report-table th:nth-child(6),
  .report-table td:nth-child(6) {
    display: none;
  }

  .report-table th,
  .report-table td {
    padding-left: 9px;
    padding-right: 9px;
    white-space: nowrap;
  }

  .report-table .num {
    font-size: 10px;
    letter-spacing: -.02em;
  }

  .report-table .month-label {
    font-size: 12.5px;
  }

  .toast-region {
    top: 12px;
    right: 12px;
    width: calc(100vw - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ==========================================================================
   Print
   ========================================================================== */

@media print {
  .sidebar,
  .topbar,
  .page-toolbar,
  .filter-card,
  .tx-toolbar,
  .filter-chips,
  .filter-overlay,
  .filter-drawer,
  .toast-region,
  .sidebar-backdrop,
  .no-print {
    display: none !important;
  }

  body,
  body.app-page,
  body.auth-page,
  body.error-page {
    background: #fff;
  }

  .app-main {
    margin: 0;
  }

  .page {
    max-width: none;
    padding: 0;
  }

  .card {
    box-shadow: none;
    break-inside: avoid;
  }

  .month-detail[hidden] {
    display: table-row !important;
  }
}
