* { box-sizing: border-box; }
:root {
  /* Deep purple UI inspired by your references */
  --bg: #0b0726;
  --bg-grad-1: #1c0f53;
  --bg-grad-2: #0b0726;
  --card: rgba(18, 16, 38, 0.6);
  --card-border: rgba(124, 58, 237, 0.35);
  --text: #e9e7ff;
  --muted: #a3a0c7;
  --primary: #7c3aed; /* violet */
  --primary-2: #a78bfa; /* lighter violet */
  --accent: #22d3ee; /* cyan hint */
  --danger: #ef4444;
}
html, body { height: 100%; }
body {
  margin: 0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, Ubuntu, Cantarell, Noto Sans, sans-serif;
  background: radial-gradient(1200px 800px at 10% -10%, var(--bg-grad-1), transparent 60%),
              radial-gradient(1000px 700px at 110% 10%, #2b1778, transparent 55%),
              linear-gradient(180deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 60%);
  color: var(--text);
}

footer { text-align: center; padding: 20px 16px; }
/* Header with burger */
.app-header{--header-h:60px; display:flex; align-items:center; gap:12px; padding:12px 16px; height:var(--header-h); position:sticky; top:0; z-index:150; background: linear-gradient(180deg, rgba(11,7,38,0.95), rgba(11,7,38,0)); }
.icon-btn{border:1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.06); color:var(--text); border-radius:12px; padding:8px 10px; cursor:pointer}
.icon-btn:hover{background: rgba(255,255,255,.1)}
.burger{font-size:18px; line-height:1;}
.app-header .title{display:flex; flex-direction:column}
.app-header .title h1{margin:0}

/* Side drawer menu */
.side-menu{ position:fixed; left:0; width:280px; background: rgba(18,16,38,.96); border-right:1px solid rgba(124,58,237,.35); backdrop-filter: blur(12px); padding:16px; transform: translateX(-100%); transition: transform .25s ease; z-index:120; overflow-y:auto; top: var(--header-h, 60px); height: calc(100dvh - var(--header-h, 60px)); }
.side-menu.open{ transform: translateX(0); }
.side-menu nav{ display:grid; gap:10px; }
.side-menu .menu-item{ text-align:left; padding:10px 12px; border-radius:12px; border:1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.06); color:var(--text); }
.side-menu .menu-item.active{ background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-color: transparent; }

/* Backdrop when menu open (covers uniquement sous le header) */
.menu-backdrop{ position:fixed; left:0; right:0; top: var(--header-h, 60px); bottom:0; background: rgba(0,0,0,.45); z-index:110; }

/* Prevent content from sliding under header */
main.layout{ margin-top: 4px; }

header h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: 0.2px; }
.subtitle { color: var(--muted); margin: 0; font-size: 13px; opacity: 0.9; }
/* Ensure main content not covered: add top padding equal to header height */
body{ --header-h: 60px; }


main.layout { max-width: 1040px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; grid-template-columns: 1.2fr 1fr; align-items: start; }

/* two columns on desktop: left = balance+history, right = quick add + settings */
.balance-card { grid-column: 1 / 2; }
.quick-add, .settings { grid-column: 2 / 3; }
.history { grid-column: 1 / 3; }

@media (max-width: 900px) {
  main.layout { grid-template-columns: 1fr; }
  .balance-card, .quick-add, .settings, .history { grid-column: 1 / 2; }
}

.card {
  position: relative;
  background: var(--card);
  border-radius: 20px;
  padding: 14px;
  border: 1px solid var(--card-border);
  box-shadow:
    0 10px 30px rgba(0,0,0,.35),
    inset 0 1px 0 rgba(255,255,255,.04);
  backdrop-filter: blur(12px);
}
.card:before {
  content: "";
  position: absolute; inset: 0; border-radius: 20px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(124,58,237,.5), rgba(34,211,238,.35));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}
.card h2 { margin: 0 0 10px; font-size: 16px; font-weight: 700; opacity: .95; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row input, .row select, .row button { height: 44px; }

input, select, button {
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 10px 12px;
}
/* Balance card styles */
.balance-card .big-total { font-size: 34px; font-weight: 800; letter-spacing: 0.3px; }
.balance-card .balance-top { display:flex; align-items:end; justify-content:space-between; gap:12px; margin-bottom:10px; }
.balance-card .balance-kpis { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap:12px; margin-bottom:12px; }
.balance-card .price-inline { display:grid; gap:8px; }

.section-header { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:6px; }
.segmented { background: rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.08); padding:4px; border-radius:999px; display:flex; gap:4px; }
.segmented button { height:30px; padding:0 10px; background:transparent; border:0; color:var(--muted); border-radius:999px; }
.segmented .is-active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color:#fff; }

input[readonly] { color: #d9d7ff; background: rgba(124,58,237,.12); border-color: rgba(124,58,237,.35); }

input:focus, select:focus, button:focus { outline: none; box-shadow: 0 0 0 3px rgba(124,58,237,.35); border-color: var(--primary-2); }

button { cursor: pointer; transition: transform .08s ease, box-shadow .2s ease; }
button.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent;
  color: #fff; font-weight: 600;
  box-shadow: 0 10px 18px rgba(124,58,237,.35);
}
button.primary:hover { transform: translateY(-1px); box-shadow: 0 14px 22px rgba(124,58,237,.45); }
button.danger {
  background: linear-gradient(135deg, #f43f5e, #fb7185);
  border-color: transparent; color: #fff;
}
button:disabled { opacity: 0.6; cursor: not-allowed; }

.muted { color: var(--muted); font-size: 12px; }

.totals-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.label { color: var(--muted); font-size: 12px; }
.value { font-size: 22px; font-weight: 700; letter-spacing: 0.2px; }

/* History table styled like a modern list */
.table-wrap { overflow-x: auto; }

 table { width: 100%; border-collapse: separate; border-spacing: 0 10px; }
 thead th { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 10px 6px; text-transform: uppercase; letter-spacing: .6px; }
 tbody td { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.06); padding: 12px 10px; font-size: 13px; }
 tbody tr td:first-child { border-top-left-radius: 12px; border-bottom-left-radius: 12px; }
 tbody tr td:last-child { border-top-right-radius: 12px; border-bottom-right-radius: 12px; }
 tbody tr:hover td { background: rgba(124,58,237,.12); border-color: rgba(124,58,237,.3); }

/* Header tweaks on small screens */
@media (max-width: 640px) {
  .totals-grid { grid-template-columns: 1fr; }
  header h1 { font-size: 20px; }
  main { padding: 12px; gap: 12px; }
}

/* Subtle animated gradient sheen on cards */
@media (prefers-reduced-motion: no-preference) {
  .card:before { animation: sheen 8s linear infinite; opacity: .6; }
  @keyframes sheen {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
  }
}
/* Transaction list (replace table) */
.tx-list { list-style:none; margin:0; padding:0; display:grid; gap:10px; }
.tx-item { display:flex; align-items:center; gap:10px; background: rgba(255,255,255,.05); border:1px solid rgba(255,255,255,.06); padding:10px; border-radius:12px; }
.tx-icon { width:36px; height:36px; display:grid; place-items:center; border-radius:10px; background: rgba(124,58,237,.18); color:#fff; font-size:16px; }
.tx-main { flex:1; min-width:0; }
.tx-title { font-weight:600; font-size:14px; }
.tx-meta { color:var(--muted); font-size:12px; }
.tx-amount { text-align:right; }
.tx-amount .round { font-weight:700; }
.badge { background: rgba(124,58,237,.25); color:#fff; border:1px solid rgba(124,58,237,.4); border-radius:999px; padding:2px 8px; font-size:11px; }

/* Bottom navigation */
.bottom-nav{ position:sticky; bottom:0; left:0; right:0; display:grid; grid-template-columns: repeat(4, 1fr); gap:10px; padding:10px 16px 14px; backdrop-filter: blur(10px); background: linear-gradient(180deg, rgba(11,7,38,0.0), rgba(11,7,38,0.85)); }
.bottom-nav .tab{ display:grid; place-items:center; gap:4px; padding:8px 0; background: rgba(255,255,255,.05); border:1px solid rgba(255,255,255,.08); border-radius:16px; color:var(--text); }
.bottom-nav .tab.active{ background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-color: transparent; }
.bottom-nav small{ font-size:11px; color: #eae7ff; }


/* Views toggling */
.view[hidden]{ display:none !important; }
.view.active{ display:block; }
.stats-view{ grid-template-columns: 1fr; }
.chart-wrap{ width:100%; height:260px; }
.stats-chart{ width:100%; height:100%; display:block; }

