/* ============================================================
   Hishab — Design System
   Hand-written CSS. No frameworks. Light + dark theme.
   ============================================================ */

/* ---------- Self-hosted Noto Sans Bengali (no CDN) ---------- */
@font-face {
  font-family: "Noto Sans Bengali"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/fonts/noto-sans-bengali-bengali-400-normal.woff2") format("woff2");
  unicode-range: U+0980-09FF, U+200C-200D, U+20B9, U+25CC;
}
@font-face {
  font-family: "Noto Sans Bengali"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/fonts/noto-sans-bengali-bengali-600-normal.woff2") format("woff2");
  unicode-range: U+0980-09FF, U+200C-200D, U+20B9, U+25CC;
}
@font-face {
  font-family: "Noto Sans Bengali"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/fonts/noto-sans-bengali-bengali-700-normal.woff2") format("woff2");
  unicode-range: U+0980-09FF, U+200C-200D, U+20B9, U+25CC;
}
@font-face {
  font-family: "Noto Sans Bengali"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/fonts/noto-sans-bengali-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+2000-206F, U+2122, U+2212;
}
@font-face {
  font-family: "Noto Sans Bengali"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/fonts/noto-sans-bengali-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+2000-206F, U+2122, U+2212;
}
@font-face {
  font-family: "Noto Sans Bengali"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/fonts/noto-sans-bengali-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+2000-206F, U+2122, U+2212;
}

/* ---------- Design tokens ---------- */
:root {
  --font-sans: "Noto Sans Bengali", "Inter", "Segoe UI", system-ui, -apple-system,
    "Hind Siliguri", "Kalpurush", "SolaimanLipi", sans-serif;

  --accent: #6366f1;
  --accent-600: #4f46e5;
  --accent-700: #4338ca;
  --accent-soft: rgba(99, 102, 241, 0.12);

  --expense: #ef4444;
  --expense-soft: rgba(239, 68, 68, 0.12);
  --income: #10b981;
  --income-soft: rgba(16, 185, 129, 0.12);
  --warn: #f59e0b;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.16);

  --maxw: 1200px;
  --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

:root,
[data-theme="light"] {
  --bg: #f4f5fb;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, #eef0ff 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 10%, #f0fbf6 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #fafbff;
  --surface-3: #f1f3fb;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --border: #e7e9f4;
  --border-strong: #d4d8ea;
}

[data-theme="dark"] {
  --bg: #0b0f1a;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(99,102,241,0.10) 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 10%, rgba(16,185,129,0.08) 0%, transparent 55%);
  --surface: #131826;
  --surface-2: #161c2c;
  --surface-3: #1c2334;
  --text: #e8ecf6;
  --text-2: #a3acc2;
  --text-3: #6b7691;
  --border: #232a3d;
  --border-strong: #2e3650;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow: 0 6px 22px rgba(0,0,0,0.45);
  --shadow-lg: 0 20px 50px rgba(0,0,0,0.55);
}

/* ---------- Reset / base ---------- */
* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  background-image: var(--bg-grad);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; }
::selection { background: var(--accent-soft); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }

/* ---------- Utility ---------- */
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.tiny { font-size: 12px; }
.sm { font-size: 13px; }
.bold { font-weight: 700; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; }
.between { justify-content: space-between; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-16 { gap: 16px; }
.grow { flex: 1; }
.hide { display: none !important; }
.mt-0{margin-top:0}.mt-8{margin-top:8px}.mt-16{margin-top:16px}.mt-24{margin-top:24px}
.mb-8{margin-bottom:8px}.mb-16{margin-bottom:16px}.mb-24{margin-bottom:24px}
.text-expense { color: var(--expense); }
.text-income { color: var(--income); }

/* ============================================================
   App shell
   ============================================================ */
/* Fixed-height shell: .app never itself scrolls or grows past the viewport.
   Its two children (.sidebar and .content, further down) each own an
   independent overflow-y region, so scrolling one never affects the other. */
.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  overflow: hidden;
}

.sidebar {
  width: 256px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  height: 100%;
  overflow-y: auto;              /* independent scroll region */
  overscroll-behavior: contain;  /* never chain into the main content's scroll */
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 10px 18px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 19px;
  box-shadow: var(--shadow-sm);
}
.brand .name { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.brand .sub { font-size: 11px; color: var(--text-3); margin-top: -2px; }

.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3); padding: 14px 12px 6px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 600; font-size: 14px;
  transition: background var(--transition), color var(--transition);
}
.nav-item .ico { font-size: 18px; width: 22px; text-align: center; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-600); }
[data-theme="dark"] .nav-item.active { color: #c7c9ff; }
.nav-sub-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 28px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 600; font-size: 14px;
  transition: background var(--transition), color var(--transition);
  border-left: 2px solid transparent; margin-left: 4px;
}
.nav-sub-item .ico { font-size: 18px; width: 22px; text-align: center; }
.nav-sub-item:hover { background: var(--surface-3); color: var(--text); }
.nav-sub-item.active { background: var(--accent-soft); color: var(--accent-600); border-left-color: var(--accent-600); }
[data-theme="dark"] .nav-sub-item.active { color: #c7c9ff; border-left-color: #c7c9ff; }
.nav-parent { cursor: default; }

.sidebar .spacer { flex: 1; }

/* main column: fixed to the shell's height; .topbar is a permanent header,
   .content (below) is the only scrolling region on this side. */
.main { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  flex-shrink: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 19px; }
.topbar .crumb { color: var(--text-3); font-size: 13px; }
.content {
  flex: 1;
  overflow-y: auto;              /* the real scroll region for page content */
  overscroll-behavior: contain;
  padding: 24px;
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
}

.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); display: grid; place-items: center;
  font-size: 17px; transition: var(--transition);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.menu-toggle { display: none; }

/* avatar */
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px;
}

/* ---------- mobile bottom nav ---------- */
.bottom-nav { display: none; }

/* ============================================================
   Components
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card.pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; }
.card-body { padding: 18px 20px; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* stat card */
.stat { padding: 20px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.stat .label { font-size: 13px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.stat .value { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .delta { font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.stat .delta.up { color: var(--expense); }
.stat .delta.down { color: var(--income); }
.stat .glyph { position: absolute; right: 14px; top: 14px; font-size: 22px; opacity: 0.85;
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 11px; border: 1px solid transparent;
  font-weight: 700; font-size: 14px; transition: var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-600); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { background: var(--expense); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* chips / badges */
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border);
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.chip-active { background: var(--accent-soft); color: var(--accent-600); border-color: var(--accent); }
button.chip { font: inherit; cursor: pointer; }
.badge { padding: 3px 9px; border-radius: 7px; font-size: 11.5px; font-weight: 700; }
.badge.expense { background: var(--expense-soft); color: var(--expense); }
.badge.income { background: var(--income-soft); color: var(--income); }
.cat-ico { font-size: 16px; width: 30px; height: 30px; border-radius: 9px;
  display: inline-grid; place-items: center; background: var(--surface-3); flex-shrink: 0; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input, .select, textarea.input {
  width: 100%; padding: 11px 13px; border-radius: 11px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font-size: 14.5px; font-family: inherit; transition: var(--transition);
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface);
}
.input::placeholder { color: var(--text-3); }
.select { appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }
.field .hint { font-size: 12px; color: var(--text-3); }
.field .err { font-size: 12.5px; color: var(--expense); font-weight: 600; }
.input.has-error, .select.has-error { border-color: var(--expense); }
.input-group { position: relative; }
.input-group .prefix { position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-weight: 700; pointer-events: none; }
.input-group .input { padding-left: 30px; }

/* combobox (searchable select) */
.combobox { position: relative; }
.combobox-trigger {
  width: 100%; text-align: left; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding-right: 34px; min-height: 44px; background-image: none;
}
.combobox-trigger::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 12px; height: 8px;
  transform: translateY(-50%);
  background: no-repeat center / contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  transition: transform var(--transition);
}
.combobox.open .combobox-trigger { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.combobox.open .combobox-trigger::after { transform: translateY(-50%) rotate(180deg); }
.combobox-value { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1; overflow: hidden; }
.combobox-ico { flex-shrink: 0; font-size: 16px; line-height: 1; }
.combobox-vlabel { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combobox-vsub { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.combobox-placeholder { color: var(--text-3); }

.combobox-panel {
  position: absolute; z-index: 50; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); overflow: hidden; display: none; flex-direction: column;
  max-height: 320px; animation: combo-in .14s ease;
}
.combobox.open .combobox-panel { display: flex; }
.combobox.drop-up .combobox-panel { top: auto; bottom: calc(100% + 6px); }
@keyframes combo-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.combobox-search-wrap { position: relative; padding: 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.combobox-search-ico { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: .6; pointer-events: none; }
.combobox-search {
  width: 100%; padding: 9px 12px 9px 32px; border-radius: 9px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
}
.combobox-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }

.combobox-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.combobox-option {
  display: flex; align-items: flex-start; gap: 9px; padding: 9px 12px; border-radius: 9px;
  cursor: pointer; font-size: 14px; line-height: 1.3; scroll-margin: 6px;
}
.combobox-option .combobox-branch { color: var(--text-3); font-size: 12px; flex-shrink: 0; margin-right: -3px; }
.combobox-option .combobox-ico { font-size: 15px; }
.combobox-otext { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; flex: 1; }
.combobox-oline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 1px 8px; min-width: 0; width: 100%; }
.combobox-olabel { white-space: normal; overflow-wrap: anywhere; }
.combobox-osub { color: var(--text-3); font-size: 12px; }
.combobox-opath { color: var(--text-3); font-size: 11px; font-style: italic; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combobox-olabel mark { background: transparent; color: var(--accent-600); font-weight: 800; }
.combobox-check { margin-left: auto; color: var(--accent); font-weight: 800; opacity: 0; flex-shrink: 0; }
.combobox-option.selected { color: var(--accent-600); font-weight: 700; }
.combobox-option.selected .combobox-check { opacity: 1; }
.combobox-option.highlighted { background: var(--accent-soft); }
.combobox-option.is-parent .combobox-olabel { font-weight: 800; text-transform: uppercase; letter-spacing: .02em; font-size: 12.5px; }
.combobox-option.is-none { color: var(--text-3); font-style: italic; }
.combobox-empty { padding: 22px 12px; text-align: center; color: var(--text-3); font-size: 13.5px; }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-3); font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-2); }
.table .amount { font-weight: 700; font-variant-numeric: tabular-nums; }

/* day group (notes-style list) */
.day-group { margin-bottom: 18px; }
.day-head { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; position: sticky; top: 0; z-index: 20; margin-bottom: 10px;
  /* Fully opaque (no color-mix/blur): a sticky element sits above already-
     scrolled content, so any transparency at all lets it show through.
     Same width/inset + card treatment as .txn-row below, for visual
     consistency — no negative-margin bleed. */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.day-head .date { font-weight: 800; font-size: 14px; }
.day-head .total { font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.txn-row { display: flex; align-items: center; gap: 13px; padding: 12px 14px;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 8px;
  transition: var(--transition); }
.txn-row:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.txn-row .meta { display: flex; flex-direction: column; min-width: 0; }
.txn-row .title { font-weight: 600; }
.txn-row .sub { font-size: 12px; color: var(--text-3); }
.txn-row .amt { font-weight: 800; font-variant-numeric: tabular-nums; margin-left: auto; }
.txn-actions { display: flex; gap: 6px; opacity: 0; transition: var(--transition); }
.txn-row:hover .txn-actions { opacity: 1; }

/* category tree */
.tree { list-style: none; margin: 0; padding: 0; }
.tree .node-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 10px; transition: var(--transition); }
.tree .node-row:hover { background: var(--surface-2); }
.tree .node-children { list-style: none; margin: 0; padding-left: 26px; border-left: 1px dashed var(--border-strong);
  margin-left: 14px; }
.tree .toggle { width: 20px; height: 20px; display: grid; place-items: center; color: var(--text-3);
  cursor: pointer; user-select: none; transition: transform var(--transition); font-size: 11px; }
.tree .toggle.collapsed { transform: rotate(-90deg); }
.tree .node-row .actions { margin-left: auto; display: flex; gap: 6px; opacity: 0; }
.tree .node-row:hover .actions { opacity: 1; }
.tree .count { font-size: 12px; color: var(--text-3); }

/* progress / budget bars */
.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bar.over > span { background: var(--expense); }

/* empty state */
.empty { text-align: center; padding: 48px 24px; color: var(--text-3); }
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* alerts */
.alert { padding: 12px 15px; border-radius: 12px; font-size: 14px; font-weight: 600; margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px; }
.alert.success { background: var(--income-soft); color: var(--income); }
.alert.error { background: var(--expense-soft); color: var(--expense); }
.alert.info { background: var(--accent-soft); color: var(--accent-600); }

/* toast */
#toast { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  border-radius: 12px; padding: 13px 16px; font-weight: 600; min-width: 220px;
  animation: toastIn .25s ease; }
.toast.success { border-left: 4px solid var(--income); }
.toast.error { border-left: 4px solid var(--expense); }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8,12,22,0.55); backdrop-filter: blur(4px);
  z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop.open { display: flex; animation: fade .2s ease; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 540px; max-height: 90vh; overflow: auto; animation: pop .2s ease; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

/* segmented control */
.segment { display: inline-flex; background: var(--surface-3); border-radius: 11px; padding: 4px; gap: 4px; }
.segment a, .segment button, .segment label { padding: 7px 14px; border-radius: 8px; font-weight: 700; font-size: 13px;
  color: var(--text-2); border: none; background: transparent; transition: var(--transition); user-select: none; }
.segment a.active, .segment button.active, .segment label.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* charts */
.chart-wrap { width: 100%; overflow-x: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.legend .item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.legend .swatch { width: 11px; height: 11px; border-radius: 3px; }

/* auth */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-aside { background: linear-gradient(150deg, #4f46e5 0%, #7c3aed 50%, #9333ea 100%);
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-aside::after { content: ""; position: absolute; inset: 0;
  background: radial-gradient(600px 300px at 20% 90%, rgba(255,255,255,0.18), transparent 60%); }
.auth-aside .z { position: relative; z-index: 1; }
.auth-aside h2 { font-size: 34px; line-height: 1.15; margin-bottom: 14px; }
.auth-aside p { color: rgba(255,255,255,0.85); font-size: 16px; max-width: 420px; }
.auth-aside .feat { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-weight: 600; }
.auth-aside .feat .b { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,0.16); display: grid; place-items: center; }
.auth-main { display: grid; place-items: center; padding: 32px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 26px; margin-bottom: 6px; }

@media (max-width: 880px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 80; transform: translateX(-100%);
    height: 100vh; height: 100dvh; /* fixed positioning escapes .app's flex sizing, so restate explicitly */
    transition: transform var(--transition); box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 70; }
  .menu-toggle { display: grid; }
  .content { padding: 16px; padding-bottom: 90px; }
  .topbar { padding: 12px 16px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-around; }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 10.5px; font-weight: 600; color: var(--text-3); padding: 4px 10px; border-radius: 10px; }
  .bottom-nav a .ico { font-size: 20px; }
  .bottom-nav a.active { color: var(--accent-600); }
  .bottom-nav .fab { background: var(--accent); color: #fff; width: 46px; height: 46px; border-radius: 50%;
    margin-top: -22px; box-shadow: var(--shadow); justify-content: center; }
}

/* ---------- print ---------- */
@media print {
  .sidebar, .topbar, .bottom-nav, .no-print, .txn-actions { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
}

/* ---------- nav badge ---------- */
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  font-size: 10.5px; font-weight: 700; background: var(--expense); color: #fff;
  margin-left: auto;
}

/* ---------- notes ---------- */
.note-grid { columns: 3; column-gap: 16px; }
@media (max-width: 1024px) { .note-grid { columns: 2; } }
@media (max-width: 760px)  { .note-grid { columns: 1; } }

.note-card {
  break-inside: avoid; margin-bottom: 16px;
  border-radius: 14px; padding: 16px; position: relative;
  border: 1.5px solid var(--border); background: var(--surface);
  transition: box-shadow var(--transition), transform var(--transition);
  height: 220px; display: flex; flex-direction: column; overflow: hidden;
}
.note-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.note-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; flex-shrink: 0; }
.note-title { font-size: 15px; font-weight: 700; line-height: 1.3; color: var(--text); }
.note-untitled { font-size: 15px; font-weight: 500; color: var(--text-3); font-style: italic; }
.note-preview { flex: 1; min-height: 0; overflow: hidden; font-size: 13.5px; color: var(--text-2); line-height: 1.65; word-break: break-word; -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%); mask-image: linear-gradient(to bottom, black 60%, transparent 100%); }
.note-preview h2 { font-size: 14px; font-weight: 700; margin: 8px 0 4px; }
.note-preview h3 { font-size: 13px; font-weight: 600; margin: 6px 0 3px; }
.note-preview ul, .note-preview ol { padding-left: 16px; margin: 4px 0; }
.note-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(0,0,0,.05); flex-shrink: 0; }
.note-view-link { font-size: 11.5px; color: var(--accent); text-decoration: none; font-weight: 600; opacity: 0; transition: opacity .2s; }
.note-card:hover .note-view-link { opacity: 1; }
.text-on-dark .note-view-link { color: rgba(255,255,255,.85); }
/* three-dot menu */
.note-menu { position: relative; flex-shrink: 0; }
.note-menu-btn {
  width: 30px; height: 30px; border-radius: 8px; border: none; background: none;
  cursor: pointer; font-size: 18px; line-height: 1; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s, background .15s;
}
.note-card:hover .note-menu-btn,
.note-menu.open .note-menu-btn { opacity: 1; }
.note-menu-btn:hover { background: rgba(0,0,0,.07); }
.note-menu-dropdown {
  position: absolute; top: calc(100% + 4px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,.14);
  min-width: 170px; z-index: 200; display: none; overflow: hidden;
}
.note-menu.open .note-menu-dropdown { display: block; }
.note-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; font-size: 13.5px; cursor: pointer;
  color: var(--text); text-decoration: none; white-space: nowrap;
  transition: background .1s; border: none; background: none;
  font: inherit; width: 100%; text-align: left;
}
.note-menu-item:hover { background: var(--surface-3); }
.note-menu-sep { height: 1px; background: var(--border); margin: 3px 0; }
.note-menu-item.danger { color: var(--expense); }
.note-menu-item.danger:hover { background: #fff0f0; }
[data-theme="dark"] .note-menu-item.danger:hover { background: #3a1010; }

/* gradient / image backgrounds */
.note-bg-image,
.note-bg-gradient { border-color: transparent !important; position: relative; }
.note-bg-image { background-size: cover !important; background-position: center !important; }
.note-bg-image::before {
  content: ''; position: absolute; inset: 0; border-radius: 13px;
  background: linear-gradient(170deg, rgba(0,0,0,.06) 0%, rgba(0,0,0,.42) 100%);
  pointer-events: none;
}
.note-bg-image > * { position: relative; }
.note-card.text-on-dark { color: rgba(255,255,255,.92) !important; }
.note-card.text-on-dark .note-title { color: #fff !important; text-shadow: 0 1px 3px rgba(0,0,0,.3); }
.note-card.text-on-dark .note-untitled { color: rgba(255,255,255,.5) !important; }
.note-card.text-on-dark .note-preview { color: rgba(255,255,255,.82) !important; }
.note-card.text-on-dark .note-footer { border-color: rgba(255,255,255,.15) !important; }
.note-card.text-on-dark .note-footer .dim { color: rgba(255,255,255,.55) !important; }
.note-card.text-on-dark .note-menu-btn { color: rgba(255,255,255,.75); }
.note-card.text-on-dark .note-menu-btn:hover { background: rgba(255,255,255,.15); }

/* === Note editor canvas === */
.note-canvas {
  display: block; width: 100%; box-sizing: border-box;
  border-radius: 16px; border: 1.5px solid var(--border); background: var(--surface);
  margin-bottom: 24px; position: relative; transition: border-color .3s;
  background-size: cover !important; background-position: center !important;
}
.note-canvas.canvas-has-image::before {
  content: ''; position: absolute; inset: 0; border-radius: 15px;
  background: linear-gradient(170deg, rgba(0,0,0,.08), rgba(0,0,0,.42));
  pointer-events: none;
}
.note-canvas.canvas-text-light  { color: rgba(255,255,255,.92); }
.note-canvas.canvas-has-image,
.note-canvas.canvas-has-gradient { border-color: transparent; }
.canvas-toolbar {
  display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 1px;
  width: 100%; box-sizing: border-box;
  padding: 7px 10px; border-radius: 15px 15px 0 0; border-bottom: 1px solid var(--border);
  background: var(--surface-2); position: relative; z-index: 2;
}
.note-canvas.canvas-text-light .canvas-toolbar {
  background: rgba(0,0,0,.25); border-bottom-color: rgba(255,255,255,.1);
}
.note-canvas.canvas-text-light .rte-btn { color: rgba(255,255,255,.78); }
.note-canvas.canvas-text-light .rte-btn:hover { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.2); }
.note-canvas.canvas-text-light .rte-sep { background: rgba(255,255,255,.2); }
.canvas-content { padding: 0; position: relative; z-index: 1; }
.canvas-title-input {
  display: block; width: 100%; box-sizing: border-box; padding: 18px 20px 10px;
  border: none; background: transparent; outline: none; color: inherit; font-family: inherit;
  font-size: 21px; font-weight: 700; line-height: 1.3;
}
.canvas-title-input::placeholder { font-weight: 500; color: var(--text-3); }
.note-canvas.canvas-text-light .canvas-title-input::placeholder { color: rgba(255,255,255,.3); }
/* canvas body — standalone (does NOT inherit rte-body class) */
.canvas-body {
  display: block; min-height: 260px; max-height: 520px; overflow-y: auto;
  padding: 4px 20px 24px; outline: none;
  font-size: 14.5px; line-height: 1.8; color: inherit; background: transparent;
}
.canvas-body:empty:before { content: attr(data-placeholder); color: var(--text-3); pointer-events: none; }
.note-canvas.canvas-text-light .canvas-body:empty:before { color: rgba(255,255,255,.3); }
.canvas-body h2 { font-size: 20px; font-weight: 700; margin: 16px 0 6px; }
.canvas-body h3 { font-size: 16px; font-weight: 600; margin: 12px 0 4px; }
.canvas-body p  { margin: 4px 0; }
.canvas-body ul, .canvas-body ol { padding-left: 24px; margin: 6px 0; }
.canvas-body li { margin: 3px 0; }
.canvas-body hr { border: none; border-top: 2px solid var(--border); margin: 14px 0; }
.canvas-body b, .canvas-body strong { font-weight: 700; }
.canvas-body a { color: var(--accent-600); text-decoration: underline; }
.canvas-body blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: inherit; opacity: .8; margin: 8px 0; }
/* inline color picker row (flex break trick) */
.rte-color-row {
  flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
  padding: 7px 3px 3px; border-top: 1px solid var(--border); margin-top: 3px;
}
.note-canvas.canvas-text-light .rte-color-row { border-top-color: rgba(255,255,255,.12); }
.rte-color-dot {
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer; flex-shrink: 0;
  border: 2px solid rgba(0,0,0,.15); transition: transform .12s, box-shadow .12s;
}
.rte-color-dot:hover { transform: scale(1.2); box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.rte-color-dot.dot-none {
  background: var(--surface-3) !important; border-color: var(--border) !important;
  display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--text-3);
}
.rte-color-indicator { display: block; width: 14px; height: 3px; border-radius: 1px; margin: 1px auto 0; }

/* background picker */
.bg-tabs { display: flex; gap: 2px; background: var(--surface-3); border-radius: 9px; padding: 3px; margin-bottom: 20px; }
.bg-tab {
  flex: 1; padding: 7px 10px; border: none; background: none; border-radius: 7px;
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--text-2);
  transition: background .15s, color .15s;
}
.bg-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.bg-panel { display: none; padding: 4px 2px; }
.bg-panel.active { display: block; }
.gradient-grid { display: grid; grid-template-columns: repeat(6,1fr); gap: 8px; }
@media (max-width:600px) { .gradient-grid { grid-template-columns: repeat(4,1fr); } }
.gradient-swatch { }
.gradient-swatch input[type=radio] { display: none; }
.gradient-swatch label {
  display: block; height: 46px; border-radius: 10px;
  border: 2.5px solid transparent; cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.gradient-swatch label:hover { transform: scale(1.07); }
.gradient-swatch input[type=radio]:checked + label {
  border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft);
  transform: scale(1.07);
}
.gradient-none label {
  background: var(--surface-3) !important; display: flex;
  align-items: center; justify-content: center; font-size: 18px; color: var(--text-3);
}
.img-upload-zone {
  display: block; border: 2px dashed var(--border); border-radius: 12px;
  padding: 28px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.img-upload-zone:hover { border-color: var(--accent); background: var(--accent-soft); }
.img-upload-zone input[type=file] { display: none; }
.img-upload-zone p { margin: 6px 0 0; font-size: 13px; color: var(--text-2); }
.img-preview { display: inline-flex; align-items: flex-start; gap: 10px; margin-top: 12px; }
.img-preview img { max-height: 80px; max-width: 160px; border-radius: 8px; object-fit: cover; }
.img-preview-remove { background: var(--expense); color: #fff; border: none; border-radius: 50%; width: 22px; height: 22px; font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px; }

/* Note color themes */
.note-clr-yellow  { background: #fffde7; border-color: #f9e04b; }
.note-clr-green   { background: #f1f8e9; border-color: #8bc34a; }
.note-clr-blue    { background: #e3f2fd; border-color: #64b5f6; }
.note-clr-pink    { background: #fce4ec; border-color: #f48fb1; }
.note-clr-purple  { background: #f3e5f5; border-color: #ce93d8; }
.note-clr-orange  { background: #fff3e0; border-color: #ffb74d; }
[data-theme="dark"] .note-clr-yellow  { background: #2a2200; border-color: #6b5700; }
[data-theme="dark"] .note-clr-green   { background: #0d2200; border-color: #2e5f00; }
[data-theme="dark"] .note-clr-blue    { background: #001a35; border-color: #1a5fa5; }
[data-theme="dark"] .note-clr-pink    { background: #2a0018; border-color: #7a1f42; }
[data-theme="dark"] .note-clr-purple  { background: #1a0028; border-color: #5e1b7a; }
[data-theme="dark"] .note-clr-orange  { background: #2a1500; border-color: #7a3d00; }

/* Color swatch picker */
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.color-swatches input[type=radio] { display: none; }
.color-swatches label {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 11px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.color-swatches label:hover { transform: scale(1.2); }
.color-swatches input[type=radio]:checked + label { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); transform: scale(1.15); }
.sw-default { background: var(--surface-3); border-color: var(--border) !important; }
.sw-yellow  { background: #f9e04b; }
.sw-green   { background: #8bc34a; }
.sw-blue    { background: #64b5f6; }
.sw-pink    { background: #f48fb1; }
.sw-purple  { background: #ce93d8; }
.sw-orange  { background: #ffb74d; }

/* Rich text editor */
.rte-wrap { border: 1.5px solid var(--border); border-radius: 12px; overflow: hidden; transition: border-color var(--transition), box-shadow var(--transition); }
.rte-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rte-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 8px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.rte-btn {
  padding: 4px 9px; border: 1px solid transparent; border-radius: 6px;
  background: none; font: inherit; font-size: 13px; cursor: pointer; color: var(--text-2); line-height: 1.5;
  transition: background var(--transition), color var(--transition);
}
.rte-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.rte-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.rte-body {
  min-height: 280px; max-height: 600px; overflow-y: auto;
  padding: 16px 18px; outline: none;
  font-size: 14.5px; line-height: 1.8; color: var(--text);
  background: var(--surface);
}
.rte-body:empty:before { content: attr(data-placeholder); color: var(--text-3); pointer-events: none; }
.rte-body h2 { font-size: 20px; font-weight: 700; margin: 16px 0 6px; }
.rte-body h3 { font-size: 16px; font-weight: 600; margin: 12px 0 4px; }
.rte-body p  { margin: 4px 0; }
.rte-body ul, .rte-body ol { padding-left: 24px; margin: 6px 0; }
.rte-body li { margin: 3px 0; }
.rte-body hr { border: none; border-top: 2px solid var(--border); margin: 14px 0; }
.rte-body b, .rte-body strong { font-weight: 700; }
.rte-body a { color: var(--accent-600); text-decoration: underline; }
.rte-body blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--text-2); margin: 8px 0; }

/* ---------- reminders ---------- */
.reminder-list { display: flex; flex-direction: column; gap: 10px; }
.reminder-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface); transition: box-shadow var(--transition);
}
.reminder-item:hover { box-shadow: var(--shadow-sm); }
.reminder-item.overdue { border-color: var(--expense);  background: var(--expense-soft); }
.reminder-item.today   { border-color: var(--accent);   background: var(--accent-soft);  }
.reminder-item.done    { opacity: .55; }

.r-check {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border);
  background: var(--surface); cursor: pointer; flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
  transition: border-color var(--transition), background var(--transition); padding: 0;
}
.r-check:hover { border-color: var(--accent); background: var(--accent-soft); }
.reminder-item.done    .r-check { background: var(--income);  border-color: var(--income);  color: #fff; }
.reminder-item.overdue .r-check { border-color: var(--expense); }
.reminder-item.today   .r-check { border-color: var(--accent);  }

.r-body  { flex: 1; min-width: 0; }
.r-title { font-weight: 600; font-size: 14.5px; color: var(--text); }
.reminder-item.done .r-title { text-decoration: line-through; color: var(--text-3); }
.r-desc  { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.r-meta  { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.r-time  { font-size: 12px; font-weight: 600; }
.reminder-item.overdue .r-time { color: var(--expense); }
.reminder-item.today   .r-time { color: var(--accent-600); }
.reminder-item:not(.overdue):not(.today):not(.done) .r-time { color: var(--text-3); }
.reminder-item.done    .r-time { color: var(--text-3); }
.r-recur { font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); }
.r-actions { display: flex; gap: 6px; flex-shrink: 0; margin-top: 1px; }

/* ---------- import preview table ---------- */
.imp-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.imp-table th, .imp-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.imp-table th { font-size: 11px; text-transform: uppercase; color: var(--text-3); letter-spacing: .04em; }
.imp-table .select { padding: 6px 28px 6px 9px; font-size: 13px; }
.imp-table input.input { padding: 6px 9px; font-size: 13px; }
.imp-row-skip { opacity: .45; }

/* ============================================================
   Insurance Module
   ============================================================ */

/* ---- policy list grid ---- */
.ins-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
@media (max-width: 640px) { .ins-grid { grid-template-columns: 1fr; } }
.ins-policy-card { transition: box-shadow .15s, transform .15s; }
.ins-policy-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.ins-policy-card.ins-expired { opacity: .72; }

/* ---- status + group badges ---- */
.badge-success { background: var(--income-soft); color: var(--income); }
.badge-warn    { background: #fef3c7; color: #d97706; }
.badge-error   { background: var(--expense-soft); color: var(--expense); }
.badge-muted   { background: var(--surface-3); color: var(--text-2); }
[data-theme="dark"] .badge-warn { background: rgba(245,158,11,.16); color: #fbbf24; }

.ins-group-badge { display: inline-flex; align-items:center; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing:.01em; }
.ins-group-badge[data-group="employee_family"] { background: rgba(59,130,246,.14); color: #3b82f6; }
.ins-group-badge[data-group="parents"]         { background: rgba(139,92,246,.14); color: #8b5cf6; }
.ins-group-badge[data-group="all"]             { background: var(--surface-3); color: var(--text-2); }

/* ---- detail page shell ---- */
.ins-detail { display: flex; flex-direction: column; gap: 20px; }
.ins-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 2px; }
.ins-section-head h2 { font-size: 17px; letter-spacing: -0.01em; display:flex; align-items:center; gap:9px; }
.ins-section-head .count-pill { font-size: 12px; font-weight: 700; color: var(--text-2); background: var(--surface-3); padding: 2px 9px; border-radius: 999px; }
.ins-section-head .acts { display:flex; gap: 8px; flex-wrap: wrap; }

/* ---- hero ---- */
.ins-hero { padding: 22px; position: relative; overflow: hidden; }
.ins-hero::before { content:""; position:absolute; inset:0;
  background: radial-gradient(520px 220px at 100% -30%, var(--accent-soft), transparent 70%); pointer-events:none; }
.ins-hero-top { display:flex; gap: 18px; align-items:flex-start; justify-content: space-between; flex-wrap: wrap; position: relative; }
.ins-hero-id { display:flex; gap: 15px; align-items:flex-start; min-width: 0; }
.ins-shield { width: 54px; height: 54px; border-radius: 15px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), #8b5cf6); color:#fff; display:grid; place-items:center;
  font-size: 25px; box-shadow: var(--shadow); }
.ins-hero-id h1 { font-size: 23px; line-height: 1.15; }
.ins-hero-id .sub { color: var(--text-2); font-size: 13.5px; margin-top: 4px; }
.ins-hero-chips { display:flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.ins-hero-meta { display:flex; gap: 26px; flex-wrap: wrap; align-items:flex-start; }
.ins-meta .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 800; }
.ins-meta .v { font-size: 14px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
@media (max-width: 620px) {
  .ins-hero { padding: 18px; }
  .ins-hero-meta { gap: 20px; margin-top: 4px; }
  .ins-hero-id h1 { font-size: 20px; }
}

/* ---- summary strip (KPIs) ---- */
.ins-summary { display: flex; padding: 0; overflow: hidden; }
.ins-summary-cell { flex: 1; padding: 16px 18px; border-right: 1px solid var(--border); min-width: 0; }
.ins-summary-cell:last-child { border-right: none; }
.ins-summary-cell .k { font-size: 12px; color: var(--text-2); font-weight: 600; display:flex; align-items:center; gap:7px; }
.ins-summary-cell .v { font-size: 23px; font-weight: 800; margin-top: 7px; letter-spacing:-0.02em; font-variant-numeric: tabular-nums; }
.ins-summary-cell.is-settled .v { color: var(--income); }
.ins-summary-cell.is-pending .v { color: var(--warn); }
@media (max-width: 620px) {
  .ins-summary { flex-direction: column; }
  .ins-summary-cell { border-right: none; border-bottom: 1px solid var(--border); display:flex; align-items:center; justify-content: space-between; padding: 14px 16px; }
  .ins-summary-cell:last-child { border-bottom: none; }
  .ins-summary-cell .v { margin-top: 0; font-size: 20px; }
}

/* ---- coverage groups ---- */
.ins-cov-group + .ins-cov-group { margin-top: 22px; }
.ins-cov-group-head { display:flex; align-items:center; gap: 10px; margin: 0 2px 12px; }
.ins-cov-group-head .t { font-weight: 800; font-size: 14px; }
.ins-cov-group-head .line { flex:1; height:1px; background: var(--border); }
.ins-cov-list { display: grid; gap: 12px; }

/* coverage card (root limit) */
.ins-cov { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; transition: border-color var(--transition), box-shadow var(--transition); }
.ins-cov:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.ins-cov-main { padding: 15px 16px; }
.ins-cov-row { display:flex; align-items:flex-start; justify-content: space-between; gap: 12px; }
.ins-cov-name { font-weight: 700; font-size: 15px; display:flex; align-items:center; gap:8px; min-width:0; }
.ins-cov-usage { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; text-align:right; }
.ins-cov-usage b { color: var(--text); font-weight: 800; }
.ins-cov-foot { display:flex; align-items:center; justify-content: space-between; gap: 10px; margin-top: 9px; font-size: 12px; }
.ins-cov-foot .used { color: var(--text-3); }
.ins-cov-foot .rem { font-weight: 700; margin-left:auto; }
.ins-cov-foot .rem .amt { color: var(--income); }
.ins-cov-foot .rem.is-low .amt { color: var(--expense); }

/* progress bar */
.ins-bar { height: 9px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 11px; }
.ins-bar > span { display:block; height:100%; border-radius: 999px; transition: width .55s cubic-bezier(.4,0,.2,1); }
.ins-bar.mini { height: 5px; margin-top: 8px; }
.bar-lvl-low  > span { background: linear-gradient(90deg, #10b981, #34d399); }
.bar-lvl-mid  > span { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bar-lvl-high > span { background: linear-gradient(90deg, #ef4444, #f87171); }

/* sub-limits */
.ins-sub-list { border-top: 1px dashed var(--border-strong); background: var(--surface-2); padding: 4px 16px 8px; }
.ins-sub { padding: 11px 0; border-bottom: 1px solid var(--border); }
.ins-sub:last-child { border-bottom: none; }
.ins-sub.lvl3 { padding-left: 20px; position: relative; }
.ins-sub.lvl3::before { content:""; position:absolute; left: 5px; top: 20px; width: 9px; height: 9px; border-left: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); border-bottom-left-radius: 4px; }
.ins-sub-top { display:flex; align-items:center; gap: 10px; }
.ins-sub-name { font-weight: 600; font-size: 13.5px; min-width:0; }
.ins-sub-usage { margin-left:auto; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space:nowrap; }
.ins-sub-usage b { color: var(--text); }
.ins-tag { display:inline-flex; align-items:center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--surface-3); color: var(--text-2); white-space:nowrap; }
.ins-tag.cap { background: var(--accent-soft); color: var(--accent-600); }
[data-theme="dark"] .ins-tag.cap { color: #c7c9ff; }

/* row actions */
.ins-acts { display:inline-flex; gap: 5px; flex-shrink:0; }
.ins-iconbtn { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); display:grid; place-items:center; font-size: 14px; transition: var(--transition); flex-shrink:0; }
.ins-iconbtn:hover { background: var(--surface-3); color: var(--text); }
.ins-iconbtn.danger:hover { background: var(--expense-soft); color: var(--expense); border-color: transparent; }
@media (hover: hover) and (pointer: fine) {
  .ins-cov-row > .ins-acts, .ins-sub-top > .ins-acts { opacity: 0; transition: opacity var(--transition); }
  .ins-cov:hover .ins-cov-row > .ins-acts, .ins-sub:hover .ins-sub-top > .ins-acts { opacity: 1; }
}

/* ---- claims ---- */
.ins-claim-list { display: grid; gap: 12px; }
.ins-claim { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; transition: border-color var(--transition), box-shadow var(--transition); }
.ins-claim:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.ins-claim-head { display:flex; gap: 14px; align-items:flex-start; padding: 14px 16px; }
.ins-claim-date { flex-shrink:0; width: 46px; text-align:center; padding-top: 2px; }
.ins-claim-date .d { font-size: 20px; font-weight: 800; line-height: 1; letter-spacing:-0.02em; }
.ins-claim-date .m { font-size: 10.5px; text-transform: uppercase; color: var(--text-3); font-weight: 800; letter-spacing:.04em; margin-top: 2px; }
.ins-claim-date .y { font-size: 11px; color: var(--text-3); }
.ins-claim-body { flex:1; min-width:0; }
.ins-claim-body .nm { font-weight: 700; font-size: 14.5px; }
.ins-claim-tags { display:flex; gap: 7px; flex-wrap: wrap; align-items:center; margin-top: 5px; }
.ins-claim-tags .meta { font-size: 12px; color: var(--text-3); }
.ins-claim-amt { flex-shrink:0; text-align:right; }
.ins-claim-amt .settled { font-size: 18px; font-weight: 800; color: var(--income); font-variant-numeric: tabular-nums; line-height:1.1; }
.ins-claim-amt .of { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; margin-top: 2px; }
.ins-claim-actbar { display:flex; align-items:center; gap: 6px; padding: 0 16px 12px; }
.ins-claim-actbar .spacer { flex:1; }

/* claim line items */
.ins-claim-items { border-top: 1px solid var(--border); background: var(--surface-2); padding: 2px 16px; }
.ins-ci { display:flex; align-items:flex-start; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ins-ci:last-child { border-bottom: none; }
.ins-ci-desc { flex: 1 1 160px; min-width: 0; }
.ins-ci-desc .t { font-weight: 700; font-size: 13px; }
.ins-ci-desc .lim { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.ins-ci-nums { display:flex; gap: 18px; margin-left:auto; }
.ins-ci-num { text-align:right; }
.ins-ci-num .lbl { font-size: 10px; text-transform: uppercase; letter-spacing:.04em; color: var(--text-3); font-weight: 700; }
.ins-ci-num .val { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.ins-ci-num.settled .val { color: var(--income); }
.ins-ci-num.ded .val { color: var(--expense); }
.ins-ci-remark { flex-basis: 100%; font-size: 12px; color: #d97706; display:flex; gap:6px; align-items:flex-start; }
[data-theme="dark"] .ins-ci-remark { color: #fbbf24; }
@media (max-width: 560px) {
  .ins-ci-nums { gap: 14px; margin-left: 0; flex-basis: 100%; justify-content: space-between; }
  .ins-ci-num { text-align:left; }
}

/* ---- add/edit limit inline panel ---- */
.ins-form-panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 16px; }
.ins-form-grid { display:grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 560px) { .ins-form-grid { grid-template-columns: 1fr; } }

/* empty state inside a card */
.ins-empty { text-align:center; padding: 36px 20px; color: var(--text-3); }
.ins-empty .big { font-size: 34px; margin-bottom: 8px; }

/* ---- coverage-details info popup ---- */
.ins-iconbtn.info { color: var(--accent-600); border-color: var(--accent-soft); }
[data-theme="dark"] .ins-iconbtn.info { color: #c7c9ff; }
.ins-iconbtn.info:hover { background: var(--accent-soft); border-color: transparent; }

#benefitModal .modal { max-width: 560px; }
#benefitBody { padding: 20px 22px; }

.ins-info-section { position: relative; border-radius: 16px; padding: 16px 18px; margin: 0 0 14px;
  border: 1px solid var(--border); overflow: hidden; }
.ins-info-section:last-child { margin-bottom: 0; }
.ins-info-section::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.ins-info-section.ok   { background: color-mix(in srgb, var(--income) 7%, var(--surface)); border-color: color-mix(in srgb, var(--income) 24%, var(--border)); }
.ins-info-section.no   { background: color-mix(in srgb, var(--expense) 7%, var(--surface)); border-color: color-mix(in srgb, var(--expense) 24%, var(--border)); }
.ins-info-section.note { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 24%, var(--border)); }
.ins-info-section.ok::before   { background: var(--income); }
.ins-info-section.no::before   { background: var(--expense); }
.ins-info-section.note::before { background: var(--accent); }

.ins-info-head { display:flex; align-items:center; gap: 11px; margin-bottom: 13px; }
.ins-info-head .hicon { width: 30px; height: 30px; border-radius: 10px; display:grid; place-items:center; font-size: 15px;
  background: var(--surface); box-shadow: var(--shadow-sm); }
.ins-info-head .htext { font-weight: 800; font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; }
.ins-info-head.ok   .htext { color: var(--income); }
.ins-info-head.no   .htext { color: var(--expense); }
.ins-info-head.note .htext { color: var(--accent-600); }
[data-theme="dark"] .ins-info-head.note .htext { color: #c7c9ff; }
.ins-info-head .hcount { margin-left:auto; font-size: 11px; font-weight: 800; min-width: 22px; text-align:center;
  padding: 2px 8px; border-radius: 999px; background: var(--surface); color: var(--text-2); border: 1px solid var(--border); }

.ins-info-list { list-style: none; margin: 0; padding: 0; display:flex; flex-direction:column; gap: 10px; }
.ins-info-item { display:flex; gap: 11px; align-items:flex-start; }
.ins-info-item .mk { flex-shrink:0; width: 21px; height: 21px; border-radius: 50%; display:grid; place-items:center;
  font-size: 11px; font-weight: 900; color: #fff; margin-top: 1px; box-shadow: var(--shadow-sm); }
.ins-info-item.ok   .mk { background: var(--income); }
.ins-info-item.no   .mk { background: var(--expense); }
.ins-info-item.note .mk { background: var(--accent); }
.ins-info-item .tx { font-size: 13.5px; line-height: 1.5; color: var(--text); }

/* benefits editor header inside the limit modal */
.lm-benefits-head { display:flex; align-items:baseline; gap: 8px; margin: 6px 0 12px; padding-top: 14px; border-top: 1px solid var(--border); }
.lm-benefits-head > span:first-child { font-weight: 800; font-size: 13px; }
.lm-benefits-head .hint { font-size: 12px; color: var(--text-3); }

/* ---- tab bar ---- */
.ins-tabs { display:flex; gap: 4px; padding: 5px; background: var(--surface-3); border-radius: 13px; overflow-x: auto; scrollbar-width: none; }
.ins-tabs::-webkit-scrollbar { display: none; }
.ins-tab { display:inline-flex; align-items:center; gap: 7px; padding: 9px 15px; border-radius: 9px; font-weight: 700; font-size: 13.5px;
  color: var(--text-2); white-space: nowrap; transition: var(--transition); }
.ins-tab:hover { color: var(--text); }
.ins-tab.active { background: var(--surface); color: var(--accent-600); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .ins-tab.active { color: #c7c9ff; }
.ins-tab .n { font-size: 11px; font-weight: 800; background: var(--accent-soft); color: var(--accent-600); padding: 1px 7px; border-radius: 999px; }
[data-theme="dark"] .ins-tab .n { color: #c7c9ff; }
.ins-tab.active .n { background: var(--accent); color: #fff; }
[data-theme="dark"] .ins-tab.active .n { color: #fff; }

/* ---- filter bar ---- */
.ins-filterbar { display:flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.ins-filterbar .ff { display:flex; flex-direction: column; gap: 5px; min-width: 0; }
.ins-filterbar .ff > label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing:.04em; }
.ins-filterbar .ff .input, .ins-filterbar .ff .select { padding: 8px 11px; font-size: 13.5px; border-radius: 10px; }
.ins-filterbar .ff.search { flex: 1 1 200px; }
.ins-filterbar .ff.search .input { min-width: 0; }
.ins-filterbar .ff .select { padding-right: 30px; }
.ins-filterbar .fbtns { display:flex; gap: 8px; margin-left: auto; }
@media (max-width: 640px) {
  .ins-filterbar { flex-direction: column; align-items: stretch; }
  .ins-filterbar .ff, .ins-filterbar .fbtns { width: 100%; }
  .ins-filterbar .fbtns { margin-left: 0; }
  .ins-filterbar .fbtns .btn { flex: 1; }
}
.ins-active-filters { display:flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.ins-active-filters .fchip { display:inline-flex; align-items:center; gap:6px; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-600); padding: 4px 10px; border-radius: 999px; }
[data-theme="dark"] .ins-active-filters .fchip { color: #c7c9ff; }

/* ---- utilization table/rows ---- */
.ins-util { display: grid; gap: 14px; }
.ins-util-root { border: 1px solid var(--border); border-left: 3px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); overflow: hidden; box-shadow: var(--shadow-sm); }
.ins-util-root[data-group="employee_family"] { border-left-color: #3b82f6; }
.ins-util-root[data-group="parents"]         { border-left-color: #8b5cf6; }
.ins-util-root[data-group="all"]             { border-left-color: var(--text-3); }
.ins-util-row { display:flex; flex-wrap:wrap; align-items:center; gap: 14px; padding: 12px 16px; }
.ins-util-row.head { background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 15px 16px; }
.ins-util-row.head .ins-util-name { font-size: 15.5px; font-weight: 800; }
.ins-util-row.child { padding: 9px 16px 9px 2px; }
.ins-util-name { flex: 1 1 auto; font-weight: 700; font-size: 14.5px; min-width:0; display:flex; align-items:center; gap: 8px; }
.ins-util-row.child .ins-util-name { font-weight: 600; font-size: 13.5px; }
/* fixed-width figure columns → LIMIT/USED/LEFT line up at every depth */
.ins-util-figs { flex-shrink:0; display:grid; grid-template-columns: repeat(3, 82px); font-variant-numeric: tabular-nums; }
.ins-util-fig { min-width: 0; text-align: right; padding-left: 6px; }
.ins-util-fig .k { font-size: 10px; text-transform: uppercase; letter-spacing:.04em; color: var(--text-3); font-weight: 700; }
.ins-util-fig .v { font-size: 13.5px; font-weight: 700; margin-top: 2px; }
.ins-util-fig .v.na { color: var(--text-3); font-weight: 600; }
.ins-util-fig.rem .v { color: var(--income); }
.ins-util-fig.rem.low .v { color: var(--expense); }
.ins-util-cta { flex-shrink:0; width: 108px; display:flex; justify-content:flex-end; }
.ins-util-bar { flex-basis: 100%; }

/* generic tree connectors — used by utilization + coverage hierarchies */
.ins-tree { position: relative; padding-left: 8px; }
.ins-tree-node { position: relative; padding-left: 22px; }
.ins-tree-node::before {   /* vertical trunk to next sibling */
  content: ""; position: absolute; left: 7px; top: 0; height: 100%;
  border-left: 1.5px solid var(--border-strong); }
.ins-tree-node:last-child::before { height: 23px; }
.ins-tree-node::after {    /* horizontal elbow into the row */
  content: ""; position: absolute; left: 7px; top: 23px; width: 14px;
  border-top: 1.5px solid var(--border-strong); }

@media (max-width: 720px) {
  .ins-util-row { gap: 10px; }
  .ins-util-name { flex-basis: 100%; }
  .ins-util-figs { flex: 1 1 auto; grid-template-columns: repeat(3, 1fr); }
  .ins-util-fig { text-align: left; padding-left: 0; }
  .ins-util-cta { width: auto; }
  .ins-tree-node { padding-left: 18px; }
}

/* ---- coverage definition rows ---- */
.ins-covdef { display:flex; align-items:center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.ins-covdef:first-child { border-top: none; }
.ins-covdef:hover { background: var(--surface-2); }
.ins-tree .ins-covdef { border-top: none; padding: 9px 12px 9px 2px; }
.ins-covdef .nm { font-weight: 600; font-size: 14px; min-width: 0; display:flex; align-items:center; gap: 9px; flex-wrap: wrap; }
.ins-covdef .vals { margin-left:auto; display:flex; gap: 9px; align-items:center; flex-wrap: wrap; justify-content:flex-end; }
.ins-covdef .val-main { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 14px; }
.ins-covdef-group { margin-bottom: 18px; }
.ins-covdef-group .ghead { display:flex; align-items:center; gap:10px; margin: 0 2px 10px; }
.ins-covdef-group .ghead .line { flex:1; height:1px; background: var(--border); }
@media (max-width: 560px) {
  .ins-covdef { flex-direction: column; align-items: stretch; gap: 8px; }
  .ins-covdef .vals { margin-left: 0; justify-content: flex-start; }
}

/* ---- pager ---- */
.pager { display:flex; align-items:center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.pager .info { font-size: 13px; color: var(--text-3); }
.pager .pages { display:flex; gap: 6px; align-items:center; flex-wrap: wrap; }
.pager .pg { min-width: 36px; height: 36px; padding: 0 10px; display:inline-flex; align-items:center; justify-content:center;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 700; font-size: 13px; transition: var(--transition); }
.pager .pg:hover { background: var(--surface-3); color: var(--text); }
.pager .pg.active { background: var(--accent); color:#fff; border-color: var(--accent); }
.pager .pg.disabled { opacity: .4; pointer-events: none; }
.pager .pg.gap { border: none; background: transparent; pointer-events: none; }

/* ============================================================
   Filter panel (collapsible) + multi-select
   ============================================================ */

/* ---- collapsible <details> filter panel ---- */
.filterbar { margin-bottom: 24px; overflow: visible; }
.filterbar > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; user-select: none; }
.filterbar > summary::-webkit-details-marker { display: none; }
.filterbar > summary .fb-ico { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-600); font-size: 16px; }
[data-theme="dark"] .filterbar > summary .fb-ico { color: #c7c9ff; }
.filterbar > summary .fb-title { font-weight: 800; font-size: 15px; }
.filterbar > summary .fb-count { font-size: 11.5px; font-weight: 800; color: #fff; background: var(--accent);
  padding: 1px 9px; border-radius: 999px; }
.filterbar > summary .fb-sub { color: var(--text-3); font-size: 12.5px; margin-left: 2px; }
.filterbar > summary .fb-chevron { margin-left: auto; color: var(--text-3); transition: transform var(--transition); font-size: 13px; }
.filterbar[open] > summary .fb-chevron { transform: rotate(180deg); }
.filterbar[open] > summary { border-bottom: 1px solid var(--border); }
.filterbar-body { padding: 18px; }

/* responsive field grid — generous min width so dropdowns breathe */
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.filter-grid .field { margin: 0; min-width: 0; }
.filter-grid .field.col-2 { grid-column: span 2; }
@media (max-width: 560px) { .filter-grid { grid-template-columns: 1fr; } .filter-grid .field.col-2 { grid-column: span 1; } }
.filter-grid .field > label { font-size: 11.5px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.filter-grid .field.exclude > label { color: var(--expense); }

/* amount range: two inputs sharing one field */
.amount-range { display: flex; align-items: center; gap: 8px; }
.amount-range .input { text-align: right; }
.amount-range .sep { color: var(--text-3); font-weight: 700; flex-shrink: 0; }

.filter-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px;
  padding-top: 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.filter-actions .grow { flex: 1; }

/* ---- multi-select ---- */
.ms { position: relative; }
.ms-trigger { width: 100%; min-height: 44px; text-align: left; cursor: pointer; display: flex;
  align-items: center; gap: 8px; padding: 6px 34px 6px 8px; background-image: none; }
.ms-trigger .ms-caret { position: absolute; right: 13px; top: 50%; transform: translateY(-50%);
  width: 12px; height: 8px; pointer-events: none;
  background: no-repeat center / contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  transition: transform var(--transition); }
.ms.open .ms-trigger { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.ms.open .ms-trigger .ms-caret { transform: translateY(-50%) rotate(180deg); }

.ms-chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; min-width: 0; flex: 1; }
.ms-ph { color: var(--text-3); padding: 3px 4px; }
.ms-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  padding: 3px 4px 3px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-700); border: 1px solid transparent; }
[data-theme="dark"] .ms-chip { color: #c7c9ff; }
.ms-chip.exclude { background: var(--expense-soft); color: var(--expense); }
.ms-chip-ico { font-size: 13px; }
.ms-chip-t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.ms-chip .ms-x { width: 17px; height: 17px; border-radius: 50%; display: grid; place-items: center;
  font-size: 10px; cursor: pointer; background: rgba(0,0,0,.08); flex-shrink: 0; transition: var(--transition); }
.ms-chip .ms-x:hover { background: var(--expense); color: #fff; }

/* multi-select options: checkbox marker */
.ms-option { align-items: center; }
.ms-option .ms-check { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border-strong);
  flex-shrink: 0; display: grid; place-items: center; transition: var(--transition); }
.ms-option .ms-check::after { content: "✓"; font-size: 11px; font-weight: 900; color: #fff; opacity: 0; }
.ms-option.selected { color: var(--text); font-weight: 600; background: var(--accent-soft); }
.ms-option.selected .ms-check { background: var(--accent); border-color: var(--accent); }
.ms-option.selected .ms-check::after { opacity: 1; }
.ms-option.highlighted { background: var(--surface-3); }
.ms-option.selected.highlighted { background: var(--accent-soft); }

/* active-filter chip row (shown on the collapsed bar) */
.active-filters { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 18px 14px; }
.active-filters .af { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  background: var(--surface-3); color: var(--text-2); padding: 4px 11px; border-radius: 999px; }
.active-filters .af b { color: var(--text); font-weight: 700; }
