/* =============================================
   Flow — "Pulse" Dark Fintech Theme
   ============================================= */

:root {
  --bg: #050505;
  --surface: #0F0F0F;
  --surface-2: #171717;
  --surface-hover: #1C1C1C;
  --bg-white: #0F0F0F;

  --primary: #00E87B;
  --primary-light: rgba(0, 232, 123, 0.1);
  --accent: #3B82F6;
  --accent-light: rgba(59, 130, 246, 0.1);

  --text: #EDEDED;
  --text-secondary: #888888;
  --text-tertiary: #555555;

  --success: #00E87B;
  --success-light: rgba(0, 232, 123, 0.1);
  --warning: #FFB800;
  --warning-light: rgba(255, 184, 0, 0.1);
  --danger: #FF4757;
  --danger-light: rgba(255, 71, 87, 0.1);

  --divider: #1A1A1A;
  --border: #1F1F1F;

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-pill: 100px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);

  --page-px: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tab-height: 56px;

  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- Light Mode ---- */
[data-theme="light"] {
  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --surface-2: #F0F0F2;
  --surface-hover: #E8E8EA;
  --bg-white: #FFFFFF;

  --primary: #00B85E;
  --primary-light: rgba(0, 184, 94, 0.1);
  --accent: #2563EB;
  --accent-light: rgba(37, 99, 235, 0.1);

  --text: #1A1A1A;
  --text-secondary: #6B6B6B;
  --text-tertiary: #999999;

  --success: #00B85E;
  --success-light: rgba(0, 184, 94, 0.1);
  --warning: #E5A600;
  --warning-light: rgba(229, 166, 0, 0.1);
  --danger: #E8364B;
  --danger-light: rgba(232, 54, 75, 0.1);

  --divider: #E5E5E7;
  --border: #D8D8DA;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

/* =========================================================
   LOADER
   ========================================================= */
#loader {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 9999;
  background: #050505;
  opacity: 1;
  transition: opacity 0.45s ease;
}
#loader.loader-out {
  opacity: 0;
  pointer-events: none;
}
.loader-inner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}
.loader-svg {
  width: 136px;
  height: 136px;
  overflow: visible;
  animation: loaderGlow 1.0s ease 1.0s forwards;
  filter: drop-shadow(0 0 0px transparent);
}
.loader-svg path {
  fill: transparent;
  stroke: #ffffff;
  stroke-width: 12;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 6000;
  stroke-dashoffset: 6000;
  animation:
    loaderDraw 0.95s cubic-bezier(0.65, 0, 0.35, 1) 0.2s both,
    loaderFill 0.4s ease-in 1.05s forwards;
}
.loader-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  opacity: 0;
  animation: loaderNameFade 0.9s ease 0.1s forwards;
}
@keyframes loaderDraw {
  from { stroke-dashoffset: 6000; }
  to   { stroke-dashoffset: 0; }
}
@keyframes loaderFill {
  from { fill: transparent; }
  to   { fill: #ffffff; }
}
@keyframes loaderGlow {
  0%   { filter: drop-shadow(0 0 0px rgba(99,102,241,0)); }
  45%  { filter: drop-shadow(0 0 22px rgba(106, 241, 99, 0.9)); }
  100% { filter: drop-shadow(0 0 12px rgba(99, 241, 106, 0.45)); }
}
@keyframes loaderNameFade {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Block app animations while loading */
body.loading #app {
  visibility: hidden;
}

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

html, body {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

a { color: inherit; text-decoration: none; -webkit-touch-callout: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; -webkit-user-select: text; user-select: text; }
img { max-width: 100%; display: block; -webkit-user-drag: none; pointer-events: none; }
hr { border: none; }


/* =============================================
   APP SHELL
   ============================================= */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
}

#header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
}

#view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tab-height) + var(--safe-bottom) + 32px);
  scroll-behavior: smooth;
}


/* =============================================
   FLOATING TAB BAR
   ============================================= */

#tab-bar {
  position: fixed;
  bottom: calc(0px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 420px;
  display: flex;
  align-items: stretch;
  height: var(--tab-height);
  background: rgba(12, 12, 12, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 28px;
  border: 1px solid rgba(255,255,255,0.06);
}

[data-theme="light"] #tab-bar {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 4px 30px rgba(0,0,0,0.1);
  z-index: 100;
  padding: 0 6px;
  box-shadow: 0 4px 30px rgba(0,0,0,0.5);
}

/* Gradient fade above tab bar */
#tab-bar::before {
  content: '';
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  height: calc(var(--tab-height) + var(--safe-bottom) + 20px);
  background: linear-gradient(to top, rgba(5,5,5,0.3) 0%, transparent 100%);
  pointer-events: none;
  z-index: 99;
}

[data-theme="light"] #tab-bar::before {
  background: linear-gradient(to top, rgba(245,245,247,0.3) 0%, transparent 100%);
}

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

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: #b7b7b7;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 4px 0;
  position: relative;
  transition: color 0.25s;
  -webkit-tap-highlight-color: transparent;
}

.tab svg {
  width: 22px;
  height: 22px;
  transition: color 0.25s, transform 0.25s var(--ease-spring);
}

.tab span { transition: color 0.25s; }

.tab.active { color: var(--primary); }
.tab.active svg { transform: translateY(-1px); }

.tab:active svg { transform: scale(0.88); }


/* =============================================
   PAGE HEADER
   ============================================= */

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px var(--page-px);
  padding-top: calc(12px + var(--safe-top));
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 30;
}

.page-header-title {
  flex: 1;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.btn-back {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
}
.btn-back:active { background: var(--surface-hover); transform: scale(0.94); }

.btn-action {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  background: none;
  border: none;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  transition: background 0.15s;
}
.btn-action:active { background: var(--primary-light); }


/* =============================================
   SEARCH BAR
   ============================================= */

.search-bar {
  padding: 8px var(--page-px) 12px;
  padding-top: calc(8px + var(--safe-top));
}

.search-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.25s;
}
.search-input::placeholder { color: var(--text-tertiary); }
.search-input:focus { border-color: var(--primary); }


/* =============================================
   CARDS
   ============================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 0 var(--page-px);
}

.card-padded { padding: 20px; }

.neon-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 0 var(--page-px);
}


/* =============================================
   BUTTONS
   ============================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.3;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: #050505;
}
.btn-primary:active { background: #00cc6d; }

.btn-secondary {
  background: var(--surface-2);
  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, 71, 87, 0.18); }

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

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

.btn-add-item {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 12px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-add-item:active { color: var(--primary); border-color: var(--primary); }


/* =============================================
   FAB
   ============================================= */

.fab {
  position: fixed;
  bottom: calc(var(--tab-height) + var(--safe-bottom) + 28px);
  right: calc(50% - 300px + 20px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #050505;
  border: none;
  font-size: 26px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 232, 123, 0.3);
  z-index: 50;
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.fab:active { transform: scale(0.9); box-shadow: 0 2px 10px rgba(0, 232, 123, 0.2); }

@media (max-width: 640px) {
  .fab { right: 20px; }
}


/* =============================================
   BADGES
   ============================================= */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge-site { background: var(--primary-light); color: var(--primary); }
.badge-maquette { background: var(--accent-light); color: var(--accent); }
.badge-abonnement { background: rgba(167, 139, 250, 0.12); color: #A78BFA; }
.badge-autres, .badge-autre { background: var(--warning-light); color: var(--warning); }
.badge-materiel { background: var(--accent-light); color: var(--accent); }
.badge-appli { background: rgba(167, 139, 250, 0.12); color: #A78BFA; }

/* Custom type management */
.custom-type-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.custom-type-row:last-child { border-bottom: none; }
.btn-icon-sm {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.btn-icon-sm:hover { background: rgba(255, 71, 87, 0.1); color: var(--danger); }


/* =============================================
   EMPTY STATE
   ============================================= */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px var(--page-px);
  text-align: center;
}

.empty-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  color: var(--text-tertiary);
  opacity: 0.5;
}
.empty-icon svg { width: 100%; height: 100%; }

.empty-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 14px;
  color: var(--text-tertiary);
  max-width: 280px;
  line-height: 1.5;
}


/* =============================================
   DASHBOARD
   ============================================= */

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

.app-brand {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.app-brand em {
  font-style: normal;
  color: var(--primary);
}

.hero-amount {
  font-size: clamp(32px, 9vw, 42px);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.hero-label {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 4px;
  font-weight: 500;
}

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

.neon-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
  animation: staggerUp 0.45s var(--ease-out) both;
}
.neon-stat:nth-child(1) { animation-delay: 0s; }
.neon-stat:nth-child(2) { animation-delay: 0.06s; }
.neon-stat:nth-child(3) { animation-delay: 0.12s; }
.neon-stat:nth-child(4) { animation-delay: 0.18s; }

.neon-stat::before {
  content: '';
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--border);
  transition: background 0.3s;
}

.neon-stat:has(.blue)::before { background: var(--accent); }
.neon-stat:has(.green)::before { background: var(--success); }
.neon-stat:has(.purple)::before { background: #A78BFA; }
.neon-stat:has(.yellow)::before { background: var(--warning); }

.neon-stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.neon-stat-value {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

.neon-stat-value.blue { color: var(--accent); }
.neon-stat-value.green { color: var(--success); }
.neon-stat-value.purple { color: #A78BFA; }
.neon-stat-value.yellow { color: var(--warning); }

.neon-stat-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 3px;
}

/* Net Profit */
.net-profit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px var(--page-px);
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.net-profit-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.net-profit-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Dashboard Sections */
.dash-section {
  margin: 16px 0 0;
  padding: 0;
}

.dash-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px var(--page-px) 8px;
}

.dash-section-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

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

/* Charts */
.chart-container {
  position: relative;
  width: 100%;
  height: 200px;
  padding: 0 var(--page-px);
  box-sizing: border-box;
}

.chart-container canvas {
  display: block;
  max-width: 100% !important;
  height: auto !important;
}

.dash-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 var(--page-px);
}

.dash-chart-half {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  min-width: 0;
  overflow: hidden;
}

.chart-container-sm {
  position: relative;
  width: 100%;
  height: 140px;
  box-sizing: border-box;
}

.chart-container-sm canvas {
  display: block;
  max-width: 100% !important;
  height: auto !important;
}

/* Top Clients */
.top-client-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background 0.15s;
}
.top-client-row:last-child { border-bottom: none; }
.top-client-row:active { background: var(--surface-hover); }

.top-client-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.top-client-body { flex: 1; min-width: 0; }

.top-client-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-client-bar-wrap {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.top-client-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.6s var(--ease-out);
}

.top-client-amount {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
  letter-spacing: -0.01em;
}

/* 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: 14px;
  color: var(--text-secondary);
}

.expense-summary-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

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

.pending-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pending-dot.blue { background: var(--accent); }
.pending-dot.orange { background: var(--warning); }
.pending-dot.green { background: var(--success); }

.pending-body { flex: 1; min-width: 0; }

.pending-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pending-type {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

.pending-date {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.pending-date.urgent { color: var(--warning); font-weight: 600; }

.pending-amount {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}

.pending-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.pending-action {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.01em;
}

.subscription-row {
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
}

.subscription-row .pending-body {
  padding-right: 8px;
}

.subscription-group-label,
.subscription-group-empty {
  padding: 14px 16px 8px;
}

.subscription-group-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.subscription-group-empty {
  font-size: 13px;
  color: var(--text-secondary);
}

.subscription-accordion {
  border-top: 1px solid var(--divider);
}

.subscription-accordion-header {
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
}

.subscription-accordion-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.subscription-accordion-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.subscription-accordion-subtitle {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.subscription-accordion-side {
  display: flex;
  align-items: center;
  gap: 10px;
}

.subscription-accordion-count {
  min-width: 30px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.subscription-accordion-header.open .subscription-accordion-count {
  border-color: rgba(0, 232, 123, 0.2);
  color: var(--primary);
}

.subscription-accordion-body {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-6px);
  transition: max-height 0.35s var(--ease-spring), opacity 0.25s ease, transform 0.25s ease;
}

.subscription-accordion-body.open {
  opacity: 1;
  transform: translateY(0);
}

.subscription-accordion-body.open .subscription-row:first-child {
  border-top: 1px solid var(--divider);
}

/* Accordion */
.neon-accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 0.15s;
}
.neon-accordion-header svg {
  transition: transform 0.3s var(--ease-spring);
  color: var(--text-tertiary);
}
.neon-accordion-header.open svg { transform: rotate(180deg); }
.neon-accordion-header.open { color: var(--text); }

.neon-accordion-body {
  display: none;
}
.neon-accordion-body.open { display: block; }


/* =============================================
   CLIENTS LIST
   ============================================= */

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

.list-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary-light), rgba(59, 130, 246, 0.1));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.list-body { flex: 1; min-width: 0; }

.list-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.list-right { text-align: right; flex-shrink: 0; }

.list-amount {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}


/* =============================================
   CLIENT DETAIL
   ============================================= */

.client-hero {
  text-align: center;
  padding: 8px var(--page-px) 20px;
}

.client-avatar-lg {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary-light), rgba(59, 130, 246, 0.12));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin: 0 auto 12px;
  border: 2px solid rgba(0, 232, 123, 0.2);
}

.client-name-lg {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.client-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
}

.client-stat { text-align: center; }

.client-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.client-stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* Client Actions */
.client-actions {
  display: flex;
  gap: 8px;
  padding: 0 var(--page-px);
  margin-bottom: 20px;
}
.client-actions .btn { flex: 1; }

/* Client Contact Card */
.client-contact-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 0 var(--page-px) 16px;
  overflow: hidden;
}

.client-contact-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  transition: background 0.15s;
  color: inherit;
}
.client-contact-row:last-child { border-bottom: none; }
a.client-contact-row:active,
.client-contact-row.copyable:active { background: var(--surface-hover); }
.client-contact-row.no-link { cursor: default; }

.client-contact-row.copy-flash {
  background: var(--primary-light) !important;
  transition: background 0.15s;
}

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

.client-contact-body { flex: 1; min-width: 0; }

.client-contact-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.client-contact-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  word-break: break-word;
}

/* Section Title */
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 var(--page-px);
  margin-bottom: 8px;
}


/* =============================================
   PRESTATION ITEMS
   ============================================= */

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

.presta-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.presta-icon.site { background: var(--primary-light); color: var(--primary); }
.presta-icon.maquette { background: var(--accent-light); color: var(--accent); }
.presta-icon.abonnement { background: rgba(167, 139, 250, 0.12); color: #A78BFA; }
.presta-icon.autres { background: var(--warning-light); color: var(--warning); }

.presta-body { flex: 1; min-width: 0; }

.presta-desc {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.presta-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.presta-right { text-align: right; flex-shrink: 0; }

.presta-amount {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.presta-status {
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
}
.presta-status.paid { color: var(--success); }
.presta-status.unpaid { color: var(--warning); }


/* =============================================
   EXPENSES
   ============================================= */

/* Stats Row */
.expenses-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 var(--page-px);
  margin-bottom: 16px;
}

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

.expenses-stat-value {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

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

/* Expense Select Toggle */
.exp-select-toggle {
  display: inline-block;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.exp-select-toggle.active {
  background: var(--danger-light);
  color: var(--danger);
  border-color: transparent;
}

/* Expense Groups */
.expense-group {
  margin: 8px var(--page-px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.expense-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.expense-group-header:active { background: var(--surface-hover); }

.expense-group-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.expense-group-left svg {
  color: var(--text-tertiary);
  transition: transform 0.3s var(--ease-spring);
}
.expense-group-header.collapsed svg { transform: rotate(-90deg); }

.expense-group-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.expense-group-count {
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-tertiary);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
}

.expense-group-total {
  font-size: 14px;
  font-weight: 700;
  color: var(--danger);
}

.expense-group-body {
  display: none;
}
.expense-group-body.open { display: block; }

/* Expense Card */
.expense-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background 0.15s;
}
.expense-card:last-child { border-bottom: none; }
.expense-card:active { background: var(--surface-hover); }
.expense-card.selected { background: var(--primary-light); }

.exp-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.exp-checkbox.checked {
  background: var(--primary);
  border-color: var(--primary);
  color: #050505;
}

.expense-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.expense-icon.materiel { background: var(--accent-light); color: var(--accent); }
.expense-icon.appli { background: rgba(167, 139, 250, 0.12); color: #A78BFA; }
.expense-icon.abonnement { background: var(--primary-light); color: var(--primary); }
.expense-icon.autre { background: var(--warning-light); color: var(--warning); }

.expense-body { flex: 1; min-width: 0; }

.expense-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-tertiary);
}
.expense-meta svg { width: 12px; height: 12px; }

.expense-right { text-align: right; flex-shrink: 0; }

.expense-amount {
  font-size: 15px;
  font-weight: 700;
  color: var(--danger);
  letter-spacing: -0.01em;
}

.expense-period {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

/* Select Bar */
.exp-select-bar {
  position: fixed;
  bottom: calc(var(--tab-height) + var(--safe-bottom) + 24px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  z-index: 50;
}

.exp-select-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

/* Group Pills */
.exp-group-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.exp-group-pill {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.exp-group-pill:active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}


/* =============================================
   INVOICES
   ============================================= */

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

.invoice-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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


/* =============================================
   INVOICE FORM
   ============================================= */

.invoice-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.inv-item-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  background: var(--danger-light);
  color: var(--danger);
  border-radius: 50%;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s;
  line-height: 1;
}
.inv-item-remove:active { opacity: 0.7; }

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

.invoice-total-bar .total-label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
}

.invoice-total-bar .total-amount {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.03em;
}


/* =============================================
   FORMS
   ============================================= */

.form-section {
  padding: 16px var(--page-px);
}

.form-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary); }

.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-tertiary); }

.form-group input:-webkit-autofill,
.form-group input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 100px var(--surface) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
}

.form-group select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23555555' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}

.settings-logo-field {
  display: grid;
  gap: 10px;
}

.settings-logo-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 86px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
}

.settings-logo-image {
  display: block;
  max-width: 100%;
  max-height: 56px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.settings-logo-empty {
  color: var(--text-tertiary);
  font-size: 13px;
}

.settings-logo-actions {
  display: flex;
  gap: 8px;
}

.settings-logo-actions > * {
  flex: 1;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-row .form-group { margin-bottom: 14px; }

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

/* Toggle Switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.toggle-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.toggle {
  -webkit-appearance: none;
  appearance: none;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: transform 0.25s var(--ease-spring), background 0.25s;
}
.toggle:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.toggle:checked::after {
  transform: translateX(20px);
  background: #050505;
}

[data-theme="light"] .toggle:checked::after {
  background: #FFFFFF;
}


/* =============================================
   SHEET / BOTTOM SHEET
   ============================================= */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.sheet-overlay.open { opacity: 1; pointer-events: auto; }

.sheet {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 1px solid var(--border);
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.35s var(--ease-spring);
  padding-bottom: calc(16px + var(--safe-bottom));
}
.sheet-overlay.open .sheet { transform: translateY(0); }

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--text-tertiary);
  margin: 10px auto 8px;
}

.sheet-content { padding: 8px 20px 16px; }

.sheet-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

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

.confirm-actions {
  display: flex;
  gap: 10px;
}
.confirm-actions .btn { flex: 1; }

.demo-sheet-kicker {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
}

.demo-sheet-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.demo-sheet-card {
  padding: 14px 12px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.demo-sheet-card-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.demo-sheet-card-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.demo-sheet-note {
  padding: 14px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface-2) 92%, var(--primary) 8%);
  border: 1px solid color-mix(in srgb, var(--border) 80%, var(--primary) 20%);
  margin-bottom: 18px;
}

.demo-sheet-note-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.demo-sheet-note p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.demo-sheet-actions {
  display: flex;
  gap: 10px;
}

.demo-sheet-actions .btn {
  flex: 1;
}

.install-sheet-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 18px 0;
}

.install-sheet-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.install-sheet-step-number {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.install-sheet-step-text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
}

.install-sheet-reminder {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 600;
  color: var(--warning);
  text-align: center;
}

@media (max-width: 420px) {
  .demo-sheet-grid {
    grid-template-columns: 1fr;
  }

  .demo-sheet-actions {
    flex-direction: column;
  }
}


/* =============================================
   TOAST
   ============================================= */

#toast {
  position: fixed;
  top: calc(var(--safe-top) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  opacity: 0;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  z-index: 500;
  transition: transform 0.35s var(--ease-spring), opacity 0.2s ease;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}
#toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
#toast.success { border-color: var(--primary); color: var(--primary); }
#toast.error { border-color: var(--danger); color: var(--danger); }


/* =============================================
   VIEW TABS
   ============================================= */

.view-tabs {
  display: flex;
  gap: 0;
  padding: 0 var(--page-px);
  border-bottom: 1px solid var(--divider);
}

.view-tab {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-tertiary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.view-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}


/* =============================================
   INVOICE PREVIEW & A4 (PRESERVED)
   ============================================= */

/* ---------- Invoice Preview ---------- */
.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,5,5,0.95);
  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(5,5,5,0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1;
}
.preview-toolbar .btn { font-size: 13px; padding: 8px 14px; color: #fff; }

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

/* ============================================
   FACTURE A4 - Style MIKAA.WEB
   ============================================ */
.invoice {
  width: 210mm;
  height: 297mm;
  background: white;
  font-family: 'Space Grotesk', '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;
}

.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.has-logo {
  width: 76mm;
  height: 18mm;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-left: auto;
  margin-bottom: 8px;
}

.invoice-header-logo {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: right center;
}

.invoice-title-large span {
  color: #00E87B;
  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;
}

.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;
}

.invoice .invoice-body {
  padding: 20px 40px;
}

.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; }

.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; }

.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; }

.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; }


/* =============================================
   SWIPE ACTIONS
   ============================================= */

.swipe-container {
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
}

.swipe-track {
  position: relative;
  z-index: 1;
  background: var(--surface);
  will-change: transform;
}

.swipe-track.swipe-snap {
  transition: transform 0.3s var(--ease-spring);
}

.swipe-reveal {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
  z-index: 0;
}
.swipe-reveal-left { left: 0; }
.swipe-reveal-right { right: 0; }

.swipe-wrapper {
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
}

.swipe-actions-left,
.swipe-actions-right {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
  z-index: 0;
}
.swipe-actions-left { left: 0; }
.swipe-actions-right { right: 0; }

.swipe-content {
  position: relative;
  z-index: 1;
  background: var(--surface);
  transition: transform 0.3s var(--ease-spring);
  will-change: transform;
}

.swipe-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
  border: none;
  cursor: pointer;
  gap: 3px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.swipe-btn svg { width: 18px; height: 18px; margin-bottom: 2px; }
.swipe-btn.accept    { background: var(--success); }
.swipe-btn.edit      { background: var(--primary); }
.swipe-btn.view      { background: var(--accent); }
.swipe-btn.delete    { background: var(--danger); }
.swipe-btn.archive   { background: var(--warning); color: #fff; }
.swipe-btn.duplicate { background: var(--accent); }
.swipe-btn.copy      { background: var(--accent); }
.swipe-btn.pdf       { background: var(--warning); color: #fff; }
.swipe-btn-danger    { background: var(--danger); }
.swipe-btn-blue      { background: var(--accent); }

/* ---- Context Menu (Desktop right-click) ---- */
.ctx-menu {
  position: fixed;
  z-index: 9999;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  padding: 6px 0;
  opacity: 0;
  transform: scale(.95);
  transition: opacity .12s, transform .12s;
  pointer-events: none;
}
.ctx-menu.open {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}
.ctx-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: .95rem;
  cursor: pointer;
  text-align: left;
}
.ctx-menu-item:hover {
  background: var(--hover);
}
.ctx-menu-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.ctx-menu-item.ctx-danger {
  color: var(--danger);
}


/* =============================================
   PULL TO REFRESH
   ============================================= */

#pullIndicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  height: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 16px;
  padding-right: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  background: var(--surface);
  z-index: 1000;
  transition: max-height 0.2s, padding 0.2s, opacity 0.2s;
  pointer-events: none;
  overflow: hidden;
}
#pullIndicator span {
  line-height: 1.2;
}
#pullIndicator.ready { color: var(--primary); }
#pullIndicator.ready .pull-spinner { border-top-color: var(--primary); }
#pullIndicator.refreshing .pull-spinner { animation: spin 0.6s linear infinite; }

.pull-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--text-tertiary);
  border-radius: 50%;
  flex-shrink: 0;
}

.pull-indicator {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%) translateY(-60px);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transition: transform 0.3s var(--ease-spring);
}
.pull-indicator svg { width: 18px; height: 18px; color: var(--primary); transition: transform 0.25s; }
.pull-indicator.pulling { transform: translateX(-50%) translateY(calc(20px + var(--safe-top))); }
.pull-indicator.refreshing svg { animation: spin 0.7s linear infinite; }


/* =============================================
   SEGMENT CONTROL & PERIOD FILTER
   ============================================= */

.segment-control {
  display: flex;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  margin: 10px var(--page-px);
}

.segment-btn {
  flex: 1;
  padding: 9px 12px;
  border: none;
  background: none;
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: 13px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s;
}
.segment-btn.active {
  background: var(--surface-2);
  color: var(--primary);
}

.period-filter {
  display: flex;
  gap: 6px;
  padding: 0 var(--page-px);
  margin-bottom: 10px;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.period-filter::-webkit-scrollbar { display: none; }

.period-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}
.period-btn.active {
  background: var(--primary);
  color: #050505;
  border-color: var(--primary);
}


/* =============================================
   CONTACT & REMINDER & CHART LEGEND
   ============================================= */

.contact-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
}
.contact-row:last-child { border-bottom: none; }

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

.contact-value { font-size: 14px; color: var(--text); font-weight: 500; word-break: break-all; }
.contact-label { font-size: 12px; color: var(--text-tertiary); }

.reminder-card {
  display: flex;
  align-items: flex-start;
  padding: 14px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--divider);
}
.reminder-card:last-child { border-bottom: none; }

.reminder-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--warning-light);
  color: var(--warning);
}
.reminder-icon.due-soon { background: var(--warning-light); color: var(--warning); }
.reminder-icon.overdue  { background: var(--danger-light); color: var(--danger); }

.reminder-body { flex: 1; min-width: 0; }
.reminder-title { font-weight: 600; font-size: 14px; color: var(--text); }
.reminder-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.4; margin-top: 2px; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 16px 0;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
}


/* =============================================
   COLOR UTILITIES
   ============================================= */

.text-green { color: var(--success) !important; }
.text-yellow { color: var(--warning) !important; }
.text-blue { color: var(--accent) !important; }
.text-purple { color: #A78BFA !important; }
.text-red { color: var(--danger) !important; }
.text-muted { color: var(--text-secondary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-sm { font-size: 12px !important; }
.font-bold { font-weight: 700 !important; }
.font-medium { font-weight: 500 !important; }

.bg-green { background: var(--success-light) !important; }
.bg-yellow { background: var(--warning-light) !important; }
.bg-blue { background: var(--accent-light) !important; }
.bg-purple { background: rgba(167, 139, 250, 0.12) !important; }
.bg-red { background: var(--danger-light) !important; }

.green { color: var(--success); }
.blue { color: var(--accent); }
.purple { color: #A78BFA; }
.yellow { color: var(--warning); }
.red { color: var(--danger); }
.orange { color: var(--warning); }


/* =============================================
   SPACING UTILITIES
   ============================================= */

.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 */
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.items-center { align-items: center; }

.hidden { display: none !important; }


/* =============================================
   ANIMATIONS
   ============================================= */

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes staggerUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* =========================================================
   AUTH PAGE
   ========================================================= */

.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px var(--page-px);
}

.auth-brand {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -2px;
  color: var(--primary);
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.auth-card code {
  font-size: 12px;
}

.auth-tabs {
  display: flex;
  margin: -24px -24px 24px;
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  font: 500 14px/1 'Space Grotesk', sans-serif;
  padding: 16px 8px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.auth-tab:first-child { border-radius: var(--radius) 0 0 0; }
.auth-tab:last-child  { border-radius: 0 var(--radius) 0 0; }

.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.auth-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
  min-height: 20px;
}

.auth-forgot {
  text-align: right;
  margin: -4px 0 16px;
}

.auth-forgot a {
  color: var(--text-tertiary);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.2s;
}

.auth-forgot a:active { color: var(--primary); }

.auth-skip {
  background: none;
  border: none;
  color: var(--text-secondary);
  font: 400 14px/1 'Space Grotesk', sans-serif;
  margin-top: 24px;
  cursor: pointer;
  padding: 12px;
  transition: color 0.2s;
}

.auth-skip:active { color: var(--text-primary); }

.auth-hint {
  color: var(--text-tertiary);
  font-size: 12px;
  margin-top: 12px;
  text-align: center;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  color: var(--text-tertiary);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-social {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font: 500 14px/1 'Space Grotesk', sans-serif;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.auth-social-btn.is-disabled {
  opacity: 0.55;
}

.auth-social-btn:active {
  background: var(--surface-hover);
  border-color: var(--text-tertiary);
}

.auth-social-note {
  margin-top: 10px;
  color: var(--text-tertiary);
  font-size: 12px;
  text-align: center;
}

/* Account / Sync in Settings */

.account-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.account-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}

.account-details {
  flex: 1;
  min-width: 0;
}

.account-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-email {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.sync-dot.offline { background: var(--text-tertiary); }

.sync-text {
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
}

.sync-btn {
  background: none;
  border: none;
  color: var(--primary);
  font: 500 13px/1 'Space Grotesk', sans-serif;
  cursor: pointer;
  padding: 4px 8px;
}

.sync-error {
  padding: 10px 12px;
  border: 1px solid rgba(255, 71, 87, 0.25);
  background: rgba(255, 71, 87, 0.08);
  border-radius: var(--radius-xs);
  color: #ff8f9a;
  font-size: 13px;
  line-height: 1.45;
}


/* =============================================
   DESKTOP LAYOUT
   ============================================= */

/* Hidden by default (mobile) */
#sidebar { display: none; }
#qr-panel { display: none; }

@media (min-width: 1024px) {

  /* ---- Shell Grid ---- */
  #desktop-shell {
    display: grid;
    grid-template-columns: 260px 1fr 320px;
    height: 100vh;
    overflow: hidden;
  }

  /* ---- Sidebar ---- */
  #sidebar {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    height: 100vh;
    overflow-y: auto;
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 28px 24px 36px;
  }

  .sidebar-logo-svg {
    width: 30px;
    height: 30px;
    fill: var(--primary);
    flex-shrink: 0;
  }

  .sidebar-brand-name {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--text);
  }

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

  .sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    position: relative;
  }

  .sidebar-item:hover {
    background: var(--surface-hover);
    color: var(--text);
  }

  .sidebar-item.active {
    background: var(--primary-light);
    color: var(--primary);
  }

  .sidebar-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--primary);
  }

  .sidebar-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  .sidebar-footer {
    padding: 20px 24px;
    font-size: 11px;
    color: var(--text-tertiary);
    letter-spacing: 0.02em;
  }

  /* ---- App container ---- */
  #app {
    max-width: none;
    margin: 0;
    height: 100vh;
    min-height: unset;
    overflow: hidden;
  }

  #view {
    padding-bottom: 32px;
  }

  #tab-bar,
  #tab-bar::before {
    display: none !important;
  }

  /* ---- QR Panel ---- */
  #qr-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-left: 1px solid var(--border);
    height: 100vh;
    overflow-y: auto;
    padding: 32px 24px;
  }

  .qr-panel-inner { display: none; } /* legacy — replaced by .qrp-inner */

  /* ---- QR Panel (redesigned) ---- */
  .qrp-inner {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
    max-width: 252px;
  }

  /* Brand row */
  .qrp-brand {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .qrp-logo {
    width: 26px;
    height: 26px;
    fill: var(--primary);
    flex-shrink: 0;
  }

  .qrp-brand-text { flex: 1; min-width: 0; }

  .qrp-brand-name {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--text);
    line-height: 1;
  }

  .qrp-brand-sub {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 2px;
  }

  .qrp-version {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 999px;
    white-space: nowrap;
  }

  /* Live stats row */
  .qrp-stats {
    display: flex;
    align-items: stretch;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
  }

  .qrp-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 6px;
    gap: 3px;
  }

  .qrp-stat-val {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
    line-height: 1;
  }

  .qrp-stat-lbl {
    font-size: 9px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.07em;
  }

  .qrp-stat-sep {
    width: 1px;
    background: var(--border);
    align-self: stretch;
    margin: 8px 0;
  }

  /* Revenue card */
  .qrp-revenue {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 12px;
    background: var(--primary-light);
    border-radius: var(--radius-md);
    border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
    text-align: center;
  }

  .qrp-revenue-val {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.03em;
  }

  .qrp-revenue-lbl {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }

  /* Divider */
  .qrp-divider {
    height: 1px;
    background: var(--border);
    margin: 2px 0;
  }

  /* QR section */
  .qrp-qr-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .qrp-qr-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.07em;
  }

  .qrp-qr-wrap {
    width: 148px;
    height: 148px;
    background: #fff;
    border-radius: 12px;
    padding: 10px;
    animation: qrGlow 4s ease-in-out infinite;
  }

  .qrp-qr-wrap canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
  }

  @keyframes qrGlow {
    0%, 100% { box-shadow: 0 0 0 1px var(--border), 0 0 0 rgba(0, 232, 123, 0); }
    50%       { box-shadow: 0 0 0 1px var(--border), 0 0 24px rgba(0, 232, 123, 0.18); }
  }

  .qrp-qr-hint {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
    line-height: 1.4;
  }

  /* Platform chips */
  .qrp-platforms {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .qrp-plat {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 999px;
  }

  /* Feature tags */
  .qrp-feats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .qrp-feat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 5px 10px;
    border-radius: 999px;
  }

  /* ---- Desktop Dashboard Overrides ---- */
  .dash-hero {
    padding-top: 28px;
  }

  .neon-stats {
    grid-template-columns: repeat(4, 1fr);
  }

  .chart-container {
    height: 260px;
  }

  .net-profit-bar {
    margin-top: 16px;
  }

  /* ---- FAB: keep inside #app column, not over QR panel ---- */
  .fab {
    bottom: 32px;
    right: calc(320px + 32px);
    position: fixed;
  }

  /* ---- Sheet as centered modal on desktop ---- */
  .sheet-overlay {
    align-items: center;
    justify-content: center;
  }

  .sheet {
    border-radius: var(--radius-lg);
    max-height: 80vh;
    max-width: 520px;
  }

  /* ---- Page header: no safe-area on desktop ---- */
  .page-header {
    padding-top: 12px;
  }

  .search-bar {
    padding-top: 8px;
  }

  /* ---- Forms: breathable on desktop ---- */
  .form-section {
    max-width: 680px;
  }

  /* ---- Auth page: constrain width ---- */
  .auth-page {
    min-height: unset;
    padding-top: 60px;
  }

  /* ---- Light theme overrides ---- */
  [data-theme="light"] #sidebar {
    background: var(--surface);
  }

  [data-theme="light"] #qr-panel {
    background: var(--surface);
  }
}

/* ---- Desktop hover & cursor interactions ---- */
@media (min-width: 1024px) and (hover: hover) {
  /* Pointer cursor on all interactive rows */
  .swipe-inner,
  .client-row,
  .invoice-row,
  .expense-row,
  .presta-row,
  .list-item {
    cursor: pointer;
  }

  /* Hover highlight on rows */
  .swipe-inner:hover,
  .client-row:hover,
  .invoice-row:hover,
  .expense-row:hover,
  .presta-row:hover,
  .list-item:hover {
    background: var(--surface-hover);
    transition: background 0.15s;
  }

  /* Right-click hint on swipe rows */
  .swipe-wrap:hover .swipe-inner::after {
    content: '⋮';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.2rem;
    pointer-events: none;
    opacity: 0.5;
  }

  /* Buttons & cards */
  .btn:hover,
  .btn-secondary:hover,
  .btn-icon:hover,
  .btn-icon-sm:hover,
  .card:hover {
    cursor: pointer;
  }
}

/* ---- Larger desktops ---- */
@media (min-width: 1440px) {
  #desktop-shell {
    grid-template-columns: 280px 1fr 360px;
  }

  .fab {
    right: calc(360px + 32px);
  }

  .qrp-qr-wrap {
    width: 168px;
    height: 168px;
  }
}
