:root {
  --bg: #f3f5fa;
  --panel: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --soft: #f1f5f9;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --occasional: #f59e0b;
  --up: #dc2626;
  --down: #059669;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 2px 8px rgba(15, 23, 42, 0.04);
  font-family: "Segoe UI", "Rubik", "Assistant", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* ----- top bar ----- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 40px; height: 40px; flex: none; filter: drop-shadow(0 4px 10px rgba(79, 70, 229, 0.3)); }
.brand-text { display: flex; flex-direction: column; }
.brand h1 { font-size: 22px; font-weight: 800; letter-spacing: 0.3px; line-height: 1.2; }
.topbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
@media (max-width: 1100px) { .topbar { position: static; } }

main { max-width: 1320px; margin: 0 auto; padding: 22px 24px 56px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.grid.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 960px) { .grid.two { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  min-width: 0;
}
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; margin-bottom: 14px; }
.panel-head h2 { font-size: 16px; }
.empty { text-align: center; padding: 56px 20px; }

.banner, .toast {
  max-width: 1272px;
  margin: 14px auto 0;
  padding: 10px 16px;
  border-radius: 10px;
}
.banner { background: #fee2e2; color: #991b1b; }
.toast { background: #dcfce7; color: #166534; }

/* ----- buttons & chips ----- */
.btn {
  font: inherit;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 16px;
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--soft); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn.icon { width: 44px; height: 44px; padding: 0; font-size: 20px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.chip:hover { background: var(--soft); }
.chip.active { background: var(--primary-soft); border-color: #c7d2fe; color: #3730a3; font-weight: 600; }
.chip.ghost { border-style: dashed; color: var(--muted); }
.chip.ghost:hover { color: var(--text); }

/* ----- trend chart ----- */
.chart svg { display: block; width: 100%; height: auto; direction: rtl; }
.chart .axis { stroke: var(--border); }
.chart .bar { cursor: pointer; outline: none; }
.chart .seg { transition: fill 0.15s; }
.chart .seg.fixed { fill: #c7d2fe; }
.chart .seg.occasional { fill: #fde68a; }
.chart .bar:hover .seg.fixed, .chart .bar:focus .seg.fixed { fill: #a5b4fc; }
.chart .bar:hover .seg.occasional, .chart .bar:focus .seg.occasional { fill: #fcd34d; }
.chart .bar.selected .seg.fixed { fill: var(--primary); }
.chart .bar.selected .seg.occasional { fill: var(--occasional); }
.chart .bar.open .seg.fixed { fill: #e0e7ff; }
.chart .bar.open .seg.occasional { fill: #fef3c7; }
.chart .bar.open.selected .seg.fixed { fill: #a5b4fc; }
.chart .bar.open.selected .seg.occasional { fill: #fcd34d; }
.chart .outline { fill: none; }
.chart .bar.open .outline { stroke: #818cf8; stroke-dasharray: 5 4; }
.chart text { text-anchor: middle; font-size: 13px; fill: var(--muted); }
.chart .value { fill: var(--text); font-weight: 600; }
.chart .seg-value { font-size: 11px; font-weight: 600; pointer-events: none; }
.chart .seg-value.fixed { fill: #3730a3; }
.chart .seg-value.occasional { fill: #92400e; }
.chart .bar.selected .seg-value.fixed { fill: #fff; }
.chart .bar.selected .seg-value.occasional { fill: #78350f; }
.chart .bar.selected .label { fill: var(--primary); font-weight: 700; }
.chart .hint { font-size: 11px; }
.chart .avg-line { stroke: #64748b; stroke-width: 1.5; stroke-dasharray: 6 5; }
.chart .avg-label { text-anchor: end; fill: #475569; font-size: 12px; }
.legend { display: flex; gap: 14px; margin-inline-end: auto; color: var(--muted); font-size: 13px; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.swatch.fixed { background: var(--primary); }
.swatch.occasional { background: var(--occasional); }

/* ----- month header & KPIs ----- */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.month-title { text-align: center; }
.month-title h2 { font-size: 24px; }
.badge {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 1px 10px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
}

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 23px; font-weight: 700; margin-top: 2px; }
.kpi-note { color: var(--muted); font-size: 12.5px; }
.kpi.up .kpi-value { color: var(--up); }
.kpi.down .kpi-value { color: var(--down); }
.kpi.fixed { border-top: 4px solid var(--primary); }
.kpi.occasional { border-top: 4px solid var(--occasional); }

/* ----- fixed / occasional ----- */
.split-bar { display: flex; height: 10px; margin-bottom: 16px; border-radius: 5px; overflow: hidden; background: var(--soft); }
.split-bar > span { display: block; height: 100%; }
.split-bar .fixed { background: var(--primary); }
.split-bar .occasional { background: var(--occasional); }
.split-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 760px) { .split-groups { grid-template-columns: 1fr; } }
.split-group { border: 1px solid var(--border); border-top: 4px solid var(--primary); border-radius: 12px; padding: 12px 14px; }
.split-group.occasional { border-top-color: var(--occasional); }
.split-group.active { background: #fafbff; box-shadow: 0 0 0 2px #c7d2fe; }
.split-group.occasional.active { background: #fffdf5; box-shadow: 0 0 0 2px #fde68a; }
.split-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 2px 10px;
  width: 100%;
  padding: 0 0 10px;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: start;
  cursor: pointer;
}
.split-head:hover .split-title { color: var(--primary); }
.split-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.split-total { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.split-meta { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; }
.split-list { list-style: none; margin: 0; padding: 0; }
.split-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--soft);
  font-size: 14px;
}
.split-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split-reason { padding: 0 8px; border-radius: 999px; background: var(--soft); color: #475569; font-size: 12px; white-space: nowrap; }
.split-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.split-list li.split-more { display: block; color: var(--muted); font-size: 13px; }

/* ----- insights ----- */
.insights { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.insights li {
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 10px;
  border-inline-start: 4px solid var(--primary);
}

/* ----- categories ----- */
.category-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 560px) { .category-layout { grid-template-columns: 1fr; } }
.donut svg { width: 190px; height: 190px; display: block; margin: 0 auto; }
.donut .arc, .donut .arc-bg { fill: none; stroke-width: 26; }
.donut .arc-bg { stroke: var(--soft); }
.donut text { text-anchor: middle; }
.donut .donut-total { font-size: 18px; font-weight: 700; fill: var(--text); }
.donut .donut-caption { font-size: 12px; fill: var(--muted); }

.category-list { display: flex; flex-direction: column; gap: 2px; max-height: 380px; overflow-y: auto; }
.category-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto 42px 92px;
  align-items: center;
  gap: 4px 10px;
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: inherit;
  text-align: start;
  background: none;
  border: 0;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
}
.category-row:hover { background: var(--soft); }
.category-row.active { background: var(--primary-soft); }
.category-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.category-share { color: var(--muted); font-size: 13px; text-align: end; }
.delta { font-size: 12px; text-align: end; white-space: nowrap; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.category-row .track { grid-column: 2 / -1; }

.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.swatch.small { width: 9px; height: 9px; margin-inline-end: 6px; vertical-align: middle; }
.track { display: block; height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; }
.track > span { display: block; height: 100%; border-radius: 3px; background: var(--primary); }

/* ----- merchants ----- */
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: rank; }
.rank-list li { counter-increment: rank; display: grid; grid-template-columns: 26px minmax(0, 1fr); column-gap: 8px; }
.rank-list li::before {
  content: counter(rank);
  grid-row: span 3;
  align-self: start;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  line-height: 22px;
}
.rank-main { display: flex; justify-content: space-between; gap: 10px; }
.rank-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-sub { color: var(--muted); font-size: 12.5px; }

/* ----- tables ----- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; text-align: start; border-bottom: 1px solid var(--soft); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; background: #f8fafc; white-space: nowrap; }
th.num, td.num { text-align: end; }
table.mini th, table.mini td { padding: 7px 8px; }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: 0; background: #f8fafc; }

.table-head { align-items: center; }
.table-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.table-tools input {
  font: inherit;
  width: 280px;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.table-wrap { max-height: 620px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.transactions thead th { position: sticky; top: 0; z-index: 1; }
.transactions tfoot td { position: sticky; bottom: 0; }
.transactions th.sortable { cursor: pointer; user-select: none; }
.transactions th.sortable:hover { color: var(--text); }
.transactions td.desc { min-width: 200px; }
.transactions tr:hover td { background: #fafbff; }
.transactions tr.refund td.num { color: var(--down); }
.empty-row { text-align: center; padding: 28px; }

.tag {
  display: inline-block;
  margin: 1px 0 1px 4px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--soft);
  color: #475569;
  white-space: nowrap;
}
.tag.refund { background: #dcfce7; color: #166534; }
.tag.standing_order { background: #fef3c7; color: #92400e; }
.tag.subscription { background: #fce7f3; color: #9d174d; }
.tag.foreign { background: #e0f2fe; color: #075985; }
.tag.cash { background: #f3e8ff; color: #6b21a8; }
.tag.installments { background: #e0e7ff; color: #3730a3; }
.tag.manual { background: #ecfccb; color: #3f6212; }

.edit-category, .edit-manual {
  border: 0;
  background: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 6px;
  font-size: 14px;
}
.edit-category:hover, .edit-manual:hover { color: var(--primary); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.kind-options.inline { flex-direction: row; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 14px; }
.kind-options.inline legend { margin-bottom: 6px; }
.custom-mark { color: var(--primary); font-size: 10px; margin-inline-start: 4px; vertical-align: middle; }
.kind-pill {
  font: inherit;
  font-size: 12.5px;
  padding: 1px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.kind-pill.fixed { background: #e0e7ff; color: #3730a3; }
.kind-pill.occasional { background: #fef3c7; color: #92400e; }
.kind-pill:hover, .kind-pill:focus-visible { border-color: currentColor; }

/* ----- commitments ----- */
.commit-list { display: flex; flex-direction: column; gap: 6px; }
.commit-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 90px; align-items: center; gap: 10px; font-size: 14px; }
.commit-row .track { height: 8px; }
.commit-row .track > span { background: #818cf8; }

/* ----- dialogs ----- */
.dialog {
  width: min(460px, 94vw);
  border: 0;
  border-radius: 16px;
  padding: 22px 24px;
  color: var(--text);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.3);
}
.dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.dialog h2 { font-size: 18px; margin-bottom: 14px; }
.dialog label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; color: var(--muted); font-size: 14px; }
.dialog input, .dialog select {
  font: inherit;
  color: var(--text);
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.dialog input:focus, .dialog select:focus, .table-tools input:focus { outline: 2px solid #c7d2fe; border-color: #a5b4fc; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.kind-options { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; border: 0; }
.dialog .kind-options label { flex-direction: row; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: 15px; }
.dialog .kind-options input { margin: 0; padding: 0; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.status { min-height: 22px; font-size: 14px; white-space: pre-line; }
.status.error { color: var(--up); }
.status.ok { color: var(--down); }
.status.busy::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-inline-end: 8px;
  border: 2px solid #c7d2fe;
  border-top-color: var(--primary);
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- tabs ----- */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; background: var(--soft); padding: 4px; border-radius: 12px; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.tab-icon { display: none; }
.narrow-only { display: none; }
.count {
  min-width: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #f59e0b;
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}
.count.alert { background: var(--up); }

/* ----- smart analysis ----- */
.insights-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  padding: 22px 24px;
  border-radius: var(--radius);
  color: #e0e7ff;
  background:
    radial-gradient(520px 260px at 92% 0%, rgba(129, 140, 248, 0.5), transparent 62%),
    radial-gradient(420px 240px at 0% 100%, rgba(245, 158, 11, 0.22), transparent 62%),
    linear-gradient(135deg, #1e1b4b, #312e81 60%, #4338ca);
  box-shadow: var(--shadow);
}
.insights-hero-text { display: flex; align-items: flex-start; gap: 14px; max-width: 660px; }
.insights-hero h2 { margin-bottom: 4px; font-size: 22px; font-weight: 800; color: #fff; }
.insights-hero p { margin: 0; font-size: 14.5px; line-height: 1.6; color: #c7d2fe; }
.insights-hero-icon { flex: none; width: 46px; height: 46px; padding: 10px; border-radius: 13px; background: rgba(255, 255, 255, 0.12); fill: #fde68a; }
.insights-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; max-width: 460px; }
.summary-chip { padding: 5px 13px; border-radius: 999px; font-size: 13.5px; color: #fff; background: rgba(255, 255, 255, 0.14); white-space: nowrap; }
.summary-chip strong { margin-inline-end: 3px; font-size: 15px; }
.summary-chip.sev-alert { background: #ef4444; }
.summary-chip.sev-warning { background: #f59e0b; color: #451a03; }
.summary-chip.sev-good { background: #10b981; }
.insights-headline { flex-basis: 100%; text-align: end; font-size: 14px; color: #fde68a; }
.insights-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 14px; }
.insight-card {
  --sev: #6366f1;
  --sev-soft: #e0e7ff;
  --sev-ink: #3730a3;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--sev);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.insight-card.sev-alert { --sev: #ef4444; --sev-soft: #fee2e2; --sev-ink: #b91c1c; }
.insight-card.sev-warning { --sev: #f59e0b; --sev-soft: #fef3c7; --sev-ink: #92400e; }
.insight-card.sev-good { --sev: #10b981; --sev-soft: #dcfce7; --sev-ink: #166534; }
.insight-icon svg {
  display: block;
  width: 42px;
  height: 42px;
  padding: 10px;
  border-radius: 12px;
  background: var(--sev-soft);
  fill: none;
  stroke: var(--sev-ink);
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.insight-tag { margin-bottom: 2px; font-size: 12px; font-weight: 700; color: var(--sev-ink); }
.insight-main h3 { margin: 0 0 4px; font-size: 16px; line-height: 1.35; }
.insight-main p { margin: 0 0 6px; font-size: 14px; line-height: 1.55; color: #334155; }
.insight-main .insight-tip { font-size: 13px; color: var(--muted); }
.insight-tip::before { content: "💡 "; }
.insight-impact { min-width: 84px; text-align: center; white-space: nowrap; }
.insight-impact strong { display: block; font-size: 18px; font-variant-numeric: tabular-nums; color: var(--sev-ink); }
.insight-impact span { font-size: 12px; color: var(--muted); }
.history-chart { margin: 4px 0 8px; }
.history-chart svg { display: block; width: 100%; max-width: 280px; height: 48px; }
.history-chart rect { fill: #cbd5e1; }
.history-chart rect.now { fill: var(--sev); }
.history-chart .range { font-size: 11.5px; color: var(--muted); }
.link-btn { padding: 0; border: 0; background: none; font: inherit; font-size: 13.5px; font-weight: 700; color: var(--primary); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.insights-note { margin: 0; text-align: center; }
@media (max-width: 560px) {
  .insight-card { grid-template-columns: auto minmax(0, 1fr); }
  .insight-impact { grid-column: 2; text-align: start; }
}

/* ----- approvals ----- */
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }

.approver-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.approver-intro { flex: 1 1 260px; }
.approver-intro h2 { font-size: 16px; }
.approver-intro p { margin: 4px 0 0; }
.approver-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.approver-form input {
  font: inherit;
  color: var(--text);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 190px;
}
.approver-form #approver-card { width: 120px; letter-spacing: 2px; }
.approver-form .status { flex-basis: 100%; min-height: 0; }
.approver-current { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 15px; }

.progress { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--soft); }
.progress span { display: block; height: 100%; }
.progress .approved { background: #10b981; }
.progress .flagged { background: #f59e0b; }
.progress-legend { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 10px; font-size: 14px; }
.progress-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 6px; }
.progress-legend strong { font-variant-numeric: tabular-nums; }

.approval-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.approval-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.approval-filters select, .approval-filters input {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.approval-filters input { width: 220px; }
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: #3730a3;
  font-weight: 600;
}

table.approvals td { vertical-align: top; }
table.approvals thead th { position: sticky; top: 0; z-index: 1; }
table.approvals .select-col { width: 34px; }
table.approvals tr.st-approved td { background: #f6fef9; }
table.approvals tr.st-flagged td { background: #fffbeb; }
table.approvals .note-input {
  font: inherit;
  font-size: 14px;
  width: 100%;
  min-width: 190px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
table.approvals .note-input:focus { outline: 2px solid #c7d2fe; border-color: #a5b4fc; }
.status-chip { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.status-chip.pending { background: var(--soft); color: #475569; }
.status-chip.approved { background: #dcfce7; color: #166534; }
.status-chip.flagged { background: #fef3c7; color: #92400e; }
.decision-meta { margin-top: 2px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.row-actions { display: flex; gap: 6px; margin-top: 6px; white-space: nowrap; }
.row-actions .approve.active { background: #10b981; border-color: #10b981; color: #fff; }
.row-actions .flag.active { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.tag.approval-approved { background: #dcfce7; color: #166534; }
.tag.approval-flagged { background: #fef3c7; color: #92400e; }

/* ----- cards (accounts) ----- */
.accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.account-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfcfe;
}
.account-head { display: flex; align-items: center; gap: 10px; }
.account-head h3 { margin: 0; font-size: 16px; }
.account-details { font-size: 14px; line-height: 1.7; }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 6px; }
.provider-badge {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  background: #64748b;
  white-space: nowrap;
}
.provider-badge.p-cal { background: #2563eb; }
.provider-badge.p-max { background: #e11d48; }
.provider-badge.p-isracard { background: #1e3a8a; }
.provider-badge.p-amex { background: #0e7490; }
.field-hint { font-size: 12px; color: var(--muted); }

/* ----- removing old cards from the card list ----- */
.card-groups { display: flex; flex-direction: column; gap: 14px; }
.card-group h3 { margin: 0 0 6px; font-size: 14px; }
.card-rows { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.card-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 12px; background: #fbfcfe; }
.card-row-text { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.card-row-text strong { font-size: 15px; overflow-wrap: anywhere; }
.card-row .btn { flex: none; min-width: 72px; }
.card-row.is-hidden { background: var(--soft); border-style: dashed; }
.card-row.is-hidden strong { color: var(--muted); text-decoration: line-through; }

/* ----- login page ----- */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  background: #f6f7fb;
}
.auth-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 56px clamp(28px, 5vw, 76px);
  color: #e0e7ff;
  background:
    radial-gradient(620px 420px at 88% 8%, rgba(129, 140, 248, 0.5), transparent 62%),
    radial-gradient(520px 380px at 8% 92%, rgba(245, 158, 11, 0.28), transparent 62%),
    linear-gradient(150deg, #1e1b4b 0%, #312e81 52%, #4338ca 100%);
}
.auth-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 85%);
  mask-image: linear-gradient(to bottom, #000, transparent 85%);
  pointer-events: none;
}
.auth-hero-inner { position: relative; max-width: 560px; display: flex; flex-direction: column; gap: 22px; }
.logo-lockup { display: flex; align-items: center; gap: 12px; }
.logo { width: 54px; height: 54px; flex: none; filter: drop-shadow(0 10px 22px rgba(99, 102, 241, 0.6)); }
.logo-name { font-size: 32px; font-weight: 800; color: #fff; letter-spacing: 0.5px; }
.hero-title { margin: 8px 0 0; font-size: clamp(30px, 3.3vw, 46px); line-height: 1.2; font-weight: 800; color: #fff; }
.hero-title em {
  font-style: normal;
  background: linear-gradient(90deg, #fbbf24, #fde68a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub { margin: 0; max-width: 500px; font-size: 17px; line-height: 1.7; color: #c7d2fe; }
.hero-card {
  max-width: 460px;
  padding: 16px 18px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 24px 60px rgba(15, 12, 60, 0.45);
  backdrop-filter: blur(8px);
}
.hero-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; font-size: 13px; color: #e0e7ff; }
.hero-legend { display: flex; gap: 14px; color: #c7d2fe; }
.hero-legend i { display: inline-block; width: 9px; height: 9px; margin-inline-end: 6px; border-radius: 3px; }
.hero-legend .fixed, .hero-bar .fixed { background: #a5b4fc; }
.hero-legend .occasional, .hero-bar .occasional { background: #fbbf24; }
.hero-bars { display: flex; align-items: flex-end; gap: 12px; height: 124px; border-bottom: 1px solid rgba(255, 255, 255, 0.2); }
.hero-bar {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transform-origin: bottom;
  animation: hero-grow 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i) * 80ms + 250ms);
}
.hero-bar span { display: block; }
.hero-bar .occasional { border-radius: 6px 6px 0 0; }
.hero-features { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 16px; }
.hero-features li { display: flex; align-items: flex-start; gap: 12px; }
.hero-features svg {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 9px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  fill: none;
  stroke: #fde68a;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hero-features strong { display: block; font-size: 15.5px; color: #fff; }
.hero-features span { font-size: 13.5px; color: #c7d2fe; }

.auth-main { max-width: none; margin: 0; padding: 40px 24px; display: grid; place-items: center; }
.auth-card {
  width: min(430px, 100%);
  padding: 36px 34px 24px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 30px 70px rgba(30, 27, 75, 0.13), 0 2px 6px rgba(30, 27, 75, 0.05);
  animation: auth-rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.auth-form { animation: auth-fade 0.3s ease both; }
.auth-form h2 { margin: 0 0 6px; font-size: 26px; font-weight: 800; }
.auth-lead { margin: 0 0 24px; font-size: 14.5px; color: var(--muted); }
.auth-form label { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; font-size: 14px; font-weight: 600; color: #334155; }
.auth-form input {
  width: 100%;
  font: inherit;
  font-size: 15.5px;
  font-weight: 400;
  color: var(--text);
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.auth-form input::placeholder { color: #a8b3c4; }
.auth-form input:hover { border-color: #cbd5e1; }
.auth-form input:focus { outline: none; border-color: #818cf8; background: #fff; box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15); }
.field-note { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.field-note.ok { color: var(--down); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 16px; padding: 4px; border-radius: 12px; background: var(--soft); }
.auth-form .segmented label { position: relative; flex-direction: row; margin: 0; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { width: 100%; padding: 9px 8px; border-radius: 9px; font-size: 14px; font-weight: 600; text-align: center; color: var(--muted); }
.segmented input:checked + span { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 2px solid #a5b4fc; }
.password-field { position: relative; display: block; }
.password-field input { padding-inline-end: 48px; }
.toggle-password {
  position: absolute;
  inset-inline-end: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
}
.toggle-password:hover, .toggle-password:focus-visible { background: var(--soft); color: var(--primary); }
.toggle-password svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.toggle-password .slash { display: none; }
.toggle-password[aria-pressed="true"] .slash { display: inline; }
.btn.cta {
  width: 100%;
  margin-top: 4px;
  padding: 13px 18px;
  border: 0;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #4f46e5 55%, #4338ca);
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn.cta:hover:not(:disabled) {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(79, 70, 229, 0.42);
}
.btn.cta:focus-visible { outline: 3px solid #c7d2fe; outline-offset: 2px; }
.auth-switch { margin: 18px 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.auth-switch a { font-weight: 700; color: var(--primary); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }
.auth-trust {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 22px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--soft);
  font-size: 12.5px;
  color: var(--muted);
}
.auth-trust svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; }
@keyframes hero-grow { from { transform: scaleY(0); } }
@keyframes auth-rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes auth-fade { from { opacity: 0; transform: translateY(6px); } }
@media (max-width: 900px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { padding: 28px 22px 32px; }
  .auth-hero-inner { gap: 12px; }
  .hero-sub, .hero-card, .hero-features { display: none; }
  .hero-title { font-size: 24px; }
  .logo { width: 44px; height: 44px; }
  .logo-name { font-size: 26px; }
  .auth-main { padding: 24px 14px 40px; place-items: start center; }
  .auth-card { padding: 28px 22px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-page *, .auth-page *::before, .auth-page *::after { animation: none !important; transition: none !important; }
}

/* ----- signed-in user & users admin ----- */
.user-menu { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.user-menu-items { display: flex; align-items: center; gap: 8px; }
.user-menu .btn { padding: 5px 12px; font-size: 13.5px; }
.avatar { display: none; }
.users-table td { vertical-align: middle; }
.users-table .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.users-table .btn { padding: 4px 10px; font-size: 13px; }
.role-chip, .user-status { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 12.5px; white-space: nowrap; }
.role-chip { background: var(--primary-soft); color: #3730a3; }
.role-chip.member { background: var(--soft); color: #475569; }
.user-status.active { background: #dcfce7; color: #166534; }
.user-status.pending { background: #fef3c7; color: #92400e; }
.user-status.blocked { background: #fee2e2; color: #991b1b; }
tr.pending-user td { background: #fffbeb; }
.secret { font-family: Consolas, "Courier New", monospace; font-size: 18px; letter-spacing: 1px; direction: ltr; }

/* ----- family ----- */
.member-list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.member { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: #fbfcfe; }
.member.pending { border-color: #fde68a; background: #fffbeb; }
.member-avatar { display: grid; flex: none; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--primary-soft); color: #3730a3; font-weight: 700; }
.member-text { display: flex; flex: 1 1 200px; flex-direction: column; min-width: 0; }
.member-text strong { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.member-text bdi { overflow-wrap: anywhere; }
.member-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.family-leave { margin-top: 12px; }
.invite-box { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.invite-code {
  padding: 6px 16px;
  border: 1px dashed #a5b4fc;
  border-radius: 10px;
  background: var(--primary-soft);
  color: #3730a3;
  font-family: Consolas, "Courier New", monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
  user-select: all;
}
.admin-subtitle { margin: 0 0 8px; font-size: 14px; }
#pending-families:not(:empty) { margin-bottom: 16px; }
.family-gate { width: 100%; max-width: 780px; margin: 0 auto; }
.family-gate h2 { margin-bottom: 8px; font-size: 22px; }
.gate-text { margin: 0 0 16px; line-height: 1.6; color: #334155; }
.gate-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.gate-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.gate-option { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; background: #fbfcfe; }
.gate-option h3 { margin: 0; font-size: 16px; }
.gate-option p { margin: 0; }
.gate-option label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.gate-option input { font: inherit; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--text); }
.gate-option input:focus { outline: 2px solid #c7d2fe; border-color: #a5b4fc; }
.gate-option .btn { margin-top: auto; }
#gate-error:not(:empty) { margin-top: 12px; }

/* ----- forecast and budget ----- */
.forecast-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 20px; margin-bottom: 12px; }
.forecast-total { display: flex; flex-direction: column; }
.forecast-total strong { font-size: 30px; line-height: 1.15; }
.forecast-vs { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.forecast-vs .up, .budget-left.up { color: var(--up); }
.forecast-vs .down { color: var(--down); }
.forecast-bar { position: relative; display: flex; height: 14px; border-radius: 999px; background: var(--soft); }
.forecast-bar .seg:first-child { border-start-start-radius: 999px; border-end-start-radius: 999px; }
.forecast-bar .seg:last-of-type { border-start-end-radius: 999px; border-end-end-radius: 999px; }
.seg.known, .dot.known { background: var(--primary); }
.seg.bills, .dot.bills { background: #a5b4fc; }
.seg.installments, .dot.installments { background: #38bdf8; }
.seg.everyday, .dot.everyday { background: repeating-linear-gradient(135deg, #f59e0b 0 5px, #fcd34d 5px 10px); }
.budget-mark { position: absolute; top: -5px; bottom: -5px; width: 3px; margin-inline-start: -1px; border-radius: 2px; background: var(--up); }
.forecast-parts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 18px; margin: 14px 0 4px; padding: 0; list-style: none; }
.forecast-parts li { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; }
.forecast-parts .part-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.forecast-parts strong { white-space: nowrap; }
.dot { flex: none; width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; }
.forecast-note { margin: 6px 0 0; }
.budget-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 18px; margin: 0; padding: 0; list-style: none; }
.budget-line { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; border-radius: 10px; }
.budget-line[data-category] { cursor: pointer; }
.budget-line[data-category]:hover { background: var(--soft); }
.budget-line.whole { grid-column: 1 / -1; padding-bottom: 12px; border-bottom: 1px solid var(--border); border-radius: 0; }
.budget-row { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.budget-name { font-weight: 600; }
.budget-line .track { height: 8px; }
.budget-line.whole .track { height: 12px; }
.budget-line .track > span { background: var(--down); }
.budget-line.near .track > span { background: #f59e0b; }
.budget-line.over .track > span { background: var(--up); }
.budget-line.over .budget-left { color: var(--up); font-weight: 600; }
.budget-empty { margin: 0; }
.budget-tools { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 8px; }
.budget-categories { display: flex; flex-direction: column; gap: 6px; max-height: 44vh; overflow: auto; padding-inline-end: 4px; }
.dialog .budget-category { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; margin: 0; color: var(--text); font-size: 14.5px; }
.budget-category > span { display: flex; flex-direction: column; min-width: 0; }
.dialog .budget-category input { flex: none; width: 110px; }

/* ----- the checking account ----- */
.bank-balance { display: flex; flex-direction: column; margin: 4px 0; }
.bank-balance strong { font-size: 22px; }
.bank-balance strong.negative { color: var(--up); }
.bank-flow-title { margin: 18px 0 8px; font-size: 15px; }
.cash-flow td.up { color: var(--up); }
.cash-flow td.down { color: var(--down); }
.bank-howto { margin: 0 0 14px; font-size: 14px; }
.bank-howto summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.bank-howto ol { margin: 8px 0; padding-inline-start: 20px; line-height: 1.7; }
.bank-howto p { margin: 0; }
.bank-result { padding: 10px 12px; border-radius: 10px; background: #f0fdf4; color: #14532d; font-size: 14px; line-height: 1.6; }
.bank-result ul { margin: 6px 0 0; padding-inline-start: 18px; }

/* ----- subscriptions and recurring charges ----- */
.ai-text { margin: 0 0 12px; line-height: 1.7; }
.ai-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.ai-tools select, .ai-ask input { font: inherit; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--text); }
.ai-ask { display: flex; gap: 8px; margin-bottom: 8px; }
.ai-ask input { flex: 1; min-width: 0; }
.ai-ask input:focus, .ai-tools select:focus { outline: 2px solid #c7d2fe; border-color: #a5b4fc; }
.ai-suggestions { margin-bottom: 8px; }
.ai-answer { margin-top: 8px; padding: 14px 16px; border: 1px solid #e0e7ff; border-radius: 12px; background: linear-gradient(135deg, #eef2ff, #faf5ff); line-height: 1.7; }
.ai-answer-head { margin-bottom: 6px; font-weight: 700; color: #3730a3; }
.ai-answer p { margin: 0 0 8px; }
.ai-answer ul { margin: 0 0 8px; padding-inline-start: 20px; }
.ai-disable { display: block; margin-top: 12px; font-weight: 400; color: var(--muted); }
.ai-preview { margin-top: 12px; }
.ai-preview summary { cursor: pointer; color: var(--primary); font-size: 13.5px; font-weight: 600; }
.ai-preview pre { max-height: 320px; overflow: auto; margin: 6px 0 0; padding: 10px; border-radius: 10px; background: var(--soft); font-size: 12px; white-space: pre-wrap; word-break: break-word; text-align: left; }
.recurring-intro { margin: -4px 0 14px; }
.recurring-group { margin-bottom: 16px; }
.recurring-group h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 0 6px; font-size: 15px; }
.recurring-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: 12px; }
.recurring-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px 16px; padding: 10px 14px; border-top: 1px solid var(--border); }
.recurring-row:first-child { border-top: 0; }
.recurring-row.stopped { background: #fafafa; }
.recurring-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recurring-main strong { overflow-wrap: anywhere; }
.recurring-amounts { display: flex; flex-direction: column; align-items: flex-end; text-align: end; white-space: nowrap; }
.tag.price-up { background: #fee2e2; color: #991b1b; }
.tag.price-down { background: #dcfce7; color: #166534; }
.recurring-stopped { margin-top: 8px; }
.recurring-stopped summary { cursor: pointer; font-weight: 600; }
.recurring-stopped p { margin: 8px 0; }

/* ----- refreshing several accounts ----- */
.credential-group { margin: 0 0 10px; padding: 8px 12px 0; border: 1px solid var(--border); border-radius: 12px; }
.credential-group legend { padding: 0 6px; font-weight: 600; font-size: 14px; }
.credential-group label { margin-bottom: 10px; }
.refresh-steps { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.refresh-steps li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; }
.refresh-steps li.current { border-color: #a5b4fc; background: var(--primary-soft); }
.step-icon { flex: none; width: 20px; font-weight: 700; text-align: center; color: var(--muted); }
.step-done .step-icon { color: var(--down); }
.step-error .step-icon { color: var(--up); }
.step-running .step-icon { color: var(--primary); }
.step-text { display: flex; flex-direction: column; min-width: 0; }

/* ----- two-step verification ----- */
.notify-kinds { display: flex; flex-direction: column; gap: 12px; margin: 0 0 12px; }
.dialog .notify-kind { flex-direction: row; align-items: flex-start; gap: 10px; margin: 0; color: var(--text); font-size: 15px; }
.dialog .notify-kind input { flex: none; margin: 4px 0 0; padding: 0; }
.notify-kind > span { display: flex; flex-direction: column; gap: 2px; }
.btn.danger { background: var(--up); border-color: var(--up); color: #fff; }
.btn.danger:hover:not(:disabled) { background: #b91c1c; }
.twofa-dialog p { margin: 0 0 10px; line-height: 1.6; }
.twofa-steps { margin: 0 0 12px; padding-inline-start: 20px; line-height: 1.6; }
.twofa-steps li { margin-bottom: 10px; }
.twofa-qr { width: 196px; height: 196px; margin: 10px auto; border: 1px solid var(--border); border-radius: 12px; background: #fff; overflow: hidden; }
.twofa-qr svg { display: block; width: 100%; height: 100%; }
.twofa-link { display: none; margin: 0 auto 8px; }
.twofa-key summary { cursor: pointer; color: var(--primary); font-size: 13.5px; font-weight: 600; }
.twofa-key .secret { margin: 6px 0 0; font-size: 16px; word-spacing: 4px; user-select: all; }
.twofa-state { color: var(--down); font-weight: 600; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.notify-admin { margin: -4px 0 14px; }

/* ----- the Gmail account the emails are sent from (site admins) ----- */
.mail-account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--soft);
}
.mail-account:empty { display: none; }
.mail-account.ok { border-color: #bbf7d0; background: #f0fdf4; }
.mail-account.warn { border-color: #fde68a; background: #fffbeb; }
.mail-account-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mail-account-text strong { overflow-wrap: anywhere; }
.mail-account .status { min-height: 0; margin: 4px 0 0; }
.mail-dialog p { margin: 0 0 10px; line-height: 1.6; }
.mail-dialog a { color: var(--primary); font-weight: 600; }
.recovery-codes {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  justify-content: center;
  gap: 6px 28px;
  margin: 0 0 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--soft);
  font-family: Consolas, "Courier New", monospace;
  font-size: 16px;
  list-style: none;
  user-select: all;
}
.code-input { font-family: Consolas, "Courier New", monospace; font-size: 20px !important; letter-spacing: 3px; text-align: center; }
.twofa-badge { margin-inline-start: 4px; font-size: 12px; }

/* ----- phones ----- */
@media (max-width: 640px) {
  .twofa-link { display: flex; width: max-content; }
  .recurring-row { grid-template-columns: minmax(0, 1fr) auto; padding: 10px 12px; }
  .recurring-row .link-btn { grid-column: 1 / -1; justify-self: start; }
  .wide-only { display: none; }
  .narrow-only { display: inline; }

  /* top bar: logo, refresh and the user menu; under them, the card filter scrolls sideways */
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "brand refresh user" "cards cards cards";
    gap: 8px 10px;
    padding: 10px 14px;
    backdrop-filter: none; /* a filter would trap the fixed tab bar inside the header */
  }
  .topbar-actions { display: contents; }
  .brand { grid-area: brand; min-width: 0; gap: 8px; }
  .brand-logo { width: 34px; height: 34px; }
  .brand h1 { font-size: 19px; }
  #freshness { font-size: 11.5px; line-height: 1.3; }
  #refresh-button { grid-area: refresh; padding: 7px 12px; font-size: 14px; }
  #card-filter { grid-area: cards; flex-wrap: nowrap; margin: 0 -14px; padding: 2px 14px 4px; overflow-x: auto; scrollbar-width: none; }
  #card-filter::-webkit-scrollbar { display: none; }
  #card-filter .chip { flex: none; white-space: nowrap; }
  #manage-cards { position: sticky; inset-inline-end: 0; background: #fff; box-shadow: 12px 0 10px -6px #fff; }
  #manage-cards::before { content: ""; position: absolute; top: -2px; bottom: -4px; inset-inline-end: -15px; width: 15px; background: #fff; }
  .user-menu { grid-area: user; position: relative; }
  .avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--primary-soft);
    color: #3730a3;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
  }
  .user-menu-items {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    z-index: 30;
    flex-direction: column;
    align-items: stretch;
    min-width: 210px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  }
  .user-menu.open .user-menu-items { display: flex; }
  #user-name { padding: 0 4px 8px; border-bottom: 1px solid var(--soft); color: var(--text); font-weight: 600; }
  .user-menu .btn { padding: 9px 12px; font-size: 15px; text-align: start; }

  /* the tabs become an app-like bar at the bottom of the screen */
  .tabs {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 20;
    flex-wrap: nowrap;
    gap: 0;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    border-radius: 0;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.07);
  }
  .tab {
    position: relative;
    flex: 1 1 0;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    padding: 6px 2px;
    font-size: 11.5px;
  }
  .tab.active { background: none; box-shadow: none; }
  .tab-icon { display: block; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tab.active .tab-icon { stroke-width: 2.3; }
  .tab .count { position: absolute; top: 1px; inset-inline-start: calc(50% + 5px); min-width: 18px; padding: 0 5px; font-size: 11px; line-height: 18px; }

  main { padding: 12px 10px calc(84px + env(safe-area-inset-bottom)); }
  .banner, .toast { margin: 10px 10px 0; }
  .stack { gap: 12px; }
  .panel { padding: 14px; }
  .month-title h2 { font-size: 20px; }
  .btn.icon { width: 40px; height: 40px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 10px 12px; }
  .kpi-value { font-size: 19px; }
  .chip { padding: 7px 14px; }

  /* 16px fields: iPhones zoom into anything smaller */
  .dialog input, .dialog select, .auth-form input, .table-tools input, .approval-filters select, .approval-filters input,
  .approver-form input, table.approvals .note-input, .ai-tools select, .ai-ask input { font-size: 16px; }
  .table-tools { width: 100%; }
  .table-tools input { width: 100%; }
  .table-wrap { max-height: none; overflow: visible; border: 0; border-radius: 0; }
  #bank-flow .table-wrap { overflow-x: auto; }
  .cash-flow th, .cash-flow td { padding: 6px; font-size: 13px; }

  /* transactions: one card each - the place and the amount first, the details under them */
  table.transactions, table.transactions thead, table.transactions tbody, table.transactions tfoot { display: block; }
  table.transactions thead tr { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 6px; }
  table.transactions thead th { position: static; padding: 4px 11px; border: 1px solid var(--border); border-radius: 999px; background: #fff; font-size: 12.5px; }
  table.transactions thead th:not(.sortable) { display: none; }
  table.transactions thead th[aria-sort="ascending"], table.transactions thead th[aria-sort="descending"] { border-color: #c7d2fe; background: var(--primary-soft); color: #3730a3; }
  table.transactions tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
  table.transactions tbody tr::after { content: ""; order: 3; flex-basis: 100%; }
  table.transactions tbody td { order: 4; padding: 0; border: 0; font-size: 12.5px; color: var(--muted); }
  table.transactions tbody td.desc { order: 1; flex: 1 1 0; min-width: 0; font-size: 15px; font-weight: 600; color: var(--text); }
  table.transactions tbody td.num { order: 2; font-size: 15px; font-weight: 700; }
  table.transactions tbody td:empty { display: none; }
  table.transactions tbody td:last-child:not(.empty-row)::before { content: "כרטיס "; }
  table.transactions tbody td.empty-row { order: 1; flex: 1 1 100%; padding: 20px; font-size: 14px; }
  table.transactions .edit-category, table.transactions .edit-manual { padding: 4px 8px; margin: -4px 0; }
  table.transactions tfoot tr { display: flex; justify-content: space-between; padding: 10px 2px 0; }
  table.transactions tfoot td { position: static; padding: 0; border: 0; background: none; }
  table.transactions tfoot td:empty { display: none; }

  /* approvals: one card each, with large buttons */
  .approval-toolbar { flex-direction: column; align-items: stretch; }
  #approval-status-filter { flex-wrap: nowrap; margin: 0 -14px; padding: 2px 14px; overflow-x: auto; scrollbar-width: none; }
  #approval-status-filter::-webkit-scrollbar { display: none; }
  #approval-status-filter .chip { flex: none; }
  .approval-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .approval-filters input, #approval-export { grid-column: 1 / -1; width: 100%; }
  .approval-filters select { min-width: 0; }
  .approver-form label { flex: 1 1 140px; }
  .approver-form input, .approver-form #approver-card { width: 100%; }
  .approver-form .btn { flex: 1 1 100%; }
  table.approvals, table.approvals thead, table.approvals tbody { display: block; }
  table.approvals thead tr { display: flex; }
  table.approvals thead th { display: none; }
  table.approvals thead th.select-col { display: flex; align-items: center; gap: 8px; position: static; width: auto; padding: 0 6px 10px; background: none; font-weight: 400; }
  table.approvals thead th.select-col::after { content: "בחירת כל ההוצאות המוצגות"; }
  table.approvals tbody tr {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "select desc amount" ". meta card" ". note note" ". status status";
    gap: 4px 10px;
    padding: 12px 6px;
    border-bottom: 1px solid var(--border);
  }
  table.approvals tbody td { padding: 0; border: 0; background: none; }
  table.approvals tr.st-approved td, table.approvals tr.st-flagged td { background: none; }
  table.approvals tr.st-approved { background: #f6fef9; }
  table.approvals tr.st-flagged { background: #fffbeb; }
  table.approvals td.select-col { grid-area: select; width: auto; }
  table.approvals td.desc { grid-area: desc; font-weight: 600; }
  table.approvals td.desc .muted { font-weight: 400; }
  table.approvals td.num { grid-area: amount; font-weight: 700; }
  table.approvals td:nth-child(2) { grid-area: meta; font-size: 12.5px; color: var(--muted); }
  table.approvals td:nth-child(2) div { display: inline; font-size: inherit; }
  table.approvals td:nth-child(2) div::before { content: " · "; }
  table.approvals td:nth-child(5) { grid-area: card; font-size: 12.5px; color: var(--muted); }
  table.approvals td:nth-child(5)::before { content: "כרטיס "; }
  table.approvals td:nth-child(6) { grid-area: note; }
  table.approvals .note-input { min-width: 0; }
  table.approvals td:nth-child(7) { grid-area: status; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
  table.approvals .row-actions { margin: 0; margin-inline-start: auto; }
  table.approvals .row-actions .btn { padding: 7px 12px; font-size: 14px; }
  table.approvals td.empty-row { grid-column: 1 / -1; }
  table.approvals input[type="checkbox"] { width: 20px; height: 20px; margin: 0; }

  /* users (site admins): one card each */
  .users-table, .users-table tbody { display: block; }
  .users-table thead { display: none; }
  .users-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name status" "email role" "family family" "created created" "login login" "actions actions";
    gap: 4px 10px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
  }
  .users-table td { padding: 0; border: 0; }
  .users-table tr.pending-user { background: #fffbeb; }
  .users-table tr.pending-user td { background: none; }
  .users-table td:nth-child(1) { grid-area: name; font-weight: 700; }
  .users-table td:nth-child(2) { grid-area: email; min-width: 0; overflow-wrap: anywhere; color: var(--muted); }
  .users-table td:nth-child(3) { grid-area: family; font-size: 13.5px; }
  .users-table td:nth-child(4) { grid-area: role; }
  .users-table td:nth-child(5) { grid-area: status; }
  .users-table td:nth-child(6) { grid-area: created; font-size: 12.5px; color: var(--muted); }
  .users-table td:nth-child(7) { grid-area: login; font-size: 12.5px; color: var(--muted); }
  .users-table td:nth-child(6)::before { content: "נרשם: "; }
  .users-table td:nth-child(7)::before { content: "כניסה אחרונה: "; }
  .users-table td:nth-child(8) { grid-area: actions; padding-top: 6px; }
  .users-table .btn { padding: 7px 12px; font-size: 14px; }
  .gate-option input { font-size: 16px; }
  .invite-code { font-size: 20px; }
}
