/* =============================================
   Flow — Dark Neon Futuristic Theme
   Mobile-first PWA
   ============================================= */

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

/* ---------- Design Tokens ---------- */
:root {
  --bg: #08080F;
  --bg-subtle: #0C0C16;
  --surface: #12121C;
  --surface-hover: #1A1A28;
  --surface-glass: rgba(255,255,255,0.03);
  --primary: #11fe68;
  --primary-hover: #05a941;
  --primary-light: rgba(17, 254, 104, 0.12);
  --primary-subtle: rgba(17, 254, 104, 0.06);
  --primary-glow: rgba(17, 254, 104, 0.25);
  --accent: #06B6D4;
  --accent-light: rgba(6, 182, 212, 0.1);
  --success: #00E85A;
  --success-light: rgba(0, 232, 90, 0.1);
  --danger: #FF4D6A;
  --danger-light: rgba(255, 77, 106, 0.1);
  --warning: #FFB800;
  --warning-light: rgba(255, 184, 0, 0.1);
  --text: #E8E8ED;
  --text-secondary: rgba(255,255,255,0.5);
  --text-tertiary: rgba(255,255,255,0.28);
  --border: rgba(255,255,255,0.08);
  --border-light: rgba(255,255,255,0.04);
  --divider: rgba(255,255,255,0.06);
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);
  --glow-purple: 0 0 20px rgba(139,92,246,0.2);
  --glow-cyan: 0 0 20px rgba(6,182,212,0.15);
  --glow-green: 0 0 20px rgba(0,232,90,0.15);
  --gradient-main: linear-gradient(135deg, #8B5CF6, #06B6D4);
  --gradient-card: linear-gradient(135deg, rgba(139,92,246,0.08), rgba(6,182,212,0.04));
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --nav-h: 72px;
  --header-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
input, textarea, select, button { 
  font: inherit; 
  color: inherit;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ---------- App Shell ---------- */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background: var(--bg);
}

#header {
  flex-shrink: 0;
  min-height: 0;
}

/* Page header */
.page-header {
  padding: 12px 20px;
  padding-top: calc(12px + var(--safe-top));
  background: rgba(8,8,15,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 30;
}

.page-header-title {
  font-size: 17px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}

.page-header .btn-back {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  color: var(--text);
}
.page-header .btn-back:active { background: var(--surface-hover); }

.page-header .btn-action {
  padding: 8px 16px;
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
  box-shadow: var(--glow-purple);
}
.page-header .btn-action:active { background: var(--primary-hover); }

/* ---------- Main Content ---------- */
#view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 20px);
  background: var(--bg);
}

/* ---------- Bottom Tab Bar ---------- */
#tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(8,8,15,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 50;
}

#tab-bar.hidden { display: none; }

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: color 0.2s;
  padding: 8px 0;
  position: relative;
}
.tab span {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.tab svg { transition: all 0.2s; }
.tab.active { color: var(--primary); }
.tab.active svg { transform: scale(1.08); filter: drop-shadow(0 0 6px rgba(139,92,246,0.5)); }
.tab:active { opacity: 0.7; }

/* ---------- Typography ---------- */
.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 20px;
  margin-bottom: 8px;
}

.hero-amount {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: #fff;
  background: linear-gradient(135deg, #fff 60%, rgba(139,92,246,0.7));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-padded {
  padding: 16px 20px;
}

.card-row {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  gap: 14px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background 0.12s;
}
.card-row:last-child { border-bottom: none; }
.card-row:active { background: var(--surface-hover); }

/* Neon card (glass effect) */
.neon-card {
  background: var(--surface);
  border-radius: var(--radius);
  margin: 0 20px;
  overflow: hidden;
  border: 1px solid var(--border);
}

/* ---------- Stats Grid ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 20px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
  text-align: center;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
}

.stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Neon stat cards (dashboard 2x2 grid) */
.neon-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 20px;
  margin-top: 20px;
}

.neon-stat {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.neon-stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-main);
  opacity: 0.4;
}
.neon-stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.neon-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}
.neon-stat-value.green { color: var(--success); text-shadow: 0 0 20px rgba(0,232,90,0.3); }
.neon-stat-value.blue { color: var(--accent); text-shadow: 0 0 20px rgba(6,182,212,0.3); }
.neon-stat-value.purple { color: var(--primary); text-shadow: 0 0 20px rgba(139,92,246,0.3); }
.neon-stat-value.yellow { color: var(--warning); text-shadow: 0 0 20px rgba(255,184,0,0.3); }
.neon-stat-value.red { color: var(--danger); text-shadow: 0 0 20px rgba(255,77,106,0.3); }
.neon-stat-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ---------- Expenses View ---------- */
.expense-card {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  gap: 12px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background 0.12s;
}
.expense-card:active { background: var(--surface-hover); }
.expense-card:last-child { border-bottom: none; }

.expense-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.expense-icon.materiel { background: rgba(255,184,0,0.12); color: var(--warning); }
.expense-icon.appli { background: rgba(6,182,212,0.12); color: var(--accent); }
.expense-icon.abonnement { background: rgba(0,232,90,0.12); color: var(--success); }
.expense-icon.autre { background: rgba(255,255,255,0.06); color: var(--text-secondary); }

.expense-body { flex: 1; min-width: 0; }
.expense-name {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.expense-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.expense-right {
  text-align: right;
  flex-shrink: 0;
}
.expense-amount {
  font-weight: 600;
  font-size: 14px;
  color: var(--danger);
}
.expense-period {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* Expenses header stats */
.expenses-stats {
  display: flex;
  gap: 0;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.expenses-stat {
  flex: 1;
  text-align: center;
}
.expenses-stat + .expenses-stat {
  border-left: 1px solid var(--divider);
}
.expenses-stat-value {
  font-size: 18px;
  font-weight: 700;
}
.expenses-stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}
.toggle-label {
  font-size: 14px;
  font-weight: 500;
}
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
  border: none;
}
.toggle:checked {
  background: var(--primary);
  box-shadow: var(--glow-purple);
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle:checked::after {
  transform: translateX(20px);
}

/* ---------- List Items ---------- */
.list-item {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  gap: 14px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--divider);
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--surface-hover); }

.list-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
  background: var(--primary-light);
  flex-shrink: 0;
  border: 1px solid rgba(139,92,246,0.2);
}

.list-body { flex: 1; min-width: 0; }
.list-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-sub {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-right {
  text-align: right;
  flex-shrink: 0;
}
.list-amount {
  font-weight: 600;
  font-size: 15px;
  color: #fff;
}
.list-tag {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-site { background: rgba(74,144,226,0.15); color: #4A90E2; }
.badge-maquette { background: rgba(168,85,247,0.15); color: #A855F7; }
.badge-abonnement { background: rgba(0,232,90,0.12); color: var(--success); }
.badge-autres { background: rgba(255,255,255,0.06); color: var(--text-secondary); }
.badge-paid { background: var(--success-light); color: var(--success); }
.badge-unpaid { background: var(--warning-light); color: var(--warning); }
.badge-materiel { background: rgba(255,184,0,0.12); color: var(--warning); }
.badge-appli { background: rgba(6,182,212,0.12); color: var(--accent); }
.badge-autre { background: rgba(255,255,255,0.06); color: var(--text-secondary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--glow-purple);
}
.btn-primary:active { background: var(--primary-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:active { background: var(--surface-hover); }

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
}
.btn-danger:active { background: rgba(255,77,106,0.2); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid rgba(143, 246, 92, 0.3);
}
.btn-outline:active { background: var(--primary-light); border-color: var(--primary); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}
.btn-ghost:active { background: var(--surface-hover); }

.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* FAB */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(105, 246, 92, 0.4);
  z-index: 40;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab:active { transform: scale(0.92); box-shadow: var(--glow-purple); }

/* ---------- Form Inputs ---------- */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle), var(--glow-purple);
}
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-tertiary);
}
.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.form-section {
  padding: 20px;
}
.form-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

/* ---------- Chart ---------- */
.chart-container {
  padding: 16px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 0 20px;
}
.chart-container canvas {
  width: 100% !important;
  max-height: 180px;
}

/* ---------- Empty State ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  text-align: center;
}
.empty-icon {
  margin-bottom: 16px;
  opacity: 0.2;
  color: var(--primary);
}
.empty-icon svg { width: 48px; height: 48px; }
.empty-title {
  font-weight: 600;
  font-size: 17px;
  margin-bottom: 6px;
  color: rgba(255,255,255,0.7);
}
.empty-desc {
  font-size: 14px;
  color: var(--text-tertiary);
  max-width: 260px;
}

/* ---------- Dashboard ---------- */
.dash-hero {
  padding: 28px 20px 20px;
  padding-top: calc(28px + var(--safe-top));
}

.dash-hero .app-brand {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.dash-hero .app-brand em {
  font-style: normal;
  color: var(--primary);
}

/* Revenue segmented bar */
.revenue-bar-wrap {
  padding: 0 20px;
  margin-top: 16px;
}
.revenue-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: rgba(255,255,255,0.04);
}
.revenue-bar span {
  display: block;
  height: 100%;
  transition: width 0.4s ease;
}
.revenue-bar .bar-site       { background: #4A90E2; }
.revenue-bar .bar-maquette   { background: #A855F7; }
.revenue-bar .bar-abonnement { background: #00E85A; }
.revenue-bar .bar-autres     { background: #FF6B6B; }

.revenue-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 20px 0;
}
.revenue-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-tertiary);
}
.revenue-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Net profit bar */
.net-profit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  margin: 16px 20px 0;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.net-profit-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-card);
  pointer-events: none;
}
.net-profit-label {
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: relative;
}
.net-profit-value {
  font-size: 20px;
  font-weight: 700;
  position: relative;
}

/* Dash section */
.dash-section {
  margin-top: 24px;
}

.dash-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  margin-bottom: 10px;
}

.dash-section-header h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dash-section-header span {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Pending payment rows */
.pending-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background 0.12s;
}
.pending-row:active { background: var(--surface-hover); }
.pending-row:last-child { border-bottom: none; }

.pending-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pending-dot.orange { background: var(--warning); box-shadow: 0 0 8px rgba(255,184,0,0.4); }
.pending-dot.green { background: var(--success); box-shadow: 0 0 8px rgba(0,232,90,0.4); }
.pending-dot.blue { background: var(--accent); box-shadow: 0 0 8px rgba(6,182,212,0.4); }

.pending-body { flex: 1; min-width: 0; }
.pending-name {
  font-weight: 500;
  font-size: 14px;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pending-type {
  font-size: 12px;
  color: var(--text-tertiary);
}
.pending-amount {
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  color: rgba(255,255,255,0.7);
}
.pending-amount.text-green { color: var(--success); }
.pending-amount.text-yellow { color: var(--warning); }

/* Accordion */
.neon-accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}
.neon-accordion-header svg { transition: transform 0.2s; }
.neon-accordion-header.open svg { transform: rotate(180deg); }
.neon-accordion-body { display: none; }
.neon-accordion-body.open { display: block; }

/* Expense summary */
.expense-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
}
.expense-summary-row:last-child { border-bottom: none; }
.expense-summary-label {
  font-size: 13px;
  color: var(--text-secondary);
}
.expense-summary-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--danger);
}

/* ---------- Client Detail ---------- */
.client-hero {
  padding: 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.client-avatar-lg {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 24px;
  color: var(--primary);
  background: var(--primary-light);
  margin-bottom: 10px;
  border: 2px solid rgba(139,92,246,0.2);
  box-shadow: var(--glow-purple);
}

.client-name-lg {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
}

.client-stats {
  display: flex;
  gap: 0;
  margin-top: 16px;
  border-top: 1px solid var(--divider);
  padding-top: 16px;
}
.client-stat {
  flex: 1;
  text-align: center;
}
.client-stat + .client-stat {
  border-left: 1px solid var(--divider);
}
.client-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}
.client-stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.client-actions {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
}
.client-actions .btn {
  flex: 1;
  padding: 10px 12px;
  font-size: 13px;
}

/* Prestation item */
.presta-item {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  gap: 12px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background 0.12s;
}
.presta-item:active { background: var(--surface-hover); }
.presta-item:last-child { border-bottom: none; }

.presta-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.presta-icon.site { background: rgba(74,144,226,0.12); color: #4A90E2; }
.presta-icon.maquette { background: rgba(168,85,247,0.12); color: #A855F7; }
.presta-icon.abonnement { background: rgba(0,232,90,0.12); color: var(--success); }
.presta-icon.autres { background: rgba(255,255,255,0.06); color: var(--text-secondary); }

.presta-body { flex: 1; min-width: 0; }
.presta-desc {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.presta-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.presta-right {
  text-align: right;
  flex-shrink: 0;
}
.presta-amount {
  font-weight: 600;
  font-size: 14px;
  color: #fff;
}
.presta-status {
  font-size: 11px;
  font-weight: 500;
}
.presta-status.paid { color: var(--success); }
.presta-status.unpaid { color: var(--warning); }

/* ---------- Tabs (Client Detail) ---------- */
.view-tabs {
  display: flex;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
}
.view-tab {
  padding: 12px 0;
  margin-right: 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-tertiary);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.view-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ---------- Invoice List Item ---------- */
.invoice-item {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  gap: 14px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background 0.12s;
}
.invoice-item:active { background: var(--surface-hover); }
.invoice-item:last-child { border-bottom: none; }

.invoice-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--primary);
}

.invoice-body { flex: 1; min-width: 0; }
.invoice-number {
  font-weight: 600;
  font-size: 15px;
}
.invoice-client {
  font-size: 13px;
  color: var(--text-secondary);
}
.invoice-right {
  text-align: right;
  flex-shrink: 0;
}
.invoice-amount {
  font-weight: 600;
  font-size: 15px;
  color: #fff;
}
.invoice-date {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ---------- Search Bar ---------- */
.search-bar {
  padding: 12px 20px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  transition: border-color 0.15s;
}
.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--glow-purple);
}
.search-input::placeholder {
  color: var(--text-tertiary);
}

/* ---------- Bottom Sheet ---------- */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.sheet-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-subtle);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-height: 90vh;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-bottom: none;
}
.sheet-overlay.open .sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
  margin: 10px auto 6px;
}

.sheet-content {
  padding: 8px 20px 32px;
  padding-bottom: calc(32px + var(--safe-bottom));
}

.sheet-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: #fff;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  top: calc(16px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  background: var(--surface);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.3s;
  max-width: calc(100vw - 40px);
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  opacity: 0;
  pointer-events: none;
}
#toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
#toast.success { background: var(--success); border-color: transparent; }
#toast.error { background: var(--danger); border-color: transparent; }

/* ---------- Invoice Form Items ---------- */
.invoice-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inv-item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  position: relative;
}

.inv-item-card .form-row {
  margin-top: 8px;
}

.inv-item-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  background: var(--danger-light);
  color: var(--danger);
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-add-item {
  width: 100%;
  padding: 12px;
  border: 1.5px dashed rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 8px;
}
.btn-add-item:active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* ---------- Invoice Total Bar ---------- */
.invoice-total-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: 8px;
  border-radius: var(--radius);
}

.invoice-total-bar .total-label {
  font-size: 14px;
  color: var(--text-secondary);
}
.invoice-total-bar .total-amount {
  font-size: 22px;
  font-weight: 700;
  color: var(--success);
  text-shadow: var(--glow-green);
}

/* ---------- Confirm Dialog ---------- */
.confirm-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.confirm-actions .btn { flex: 1; }

.confirm-text {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 4px;
}

/* ---------- Settings ---------- */
.settings-section {
  padding: 20px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
}
.settings-item:last-child { border-bottom: none; }
.settings-item-label { font-weight: 500; }
.settings-item-desc { font-size: 13px; color: var(--text-secondary); }

/* Chevron */
.chevron::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--text-tertiary);
  border-bottom: 2px solid var(--text-tertiary);
  transform: rotate(-45deg);
  margin-left: 4px;
}

/* ---------- Invoice Preview Overlay ---------- */
.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.preview-toolbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(10px);
  z-index: 1;
}
.preview-toolbar .btn {
  font-size: 13px;
  padding: 8px 14px;
}

.preview-scroll {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 16px;
}

/* ============================================
   FACTURE A4 - Style MIKAA.WEB (exact /facture)
   ============================================ */
.invoice {
  width: 210mm;
  height: 297mm;
  background: white;
  font-family: 'Inter', 'Aptos', sans-serif;
  font-size: 10pt;
  line-height: 1.4;
  color: #333;
  position: relative;
  overflow: hidden;
  page-break-after: always;
  page-break-inside: avoid;
}

.invoice:last-child {
  page-break-after: auto;
}

#invoicePage2 {
  page-break-before: always;
}

/* Header simple blanc */
.invoice-header {
  padding: 30px 40px 25px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.company-brand {
  color: #000;
}

.company-brand .logo {
  font-size: 11pt;
  font-weight: 700;
  letter-spacing: 0px;
  margin-top: 25px;
}

.company-brand .location {
  font-size: 9pt;
  color: #333;
  margin-top: 0px;
  line-height: 1.5;
}

.invoice-info-header {
  text-align: right;
  color: #000;
  margin-top: 0;
}

.invoice-title-large {
  font-size: 28pt;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 2px;
  margin-top: 0;
}

.invoice-title-large span {
  color: #00FF88;
  font-size: 40pt;
  font-weight: 700;
}

.invoice-number-label {
  font-size: 9pt;
  color: #333;
}

.invoice-number-value {
  font-size: 9pt;
  font-weight: 600;
  color: #333;
}

.company-email {
  font-size: 9pt;
  color: #333;
  margin-top: 2px;
}

/* Solde dû */
.balance-due-box {
  background: white;
  padding: 10px 40px 10px;
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  flex-direction: column;
  text-align: right;
}

.balance-due-label {
  font-size: 10pt;
  color: #000;
  font-weight: 700;
  margin-bottom: 2px;
}

.balance-due-amount {
  font-size: 18pt;
  font-weight: 700;
  color: #000;
}

/* Corps de la facture */
.invoice .invoice-body {
  padding: 20px 40px;
}

/* Info client et dates */
.invoice-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 25px;
}

.client-section {
  flex: 1;
}

.client-section h4 {
  font-size: 9pt;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  font-weight: 500;
}

.client-name {
  font-size: 10pt;
  font-weight: 600;
  color: #333;
}

.client-address {
  font-size: 10pt;
  color: #555;
  line-height: 1.5;
}

.dates-section {
  text-align: right;
}

.date-row {
  margin-bottom: 8px;
}

.date-label {
  font-size: 9pt;
  color: #888;
}

.date-value {
  font-size: 10pt;
  font-weight: 600;
  color: #333;
}

/* Tableau des éléments */
.items-table {
  width: 100%;
  border-collapse: collapse;
}

.items-table thead th {
  background: #4a4a4a;
  color: white;
  padding: 10px 12px;
  text-align: left;
  font-size: 9pt;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0px;
}

.items-table thead th:first-child {
  width: 40px;
  text-align: center;
}

.items-table thead th:last-child {
  text-align: right;
}

.items-table thead th:nth-child(3),
.items-table thead th:nth-child(4) {
  text-align: center;
  width: 80px;
}

.items-table tbody td {
  padding: 14px 15px;
  border-bottom: 1px solid #eee;
  font-size: 10pt;
}

.items-table tbody td:first-child {
  text-align: center;
  color: #888;
}

.items-table tbody td:nth-child(3),
.items-table tbody td:nth-child(4) {
  text-align: center;
}

.items-table tbody td:last-child {
  text-align: right;
  font-weight: 500;
}

/* Totaux */
.totals-section {
  display: flex;
  justify-content: flex-end;
}

.totals-box {
  width: 220px;
}

.invoice .total-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 15px;
}

.invoice .total-row.grand-total {
  color: #000;
  font-weight: 700;
}

.invoice .total-row.balance-due {
  background: #e5e5e5;
  color: #000;
  font-weight: 700;
}

.invoice .total-label {
  color: inherit;
}

.invoice .total-value {
  font-weight: 600;
}

/* Section QR / Paiement suisse */
.payment-slip {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 90mm;
  border-top: 1px dashed #000;
  display: flex;
  background: white;
}

.payment-slip:empty {
  display: none;
}

.receipt-section {
  width: 62mm;
  padding: 5mm 5mm;
  border-right: 1px dashed #000;
  font-size: 8pt;
  position: relative;
}

.payment-section {
  flex: 1;
  padding: 5mm 5mm;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 15px;
}

.slip-title {
  font-size: 11pt;
  font-weight: 700;
  margin-bottom: 5mm;
}

.slip-label {
  font-size: 6pt;
  font-weight: 700;
  margin-bottom: 1mm;
  margin-top: 3mm;
}

.slip-value {
  font-size: 8pt;
  line-height: 1.3;
}

.slip-value.iban {
  font-size: 8pt;
  letter-spacing: 0.3px;
  font-weight: 400;
}

.qr-section {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

#qrcode {
  width: 50mm;
  height: 50mm;
  margin: 0;
  position: relative;
  overflow: hidden;
}

#qrcode canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

#qrcode::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8mm;
  height: 8mm;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#qrcode::before {
  content: '+';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 22pt;
  font-weight: 900;
  color: #fff;
  z-index: 10;
  line-height: 1;
}

#qrcode.hide-cross-before::before {
  display: none;
}

.payment-details {
  display: flex;
  flex-direction: column;
}

.amount-section {
  margin-top: 3mm;
}

.amount-label {
  font-size: 6pt;
  font-weight: 700;
  margin-bottom: 1mm;
}

.amount-row {
  display: flex;
  gap: 15px;
}

.amount-item {
  display: flex;
  flex-direction: column;
}

.amount-value {
  font-size: 8pt;
  font-weight: 400;
}

/* Preview Container */
.preview-container {
  transform-origin: top center;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- Invoice Preview Overlay ---------- */
.invoice-preview-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: #0a0a14;
  display: flex;
  flex-direction: column;
}

.invoice-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(15, 15, 26, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.invoice-preview-close {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.invoice-preview-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.invoice-preview-title {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.invoice-preview-download {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.invoice-preview-download:hover {
  transform: scale(1.02);
}

.invoice-preview-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px;
}

/* Mobile: scale down to fit */
@media (max-width: 900px) {
  .preview-container {
    transform: scale(0.48);
  }
}

@media (max-width: 600px) {
  .preview-container {
    transform: scale(0.42);
  }
}

@media print {
  .invoice-preview-overlay {
    display: none;
  }
  .invoice {
    width: 100%;
    box-shadow: none;
  }
}

/* ---------- Utility Spacing ---------- */
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.px-20 { padding-left: 20px; padding-right: 20px; }
.py-8 { padding-top: 8px; padding-bottom: 8px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 13px; }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in {
  animation: fadeIn 0.3s ease-out;
}
@keyframes neonPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ---------- Scrollbar ---------- */
#view::-webkit-scrollbar { display: none; }
#view { -ms-overflow-style: none; scrollbar-width: none; }

/* ---------- Landscape / Tablet ---------- */
@media (min-width: 768px) {
  #view {
    max-width: 480px;
    margin: 0 auto;
  }
  #tab-bar {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}
