/* ─── KAKO Budget PWA — Styles ──────────────────────────────────────────────
   Thème : fond clair #F4F7FB, cartes sombres #131320, accent bleu #2563EB
   ─────────────────────────────────────────────────────────────────────────── */

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

:root {
  --blue:    #2563EB;
  --red:     #FF6B6B;
  --green:   #22C55E;
  --bg:      #F4F7FB;
  --card:    #131320;
  --card2:   #1A1A2E;
  --text:    #1E293B;
  --light:   #E8E8F0;
  --muted:   #888;
  --border:  rgba(255,255,255,0.07);
  --font:    'DM Sans', 'Segoe UI', system-ui, sans-serif;
}

html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, textarea { font-family: var(--font); }
input:focus, button:focus, textarea:focus { outline: none; }
a { text-decoration: none; color: inherit; }

/* ── Boot loader ── */
.boot-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  gap: 12px;
}
.boot-icon { font-size: 48px; }
.boot-text { font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }

/* ══════════════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  padding: 10px 24px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 9999;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { background: #22C55E; box-shadow: 0 4px 20px rgba(34,197,94,0.45); }
.toast.error   { background: #FF4444; box-shadow: 0 4px 20px rgba(255,68,68,0.45); }
.toast.info    { background: var(--blue); box-shadow: 0 4px 20px rgba(37,99,235,0.45); }

/* ══════════════════════════════════════════════════════════
   AUTH SCREEN
   ══════════════════════════════════════════════════════════ */
.auth-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  min-height: 100dvh;
  background: linear-gradient(160deg, #F4F7FB 0%, #EEF2FF 100%);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 28px;
  padding: 32px 24px 28px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.10);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-brand { font-size: 11px; letter-spacing: 3px; color: var(--blue); font-weight: 700; text-transform: uppercase; }
.auth-title { font-size: 28px; font-weight: 900; color: var(--text); margin-top: 2px; letter-spacing: -0.5px; }
.auth-subtitle { font-size: 13px; color: #94A3B8; margin-top: 4px; }

.auth-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: #F1F5F9;
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 24px;
}
.auth-tab {
  padding: 11px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 700;
  color: #94A3B8;
  transition: all 0.2s;
}
.auth-tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.auth-hint {
  text-align: center;
  font-size: 13px;
  color: #94A3B8;
  margin-top: 16px;
  line-height: 1.5;
}
.auth-link {
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
}

.install-banner {
  margin-top: 14px;
  width: 100%;
  max-width: 420px;
  background: var(--blue);
  color: #fff;
  border-radius: 16px;
  padding: 14px 20px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37,99,235,0.35);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(37,99,235,0.35); }
  50%       { box-shadow: 0 4px 28px rgba(37,99,235,0.55); }
}

/* ══════════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════════ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(255,255,255,0.97);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  flex-shrink: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.header-brand { font-size: 10px; letter-spacing: 3px; color: var(--blue); font-weight: 700; text-transform: uppercase; }
.header-title { font-size: 22px; font-weight: 900; letter-spacing: -0.5px; color: var(--text); line-height: 1.1; }
.header-right  { display: flex; align-items: center; gap: 10px; }

.add-btn {
  background: var(--blue);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 26px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(37,99,235,0.4);
  line-height: 1;
  padding-bottom: 2px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.add-btn:active { transform: scale(0.93); box-shadow: 0 2px 8px rgba(37,99,235,0.3); }

.user-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.offline-pill {
  font-size: 10px;
  font-weight: 700;
  background: #FEF3C7;
  color: #92400E;
  padding: 4px 10px;
  border-radius: 50px;
  white-space: nowrap;
}
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #FFC857;
  animation: blink 1s ease-in-out infinite;
}
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

.main {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

/* ── Bottom Nav ── */
.bottom-nav {
  display: flex;
  background: rgba(13,13,20,0.98);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 8px;
  padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
  flex-shrink: 0;
}
.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 2px;
  opacity: 0.38;
  transition: opacity 0.15s;
}
.nav-tab.active { opacity: 1; }
.nav-icon  { font-size: 22px; line-height: 1; display: block; }
.nav-label { font-size: 9px; font-weight: 700; letter-spacing: 0.4px; color: #666; text-transform: uppercase; }
.nav-tab.active .nav-label { color: var(--blue); }

/* ══════════════════════════════════════════════════════════
   SCROLL CONTAINERS
   ══════════════════════════════════════════════════════════ */
.scroll-view {
  height: 100%;
  overflow-y: auto;
  padding: 0 16px 24px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.scroll-view::-webkit-scrollbar { display: none; }

/* ══════════════════════════════════════════════════════════
   DASHBOARD
   ══════════════════════════════════════════════════════════ */
.balance-card {
  background: linear-gradient(135deg, #1A2A1A 0%, #0F1F0F 100%);
  border-radius: 24px;
  padding: 28px;
  margin-top: 16px;
  margin-bottom: 14px;
  border: 1px solid rgba(99,211,130,0.2);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.balance-label  { font-size: 12px; color: var(--blue); letter-spacing: 2px; font-weight: 700; text-transform: uppercase; }
.balance-amount { font-size: 34px; font-weight: 900; letter-spacing: -1px; margin-top: 6px; line-height: 1; }
.balance-sub    { font-size: 12px; color: #888; margin-top: 6px; }

.row  { display: flex; }
.g-12 { gap: 12px; }
.mb-14 { margin-bottom: 14px; }

.stat-card { flex: 1; border-radius: 20px; padding: 18px 16px; border: 1px solid transparent; }
.stat-in   { background: rgba(99,211,130,0.08);  border-color: rgba(99,211,130,0.2); }
.stat-out  { background: rgba(255,107,107,0.08); border-color: rgba(255,107,107,0.2); }
.stat-icon { font-size: 22px; margin-bottom: 6px; }
.stat-lbl  { font-size: 11px; font-weight: 700; letter-spacing: 1.2px; margin-bottom: 4px; }
.stat-amt  { font-size: 15px; font-weight: 800; color: var(--text); word-break: break-word; }

/* Generic card */
.card {
  background: var(--card);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.card-title {
  font-size: 12px;
  font-weight: 700;
  color: #AAA;
  margin-bottom: 14px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.card-title.no-mb { margin-bottom: 0; }

/* Section header */
.sec-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.link-btn { color: var(--blue); font-size: 12px; font-weight: 700; letter-spacing: 0.5px; cursor: pointer; }

/* Month stats */
.month-row { display: flex; align-items: center; }
.month-item { flex: 1; }
.month-item-lbl { font-size: 11px; margin-bottom: 3px; }
.month-item-val { font-size: 14px; font-weight: 800; color: var(--light); word-break: break-all; }
.vdiv { width: 1px; height: 36px; background: rgba(255,255,255,0.08); margin: 0 8px; flex-shrink: 0; }

/* Progress bar */
.prog-bg { background: rgba(0,0,0,0.07); border-radius: 50px; height: 6px; overflow: hidden; }
.prog-bg.dark { background: rgba(255,255,255,0.06); }
.prog-fill { height: 6px; border-radius: 50px; background: var(--blue); transition: width 0.5s ease; }

/* ══════════════════════════════════════════════════════════
   TRANSACTION ROW
   ══════════════════════════════════════════════════════════ */
.tx-row {
  background: var(--card);
  border-radius: 16px;
  padding: 13px 13px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 11px;
}
.tx-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.tx-info  { flex: 1; min-width: 0; }
.tx-label { font-weight: 700; font-size: 13px; color: var(--light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-desc  { font-size: 11px; color: #666; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-date  { font-size: 10px; color: #555; margin-top: 2px; }
.tx-right { flex-shrink: 0; text-align: right; min-width: 80px; }
.tx-amt   { font-weight: 800; font-size: 13px; display: block; }
.tx-acts  { display: flex; gap: 10px; margin-top: 5px; justify-content: flex-end; }
.tx-acts button { font-size: 14px; padding: 2px 4px; }
.tx-acts button:active { transform: scale(0.85); }

/* ══════════════════════════════════════════════════════════
   TRANSACTIONS VIEW
   ══════════════════════════════════════════════════════════ */
.txs-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.filters { padding: 8px 16px 0; flex-shrink: 0; }
.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }
.chip {
  padding: 6px 14px;
  border-radius: 50px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.75);
  font-size: 12px;
  font-weight: 600;
  color: #64748B;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.15s;
}
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.filter-count { font-size: 12px; color: #94A3B8; margin: 0 0 8px; }

.tx-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 24px;
  scrollbar-width: none;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.tx-list::-webkit-scrollbar { display: none; }

/* ══════════════════════════════════════════════════════════
   ADD / EDIT FORM
   ══════════════════════════════════════════════════════════ */
.view-title { font-size: 20px; font-weight: 800; margin: 16px 0 20px; letter-spacing: -0.5px; color: var(--text); }

.field-lbl {
  font-size: 11px;
  font-weight: 700;
  color: #64748B;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
  margin-top: 4px;
  display: block;
}
.input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 16px;
  background: #fff;
  border: 1.5px solid #E2E8F0;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  display: block;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.input::placeholder { color: #CBD5E1; }
input[type=date]::-webkit-calendar-picker-indicator { opacity: 0.5; }

.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 20px;
  background: rgba(0,0,0,0.04);
  border-radius: 16px;
  padding: 5px;
}
.type-btn { padding: 12px; border-radius: 12px; font-size: 14px; font-weight: 800; color: #888; transition: all 0.2s; }
.type-btn.t-in  { background: var(--blue); color: #fff; }
.type-btn.t-out { background: var(--red);  color: #fff; }

.cat-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.cat-btn {
  width: calc(50% - 4px);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid #E2E8F0;
  background: #fff;
  font-size: 12px;
  color: #94A3B8;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}
.cat-btn.on { color: var(--text); font-weight: 700; }
.cat-btn .ci { font-size: 18px; flex-shrink: 0; }

.btn-primary {
  width: 100%;
  padding: 16px;
  border-radius: 16px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 0.5px;
  margin-top: 8px;
  box-shadow: 0 4px 16px rgba(37,99,235,0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:active { transform: scale(0.98); box-shadow: 0 2px 8px rgba(37,99,235,0.25); }
.btn-secondary {
  width: 100%;
  padding: 13px;
  border-radius: 16px;
  background: rgba(0,0,0,0.04);
  color: #94A3B8;
  font-weight: 700;
  font-size: 14px;
  margin-top: 10px;
  margin-bottom: 20px;
}

/* ══════════════════════════════════════════════════════════
   ANALYTICS
   ══════════════════════════════════════════════════════════ */
.bar-chart { display: flex; gap: 4px; align-items: flex-end; height: 120px; }
.bar-col   { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0; }
.bar-pair  { display: flex; gap: 2px; align-items: flex-end; height: 100px; width: 100%; }
.bar       { flex: 1; border-radius: 3px 3px 0 0; min-height: 3px; }
.bar-lbl   { font-size: 9px; color: #666; margin-top: 4px; text-align: center; }

.legend { display: flex; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #888; }
.legend-dot  { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

.cat-stat { margin-bottom: 14px; }
.cat-stat-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cat-stat-name { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.cat-stat-lbl  { font-size: 13px; font-weight: 600; color: var(--light); }
.cat-stat-vals { text-align: right; }
.cat-stat-amt  { font-size: 13px; font-weight: 700; display: block; }
.cat-stat-pct  { font-size: 11px; color: #888; }

/* ══════════════════════════════════════════════════════════
   ADMIN DASHBOARD
   ══════════════════════════════════════════════════════════ */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.admin-kpi {
  background: var(--card);
  border-radius: 18px;
  padding: 18px 16px;
  border: 1px solid var(--border);
  text-align: center;
}
.admin-kpi-val { font-size: 28px; font-weight: 900; color: var(--blue); line-height: 1; }
.admin-kpi-lbl { font-size: 10px; font-weight: 700; color: #888; margin-top: 6px; text-transform: uppercase; letter-spacing: 0.5px; }

.user-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.user-row:last-child { border-bottom: none; }
.user-name { font-size: 13px; font-weight: 600; color: var(--light); }
.user-email { font-size: 11px; color: #666; margin-top: 1px; }
.user-date  { font-size: 11px; color: #555; }

/* ══════════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════════ */
.empty {
  text-align: center;
  padding: 48px 20px;
}
.empty-ico  { font-size: 52px; margin-bottom: 12px; }
.empty-txt  { font-size: 14px; font-weight: 600; color: #94A3B8; }
.empty-hint { font-size: 12px; color: #CBD5E1; margin-top: 4px; }

/* ══════════════════════════════════════════════════════════
   MODALS & OVERLAYS
   ══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal-sheet {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: #1A1A2E;
  border-radius: 24px 24px 0 0;
  padding: 24px 20px max(24px, env(safe-area-inset-bottom));
  border: 1px solid rgba(255,255,255,0.08);
}
.modal-title { font-size: 16px; font-weight: 800; color: var(--light); margin-bottom: 16px; }
.modal-btn {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.modal-btn:active { opacity: 0.8; }
.modal-btn-red    { background: rgba(255,68,68,0.15); color: #FF6B6B; }
.modal-btn-cancel { background: rgba(255,255,255,0.05); color: #888; }

/* ══════════════════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════════════════ */
.text-blue  { color: var(--blue); }
.text-red   { color: var(--red); }
.text-green { color: var(--green); }
.text-light { color: var(--light); }
.fw-900 { font-weight: 900; }
.mt-16 { margin-top: 16px; }
