/* ─────────────────────────────────────────────────────────────────────────────
   Ozeil.io — Design System
   Palette : vert sauge moderne, neutres chauds, accents précis
   Typographie : Syne (display) + Inter (corps)
───────────────────────────────────────────────────────────────────────────── */

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

/* ─── DESIGN TOKENS — LIGHT ─────────────────────────────────────────────── */
:root {
  --font-display : 'Syne', system-ui, sans-serif;
  --font-body    : 'Inter', system-ui, sans-serif;

  --bg           : #f2f4f2;
  --bg-2         : #e8ece8;
  --surface      : #ffffff;
  --surface-2    : #f7f9f7;
  --border       : #dce5dc;
  --border-2     : #c8d4c8;

  --text         : #111a11;
  --text-2       : #4a5e4a;
  --text-3       : #849484;

  --brand        : #2d6a4f;
  --brand-mid    : #40916c;
  --brand-light  : #74c69d;
  --brand-pale   : #d8f3dc;
  --brand-soft   : #e8f5e9;

  --accent       : #1b2e1b;
  --accent-soft  : #edf4ed;

  --income       : #2d6a4f;
  --income-bg    : #d8f3dc;
  --expense      : #c0392b;
  --expense-bg   : #fdecea;
  --neutral      : #40916c;

  --shadow-sm    : 0 1px 3px rgba(17,26,17,.06), 0 1px 2px rgba(17,26,17,.04);
  --shadow       : 0 4px 16px rgba(17,26,17,.07), 0 2px 6px rgba(17,26,17,.04);
  --shadow-lg    : 0 16px 48px rgba(17,26,17,.11), 0 4px 12px rgba(17,26,17,.07);

  --radius       : 14px;
  --radius-sm    : 9px;
  --radius-lg    : 20px;
  --sidebar-w    : 264px;
  --topbar-h     : 62px;
  --transition   : .2s cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
  --bg           : #0d120d;
  --bg-2         : #141c14;
  --surface      : #182018;
  --surface-2    : #1e281e;
  --border       : #253225;
  --border-2     : #2e3e2e;
  --text         : #e8f0e8;
  --text-2       : #8aab8a;
  --text-3       : #526052;
  --brand        : #52b788;
  --brand-mid    : #74c69d;
  --brand-light  : #95d5b2;
  --brand-pale   : #1a3320;
  --brand-soft   : #162316;
  --accent       : #c8e6c8;
  --accent-soft  : #1a2a1a;
  --income       : #52b788;
  --income-bg    : #0d2a18;
  --expense      : #e57373;
  --expense-bg   : #2a0d0d;
  --shadow-sm    : 0 1px 3px rgba(0,0,0,.35);
  --shadow       : 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg    : 0 16px 48px rgba(0,0,0,.55);
}

/* ─── RESET ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html  { font-size: 16px; scroll-behavior: smooth; }
body  {
  font-family: var(--font-body);
  background: var(--bg); color: var(--text);
  display: flex; min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  overflow-x: hidden;
}
input, select, textarea, button { font-family: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ─── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); min-height: 100vh;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 100;
  transition: transform var(--transition), background var(--transition);
}
.sidebar-header {
  padding: 22px 20px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff; box-shadow: 0 2px 8px rgba(45,106,79,.35);
}
.logo-text {
  font-family: var(--font-display); font-size: 18px; font-weight: 800;
  color: var(--text); letter-spacing: -0.4px;
}
.logo-text span { color: var(--brand-mid); }
.sidebar-close { display: none; color: var(--text-2); font-size: 18px; padding: 4px 8px; border-radius: 6px; }
.sidebar-close:hover { background: var(--bg-2); }
.sidebar-section { padding: 16px 12px; border-bottom: 1px solid var(--border); }
.section-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-3); padding: 0 8px; margin-bottom: 8px;
}
.account-list { display: flex; flex-direction: column; gap: 2px; }
.account-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius-sm); cursor: pointer; transition: background var(--transition); position: relative;
}
.account-item:hover { background: var(--bg-2); }
.account-item.active { background: var(--brand-soft); }
.account-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.account-info { flex: 1; min-width: 0; }
.account-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-bal { font-size: 11px; color: var(--text-2); }
.account-actions { display: none; gap: 4px; }
.account-item:hover .account-actions { display: flex; }
.account-action-btn { color: var(--text-3); font-size: 13px; padding: 2px 4px; border-radius: 4px; }
.account-action-btn:hover { color: var(--text); background: var(--border); }
.all-accounts-btn {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius-sm); cursor: pointer; transition: background var(--transition);
  width: 100%; color: var(--text); font-size: 13px; font-weight: 500;
}
.all-accounts-btn:hover { background: var(--bg-2); }
.all-accounts-btn.active { background: var(--brand-soft); }
.btn-add-account {
  display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; color: var(--text-2);
  transition: all var(--transition); border: 1.5px dashed var(--border-2);
}
.btn-add-account:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  color: var(--text-2); cursor: pointer; transition: all var(--transition);
}
.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-icon { font-style: normal; width: 18px; text-align: center; }
.sidebar-footer { margin-top: auto; padding: 16px 12px; border-top: 1px solid var(--border); }
.theme-toggle {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  color: var(--text-2); transition: all var(--transition);
}
.theme-toggle:hover { background: var(--bg-2); color: var(--text); }
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 99; backdrop-filter: blur(2px);
}

/* ─── MAIN ───────────────────────────────────────────────────────────────── */
.main {
  flex: 1; margin-left: var(--sidebar-w); min-height: 100vh;
  display: flex; flex-direction: column; transition: margin var(--transition);
}

/* ─── TOPBAR ─────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h); background: var(--surface); 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;
  transition: background var(--transition); position: sticky;
}
.topbar::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-light) 100%);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.hamburger { display: none; flex-direction: column; gap: 5px; padding: 6px; border-radius: 6px; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; }
.hamburger:hover { background: var(--bg-2); }
.page-title {
  font-family: var(--font-display); font-size: 19px; font-weight: 700;
  color: var(--text); letter-spacing: -0.3px;
}
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.month-selector {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg-2); border-radius: 10px; padding: 4px;
}
.month-selector button {
  width: 30px; height: 30px; border-radius: 7px; font-size: 18px; color: var(--text-2);
  transition: all var(--transition); display: flex; align-items: center; justify-content: center;
}
.month-selector button:hover { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.month-selector span { font-size: 13px; font-weight: 600; color: var(--text); min-width: 92px; text-align: center; }
.account-badge {
  background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 600;
  padding: 5px 12px; border-radius: 20px; border: 1px solid var(--brand-pale); white-space: nowrap;
}

/* ─── VIEWS ──────────────────────────────────────────────────────────────── */
.view { display: none; padding: 24px; }
.view.active { display: block; }

/* ─── STAT CARDS ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
  background: var(--border); transition: background var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-card:hover::after { background: var(--brand-light); }
.stat-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-3); margin-bottom: 8px; }
.stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -1px; }
.stat-value.income  { color: var(--income); }
.stat-value.expense { color: var(--expense); }
.stat-value.balance { color: var(--text); }
.stat-sub { font-size: 11px; color: var(--text-3); margin-top: 5px; }

/* ─── DASHBOARD GRID ─────────────────────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-weight: 600; font-size: 14px; color: var(--text); }
.card-action { font-size: 12px; color: var(--brand); cursor: pointer; font-weight: 500; }
.card-action:hover { text-decoration: underline; }

/* ─── CHARTS ─────────────────────────────────────────────────────────────── */
.mini-chart { width: 100%; }
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.chart-bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; justify-content: flex-end; }
.chart-bars-inner { display: flex; gap: 2px; align-items: flex-end; width: 100%; height: 100%; justify-content: center; }
.bar { flex: 1; border-radius: 4px 4px 0 0; min-height: 2px; transition: height .4s cubic-bezier(.4,0,.2,1); max-width: 16px; }
.bar.income-bar  { background: var(--income); opacity: .85; }
.bar.expense-bar { background: var(--expense); opacity: .75; }
.bar-label { font-size: 9px; color: var(--text-3); white-space: nowrap; margin-top: 4px; }
.chart-legend { display: flex; gap: 16px; margin-top: 12px; }
.chart-legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-2); }
.chart-legend-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ─── CATEGORY BARS ──────────────────────────────────────────────────────── */
.cat-list { display: flex; flex-direction: column; gap: 9px; }
.cat-row { display: flex; align-items: center; gap: 10px; }
.cat-icon-sm { font-size: 15px; width: 22px; text-align: center; flex-shrink: 0; }
.cat-name-sm { font-size: 12px; color: var(--text); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-bar-wrap { flex: 2; background: var(--bg-2); border-radius: 4px; height: 5px; overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 4px; transition: width .4s ease; }
.cat-amount { font-size: 12px; font-weight: 600; color: var(--text); min-width: 64px; text-align: right; }

/* ─── TRANSACTIONS ───────────────────────────────────────────────────────── */
.tx-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tx-filter-tabs { display: flex; gap: 4px; background: var(--bg-2); border-radius: 10px; padding: 4px; }
.filter-tab { padding: 6px 14px; border-radius: 7px; font-size: 12px; font-weight: 500; color: var(--text-2); transition: all var(--transition); cursor: pointer; }
.filter-tab.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); font-weight: 600; }
.tx-list { display: flex; flex-direction: column; gap: 5px; }
.tx-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 16px;
  transition: box-shadow var(--transition), border-color var(--transition);
  animation: fadeSlide .2s ease;
}
.tx-item:hover { box-shadow: var(--shadow-sm); border-color: var(--border-2); }
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.tx-cat-icon { font-size: 18px; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: var(--bg-2); border-radius: 10px; flex-shrink: 0; }
.tx-info { flex: 1; min-width: 0; }
.tx-label { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.tx-tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 10px; font-weight: 500; background: var(--bg-2); color: var(--text-3); margin-right: 4px; }
.tx-fixed-tag { background: #fef9c3; color: #854d0e; }
[data-theme="dark"] .tx-fixed-tag { background: #422006; color: #fbbf24; }
.tx-amount { font-family: var(--font-display); font-size: 15px; font-weight: 700; letter-spacing: -0.3px; white-space: nowrap; }
.tx-amount.income  { color: var(--income); }
.tx-amount.expense { color: var(--expense); }
.tx-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--transition); }
.tx-item:hover .tx-actions { opacity: 1; }
.tx-btn { color: var(--text-3); padding: 4px 6px; border-radius: 6px; font-size: 13px; transition: all var(--transition); }
.tx-btn:hover { background: var(--bg-2); color: var(--text); }
.tx-btn.del:hover { background: var(--expense-bg); color: var(--expense); }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: var(--text-3); text-align: center; }
.empty-icon  { font-size: 44px; margin-bottom: 14px; opacity: .4; }
.empty-title { font-size: 15px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.empty-sub   { font-size: 12px; }

/* ─── FIXED CHARGES ──────────────────────────────────────────────────────── */
.fixed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.fixed-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.fixed-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.fixed-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.fixed-card-icon  { font-size: 20px; }
.fixed-card-title { font-size: 14px; font-weight: 600; color: var(--text); flex: 1; }
.fixed-card-badge { font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.fixed-card-badge.expense { background: var(--expense-bg); color: var(--expense); }
.fixed-card-badge.income  { background: var(--income-bg);  color: var(--income); }
.fixed-card-amount { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.fixed-card-amount.expense { color: var(--expense); }
.fixed-card-amount.income  { color: var(--income); }
.fixed-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.fixed-card-cat { font-size: 11px; color: var(--text-3); }
.fixed-card-actions { display: flex; gap: 4px; align-items: center; }
.toggle-switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--border-2); border-radius: 10px; transition: .2s; }
.toggle-slider:before { content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: white; left: 3px; top: 3px; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
input:checked + .toggle-slider { background: var(--income); }
input:checked + .toggle-slider:before { transform: translateX(16px); }

/* ─── SEARCH ─────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 12px 18px; margin-bottom: 18px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-bar:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent); }
.search-icon  { font-size: 18px; color: var(--text-3); }
.search-input { flex: 1; background: none; border: none; outline: none; font-size: 15px; color: var(--text); }
.search-input::placeholder { color: var(--text-3); }
.search-filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.search-filter { padding: 5px 14px; border-radius: 20px; font-size: 12px; font-weight: 500; border: 1.5px solid var(--border); color: var(--text-2); cursor: pointer; transition: all var(--transition); }
.search-filter.active { background: var(--brand); border-color: var(--brand); color: white; }
.search-count { font-size: 12px; color: var(--text-3); margin-bottom: 10px; }

/* ─── CATEGORIES ─────────────────────────────────────────────────────────── */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.cat-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 14px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; position: relative; transition: box-shadow var(--transition), border-color var(--transition); }
.cat-card:hover { box-shadow: var(--shadow-sm); border-color: var(--border-2); }
.cat-card-icon { font-size: 24px; }
.cat-card-name { font-size: 12px; font-weight: 500; color: var(--text); }
.cat-card-del { position: absolute; top: 6px; right: 6px; opacity: 0; color: var(--text-3); font-size: 12px; background: var(--bg-2); border-radius: 4px; padding: 2px 5px; transition: opacity var(--transition); }
.cat-card:hover .cat-card-del { opacity: 1; }
.cat-card-del:hover { color: var(--expense); background: var(--expense-bg); }
.cat-add-card { background: none; border: 1.5px dashed var(--border-2); border-radius: var(--radius-sm); padding: 14px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; color: var(--text-3); transition: all var(--transition); font-size: 12px; font-weight: 500; }
.cat-add-card:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.cat-add-icon { font-size: 22px; }

/* ─── MODALS ─────────────────────────────────────────────────────────────── */
.modal-backdrop { display: none; position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.45); align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(4px); }
.modal-backdrop.open { display: flex; animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 480px; box-shadow: var(--shadow-lg); animation: slideUp .22s cubic-bezier(.34,1.5,.64,1); border: 1px solid var(--border); }
.modal.modal-sm { max-width: 360px; }
@keyframes slideUp {
  from { transform: translateY(20px) scale(.97); opacity: 0; }
  to   { transform: translateY(0)    scale(1);   opacity: 1; }
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--text); }
.modal-close { color: var(--text-3); font-size: 18px; padding: 4px 8px; border-radius: 6px; transition: all var(--transition); }
.modal-close:hover { background: var(--bg-2); color: var(--text); }
.modal-body   { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 11px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .5px; }
input[type="text"], input[type="number"], input[type="month"], select, textarea {
  background: var(--bg-2); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 13px; font-size: 14px; color: var(--text); width: 100%; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition); appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent);
  background: var(--surface);
}
input[type="color"] { padding: 4px; height: 40px; cursor: pointer; }
textarea { resize: vertical; }
.type-toggle { display: flex; gap: 4px; background: var(--bg-2); border-radius: 10px; padding: 4px; }
.type-btn { flex: 1; padding: 8px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--text-2); transition: all var(--transition); }
.type-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.icon-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-opt { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; font-size: 20px; border-radius: 10px; cursor: pointer; border: 2px solid transparent; background: var(--bg-2); transition: all var(--transition); }
.icon-opt:hover { background: var(--brand-soft); }
.icon-opt.selected { border-color: var(--brand); background: var(--brand-soft); }
.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-opt { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: all var(--transition); box-shadow: 0 0 0 2px var(--surface); }
.color-opt.selected { border-color: var(--text); transform: scale(1.15); }
.color-opt:hover { transform: scale(1.1); }

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */
.btn { padding: 9px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; transition: all var(--transition); }
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-mid); box-shadow: 0 4px 12px rgba(45,106,79,.3); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text); }
.btn-danger { background: var(--expense); color: white; }
.btn-danger:hover { opacity: .85; }

/* ─── FAB ────────────────────────────────────────────────────────────────── */
.fab {
  position: fixed; right: 24px; bottom: 28px; width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-mid) 100%); color: white; font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(45,106,79,.45); z-index: 80; transition: all var(--transition);
}
.fab:hover { transform: scale(1.08) rotate(90deg); box-shadow: 0 8px 28px rgba(45,106,79,.55); }

/* ─── TOAST ──────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 88px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 300; }
.toast { background: var(--accent); color: var(--bg); padding: 11px 18px; border-radius: 10px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); animation: toastIn .3s cubic-bezier(.34,1.5,.64,1); }
.toast.success { background: var(--brand); color: white; }
.toast.error   { background: var(--expense); color: white; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(.9); }
  to   { opacity: 1; transform: translateX(0)    scale(1); }
}

/* ─── APPLY BANNER ───────────────────────────────────────────────────────── */
.apply-banner { background: var(--brand-soft); border: 1.5px solid var(--brand-pale); border-radius: var(--radius); padding: 13px 18px; display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
[data-theme="dark"] .apply-banner { background: var(--brand-pale); border-color: var(--brand-mid); }
.apply-banner-text { flex: 1; font-size: 13px; color: var(--brand); font-weight: 500; }
.apply-banner-btn { background: var(--brand); color: white; border: none; padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all var(--transition); }
.apply-banner-btn:hover { background: var(--brand-mid); }

/* ─── ACCOUNT CARDS ──────────────────────────────────────────────────────── */
.accounts-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 22px; scrollbar-width: none; }
.accounts-row::-webkit-scrollbar { display: none; }
.account-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 16px 18px; min-width: 170px; cursor: pointer; position: relative; overflow: hidden; transition: all var(--transition); }
.account-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.account-card.selected { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent); }
.account-card-icon    { font-size: 22px; margin-bottom: 8px; }
.account-card-name    { font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 4px; }
.account-card-balance { font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: -0.5px; color: var(--text); }

/* ─── SECTION HEADERS ────────────────────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title { font-family: var(--font-display); font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }

/* ─── MISC ───────────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-3); }
.text-sm    { font-size: 12px; }
.divider    { height: 1px; background: var(--border); margin: 16px 0; }
.balance-positive { color: var(--income); }
.balance-negative { color: var(--expense); }
.highlight { background: #d8f3dc; border-radius: 3px; padding: 0 2px; color: var(--brand); }
[data-theme="dark"] .highlight { background: var(--brand-pale); color: var(--brand-light); }

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-close { display: block; }
  .sidebar-overlay.open { display: block; }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
  .topbar { padding: 0 16px; }
  .view { padding: 16px; }
  .fab { right: 16px; bottom: 20px; }
  .toast-container { right: 16px; bottom: 80px; }
  .month-selector span { min-width: 70px; font-size: 12px; }
  .account-badge { display: none; }
  .fixed-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 20px; }
}
@media (max-width: 480px) {
  .modal { border-radius: var(--radius); }
  .modal-body { padding: 16px; }
  .modal-header, .modal-footer { padding: 14px 16px; }
  .tx-item { padding: 10px 12px; gap: 10px; }
  .tx-actions { opacity: 1; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* ─── INLINE SEARCH ──────────────────────────────────────────────────────── */
.inline-search {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-2); border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  min-width: 200px; max-width: 320px;
}



.inline-search:focus-within {
  border-color: var(--brand); background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent);
}
.inline-search-icon  { font-size: 15px; color: var(--text-3); flex-shrink: 0; }
.inline-search-input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 13px; color: var(--text); min-width: 0;
}
.inline-search-input::placeholder { color: var(--text-3); }
.inline-search-clear {
  color: var(--text-3); font-size: 14px; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; background: var(--border-2);
  transition: all var(--transition); flex-shrink: 0;
}
.inline-search-clear:hover { background: var(--expense-bg); color: var(--expense); }

/* Dropdown */
.search-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 200;
  overflow: hidden; min-width: 380px;
  animation: slideDown .15s cubic-bezier(.34,1.5,.64,1);
}
.search-dropdown.open { display: block; }

@keyframes slideDown {
  from { opacity:0; transform: translateY(-8px) scale(.98); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

.sd-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 6px; font-size: 11px; color: var(--text-3); border-bottom: 1px solid var(--border);
}
.sd-filters { display: flex; gap: 4px; }
.sd-filter {
  padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 500;
  border: 1px solid var(--border); color: var(--text-2); cursor: pointer; transition: all var(--transition);
}
.sd-filter.active { background: var(--brand); border-color: var(--brand); color: white; }

.sd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; cursor: pointer; transition: background var(--transition);
}
.sd-item:hover { background: var(--bg-2); }
.sd-icon { font-size: 18px; flex-shrink: 0; }
.sd-info { flex: 1; min-width: 0; }
.sd-label { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-meta  { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.sd-amount { font-size: 13px; font-weight: 700; white-space: nowrap; }
.sd-amount.income  { color: var(--income); }
.sd-amount.expense { color: var(--expense); }
.sd-del {
  color: var(--text-3); font-size: 12px; padding: 3px 6px; border-radius: 5px;
  opacity: 0; transition: all var(--transition);
}
.sd-item:hover .sd-del { opacity: 1; }
.sd-del:hover { background: var(--expense-bg); color: var(--expense); }
.sd-empty { padding: 20px 14px; font-size: 13px; color: var(--text-3); text-align: center; }

/* ─── ANALYTICS ──────────────────────────────────────────────────────────── */
.analytics-kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
  gap: 14px; margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-sm); transition: box-shadow var(--transition), transform var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.kpi-label { font-size: 11px; color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.kpi-value { font-family: var(--font-display); font-size: 18px; font-weight: 700; letter-spacing: -.4px; }
.kpi-value.income  { color: var(--income); }
.kpi-value.expense { color: var(--expense); }

.analytics-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* 12-month chart */
.chart-12 {
  display: flex; align-items: flex-end; gap: 4px; height: 130px;
  overflow-x: auto; padding-bottom: 4px; scrollbar-width: none;
}
.chart-12::-webkit-scrollbar { display: none; }
.chart12-group {
  flex: 1; min-width: 32px; display: flex; flex-direction: column;
  align-items: center; gap: 3px; height: 100%; justify-content: flex-end;
}
.chart12-bars {
  display: flex; gap: 2px; align-items: flex-end;
  width: 100%; justify-content: center; height: 110px;
}
.chart12-bar {
  flex: 1; border-radius: 3px 3px 0 0; min-height: 2px; max-width: 12px;
  transition: height .4s cubic-bezier(.4,0,.2,1);
}
.chart12-bar.income-bar  { background: var(--income); opacity: .85; }
.chart12-bar.expense-bar { background: var(--expense); opacity: .75; }
.chart12-label { font-size: 8px; color: var(--text-3); white-space: nowrap; text-align: center; }

/* Savings rate chart */
.savings-chart {
  display: flex; align-items: flex-end; gap: 4px; height: 120px;
  overflow-x: auto; scrollbar-width: none; padding-bottom: 4px;
}
.savings-chart::-webkit-scrollbar { display: none; }
.savings-col { flex: 1; min-width: 32px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.savings-bar-wrap { display: flex; align-items: flex-end; height: 90px; }
.savings-bar { width: 14px; border-radius: 3px; min-height: 4px; }
.savings-bar.pos { background: var(--income); opacity: .85; }
.savings-bar.neg { background: var(--expense); opacity: .75; }
.savings-label     { font-size: 8px; color: var(--text-3); white-space: nowrap; text-align: center; }
.savings-label-top { font-size: 8px; font-weight: 600; color: var(--text-2); text-align: center; min-height: 14px; }

/* Donut chart */
.donut-wrap  { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut-svg   { width: 110px; height: 110px; flex-shrink: 0; }
.donut-legend { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 6px; }
.donut-legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px;
}
.donut-legend-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.donut-legend-name { flex: 1; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.donut-legend-pct  { color: var(--text-3); font-weight: 500; min-width: 30px; text-align: right; }
.donut-legend-amt  { color: var(--text-2); font-weight: 600; min-width: 70px; text-align: right; }

/* Top 5 */
.top5-list { display: flex; flex-direction: column; gap: 8px; }
.top5-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.top5-item:last-child { border-bottom: none; }
.top5-rank {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--bg-2); display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--text-3); flex-shrink: 0;
}
.top5-icon  { font-size: 18px; flex-shrink: 0; }
.top5-info  { flex: 1; min-width: 0; }
.top5-label { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top5-meta  { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.top5-amount { font-size: 14px; font-weight: 700; white-space: nowrap; }

.card-action-muted { font-size: 11px; color: var(--text-3); }

/* ─── RESPONSIVE ANALYTICS ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .analytics-grid-2 { grid-template-columns: 1fr; }
  .donut-wrap { justify-content: center; }
}
@media (max-width: 768px) {
  .inline-search { min-width: 140px; max-width: 200px; }
  .search-dropdown { min-width: 300px; right: auto; }
  .analytics-kpi-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .inline-search { min-width: 110px; }
  .analytics-kpi-row { grid-template-columns: 1fr; }
}
