/* ─── Design tokens ─────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Background */
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-hover: #f1f5f9;

  /* Sidebar */
  --sidebar-bg: #0f172a;
  --sidebar-surface: #1e293b;
  --sidebar-border: #334155;
  --sidebar-text: #cbd5e1;
  --sidebar-text-muted: #64748b;
  --sidebar-active-bg: #2563eb;
  --sidebar-active-text: #ffffff;
  --sidebar-hover-bg: #1e293b;

  /* Brand */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --primary-soft: #eff6ff;
  --primary-ring: rgba(37, 99, 235, 0.22);

  /* Semantic */
  --success: #16a34a;
  --success-dark: #15803d;
  --success-soft: #f0fdf4;
  --success-border: #bbf7d0;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --warning-border: #fde68a;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --info: #0891b2;
  --info-soft: #ecfeff;

  /* Text */
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --muted-light: #94a3b8;

  /* Borders */
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.10), 0 1px 4px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 32px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-xl: 0 24px 64px rgba(15, 23, 42, 0.20), 0 4px 16px rgba(15, 23, 42, 0.08);

  /* Shape */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Bootstrap overrides */
  --bs-body-bg: #f0f2f5;
  --bs-body-color: #0f172a;
}

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

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
}

button, input, select, textarea {
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease,
    color 0.15s ease,
    transform 0.1s ease;
}

h1, h2, h3, h4, p { margin-top: 0; }

h1 {
  margin-bottom: 10px;
  font-size: 1.55rem;
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  margin-bottom: 0;
  font-size: 0.95rem;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ─── Layout shell ───────────────────────────────────────────────────────── */
.page-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

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

.sidebar-nav {
  flex: 1;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 4px; }

/* Sidebar nav grows to fill space, pushing footer down */
.sidebar-nav {
  flex: 1;
}

/* Sidebar brand */
.sidebar > div:first-child {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 8px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.sidebar-logo {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 7px;
}

.sidebar-brand .eyebrow {
  margin: 0;
  color: var(--primary-light);
  font-size: 0.63rem;
  letter-spacing: 0.16em;
}

.sidebar > div:first-child .eyebrow {
  color: var(--primary-light);
  font-size: 0.63rem;
  letter-spacing: 0.16em;
}

.sidebar h1 {
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.sidebar .muted {
  color: var(--sidebar-text-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

/* Sidebar navigation */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  flex: 1;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-right: 8px;
  opacity: 0.8;
}

.nav-tab-button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: transparent;
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.25;
  cursor: pointer;
  text-align: left;
  justify-content: flex-start;
  transition: all 0.15s ease;
  letter-spacing: -0.01em;
  gap: 0;
}

.nav-tab-button:hover {
  background: var(--sidebar-hover-bg);
  color: #ffffff;
}

.nav-tab-button.active {
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.nav-tab-button.active .nav-icon {
  opacity: 1;
}

.nav-tab-button.active:hover {
  background: var(--primary-dark);
}

/* Sidebar panel (Criar mês) */
.sidebar .panel {
  margin: 8px 12px 12px;
  padding: 14px;
  background: var(--sidebar-surface);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius);
  box-shadow: none;
}

.sidebar .panel .section-head {
  border-bottom-color: var(--sidebar-border);
  margin-bottom: 12px;
  padding-bottom: 10px;
}

.sidebar .panel h2 {
  color: #e2e8f0;
  font-size: 0.82rem;
}

.sidebar .panel .ghost-button.icon-button {
  background: transparent;
  border-color: var(--sidebar-border);
  color: var(--sidebar-text-muted);
  font-size: 0.72rem;
}

.sidebar .panel .ghost-button.icon-button:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text);
}

.sidebar .panel input,
.sidebar .panel select {
  background: var(--sidebar-bg);
  border-color: var(--sidebar-border);
  color: #e2e8f0;
}

.sidebar .panel input::placeholder {
  color: var(--sidebar-text-muted);
}

.sidebar .panel .field-label span {
  color: var(--sidebar-text-muted);
}

.sidebar .panel button[type="submit"] {
  background: var(--primary);
  color: #ffffff;
  border-color: transparent;
  font-size: 0.82rem;
}

.sidebar .panel button[type="submit"]:hover {
  background: var(--primary-dark);
}

/* ─── Context bar ────────────────────────────────────────────────────────── */
.context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.context-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.context-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #94a3b8;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}

.context-title {
  margin: 0 0 2px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.context-sub {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 420px;
}

.context-selectors {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-shrink: 0;
}

.context-selector-group {
  display: grid;
  gap: 4px;
}

.context-selector-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.context-selector-group select {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.875rem;
  min-width: 140px;
  background: var(--surface-soft);
  border-color: var(--line);
}

/* ─── Privacy toggle button ─────────────────────────────────────────────── */
.privacy-toggle {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  align-self: flex-end;
  flex-shrink: 0;
}

.privacy-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
  color: var(--text);
}

.privacy-toggle.active {
  background: #fef9c3;
  border-color: #fde68a;
  color: #b45309;
}

.privacy-toggle svg {
  width: 17px;
  height: 17px;
}

/* ─── Values hidden (privacy mode) ──────────────────────────────────────── */
.values-hidden #stats-grid .stat-card strong,
.values-hidden #stats-breakdown .stat-card strong,
.values-hidden #stats-breakdown .stat-sub,
.values-hidden #stats-breakdown .stat-progress-wrap,
.values-hidden .action-card-hint,
.values-hidden .history-list .list-card,
.values-hidden #economy-insights,
.values-hidden #panel-fixed .list-card small,
.values-hidden .inline-chart,
.values-hidden [id$="-chart"] {
  filter: blur(7px);
  user-select: none;
  pointer-events: none;
}

/* ─── Sidebar nav separator ──────────────────────────────────────────────── */
.sidebar-nav-sep {
  height: 1px;
  background: var(--sidebar-border);
  margin: 6px 0;
}

/* ─── Sidebar footer ─────────────────────────────────────────────────────── */
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
  margin-top: auto;
}

.sidebar-danger-btn,
.sidebar-action-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sidebar-danger-btn {
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.08);
  color: #fca5a5;
}

.sidebar-danger-btn:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.15);
  color: #fecaca;
  transform: none;
  box-shadow: none;
}

.sidebar-danger-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.sidebar-action-btn {
  border: 1px solid var(--sidebar-border);
  background: transparent;
  color: var(--sidebar-text);
}

.sidebar-action-btn:hover {
  background: var(--sidebar-hover-bg);
  color: #ffffff;
  transform: none;
  box-shadow: none;
}

/* ─── Months view ────────────────────────────────────────────────────────── */
.months-group {
  margin-bottom: 16px;
}

.months-group:last-child {
  margin-bottom: 0;
}

.months-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.months-group-header strong {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.months-group-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

.months-group-list {
  display: grid;
  gap: 8px;
}

/* ─── Profiles view layout ───────────────────────────────────────────────── */
.layout-grid .column.wide {
  min-width: 0;
}

/* ─── Profiles page (pf-) ────────────────────────────────────────────────── */

/* Layout */
.profiles-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.profiles-hero-icon {
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: #eff6ff;
  color: var(--primary);
}

.profiles-hero-icon svg {
  width: 34px;
  height: 34px;
  display: block;
}

.profiles-hero-text {
  min-width: 0;
}

.profiles-hero-text h2 {
  margin: 0 0 4px;
  font-size: 1.45rem;
  line-height: 1.15;
}

.pf-layout {
  --profiles-panel-height: 512px;
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

@media (max-width: 860px) { .pf-layout { grid-template-columns: 1fr; } }

/* Left form panel */
.pf-form-col {
  display: flex;
  flex-direction: column;
}

.pf-form-panel {
  padding: 0;
  overflow: hidden;
  flex: 1;
  min-height: var(--profiles-panel-height);
}

.pf-form-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.pf-form-header svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
  flex-shrink: 0;
}

.pf-form-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 20px 20px;
}

/* Color swatches */
.pf-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.pf-swatch {
  width: 22px !important;
  height: 22px !important;
  inline-size: 22px !important;
  block-size: 22px !important;
  min-width: 22px !important;
  min-height: 22px !important;
  max-width: 22px;
  max-height: 22px;
  flex: 0 0 22px;
  aspect-ratio: 1 / 1;
  padding: 0 !important;
  appearance: none;
  box-sizing: border-box;
  border-radius: 999px !important;
  background: var(--sw-color, #ccc);
  border: 1.5px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  overflow: hidden;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  outline: none;
}

.pf-swatch:hover { transform: scale(1.12); }

.pf-swatch--selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--sw-color);
}

.pf-swatch-check {
  width: 11px;
  height: 11px;
  opacity: 0;
  transition: opacity 0.12s;
}

.pf-swatch--selected .pf-swatch-check { opacity: 1; }

/* Preview */
.pf-preview-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.pf-preview-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 12px 6px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.pf-preview-card { background: var(--surface); }

.pf-preview-banner {
  height: 56px;
  transition: background 0.2s;
  position: relative;
}

.pf-preview-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  border: 2.5px solid rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  position: absolute;
  bottom: -20px;
  left: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.pf-preview-body {
  padding: 26px 14px 12px;
  position: relative;
}

.pf-preview-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}

.pf-preview-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

.pf-preview-meta svg { width: 11px; height: 11px; flex-shrink: 0; }

.pf-preview-edit-icon {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  pointer-events: none;
}

.pf-preview-edit-icon svg { width: 11px; height: 11px; color: var(--text-muted); }

/* Submit button */
.pf-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s;
}

.pf-submit-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 2px 10px rgba(37,99,235,0.35);
}

.pf-submit-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Right panel */
.pf-list-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pf-list-panel {
  padding: 0;
  overflow: hidden;
  min-height: var(--profiles-panel-height);
}

.pf-list-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.pf-list-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 2px;
}

.pf-list-header p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

/* Profile rows */
.pf-profile-list {
  display: grid;
  gap: 12px;
  padding: 16px 20px 20px;
}

.pf-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: background 0.1s, border-color 0.1s, box-shadow 0.1s;
}

.pf-row:hover {
  background: var(--surface);
  border-color: var(--line-strong);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.pf-row-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.pf-row-info { flex: 1; min-width: 0; }

.pf-row-name {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 2px;
}

.pf-row-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

.pf-row-meta svg { width: 11px; height: 11px; flex-shrink: 0; }

/* Status badge */
.pf-badge {
  flex-shrink: 0;
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 99px;
  border: 1.5px solid;
}

.pf-badge--active {
  color: var(--success);
  border-color: var(--success);
  background: transparent;
}

.pf-badge--inactive {
  color: var(--text-muted);
  border-color: var(--line-strong);
  background: transparent;
}

/* Icon buttons */
.pf-icon-btn {
  width: 32px !important;
  min-width: 32px !important;
  height: 32px !important;
  min-height: 32px !important;
  padding: 0 !important;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  overflow: hidden;
  line-height: 1;
}

.pf-icon-btn:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
  color: var(--text);
}

.pf-icon-btn--danger { color: var(--danger); border-color: transparent; }
.pf-icon-btn--danger:hover { background: #fff1f0; border-color: #fca5a5; color: #b91c1c; }
.pf-icon-btn svg { width: 15px; height: 15px; flex-shrink: 0; display: block; }

.pf-icon-btn::before {
  content: none !important;
}

/* Info box */
.pf-info-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  font-size: 0.8rem;
  color: #1d4ed8;
  line-height: 1.5;
}

.pf-info-box svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

/* Empty state */
.pf-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 24px;
  text-align: center;
}

.pf-empty svg { width: 56px; height: 56px; opacity: 0.4; }

.pf-empty p {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0;
}

.pf-empty span { font-size: 0.8rem; color: #94a3b8; }

/* Hidden count badge kept for compat */
.profiles-count.hidden { display: none; }

/* ─────────────────────── old profiles styles below (kept for safety) ────── */
.profiles-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.profiles-page-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profiles-page-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1px solid #bfdbfe;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.profiles-page-icon svg {
  width: 22px;
  height: 22px;
}

.profiles-page-title h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 2px;
  letter-spacing: -0.02em;
}

.profiles-page-title .eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 2px;
}

.profiles-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 4px 12px;
}

.profiles-layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 860px) {
  .profiles-layout { grid-template-columns: 1fr; }
}

/* Form panel */
.profiles-form-panel {
  position: sticky;
  top: 24px;
  padding: 0;
  overflow: hidden;
}

.profile-form-avatar-preview {
  background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
  padding: 28px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.profile-form-big-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.25);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 0 0 4px rgba(255,255,255,0.1);
  transition: background 0.2s;
}

.profile-form-avatar-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
}

/* Color presets */
.profile-color-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.profile-preset-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  outline: none;
}

.profile-preset-swatch:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.profile-preset-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px currentColor;
  transform: scale(1.1);
}

.profile-custom-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.profile-custom-color-row input[type="color"] {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  padding: 1px;
  cursor: pointer;
  background: none;
}

/* Profile tiles grid */
.profile-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.profile-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
}

.profile-tile:hover {
  box-shadow: var(--shadow-md, var(--shadow));
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.profile-tile--active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.profile-tile-banner {
  height: 80px;
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: 0 16px 0;
}

.profile-tile-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  border: 3px solid rgba(255,255,255,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transform: translateY(50%);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.profile-tile-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 99px;
  border: 1px solid rgba(255,255,255,0.3);
}

.profile-tile-body {
  padding: 34px 16px 14px;
}

.profile-tile-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}

.profile-tile-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

.profile-tile-footer {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
}

.profile-tile-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text-secondary);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.profile-tile-btn:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
  color: var(--text);
}

.profile-tile-btn svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.profile-tile-btn--danger {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
}

.profile-tile-btn--danger:hover {
  background: #fff1f0;
  border-color: #fca5a5;
  color: #b91c1c;
}

.profile-empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 60px 24px;
  text-align: center;
}

.profile-empty-state svg {
  width: 64px;
  height: 64px;
  opacity: 0.35;
}

.profile-empty-state p {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0;
}

.profile-empty-state span {
  font-size: 0.82rem;
  color: #94a3b8;
  max-width: 240px;
}

/* ─── Main content ───────────────────────────────────────────────────────── */
.content {
  min-width: 0;
  padding: 28px;
}

/* ─── Login ──────────────────────────────────────────────────────────────── */

/* ─── Buttons ────────────────────────────────────────────────────────────── */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.25;
  cursor: pointer;
  letter-spacing: -0.01em;
}

button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

button:active {
  transform: translateY(0);
  box-shadow: none;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.ghost-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text-secondary);
  font-weight: 500;
}

.ghost-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
  color: var(--text);
  box-shadow: var(--shadow-xs);
  transform: translateY(-1px);
}

.danger-button {
  width: auto;
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
}

.danger-button:hover {
  border-color: #fca5a5;
  background: #fee2e2;
  color: var(--danger-dark);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
  transform: translateY(-1px);
}

.icon-button {
  width: auto;
  min-height: 32px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0;
}

/* ─── Form controls ──────────────────────────────────────────────────────── */
input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
}

input:hover, select:hover, textarea:hover {
  border-color: var(--line-strong);
}

textarea {
  resize: vertical;
}

input::placeholder, textarea::placeholder {
  color: var(--muted-light);
}

input[type="color"] {
  min-height: 42px;
  padding: 5px;
  cursor: pointer;
}

.field-label {
  display: grid;
  gap: 5px;
  color: var(--text);
}

.field-label span {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.stack-form, .expense-form {
  display: grid;
  gap: 12px;
}

/* ─── Cards & panels ─────────────────────────────────────────────────────── */
.panel,
.hero-card,
.stat-card,
.modal-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel {
  padding: 20px;
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding: 24px 28px;
  border-top: 4px solid var(--primary);
  background: linear-gradient(135deg, var(--surface) 0%, #f8fbff 100%);
  box-shadow: var(--shadow);
}

.hero-card h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 6px;
}

.hero-actions {
  display: grid;
  gap: 10px;
  min-width: 260px;
}

.selectors {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.section-total {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

/* ─── Stat cards ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 20px;
  border-left: 4px solid var(--primary);
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--primary-soft);
  transform: translate(30px, -30px);
  pointer-events: none;
}

.stat-card small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

/* Stat card color variants */
.stat-card--blue    { border-left-color: var(--primary); }
.stat-card--blue::after { background: var(--primary-soft); }
.stat-card--green   { border-left-color: var(--success); }
.stat-card--green::after { background: var(--success-soft); }
.stat-card--warning { border-left-color: var(--warning); }
.stat-card--warning::after { background: var(--warning-soft); }
.stat-card--info    { border-left-color: var(--info); }
.stat-card--info::after { background: var(--info-soft); }
.stat-card--danger  { border-left-color: var(--danger); }
.stat-card--danger::after { background: var(--danger-soft); }
.stat-card--danger strong { color: var(--danger); }
.stat-card--slate   { border-left-color: #64748b; }
.stat-card--slate::after { background: #f1f5f9; }
.stat-card--purple  { border-left-color: #9333ea; }
.stat-card--purple::after { background: #f3e8ff; }
.stat-card--amber   { border-left-color: #d97706; }
.stat-card--amber::after { background: #fef9c3; }

/* Stats breakdown row */
.stats-breakdown {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-sub {
  display: block;
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Fuel progress bar */
.stat-progress-wrap {
  height: 5px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 10px;
  margin-bottom: 2px;
}

.stat-progress-bar {
  height: 100%;
  background: #d97706;
  border-radius: 99px;
  transition: width 0.4s ease;
  min-width: 4px;
}

.stat-progress-bar--over {
  background: var(--danger);
}

/* ─── Action cards grid ──────────────────────────────────────────────────── */
.action-cards-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  margin-bottom: 20px;
}

.action-cards-col {
  display: grid;
  gap: 12px;
}

.action-card {
  padding: 0;
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.action-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.action-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  cursor: default;
}

.action-card-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-card-icon-wrap svg {
  width: 20px;
  height: 20px;
}

.action-icon--green  { background: #dcfce7; color: #16a34a; }
.action-icon--orange { background: #ffedd5; color: #ea580c; }
.action-icon--purple { background: #f3e8ff; color: #9333ea; }
.action-icon--blue   { background: #dbeafe; color: #2563eb; }
.action-icon--slate  { background: #f1f5f9; color: #475569; }
.action-icon--amber  { background: #fef9c3; color: #b45309; }

.action-card-info {
  flex: 1;
  min-width: 0;
}

.action-card-info h2 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 3px;
  line-height: 1.3;
}

.action-card-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-card-cta {
  flex-shrink: 0;
  width: auto;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}

.action-card-cta:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.action-card-cta--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.action-card-cta--primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.action-card--primary .action-card-head {
  background: linear-gradient(135deg, #f0f7ff 0%, #e8f2ff 100%);
  border-bottom: 1px solid #dbeafe;
}

/* ─── Layout grid ────────────────────────────────────────────────────────── */
.layout-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  margin-bottom: 20px;
}

.column {
  display: grid;
  gap: 16px;
}

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

.chart-panel {
  min-height: 340px;
}

.chart-panel--full {
  grid-column: 1 / -1;
}

.full-width-panel {
  margin-bottom: 16px;
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.expense-table {
  width: 100%;
  min-width: 860px;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
}

.expense-table th,
.expense-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  vertical-align: middle;
  font-size: 0.82rem;
  line-height: 1.3;
  white-space: nowrap;
}

.expense-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  position: sticky;
  top: 0;
  z-index: 1;
}

.expense-table tbody tr {
  transition: background 0.1s;
}

.expense-table tbody tr:hover td {
  background: #f8fbff;
}

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

.expense-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-table td:last-child,
.expense-table th:last-child {
  text-align: center;
}

.expense-table td:nth-last-child(2),
.expense-table th:nth-last-child(2) {
  text-align: right;
}

.query-total {
  margin-top: 16px;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: right;
  color: var(--text);
}

/* ─── Query form ─────────────────────────────────────────────────────────── */
.query-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.card-import-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

/* ─── Inline actions ─────────────────────────────────────────────────────── */
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-actions button,
.card-actions button {
  width: auto;
}

/* ─── Forecast & fieldsets ───────────────────────────────────────────────── */
.forecast-block,
.travel-fieldset {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.forecast-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.forecast-preview {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  line-height: 1.5;
  font-size: 0.85rem;
  color: var(--muted);
}

.inline-chart {
  margin-top: 18px;
  min-height: 220px;
}

/* ─── List items ─────────────────────────────────────────────────────────── */
.profile-list,
.item-list,
.history-list,
.insight-grid {
  display: grid;
  gap: 10px;
}

.tag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tag:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-xs);
}

.tag-content,
.tag-name,
.tag-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.tag-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}

.list-card,
.history-card,
.insight-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.list-card:hover,
.history-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-xs);
}

.list-card-head,
.history-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-left: auto;
}

.card-actions .ghost-button,
.card-actions .danger-button {
  min-width: 32px;
  min-height: 32px;
  padding: 0;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-card small,
.list-card small,
.insight-card small,
.tag small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

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

.insight-card {
  padding: 16px;
}

.empty-state {
  padding: 20px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
  font-size: 0.875rem;
}

/* ─── Action icon buttons ────────────────────────────────────────────────── */
.icon-actions {
  display: grid;
  gap: 6px;
}

.icon-action {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-grid;
  place-items: center;
  font-size: 0;
  line-height: 1;
}

.tag-meta {
  margin-left: auto;
}

.tag-meta .danger-button,
button[data-investment-edit],
button[data-contribution-edit],
button[data-fixed-edit],
button[data-category-edit],
button[data-expense-edit],
button[data-travel-edit],
button[data-investment-contribution],
button[data-investment-delete],
button[data-contribution-delete],
button[data-fixed-delete],
button[data-category-delete],
button[data-expense-delete],
button[data-travel-delete] {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 0;
  line-height: 1;
}

button[data-investment-edit]::before,
button[data-contribution-edit]::before,
button[data-fixed-edit]::before,
button[data-category-edit]::before,
button[data-expense-edit]::before,
button[data-travel-edit]::before {
  content: "";
  width: 15px;
  height: 15px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 20h9' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 20h9' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

button[data-investment-contribution]::before {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 5v14M5 12h14' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 5v14M5 12h14' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

button[data-investment-delete]::before,
button[data-contribution-delete]::before,
button[data-fixed-delete]::before,
button[data-category-delete]::before,
button[data-expense-delete]::before,
button[data-travel-delete]::before {
  content: "";
  width: 15px;
  height: 15px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6M10 11v5M14 11v5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6M10 11v5M14 11v5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Admin buttons */
button[data-admin-user-role],
button[data-admin-user-active],
button[data-admin-user-delete] {
  width: auto;
  min-width: 80px;
  min-height: 30px;
  padding: 4px 10px;
  font-size: 0.76rem;
}

/* ─── Calendar ───────────────────────────────────────────────────────────── */
.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.83rem;
}

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

.legend-swatch {
  width: 12px;
  height: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.legend-swatch--within { background: var(--success-soft); border-color: var(--success-border); }
.legend-swatch--over { background: var(--danger-soft); border-color: var(--danger-border); }
.legend-swatch--future { background: var(--surface); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-weekday {
  padding: 6px 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.calendar-spacer { min-height: 0; }

.calendar-day {
  display: grid;
  align-content: start;
  gap: 5px;
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.calendar-day:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-xs);
}

.calendar-day strong {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.calendar-day strong span {
  margin-left: 4px;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.calendar-day small {
  color: var(--muted);
  font-size: 0.75rem;
}

.calendar-day--within {
  border-color: var(--success-border);
  background: var(--success-soft);
}

.calendar-day--over {
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

.calendar-day--future { background: var(--surface); }

/* ─── Panel visibility ───────────────────────────────────────────────────── */
.panel-body.hidden,
.hidden {
  display: none !important;
}

/* ─── Popup panels ───────────────────────────────────────────────────────── */
.panel-popup-active {
  overflow: hidden;
}

.panel-popup-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}

.panel-body.popup-open {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 1050;
  display: block;
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  transform: translate(-50%, -50%);
}

.panel-popup-head {
  position: sticky;
  top: -20px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -20px -20px 18px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.panel-popup-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
  isolation: isolate;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 540px);
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

.modal-head {
  margin-bottom: 20px;
}

/* ─── Investment & travel detail ─────────────────────────────────────────── */
.investment-table { table-layout: fixed; }

.investment-table th,
.investment-table td {
  padding: 8px 12px;
  font-size: 0.78rem;
}

.investment-table th:last-child,
.investment-table td:last-child,
.investment-contribution-table th:last-child,
.investment-contribution-table td:last-child {
  text-align: left;
}

.investment-actions,
.travel-actions,
.table-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  white-space: nowrap;
}

.investment-actions button,
.travel-actions button,
.table-actions button {
  width: auto;
  min-width: 30px;
  min-height: 30px;
  padding: 5px 8px;
  font-size: 0.74rem;
}

.investment-row,
.travel-row {
  cursor: pointer;
}

.investment-detail-row td,
.travel-detail-row td {
  padding: 0;
  background: var(--surface);
  overflow: visible;
}

.investment-detail,
.travel-detail {
  display: grid;
  gap: 16px;
  padding: 18px;
  background: var(--surface-soft);
  border-top: 1px solid var(--line);
  min-width: 0;
}

.investment-detail .apexcharts-canvas,
.investment-detail .apexcharts-svg,
.investment-detail .apexcharts-inner,
.investment-detail .apexcharts-graphical {
  overflow: visible !important;
}

.investment-detail .apexcharts-tooltip {
  z-index: 40;
  pointer-events: none;
}

.investment-detail [id^="investment-chart-"] {
  min-width: 0;
}

.investment-metrics,
.travel-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.travel-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.investment-metric,
.travel-metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: box-shadow 0.15s;
}

.investment-metric:hover,
.travel-metric:hover {
  box-shadow: var(--shadow-xs);
}

.investment-metric small,
.travel-metric small,
.travel-metric span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.investment-metric strong,
.travel-metric strong {
  display: block;
  margin-top: 6px;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.investment-detail-table {
  min-width: 760px;
  table-layout: fixed;
}

.investment-detail-table th,
.investment-detail-table td {
  padding: 7px 10px;
  font-size: 0.76rem;
}

.investment-contribution-table {
  min-width: 420px;
  margin-top: 14px;
}

.investment-form {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.investment-form .field-label span { font-size: 0.73rem; }
.investment-form input {
  min-height: 38px;
  padding: 7px 10px;
  font-size: 0.84rem;
}

.investment-helper {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ─── Travel form ────────────────────────────────────────────────────────── */
.travel-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.travel-field-wide { grid-column: 1 / -1; }

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

.travel-fieldset--triple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.travel-fieldset--flight {
  grid-template-columns: auto repeat(3, minmax(0, 1fr));
  align-items: end;
}

.travel-fieldset legend {
  float: none;
  width: auto;
  margin-bottom: 4px;
  padding: 0 6px;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.travel-subtitle {
  align-self: center;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
}

/* ─── Card import ────────────────────────────────────────────────────────── */
.history-table { min-width: 760px; }
.history-table td:nth-child(5) {
  max-width: 320px;
  white-space: normal;
}

.card-import-table {
  min-width: 1240px;
  table-layout: fixed;
}

.card-import-table th,
.card-import-table td {
  padding: 6px 10px;
  font-size: 0.75rem;
  line-height: 1.2;
}

.card-import-table th:first-child,
.card-import-table td:first-child { width: 86px; text-align: center; }

.card-import-table th:nth-child(2),
.card-import-table td:nth-child(2) { width: 110px; }

.card-import-table th:nth-child(3),
.card-import-table td:nth-child(3) { width: 190px; }

.card-import-table th:nth-child(5),
.card-import-table td:nth-child(5) { width: 170px; }

.card-import-table th:nth-child(6),
.card-import-table td:nth-child(6) { width: 120px; text-align: right; }

.card-import-table th:nth-child(7),
.card-import-table td:nth-child(7) { width: 210px; text-align: left; }

.card-import-table th:nth-last-child(2),
.card-import-table td:nth-last-child(2) { text-align: left; }

.card-import-table select {
  min-height: 28px;
  padding: 3px 7px;
  font-size: 0.74rem;
}

.card-import-installments {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  margin-top: 5px;
}

.card-import-installments input {
  min-height: 28px;
  padding: 3px 6px;
  font-size: 0.74rem;
}

.card-import-table input[type="checkbox"] {
  width: 14px;
  height: 14px;
  min-height: 14px;
  padding: 0;
  vertical-align: middle;
  accent-color: var(--primary);
}

.card-import-status {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: var(--radius-full);
  padding: 2px 8px;
  background: var(--success-soft);
  color: var(--success-dark);
  font-weight: 700;
  font-size: 0.72rem;
}

.card-import-table tfoot td {
  border-top: 1px solid var(--line-strong);
  border-bottom: 0;
  background: var(--surface-soft);
  font-size: 0.8rem;
  font-weight: 700;
}

.card-import-table tfoot td:first-child { text-align: right; }
.card-import-table tfoot td:nth-child(2) { text-align: right; }

.card-import-status--duplicate { background: #dcfce7; color: #166534; }
.card-import-status--out { background: var(--danger-soft); color: var(--danger); }

.card-import-group-row td {
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  background: #eff6ff;
  color: var(--text);
  font-size: 0.78rem;
}

.card-import-group-row strong,
.card-import-group-row span {
  display: inline-flex;
  margin-right: 12px;
}

.card-import-duplicate-cell {
  white-space: normal;
  line-height: 1.3;
}

.card-import-row--duplicate td {
  background: #f0fdf4;
}

.card-import-actions {
  margin-top: 14px;
  justify-content: flex-end;
}

/* ─── Fixed mode filters ─────────────────────────────────────────────────── */
.fixed-mode-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.fixed-mode-filters--single { grid-template-columns: 1fr; }

.fixed-mode-filter-group { position: relative; }

.fixed-mode-filter-toggle {
  justify-content: space-between;
  width: 100%;
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
}

.fixed-mode-filter-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.fixed-mode-filter-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.fixed-mode-filter-toggle strong {
  margin: 0;
  font-weight: 600;
}

.fixed-mode-filter-popup {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 5;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.fixed-mode-filter-options {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.fixed-mode-filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
}

.fixed-mode-filter-option input {
  width: auto;
  min-height: 0;
  margin: 0;
  accent-color: var(--primary);
}

/* ─── Note tooltip ───────────────────────────────────────────────────────── */
.expense-note-cell {
  position: relative;
  width: 48px;
  overflow: visible;
}

.expense-note-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.68rem;
  font-weight: 800;
  cursor: default;
}

.expense-note-trigger::after {
  content: attr(data-note);
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  z-index: 30;
  min-width: 180px;
  max-width: 280px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: #1e293b;
  color: #f1f5f9;
  box-shadow: var(--shadow-lg);
  font-size: 0.76rem;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity 0.15s ease;
}

.expense-note-trigger:hover::after { opacity: 1; }

.expense-note-empty { color: var(--muted-light); }

/* ─── Mobile-only elements (hidden on desktop) ───────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--sidebar-border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 300;
}

.mobile-hamburger {
  width: 38px !important;
  min-width: 38px !important;
  height: 38px !important;
  min-height: 38px !important;
  padding: 0 !important;
  background: rgba(255,255,255,0.06) !important;
  border: 1px solid var(--sidebar-border) !important;
  border-radius: var(--radius-sm);
  color: #e2e8f0 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: none !important;
  transform: none !important;
}

.mobile-hamburger:hover {
  background: rgba(255,255,255,0.12) !important;
  transform: none !important;
  box-shadow: none !important;
}

.mobile-hamburger svg { width: 20px; height: 20px; flex-shrink: 0; }

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
}

.mobile-brand-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-header-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94a3b8;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 290;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.mobile-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-close-btn {
  display: none;
  width: 34px !important;
  min-width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
  padding: 0 !important;
  background: rgba(255,255,255,0.06) !important;
  border: 1px solid var(--sidebar-border) !important;
  border-radius: var(--radius-sm);
  color: #94a3b8 !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: none !important;
  transform: none !important;
}

.sidebar-close-btn:hover {
  background: rgba(255,255,255,0.1) !important;
  color: #e2e8f0 !important;
  transform: none !important;
  box-shadow: none !important;
}

.sidebar-close-btn svg { width: 16px; height: 16px; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */

/* Tablet: sidebar becomes top horizontal nav strip */
@media (max-width: 1100px) {
  .page-shell { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: column;
    padding: 0;
  }

  .sidebar > div:first-child { padding: 20px; }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 6px;
  }

  .nav-tab-button {
    width: auto;
    flex-shrink: 0;
  }

  .sidebar .panel { margin: 0 14px 14px; }

  .hero-card { align-items: stretch; flex-direction: column; }
  .hero-actions, .selectors { min-width: 0; }
}

/* Large tablets: 2-column stats, collapse action/layout grids */
@media (max-width: 960px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .layout-grid,
  .charts-grid,
  .action-cards-grid {
    grid-template-columns: 1fr;
  }
}

/* Forms single-column on smaller tablets */
@media (max-width: 900px) {
  .query-form,
  .card-import-form,
  .investment-form,
  .investment-metrics,
  .travel-form,
  .travel-fieldset,
  .travel-fieldset--flight,
  .travel-fieldset--triple,
  .travel-metrics,
  .insight-grid,
  .fixed-mode-filters {
    grid-template-columns: 1fr;
  }
}

/* Mobile: drawer sidebar + full mobile layout */
@media (max-width: 768px) {
  /* Show mobile elements */
  .mobile-header { display: flex; }
  .mobile-overlay { display: block; }
  .sidebar-close-btn { display: flex; }

  /* Prevent body scroll when drawer is open */
  body.drawer-locked { overflow: hidden; }

  /* Page shell: no sidebar in flow */
  .page-shell { grid-template-columns: 1fr; }

  /* Sidebar becomes fixed drawer */
  .sidebar {
    position: fixed !important;
    top: 0; left: 0;
    height: 100vh !important;
    width: 272px;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.28s ease;
    z-index: 310;
    overflow-y: auto;
    flex-direction: column !important;
    padding: 0 !important;
  }

  .sidebar.drawer-open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
  }

  /* Restore vertical nav inside drawer */
  .sidebar-nav {
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    padding: 8px 12px !important;
    gap: 2px !important;
  }

  .nav-tab-button {
    width: 100% !important;
    justify-content: flex-start !important;
  }

  /* Sidebar header inside drawer */
  .sidebar > div:first-child {
    padding: 16px 16px 14px !important;
  }

  /* Close button row */
  .sidebar-close-btn {
    margin: 10px 10px 0 auto;
    display: flex;
  }

  /* Content: push down for fixed header */
  .content {
    padding: 72px 14px 28px;
  }

  /* Context bar: stack vertically */
  .context-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 14px;
    border-left-width: 3px;
  }

  .context-selectors {
    flex-wrap: wrap;
    width: 100%;
    gap: 8px;
    align-items: stretch;
  }

  .context-selector-group {
    flex: 1;
    min-width: 120px;
  }

  .context-selector-group select {
    min-width: 0;
    width: 100%;
  }

  .privacy-toggle {
    align-self: flex-end;
  }

  .context-sub {
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .context-title {
    white-space: normal;
    overflow: visible;
  }

  /* Stats: 2 columns on mobile */
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
  }

  .stats-breakdown {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
  }

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

  .stat-card strong { font-size: 1.2rem; }

  .stat-sub { white-space: normal; }

  /* All panel grids: single column */
  .layout-grid,
  .charts-grid,
  .action-cards-grid {
    grid-template-columns: 1fr;
  }

  /* ── Forms: prevent overflow on mobile ──────────────────────── */
  .query-form,
  .card-import-form {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  /* Datas na mesma linha, lado a lado */
  #expense-query-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  /* Pessoa e Categoria ocupam a linha inteira */
  #expense-query-form .field-label:nth-child(3),
  #expense-query-form .field-label:nth-child(4) {
    grid-column: 1 / -1;
  }

  /* Force inputs/selects to respect their container width */
  input, select, textarea {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .field-label {
    min-width: 0;
    overflow: hidden;
  }

  /* Query form: compact date inputs on mobile */
  #expense-query-form input[type="date"] {
    width: 87%;
    min-width: 0;
    min-height: 34px;
    padding: 5px 6px;
    font-size: 0.78rem;
  }

  #expense-query-form select {
    min-height: 34px;
    padding: 5px 8px;
    font-size: 0.8rem;
  }

  /* Scrollable table container clips properly */
  .table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Profiles */
  .pf-layout {
    grid-template-columns: 1fr !important;
    align-items: start !important;
  }

  .pf-form-col { flex-direction: column; }

  /* Panels */
  .panel { padding: 16px; }
  .hero-card { padding: 16px; flex-direction: column; align-items: flex-start; }
  .hero-actions { width: 100%; min-width: 0; }

  /* Section heads: allow wrapping */
  .section-head {
    flex-wrap: wrap;
    gap: 8px;
  }

  .action-card-hint {
    white-space: normal;
    line-height: 1.4;
  }

  /* Calendar: compact squares on mobile, info via tap popup */
  .calendar-grid { gap: 3px; }
  .calendar-weekday { font-size: 0.58rem; padding: 3px 0; letter-spacing: 0; }
  .calendar-day {
    min-height: 42px !important;
    padding: 4px 2px !important;
    cursor: pointer;
    align-items: center;
    justify-items: center;
    gap: 3px;
    border-radius: 6px;
  }
  .calendar-day small { display: none; }
  .calendar-day strong { font-size: 0.78rem; text-align: center; }
  .calendar-day strong span { display: none; }
  .calendar-day:active { opacity: 0.75; }

  /* Table/list cards: reduce padding */
  .list-card { padding: 10px 12px; }

  /* Popup panels on mobile */
  .panel-body.popup-open {
    max-height: calc(100vh - 72px);
    padding: 14px;
  }

  .panel-body.popup-open .panel-popup-head {
    top: -14px;
    margin: -14px -14px 14px;
    padding: 12px 14px;
  }
}

/* Very small phones */
@media (max-width: 400px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stats-breakdown {
    grid-template-columns: 1fr;
  }

  .content { padding: 68px 12px 24px; }

  .stat-card strong { font-size: 1.1rem; }

  .mobile-brand-name { display: none; }
}

/* ─── Calendar day popup (mobile bottom sheet) ───────────────────────────── */
.cal-day-popup {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
}

.cal-day-popup.visible { display: block; }

.cal-day-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.cal-day-popup-card {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 8px 20px 36px;
  box-shadow: 0 -10px 48px rgba(15, 23, 42, 0.22);
  animation: cal-slide-up 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes cal-slide-up {
  from { transform: translateY(110%); }
  to   { transform: translateY(0); }
}

.cal-day-popup-handle {
  width: 38px;
  height: 4px;
  background: var(--line-strong);
  border-radius: 2px;
  margin: 0 auto 18px;
}

.cal-day-popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.cal-day-popup-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.025em;
  margin: 0 0 2px;
}

.cal-day-popup-weekday {
  font-size: 0.78rem;
  color: var(--muted);
}

.cal-popup-close-btn {
  width: 32px !important;
  min-width: 32px !important;
  height: 32px !important;
  min-height: 32px !important;
  padding: 0 !important;
  background: var(--surface-hover) !important;
  border: 1px solid var(--line) !important;
  border-radius: 50% !important;
  color: var(--muted) !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: none !important;
  transform: none !important;
}

.cal-popup-close-btn:hover {
  background: var(--line) !important;
  color: var(--text) !important;
  transform: none !important;
  box-shadow: none !important;
}

.cal-popup-close-btn svg { width: 14px; height: 14px; display: block; }

.cal-day-popup-rows { display: grid; gap: 10px; }

.cal-day-popup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

.cal-day-popup-row span { color: var(--muted); }

.cal-popup-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.cal-popup-value--positive { color: var(--success); }
.cal-popup-value--negative { color: var(--danger); }
.cal-popup-value--neutral  { color: var(--muted); }
