/* ================================================================
   DUARTE FAMILY OS — Base Stylesheet
   System font stack. No external CDN dependencies.
   ================================================================ */

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
  --color-bg:          #0f172a;   /* slate-900 */
  --color-sidebar:     #1e293b;   /* slate-800 */
  --color-surface:     #1e293b;
  --color-surface-2:   #334155;   /* slate-700 */
  --color-border:      #334155;
  --color-text:        #f1f5f9;   /* slate-100 */
  --color-text-muted:  #94a3b8;   /* slate-400 */
  --color-text-dim:    #64748b;   /* slate-500 */

  --color-primary:     #2563eb;   /* blue-600 */
  --color-primary-h:   #1d4ed8;   /* blue-700 hover */
  --color-income:      #16a34a;   /* green-600 */
  --color-expense:     #dc2626;   /* red-600 */
  --color-debt:        #d97706;   /* amber-600 */
  --color-tax:         #7c3aed;   /* violet-600 */
  --color-warning:     #f59e0b;
  --color-success:     #10b981;
  --color-error:       #ef4444;

  --sidebar-width:     240px;
  --topbar-height:     56px;
  --radius:            8px;
  --radius-sm:         4px;
  --shadow:            0 4px 24px rgba(0,0,0,.35);
  --transition:        .15s ease;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
ul { list-style: none; }

/* ── App shell layout ────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--color-border);
}
.sidebar__brand-icon {
  font-size: 22px;
  color: var(--color-primary);
  line-height: 1;
}
.sidebar__brand-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-text);
  letter-spacing: -.01em;
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
}
.sidebar__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar__user-name  { font-size: 14px; font-weight: 600; color: var(--color-text); }
.sidebar__user-role  { font-size: 11px; color: var(--color-text-muted); text-transform: capitalize; }

.sidebar__nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}
.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 14px;
  color: var(--color-text-muted);
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}
.sidebar__link:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
  text-decoration: none;
}
.sidebar__link--active {
  background: rgba(37,99,235,.15);
  color: #93c5fd;
  border-right: 3px solid var(--color-primary);
}
.sidebar__link svg { flex-shrink: 0; opacity: .8; }

.sidebar__footer {
  border-top: 1px solid var(--color-border);
  padding: 8px 0;
}
.sidebar__link--logout:hover {
  background: rgba(239,68,68,.1);
  color: var(--color-error);
}

/* ── Main area ───────────────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--color-sidebar);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar__menu-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  padding: 4px;
  display: none; /* shown on mobile via media query */
  border-radius: var(--radius-sm);
}
.topbar__menu-btn:hover { color: var(--color-text); background: var(--color-surface-2); }
.topbar__title { font-size: 16px; font-weight: 600; color: var(--color-text); }

/* ── Content ─────────────────────────────────────────────────── */
.content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
}

/* ── Page header ─────────────────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-header__title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 4px;
}
.page-header__sub { font-size: 14px; color: var(--color-text-muted); }

/* ── Stat grid ───────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: var(--radius) 0 0 var(--radius);
}
.stat-card--income::before  { background: var(--color-income); }
.stat-card--expense::before { background: var(--color-expense); }
.stat-card--tax::before     { background: var(--color-tax); }
.stat-card--networth::before{ background: var(--color-primary); }
.stat-card--debt::before    { background: var(--color-debt); }

.stat-card__label { font-size: 12px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.stat-card__value { font-size: 26px; font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; }
.stat-card__sub   { font-size: 12px; color: var(--color-text-dim); margin-top: 4px; }

/* ── Section ─────────────────────────────────────────────────── */
.section { margin-bottom: 32px; }
.section__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-list { display: flex; flex-direction: column; gap: 12px; }

/* ── User management card ────────────────────────────────────── */
.user-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.user-card--inactive { opacity: .55; }
.user-card__info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 200px;
}
.user-card__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-card__name   { font-weight: 600; font-size: 15px; }
.user-card__legal  { font-size: 12px; color: var(--color-text-muted); margin-left: 6px; }
.user-card__meta   { font-size: 13px; color: var(--color-text-muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.user-card__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Inline form (details/summary) ──────────────────────────── */
.inline-form summary {
  list-style: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.inline-form summary::marker,
.inline-form summary::-webkit-details-marker { display: none; }
.inline-form__body {
  margin-top: 12px;
  padding: 16px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 100%;
}
.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.form-hint { font-size: 12px; color: var(--color-text-dim); margin-top: 8px; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge--info    { background: rgba(37,99,235,.18); color: #93c5fd; }
.badge--ok      { background: rgba(16,185,129,.18); color: #6ee7b7; }
.badge--warning { background: rgba(245,158,11,.18); color: #fcd34d; }
.badge--error   { background: rgba(239,68,68,.18);  color: #fca5a5; }
.badge--role    { background: var(--color-surface-2); color: var(--color-text-muted); }
.badge--tn      { background: rgba(16,185,129,.12); color: #6ee7b7; font-size: 12px; font-weight: 500; text-transform: none; letter-spacing: 0; padding: 3px 8px; }

/* ── Alerts & flash ──────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert--error   { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.alert--success { background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.3); color: #6ee7b7; }
.alert--warning { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.3); color: #fcd34d; }

.flash {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  max-width: 90vw;
  animation: slideDown .2s ease;
}
.flash--error   { background: #7f1d1d; border: 1px solid #dc2626; color: #fca5a5; }
.flash--success { background: #064e3b; border: 1px solid #10b981; color: #6ee7b7; }
.flash__close { background: none; border: none; color: inherit; font-size: 16px; opacity: .7; padding: 0 0 0 8px; }
.flash__close:hover { opacity: 1; }
@keyframes slideDown { from { transform: translateX(-50%) translateY(-12px); opacity:0; } }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 180px; }
.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.form-label__link { font-weight: 400; font-size: 12px; color: var(--color-primary); }
.form-label__link:hover { text-decoration: underline; }

.form-input {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  padding: 10px 12px;
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.2);
}
.form-input--sm { padding: 7px 10px; font-size: 13px; }
.form-input::placeholder { color: var(--color-text-dim); }

.input-password-wrap { position: relative; }
.input-password-wrap .form-input { padding-right: 42px; }
.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-text-dim);
  padding: 2px;
  display: flex;
  align-items: center;
}
.password-toggle:hover { color: var(--color-text-muted); }

/* Password strength bar */
.password-strength { height: 4px; border-radius: 2px; margin-top: 6px; background: var(--color-border); transition: all .3s; }
.password-strength[data-level="1"] { background: var(--color-error); width: 25%; }
.password-strength[data-level="2"] { background: var(--color-debt); width: 50%; }
.password-strength[data-level="3"] { background: var(--color-warning); width: 75%; }
.password-strength[data-level="4"] { background: var(--color-success); width: 100%; }

/* Password rules list */
.password-rules {
  list-style: disc;
  margin: 0 0 16px 20px;
  font-size: 13px;
  color: var(--color-text-muted);
}
.password-rules li { margin-bottom: 2px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), opacity var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn--full   { width: 100%; }
.btn--sm     { padding: 6px 12px; font-size: 13px; }

.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-h); }

.btn--danger  { background: var(--color-error); color: #fff; }
.btn--danger:hover { opacity: .85; }

.btn--warning { background: var(--color-debt); color: #fff; }
.btn--warning:hover { opacity: .85; }

.btn--success { background: var(--color-income); color: #fff; }
.btn--success:hover { opacity: .85; }

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border);
}
.btn--ghost:hover { background: var(--color-surface-2); color: var(--color-text); }

/* ── Auth pages ──────────────────────────────────────────────── */
.auth-body {
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}
.auth-brand__icon {
  font-size: 36px;
  color: var(--color-primary);
  display: block;
  margin-bottom: 8px;
}
.auth-brand__name {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
}
.auth-brand__sub {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.auth-form { display: flex; flex-direction: column; gap: 18px; }
.auth-card__note { font-size: 13px; color: var(--color-text-muted); margin-bottom: 16px; }
.auth-card__back {
  display: block;
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--color-text-muted);
}
.auth-card__back:hover { color: var(--color-text); }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  color: var(--color-text-muted);
  font-size: 14px;
  padding: 16px;
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  text-align: center;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -var(--sidebar-width);
    transform: translateX(calc(-1 * var(--sidebar-width)));
    transition: transform .25s ease;
    height: 100%;
  }
  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.5);
  }
  .topbar__menu-btn { display: flex; }
  .content { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 24px 20px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* ================================================================
   MODULE 2 — Dashboard components
   ================================================================ */

/* ── Stat card variants ──────────────────────────────────────── */
.stat-card--urgent    { border-color: var(--color-error); }
.stat-card--urgent::before { background: var(--color-error); }
.stat-card--ok-glow::before { background: var(--color-success); }

/* ── Value colors ────────────────────────────────────────────── */
.val--positive { color: #4ade80; }
.val--negative { color: #f87171; }

/* ── Charts row ──────────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.charts-row--thirds { grid-template-columns: 1fr 2fr; }

.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.chart-card--span2 { grid-column: span 1; } /* inherits from parent grid */
.chart-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}
.chart-card__title { font-size: 15px; font-weight: 600; color: var(--color-text); }
.chart-card__sub   { font-size: 12px; color: var(--color-text-muted); }

.chart-wrap        { position: relative; flex: 1; min-height: 220px; }
.chart-wrap--sm    { min-height: 180px; }
.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 160px;
  color: var(--color-text-muted);
  font-size: 13px;
  text-align: center;
  padding: 16px;
}

/* ── Tax breakdown ───────────────────────────────────────────── */
.tax-breakdown { display: flex; flex-direction: column; gap: 0; }
.tax-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
  color: var(--color-text-muted);
}
.tax-row:last-child { border-bottom: none; }
.tax-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 500; color: var(--color-text); }
.tax-row--total { font-weight: 600; color: var(--color-text); }
.tax-row--total span { color: var(--color-text); }
.tax-row--gap   { font-weight: 700; font-size: 15px; padding: 10px 0; }
.tax-row--urgent span:last-child { color: #f87171; }
.tax-row--warn  span:last-child  { color: #fcd34d; }
.tax-row--ok    span:last-child  { color: #4ade80; }
.tax-row--note  { font-size: 12px; opacity: .75; }
.tax-row--tn    span:last-child  { color: #4ade80; font-size: 13px; }

/* ── Entity cards ────────────────────────────────────────────── */
.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.entity-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.entity-card__name { font-weight: 700; font-size: 15px; color: var(--color-text); }
.entity-card__type { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-dim); }
.entity-card__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0;
}
.entity-stat__label { font-size: 11px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.entity-stat__val   { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.entity-card__bar-bg { background: var(--color-border); border-radius: 2px; height: 4px; }
.entity-card__bar    { height: 4px; border-radius: 2px; transition: width .4s ease; }
.entity-card__link   { font-size: 12px; color: var(--color-primary); margin-top: 4px; }
.entity-card__link:hover { text-decoration: underline; }

/* ── AI Insights ─────────────────────────────────────────────── */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.insight-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  transition: opacity .3s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.insight-card--urgent { border-left: 4px solid var(--color-error); }
.insight-card--warning{ border-left: 4px solid var(--color-warning); }
.insight-card--info   { border-left: 4px solid var(--color-primary); }

.insight-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.insight-card__badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--color-text-dim);
}
.insight-card__dismiss {
  background: none;
  border: none;
  color: var(--color-text-dim);
  font-size: 12px;
  padding: 0 2px;
  cursor: pointer;
}
.insight-card__dismiss:hover { color: var(--color-text); }
.insight-card__title  { font-weight: 600; font-size: 14px; color: var(--color-text); }
.insight-card__body   { font-size: 13px; color: var(--color-text-muted); line-height: 1.5; }
.insight-card__age    { font-size: 11px; color: var(--color-text-dim); margin-top: 4px; }

/* ── Data tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--color-border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead th {
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.data-table tbody tr { border-bottom: 1px solid var(--color-border); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255,255,255,.025); }
.data-table td { padding: 10px 14px; color: var(--color-text); vertical-align: middle; }
.td-date  { white-space: nowrap; color: var(--color-text-muted); font-size: 13px; }
.td-muted { color: var(--color-text-muted); font-size: 13px; }
.align-right { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Responsive dashboard ────────────────────────────────────── */
@media (max-width: 900px) {
  .charts-row        { grid-template-columns: 1fr; }
  .charts-row--thirds{ grid-template-columns: 1fr; }
}

/* ================================================================
   MODULE 3 — Income / Entry Form components
   ================================================================ */

/* ── Entry form layout ───────────────────────────────────────── */
.entry-form { max-width: 860px; }

.form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.form-section__title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.form-group--wide { grid-column: 1 / -1; }

.form-label-hint {
  font-weight: 400;
  font-size: 11px;
  color: var(--color-text-dim);
}

.form-textarea {
  resize: vertical;
  min-height: 70px;
}

/* $ prefix inputs */
.input-prefix-wrap { position: relative; }
.input-prefix {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  font-weight: 600;
  pointer-events: none;
}
.input-has-prefix { padding-left: 24px; }

/* ── Owner selector ──────────────────────────────────────────── */
.owner-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.owner-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.owner-option input[type=radio] { accent-color: var(--color-primary); }
.owner-option__label { font-size: 14px; font-weight: 500; color: var(--color-text); }
.owner-select-wrap { margin-top: 4px; }

/* ── Checkboxes ──────────────────────────────────────────────── */
.checkbox-group { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-text);
}
.checkbox-label input[type=checkbox] { accent-color: var(--color-primary); width: 16px; height: 16px; }

/* ── Type hint ───────────────────────────────────────────────── */
.type-hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 6px;
  padding: 6px 10px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-primary);
  display: none;
}

/* ── Form actions ────────────────────────────────────────────── */
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ── Autocomplete ────────────────────────────────────────────── */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 200;
  display: none;
  max-height: 220px;
  overflow-y: auto;
}
.autocomplete-item {
  padding: 9px 14px;
  font-size: 14px;
  color: var(--color-text);
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: rgba(37,99,235,.15); color: #93c5fd; }

/* ── Summary bar (income list) ───────────────────────────────── */
.summary-bar {
  display: flex;
  gap: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.summary-bar__total {
  flex: 1.5;
  padding: 14px 20px;
  border-right: 1px solid var(--color-border);
}
.summary-bar__q {
  flex: 1;
  border-right: 1px solid var(--color-border);
}
.summary-bar__q:last-child { border-right: none; }
.summary-bar__q a {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  height: 100%;
  text-decoration: none;
  transition: background var(--transition);
}
.summary-bar__q a:hover { background: var(--color-surface-2); }
.summary-bar__q--active a { background: rgba(37,99,235,.12); }
.summary-bar__label { font-size: 11px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .05em; }
.summary-bar__value { font-size: 16px; font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; margin-top: 4px; }
.summary-bar__total .summary-bar__value { font-size: 20px; color: #4ade80; }

/* ── Filter bar ──────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.filter-bar__group { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: 11px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .05em; }

/* ── Table extras ────────────────────────────────────────────── */
.td-primary   { font-weight: 500; color: var(--color-text); }
.td-secondary { font-size: 12px; color: var(--color-text-dim); margin-top: 2px; }
.td-actions   { white-space: nowrap; }
.table-foot-total { background: var(--color-bg); }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination__btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  text-decoration: none;
}
.pagination__btn:hover { background: var(--color-surface-2); color: var(--color-text); text-decoration: none; }
.pagination__btn--active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
