@font-face { font-family: 'Baloo 2'; src: url('../fonts/Baloo2-variable.ttf') format('truetype'); font-style: normal; font-weight: 400 800; font-display: swap; }
@font-face { font-family: 'Baloo Bhaijaan 2'; src: url('../fonts/BalooBhaijaan2-variable.ttf') format('truetype'); font-style: normal; font-weight: 400 800; font-display: swap; }
/* ═══════════════════════════════════════════════════
   app.css — Theme variables, layout, global styles
   Three themes on <html>:  (no class) = Dark  |  .theme-light = Light  |  .theme-colored = Colored
   Every theme defines the SAME tokens, so components never branch on the theme. Text tokens are chosen so ordinary text keeps >= 4.5:1
   on the surfaces it sits on (checked by updates/test-scripts/ux4_theme_brand_tests.mjs, which parses this file).
   ═══════════════════════════════════════════════════ */

/* ─── CSS Variables (Dark — the default) ────────────────────────────────── */
:root {
  color-scheme: dark;

  --bg-base:       #0a0a0a;
  --bg-surface:    #111827;
  --bg-card:       #1f2937;
  --bg-hover:      #283241;
  --bg-input:      #1f2937;

  --text-primary:  #f3f4f6;
  --text-secondary:#d1d5db;
  --text-muted:    #9ca3af;

  --border:        #374151;
  --border-light:  #4b5563;

  /* Accent fills (backgrounds with white text) are separate from accent TEXT colours so both stay readable */
  --color-primary: #3b82f6;
  --color-link:    #60a5fa;
  --btn-primary-bg:    #2563eb;
  --btn-primary-hover: #1d4ed8;
  --btn-success-bg:    #15803d;
  --btn-success-hover: #166534;
  --btn-danger-bg:     #dc2626;
  --btn-danger-hover:  #b91c1c;
  --focus-ring:    rgba(96,165,250,.35);

  --color-income:  #4ade80;
  --color-warning: #fbbf24;
  --color-danger:  #f87171;
  --color-success: #4ade80;
  --color-info:    #60a5fa;
  --color-purple:  #a78bfa;

  /* Semantic cues (always paired with text/icon, never colour alone) */
  --color-expense: #f87171;                      /* muted red, readable on dark cards */
  --color-work:        #60a5fa;
  --color-work-bg:     rgba(59,130,246,.16);
  --color-personal:    #2dd4bf;
  --color-personal-bg: rgba(20,184,166,.16);

  /* Layout chrome. Dark/Light reuse the card surfaces; Colored gives the sidebar its own darker tone. */
  --sidebar-bg:         var(--bg-surface);
  --sidebar-border:     var(--border);
  --sidebar-text:       var(--text-secondary);
  --sidebar-brand:      var(--text-primary);
  --sidebar-hover-bg:   var(--bg-hover);
  --sidebar-hover-text: var(--text-primary);
  --sidebar-active-bg:  rgba(59,130,246,.15);
  --sidebar-active-text:var(--color-link);
  --sidebar-logout:     var(--color-danger);
  --topbar-bg:          var(--bg-surface);
  --table-head-bg:      var(--bg-surface);
  --scope-bg:           var(--bg-card);

  /* Stat-card tones: neutral in Dark and Light, lightly tinted in Colored (income green, expense rose, net blue, savings violet).
     The label and the figure always carry the meaning; the tint is only a calm cue. */
  --tone-income-bg:     var(--bg-card);   --tone-income-border:  var(--border);
  --tone-expense-bg:    var(--bg-card);   --tone-expense-border: var(--border);
  --tone-net-bg:        var(--bg-card);   --tone-net-border:     var(--border);
  --tone-savings-bg:    var(--bg-card);   --tone-savings-border: var(--border);

  --sidebar-width: 240px;
  --topbar-height: 60px;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-lg:     0 10px 25px rgba(0,0,0,.5);
  --transition:    0.2s ease;

  /* ── Shorthand aliases used by inline page styles ── */
  --text:          var(--text-primary);
  --accent:        var(--color-primary);
  --surface:       var(--bg-card);
  --surface-hover: var(--bg-hover);
}

/* ─── Light Mode Overrides ──────────────────────────────────────────────── */
.theme-light {
  color-scheme: light;

  --bg-base:       #f9fafb;
  --bg-surface:    #ffffff;
  --bg-card:       #ffffff;
  --bg-hover:      #f3f4f6;
  --bg-input:      #f9fafb;

  --text-primary:  #111827;
  --text-secondary:#4b5563;
  --text-muted:    #5b6472;

  --border:        #e5e7eb;
  --border-light:  #d1d5db;

  --color-link:    #1d4ed8;
  --focus-ring:    rgba(37,99,235,.28);

  /* Darker semantic tones so text/icons keep >= 4.5:1 on white cards and on their own tinted badges */
  --color-income:      #166534;
  --color-success:     #166534;
  --color-expense:     #b91c1c;
  --color-danger:      #b91c1c;
  --color-warning:     #92400e;
  --color-info:        #1d4ed8;
  --color-purple:      #6d28d9;
  --color-work:        #1d4ed8;
  --color-work-bg:     rgba(37,99,235,.10);
  --color-personal:    #0f766e;
  --color-personal-bg: rgba(13,148,136,.10);

  --sidebar-active-bg:  rgba(37,99,235,.10);

  --shadow:        0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 25px rgba(0,0,0,.15);
}

/* ─── Colored Mode ──────────────────────────────────────────────────────────
   A calm light workspace with a darker green-teal sidebar (echoing the brand mark) and lightly tinted stat cards. The palette is this
   project's own proposal: it is NOT a verified match of any other application's interface. */
.theme-colored {
  color-scheme: light;

  --bg-base:       #f2f5f4;
  --bg-surface:    #ffffff;
  --bg-card:       #ffffff;
  --bg-hover:      #e6eeeb;
  --bg-input:      #ffffff;

  --text-primary:  #14211d;
  --text-secondary:#3f524c;
  --text-muted:    #566860;

  --border:        #d2ddd9;
  --border-light:  #bccbc5;

  --color-primary: #0f766e;
  --color-link:    #1d4ed8;
  --btn-primary-bg:    #0f766e;
  --btn-primary-hover: #115e59;
  --focus-ring:    rgba(15,118,110,.30);

  --color-income:      #166534;
  --color-success:     #166534;
  --color-expense:     #9f1239;
  --color-danger:      #b91c1c;
  --color-warning:     #92400e;
  --color-info:        #1d4ed8;
  --color-purple:      #6d28d9;
  --color-work:        #1d4ed8;
  --color-work-bg:     rgba(37,99,235,.10);
  --color-personal:    #0f766e;
  --color-personal-bg: rgba(13,148,136,.10);

  --sidebar-bg:         #1d3a35;
  --sidebar-border:     #2b4a44;
  --sidebar-text:       #d6e4e0;
  --sidebar-brand:      #ffffff;
  --sidebar-hover-bg:   #26463f;
  --sidebar-hover-text: #ffffff;
  --sidebar-active-bg:  #2d5a4f;
  --sidebar-active-text:#ffffff;
  --sidebar-logout:     #fca5a5;
  --topbar-bg:          #ffffff;
  --table-head-bg:      #eaf1ee;
  --scope-bg:           #e9f2ef;

  --tone-income-bg:     #e5f4ea;   --tone-income-border:  #b9dcc5;
  --tone-expense-bg:    #fbe9ec;   --tone-expense-border: #efc3cb;
  --tone-net-bg:        #e4eefb;   --tone-net-border:     #b9d0ee;
  --tone-savings-bg:    #ece8f7;   --tone-savings-border: #cfc6e9;

  --shadow:        0 1px 2px rgba(20,60,50,.07), 0 2px 8px rgba(20,60,50,.05);
  --shadow-lg:     0 10px 25px rgba(20,60,50,.18);
}

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

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

body {
  /* Brand type: Baloo 2 (English) with Baloo Bhaijaan 2 for Arabic data, then system fonts. The fonts are hosted locally under assets/fonts (display=swap), compatible with the existing self-only CSP. */
  font-family: 'Baloo 2', 'Baloo Bhaijaan 2', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--color-link); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { display: block; }

button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* Figures line up in columns (ignored by fonts without tabular figures) */
.stat-card-value, .amount-income, .amount-expense, td, th, input[type="number"] { font-variant-numeric: tabular-nums; }

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

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

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  min-height: var(--topbar-height);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-brand);
}

/* The supplied preliminary brand mark, shown unchanged and scaled by CSS only (object-fit keeps its square proportions; the rounded corners are
   presentation, the file has no transparency) */
.brand-logo { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; }
.logo-text { font-size: 1.1rem; font-weight: 700; color: var(--sidebar-brand); letter-spacing: -0.3px; }

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--sidebar-text);
  padding: 10px;                      /* 20px glyph + padding = 40px; the close control is easy to hit on a phone */
  border-radius: 6px;
}
.sidebar-close:hover { color: var(--sidebar-hover-text); background: var(--sidebar-hover-bg); }
.sidebar-close svg { width: 20px; height: 20px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-hover-text); text-decoration: none; }
.nav-item:focus-visible { outline: 2px solid var(--sidebar-active-text); outline-offset: 1px; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 600; }
.nav-item.active svg { stroke: var(--sidebar-active-text); }
.nav-item svg { flex-shrink: 0; opacity: 0.9; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
}

.nav-logout { color: var(--sidebar-logout) !important; }
.nav-logout:hover { background: rgba(239,68,68,0.14) !important; }

/* Overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ─── Main Wrapper ──────────────────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ─── Topbar ────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.topbar .page-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .hamburger { flex: 0 0 auto; }

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--radius);
}
.hamburger:hover { background: var(--bg-hover); color: var(--text-primary); }

.page-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Currency switcher pill (topbar) */
.currency-pill {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.5px;
  white-space: nowrap;
  min-height: 36px;
}
.currency-pill:hover { background: var(--btn-primary-bg); color: #fff; border-color: var(--btn-primary-bg); }

/* Currency option buttons inside modal */
.cur-option-group { display: flex; gap: 10px; flex-wrap: wrap; }
.cur-option {
  flex: 1;
  min-width: 80px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  background: none;
  transition: border-color var(--transition), background var(--transition);
}
.cur-option:hover { border-color: var(--color-primary); background: rgba(59,130,246,.06); }
.cur-option.active { border-color: var(--color-primary); background: rgba(59,130,246,.12); }
.cur-option-code { display: block; font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.cur-option-name { display: block; font-size: .72rem; color: var(--text-muted); margin-top: 3px; }

/* Rate input row inside modal */
.cur-rate-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cur-rate-base   { font-size: .875rem; color: var(--text-muted); white-space: nowrap; }
.cur-rate-target { font-size: .875rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.cur-rate-input  { max-width: 160px; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  position: relative;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn:focus-visible { outline: 2px solid var(--color-link); outline-offset: 1px; }

/* Theme button: the icon of the CURRENT theme (sun = Light, moon = Dark, drop = Colored), chosen by <html data-theme> (theme.js / layout.php) */
.theme-ic { display: none; }
html:not([data-theme]) .theme-ic-dark,
html[data-theme="light"] .theme-ic-light,
html[data-theme="dark"] .theme-ic-dark,
html[data-theme="colored"] .theme-ic-colored { display: block; }

/* Brief confirmation of the new theme name under the button (a status text, not another control) */
.theme-toggle-wrap { position: relative; display: flex; }
.theme-feedback {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  padding: 4px 10px; border-radius: var(--radius); white-space: nowrap; pointer-events: none;
  background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-size: 0.8rem; font-weight: 600; opacity: 0; transition: opacity var(--transition);
}
.theme-feedback.show { opacity: 1; }
.theme-feedback:empty { display: none; }

.notification-btn { position: relative; }
.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--btn-danger-bg);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--btn-primary-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: default;
  user-select: none;
}

/* ─── Main Content ──────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 24px;
  overflow-x: hidden;   /* last-resort guard only; the causes of clipping are fixed at the grid/card level */
}
.main-content:focus { outline: none; }   /* programmatic focus target when a dialog's opener was re-rendered away (modal_a11y.js) */

/* ─── Typography Utilities ──────────────────────────────────────────────── */
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-income    { color: var(--color-income); }
.text-expense   { color: var(--color-expense); }
.text-success   { color: var(--color-success); }
.text-warning   { color: var(--color-warning); }
.text-danger    { color: var(--color-danger); }
.text-info      { color: var(--color-info); }
.text-center    { text-align: center; }
.text-right     { text-align: right; }
.text-sm        { font-size: 0.85rem; }
.text-xs        { font-size: 0.75rem; }
.text-lg        { font-size: 1.125rem; }
.font-bold      { font-weight: 700; }
.font-semibold  { font-weight: 600; }
.font-medium    { font-weight: 500; }

/* ─── Layout Utilities ──────────────────────────────────────────────────── */
.flex           { display: flex; }
.flex-col       { flex-direction: column; }
.items-center   { align-items: center; }
.items-start    { align-items: flex-start; }
.justify-between{ justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1          { gap: 4px; }
.gap-2          { gap: 8px; }
.gap-3          { gap: 12px; }
.gap-4          { gap: 16px; }
.gap-6          { gap: 24px; }
.flex-1         { flex: 1; }
.w-full         { width: 100%; }

.grid           { display: grid; }
/* minmax(0, 1fr): a plain 1fr track has an automatic minimum of its content's min-content width, so one long row
   or a wide canvas widened the whole column past the viewport (observed at 390px: cards 603px wide). */
.grid-cols-2    { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3    { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4    { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid > *       { min-width: 0; }

/* Dashboard chart row: wider left column on desktop, stacks on mobile */
.dashboard-charts-row { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
/* Reports chart row (was an inline style that could not stack) */
.reports-charts-row   { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }

/* Chart container: Chart.js sizes the canvas to this box, so it must be shrinkable and positioned */
.chart-box      { position: relative; height: 260px; min-width: 0; max-width: 100%; }
.chart-box-lg   { height: 280px; }

/* Long text inside flex rows: let the text column shrink instead of pushing the amount out of view */
.row-main       { flex: 1 1 auto; min-width: 0; }
.row-clamp-2    { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.row-wrap       { overflow-wrap: anywhere; }
.row-amount     { flex: 0 0 auto; white-space: nowrap; }

/* ─── Spacing Utilities ─────────────────────────────────────────────────── */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.p-4  { padding: 16px; }
.p-6  { padding: 24px; }

/* ─── Alert/Toast ───────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: slideIn 0.2s ease;
  font-size: 0.9rem;
}

.toast.toast-success { border-left: 3px solid var(--color-success); }
.toast.toast-error   { border-left: 3px solid var(--color-danger); }
.toast.toast-warning { border-left: 3px solid var(--color-warning); }
.toast.toast-info    { border-left: 3px solid var(--color-info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(8px); }
}

/* ─── Loading Spinner ───────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty State ───────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state svg { margin: 0 auto 12px; opacity: 0.4; }
.empty-state p   { font-size: 0.95rem; }

/* ─── Page Header ───────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header h1.page-title { font-size: 1.35rem; font-weight: 700; color: var(--text-primary); }
.page-header h2             { font-size: 1.25rem; font-weight: 700; }
.page-subtitle { font-size: .8125rem; color: var(--text-muted); margin-top: 2px; }
.page-actions  { display: flex; gap: 8px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }
.hidden        { display: none !important; }

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-overlay.open { display: block; }
  .sidebar-close        { display: flex; }
  .hamburger            { display: flex; }

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

  .main-content { padding: 16px; }

  .topbar { padding: 0 16px; }

  .grid-cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-cols-2 { grid-template-columns: minmax(0, 1fr); }
  /* Medium widths (~768px): three cards in two columns would leave a gap beside the third (Period net) — it takes the full row.
     Phones (<= 480px) are one column (below) and are not touched by this rule. */
  .grid-cols-3 > :nth-child(3):last-child { grid-column: 1 / -1; }
  .dashboard-charts-row,
  .reports-charts-row   { grid-template-columns: minmax(0, 1fr); }

  .toast-container { bottom: 16px; right: 16px; left: 16px; max-width: none; }

  /* Page header stacks on narrow screens */
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-actions { width: 100%; }

  /* Hide less-critical table columns on mobile */
  .table .hide-mobile { display: none; }
}

@media (max-width: 480px) {
  /* Top bar: all controls stay at full size; the space comes from tighter gaps and the (ellipsised) title */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-left { gap: 6px; }
  .topbar-right { gap: 4px; }
  .topbar .page-title { font-size: 0.98rem; }

  .grid-cols-4,
  .grid-cols-3,
  .grid-cols-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-cols-3 > :nth-child(3):last-child { grid-column: auto; }

  .page-header h1.page-title { font-size: 1.15rem; }

  /* Stat cards: smaller value text on tiny screens */
  .stat-card-value { font-size: 1.3rem; }

  /* Full-width buttons on tiny screens */
  .page-actions .btn { flex: 1; justify-content: center; }

  /* Filters wrap better */
  .filters-bar { gap: 6px; }
  .filters-bar .form-control { min-width: 120px; }
}

/* ─── Hide/Show Amounts ──────────────────────────────────────────────────── */
/* When .amounts-hidden is on <body>, blur financial figures */
.amounts-hidden .stat-card-value,
.amounts-hidden .amount-income,
.amounts-hidden .amount-expense,
.amounts-hidden [data-sensitive] {
  color: transparent !important;
  text-shadow: 0 0 10px var(--text-primary);
  user-select: none;
  transition: color 0.25s, text-shadow 0.25s;
}

/* ─── Profile Dropdown ───────────────────────────────────────────────────── */
.user-menu {
  position: relative;
}
.user-avatar {
  cursor: pointer;
  user-select: none;
}
.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  overflow: hidden;
  animation: modalIn 0.15s ease;
}
.user-dropdown.open { display: block; }
.user-dropdown-header {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.user-dropdown-name  { font-size: .875rem; font-weight: 600; color: var(--text-primary); }
.user-dropdown-email { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: .875rem;
  color: var(--text-primary);
  background: none;
  border: none;
  width: 100%;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition);
}
.user-dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.user-dropdown-item.danger { color: var(--color-danger); }
.user-dropdown-item.danger:hover { background: rgba(239,68,68,.1); }
.user-dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
