:root {
  --bg: #06080d;
  --bg-elevated: #0c1018;
  --surface: rgba(14, 18, 28, 0.72);
  --surface-solid: #111827;
  --ink: #f1f5f9;
  --muted: #8b9cb3;
  --line: rgba(148, 163, 184, 0.12);
  --line-strong: rgba(148, 163, 184, 0.22);
  --accent: #2dd4bf;
  --accent-dim: rgba(45, 212, 191, 0.14);
  --accent-glow: rgba(45, 212, 191, 0.35);
  --expense: #fb7185;
  --expense-dim: rgba(251, 113, 133, 0.12);
  --invest: #60a5fa;
  --invest-dim: rgba(96, 165, 250, 0.12);
  --save: #4ade80;
  --save-dim: rgba(74, 222, 128, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Sora", var(--font);
  --nav-h: calc(4.5rem + env(safe-area-inset-bottom));
  /* Échelle harmonique */
  --text-xs: 0.6875rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.875rem;
  --text-3xl: 2.5rem;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --gap: var(--space-4);
  --panel-pad: var(--space-5);
  --btn-h: 2.75rem;
  --btn-h-sm: 2.375rem;
  --content-pad: var(--space-4);
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: var(--text-md);
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(45, 212, 191, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(96, 165, 250, 0.08), transparent 50%),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: auto, auto, 48px 48px, 48px 48px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 30%, black 20%, transparent 100%);
}

.hidden {
  display: none !important;
}

.auth-boot {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.shell,
.auth-screen {
  position: relative;
  z-index: 1;
}

.shell {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  :root {
    --content-pad: var(--space-5);
    --panel-pad: var(--space-6);
  }

  main {
    padding-left: var(--content-pad) !important;
    padding-right: var(--content-pad) !important;
  }

  .topbar {
    padding-left: var(--content-pad) !important;
    padding-right: var(--content-pad) !important;
  }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: max(0.75rem, env(safe-area-inset-top)) var(--content-pad) 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  background: rgba(6, 8, 13, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-lg);
  letter-spacing: -0.03em;
}

.brand span {
  color: var(--accent);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.user-chip {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
  max-width: min(140px, 32vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

#btn-logout {
  width: auto;
  min-height: var(--btn-h-sm);
  padding: 0.5rem 0.875rem;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

main {
  flex: 1;
  padding: var(--space-3) var(--content-pad) var(--nav-h);
  width: 100%;
}

.view-layout {
  display: grid;
  gap: var(--gap);
}

.view-layout > .panel + .panel {
  margin-top: 0;
}

.panel {
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--panel-pad);
}

.panel + .panel {
  margin-top: var(--gap);
}

.panel-title {
  margin: 0 0 var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.panel-title--flush {
  margin-bottom: 0;
}

.panel-hero {
  position: relative;
  overflow: hidden;
  padding: 1.35rem 1.25rem;
  background: linear-gradient(145deg, rgba(45, 212, 191, 0.08) 0%, rgba(14, 18, 28, 0.9) 45%);
  border-color: rgba(45, 212, 191, 0.2);
}

.panel-hero::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -20%;
  width: 55%;
  height: 120%;
  background: radial-gradient(circle, var(--accent-glow), transparent 65%);
  opacity: 0.35;
  pointer-events: none;
}

.hero-total {
  position: relative;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(var(--text-2xl), 5vw, var(--text-3xl));
  font-weight: 600;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.hero-sub {
  position: relative;
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.45;
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.625rem;
}

@media (min-width: 360px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.kpi {
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.65rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  min-width: 0;
}

.kpi-label {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
  line-height: 1.2;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: clamp(0.9375rem, 3.2vw, 1.0625rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi--save {
  background: var(--save-dim);
  border-color: rgba(74, 222, 128, 0.22);
}

.kpi--save .kpi-value {
  color: var(--save);
}

.kpi--invest {
  background: var(--invest-dim);
  border-color: rgba(96, 165, 250, 0.22);
}

.kpi--invest .kpi-value {
  color: var(--invest);
}

.kpi--expense {
  background: var(--expense-dim);
  border-color: rgba(251, 113, 133, 0.22);
}

.kpi--expense .kpi-value {
  color: var(--expense);
}

.type-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.125rem;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
}

.type-tab {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 0.65rem 0.35rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.type-tab.active[data-type="depense"] {
  background: var(--expense-dim);
  border-color: rgba(251, 113, 133, 0.35);
  color: var(--expense);
  box-shadow: 0 0 20px rgba(251, 113, 133, 0.12);
}

.type-tab.active[data-type="salaire"],
.type-tab.active[data-type="epargne"] {
  background: var(--save-dim);
  border-color: rgba(74, 222, 128, 0.35);
  color: var(--save);
  box-shadow: 0 0 20px rgba(74, 222, 128, 0.1);
}

.type-tab.active[data-type="investissement"] {
  background: var(--invest-dim);
  border-color: rgba(96, 165, 250, 0.35);
  color: var(--invest);
  box-shadow: 0 0 20px rgba(96, 165, 250, 0.1);
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: var(--space-2);
  color: var(--muted);
  letter-spacing: 0.01em;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.95rem;
  font: inherit;
  font-size: var(--text-base);
  color: var(--ink);
  background: rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input::placeholder {
  color: rgba(139, 156, 179, 0.55);
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(45, 212, 191, 0.55);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.amount-input {
  font-family: var(--font-display);
  font-size: clamp(1.625rem, 5vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 1rem !important;
  background: rgba(45, 212, 191, 0.04) !important;
  border-color: rgba(45, 212, 191, 0.18) !important;
}

input[type="date"] {
  color-scheme: dark;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--btn-h);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.125rem;
  font: inherit;
  font-weight: 600;
  font-size: var(--text-base);
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn--auto {
  width: auto;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #2dd4bf 0%, #14b8a6 100%);
  color: #042f2e;
  box-shadow: 0 8px 28px rgba(45, 212, 191, 0.25);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
  box-shadow: 0 10px 32px rgba(45, 212, 191, 0.32);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  border: 1px solid var(--line-strong);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}

.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.entry-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.entry-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.entry-item:first-child {
  padding-top: 0;
}

.entry-left {
  min-width: 0;
  flex: 1;
}

.entry-label {
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-meta {
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.entry-amount {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.entry-amount--depense {
  color: var(--expense);
}

.entry-amount--epargne {
  color: var(--save);
}

.entry-amount--investissement {
  color: var(--invest);
}

.chart-wrap {
  position: relative;
  height: clamp(220px, 40vw, 280px);
  width: 100%;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-1);
  background: rgba(10, 12, 18, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
  padding: var(--space-2) var(--space-3) calc(var(--space-2) + env(safe-area-inset-bottom));
}

.nav-btn {
  border: none;
  background: transparent;
  padding: 0.625rem var(--space-2);
  min-height: var(--btn-h);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1.25rem, env(safe-area-inset-top)) 1rem max(1.25rem, env(safe-area-inset-bottom));
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-card h1 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.04em;
}

.auth-card h1::after {
  content: ".";
  color: var(--accent);
}

.auth-card > p:first-of-type {
  margin: 0 0 1.35rem;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.demo-box {
  margin-top: 1.25rem;
  padding: 0.85rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(148, 163, 184, 0.28);
  background: rgba(0, 0, 0, 0.18);
  text-align: center;
}

.demo-box-title {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.demo-box-creds {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--ink);
}

.demo-box-creds code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
  color: var(--accent);
}

.demo-box .btn {
  width: 100%;
}

.auth-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.125rem;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
}

.auth-toggle button {
  flex: 1;
  min-height: 44px;
}

.msg {
  font-size: 0.8125rem;
  margin-top: 0.875rem;
  min-height: 1.25rem;
  line-height: 1.45;
}

.msg--error {
  color: var(--expense);
}

.msg--ok {
  color: var(--save);
}

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
  padding: 1.75rem 0.5rem;
  line-height: 1.5;
}

.day-hint--flush {
  margin-bottom: 0;
}

.panel-hero--compact {
  padding: var(--panel-pad);
}

.panel-hero--compact .hero-total {
  font-size: clamp(var(--text-xl), 4.5vw, var(--text-2xl));
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.day-date {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.01em;
}

.day-hint {
  margin: 0 0 var(--space-4);
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.5;
}

.onboarding-lead {
  margin: 0 0 0.65rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--ink);
}

.onboarding-note {
  margin: 0 0 1.25rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(45, 212, 191, 0.22);
  background: var(--accent-dim);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--muted);
}

.onboarding-note strong {
  color: var(--accent);
  font-weight: 600;
}

.onboarding-logout {
  width: 100%;
  margin-top: 0.75rem;
}

.auth-card--onboarding {
  max-width: min(100%, 640px);
  max-height: min(92vh, 780px);
  overflow-y: auto;
}

@media (min-width: 768px) {
  .auth-card--onboarding {
    max-width: min(100%, 860px);
    max-height: none;
  }
}

.onboarding-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.onboarding-step-dot {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.25);
}

.onboarding-step-dot.active {
  border-color: rgba(45, 212, 191, 0.5);
  background: var(--accent-dim);
  color: var(--accent);
}

.onboarding-step-line {
  width: 2.5rem;
  height: 1px;
  background: var(--line);
}

.onboarding-fixed-grid {
  max-height: 42vh;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.fixed-row--custom {
  grid-template-columns: 1fr minmax(88px, 34%);
}

.fixed-custom-label {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 0.8125rem;
  color: var(--ink);
  padding: 0.25rem 0;
}

.fixed-custom-label:focus {
  outline: none;
}

.fixed-custom-label::placeholder {
  color: rgba(139, 156, 179, 0.55);
}

.fixed-costs-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1rem 0;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(167, 139, 250, 0.1);
  border: 1px solid rgba(167, 139, 250, 0.22);
  font-size: 0.875rem;
  color: var(--muted);
}

.fixed-costs-total strong {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  color: #a78bfa;
  font-variant-numeric: tabular-nums;
}

.fixed-costs-total--panel {
  margin-top: 0;
}

.hero-sub--fixed {
  margin-top: 0.35rem;
  color: #a78bfa;
}

/* ——— Dashboard Suivi ——— */
.view-layout--stats {
  gap: var(--gap);
}

.view-layout--stats > .panel,
.view-layout--stats > .dash-header,
.view-layout--stats > .dash-kpi-grid {
  margin-top: 0;
}

.dash-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding: var(--panel-pad);
  background: linear-gradient(145deg, rgba(45, 212, 191, 0.1) 0%, rgba(14, 18, 28, 0.92) 50%);
  border-color: rgba(45, 212, 191, 0.22);
}

.dash-title {
  margin: 0 0 var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.dash-hero-total {
  margin: 0;
  font-size: clamp(var(--text-2xl), 4vw, var(--text-3xl));
  white-space: nowrap;
}

.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.dash-kpi {
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.24);
  min-height: 5.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.dash-kpi-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: var(--space-2);
}

.dash-kpi-value {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.dash-kpi--liquid {
  border-color: rgba(45, 212, 191, 0.22);
  background: rgba(45, 212, 191, 0.06);
}

.dash-kpi--liquid .dash-kpi-value {
  color: var(--accent);
}

.dash-kpi--invest {
  border-color: rgba(96, 165, 250, 0.22);
  background: rgba(96, 165, 250, 0.06);
}

.dash-kpi--invest .dash-kpi-value {
  color: var(--invest);
}

.dash-kpi--gain {
  border-color: rgba(167, 139, 250, 0.22);
  background: rgba(167, 139, 250, 0.08);
}

.dash-kpi--gain .dash-kpi-value {
  color: #a78bfa;
}

.dash-header-text {
  min-width: 0;
  flex: 1;
}

.dash-kpi--fixed {
  border-color: rgba(167, 139, 250, 0.18);
}

.dash-portfolio-head {
  margin-bottom: var(--space-4);
}

.portfolio-stats--dash {
  margin-bottom: var(--space-4);
}

.portfolio-form-inline {
  margin: 0;
}

.portfolio-field-inline {
  margin-bottom: 0;
}

.portfolio-input-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.amount-input--inline {
  font-size: var(--text-lg) !important;
  text-align: left !important;
  padding: 0.75rem 1rem !important;
  width: 100%;
}

.portfolio-input-row .btn-primary {
  width: 100%;
}

.entry-list--compact .entry-item {
  padding: 0.65rem 0;
}

.entry-list--compact .entry-label {
  font-size: var(--text-base);
}

.dash-recent {
  display: flex;
  flex-direction: column;
}

.dash-recent .entry-list {
  flex: 1;
  min-height: 0;
}

.form-actions {
  margin-top: var(--space-2);
}

.form-actions .btn-primary {
  width: 100%;
}

.dash-kpi-link {
  margin-top: auto;
  padding-top: var(--space-2);
  padding-left: 0;
  padding-right: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  align-self: flex-start;
}

.dash-kpi-link:hover {
  text-decoration: underline;
}

.dash-portfolio {
  padding: var(--panel-pad);
}

.view-layout--settings {
  gap: var(--gap);
}

.settings-header {
  padding: var(--panel-pad);
}

@media (min-width: 640px) {
  .dash-kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .portfolio-input-row {
    flex-direction: row;
    align-items: stretch;
  }

  .portfolio-input-row .amount-input--inline {
    flex: 1;
    min-width: 0;
  }

  .portfolio-input-row .btn-primary {
    width: auto;
    min-width: 10rem;
    flex-shrink: 0;
  }

  /* Tablette : Jour en 2 colonnes */
  .view-layout--day {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .view-layout--day .panel-hero {
    grid-column: 1 / -1;
  }

  .view-layout--day .panel:nth-child(2) {
    grid-column: 1;
  }

  .view-layout--day .panel:nth-child(3) {
    grid-column: 2;
    align-self: start;
  }

  .chart-wrap--compact {
    height: clamp(220px, 36vw, 320px);
  }
}

@media (min-width: 900px) {
  .view-layout--settings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .view-layout--settings .settings-header {
    grid-column: 1 / -1;
  }
}

.daily-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.daily-row {
  display: grid;
  grid-template-columns: 1fr minmax(88px, 34%);
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  cursor: text;
}

.daily-row:focus-within {
  border-color: rgba(45, 212, 191, 0.45);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.daily-row-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink);
  line-height: 1.35;
}

.daily-input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink);
  padding: 0.25rem 0;
}

.daily-input:focus {
  outline: none;
}

.daily-input::placeholder {
  color: rgba(139, 156, 179, 0.45);
}

.daily-input:disabled {
  opacity: 0.55;
}

.daily-divider {
  margin: 1.125rem 0 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.day-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1rem 0;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--expense-dim);
  border: 1px solid rgba(251, 113, 133, 0.2);
  font-size: 0.875rem;
  color: var(--muted);
}

.day-total strong {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  color: var(--expense);
  font-variant-numeric: tabular-nums;
}

.day-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0.75rem 0 0.35rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  border: 1px solid rgba(45, 212, 191, 0.22);
  font-size: 0.875rem;
  color: var(--muted);
}

.day-balance strong {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.day-balance--negative strong {
  color: var(--expense);
}

.day-hint--inline {
  margin: 0 0 1rem;
}

.day-form-summary {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0.75rem 0 0.35rem;
}

.day-form-actions {
  margin-top: 0.25rem;
}

.kpi-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.kpi-breakdown strong {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.kpi-breakdown-gain strong {
  color: #a78bfa;
}

/* Statut journée (hero) */
.day-status {
  position: relative;
  z-index: 2;
  margin-top: var(--space-4);
  width: 100%;
}

.day-status--hint {
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.55;
}

.day-status--closed {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: rgba(74, 222, 128, 0.07);
  border: 1px solid rgba(74, 222, 128, 0.2);
}

.day-status-dot {
  flex-shrink: 0;
  width: 0.55rem;
  height: 0.55rem;
  margin-top: 0.4rem;
  border-radius: 999px;
  background: var(--save);
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.45);
}

.day-status-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.day-status-title {
  display: block;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--save);
  line-height: 1.35;
}

.day-status-sub {
  display: block;
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.45;
}

/* Graphiques */
.chart-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.chart-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.chart-panel-meta {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.chart-stage {
  position: relative;
  padding: var(--space-4) var(--space-3) var(--space-3);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(148, 163, 184, 0.08);
  overflow: hidden;
}

.chart-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.05) 0%, transparent 45%);
  pointer-events: none;
}

.chart-stage .chart-wrap {
  position: relative;
  z-index: 1;
}

.portfolio-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.portfolio-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  font-size: 0.8125rem;
  color: var(--muted);
}

.portfolio-stat strong {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.portfolio-stat--gain strong {
  color: #a78bfa;
}

@media (min-width: 480px) {
  .portfolio-stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

.day-closed .daily-input,
.day-closed #btn-close-day {
  pointer-events: none;
  opacity: 0.65;
}

.chart-wrap--compact {
  height: clamp(180px, 36vw, 240px);
}

.chart-wrap--tall {
  height: clamp(260px, 48vw, 340px);
}

.chart-note {
  margin: 0;
  padding-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.5;
}

.chart-note strong {
  color: var(--accent);
  font-weight: 600;
}

@media (min-width: 480px) {
  .daily-grid:not(.daily-grid--short) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
}

/* ——— Desktop (Mac / grand écran) ——— */
@media (min-width: 1024px) {
  :root {
    --nav-h: 1.5rem;
  }

  body {
    padding: 1.25rem;
  }

  .shell {
    max-width: min(96vw, 1360px);
    width: 100%;
    min-height: calc(100dvh - 2.5rem);
    display: grid;
    grid-template-areas:
      "header header"
      "nav main";
    grid-template-columns: 220px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    border: 1px solid var(--line-strong);
    border-radius: 20px;
    background: rgba(8, 10, 16, 0.82);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.55);
    overflow: hidden;
  }

  .topbar {
    grid-area: header;
    position: relative;
    padding: 1rem 1.75rem;
  }

  .brand {
    font-size: 1.2rem;
  }

  .user-chip {
    max-width: 180px;
    font-size: 0.8125rem;
  }

  #btn-logout {
    font-size: 0.8125rem;
    padding: 0.5rem 1rem;
  }

  .bottom-nav {
    grid-area: nav;
    position: sticky;
    top: 0;
    align-self: start;
    height: auto;
    min-height: 100%;
    max-width: none;
    width: auto;
    left: auto;
    transform: none;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    border-top: none;
    border-right: 1px solid var(--line);
    border-radius: 0;
    padding: 1.25rem 0.85rem;
    gap: 0.4rem;
    background: rgba(6, 8, 13, 0.5);
  }

  .nav-btn {
    font-size: 0.875rem;
    padding: 0.8rem 1rem;
    min-height: 46px;
    text-align: left;
    border-radius: var(--radius-sm);
  }

  main {
    grid-area: main;
    padding: var(--space-6) var(--space-6) var(--space-8);
    overflow-y: auto;
  }

  .view-layout {
    gap: var(--space-4);
  }

  .onboarding-fixed-grid {
    max-height: none;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .chart-wrap--tall {
    height: 360px;
  }

  .chart-wrap {
    height: 300px;
  }

  .dash-chart-side .chart-wrap {
    height: 360px;
  }

  /* Jour : formulaire à gauche, graphique à droite */
  .view-layout--day {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    align-items: start;
  }

  .view-layout--day .panel-hero {
    grid-column: 1 / -1;
  }

  .view-layout--day .panel-hero--compact {
    padding: var(--space-6);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto auto;
    column-gap: var(--space-8);
    row-gap: var(--space-3);
    align-items: start;
  }

  .view-layout--day .panel-hero--compact .panel-title {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 0;
  }

  .view-layout--day .panel-hero--compact .hero-total {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    font-size: var(--text-3xl);
    text-align: right;
    white-space: nowrap;
  }

  .view-layout--day .panel-hero--compact .kpi-breakdown {
    grid-column: 1;
    grid-row: 2;
    margin: 0;
  }

  .view-layout--day .panel-hero--compact .day-status {
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: 0;
  }

  .view-layout--day .panel-hero--compact .hero-sub--fixed {
    grid-column: 1 / -1;
    grid-row: 4;
    margin-top: 0;
  }

  .view-layout--day .kpi-breakdown {
    gap: var(--space-5) var(--space-8);
    font-size: var(--text-sm);
  }

  .view-layout--day .panel:nth-child(2) {
    grid-column: 1;
  }

  .view-layout--day .panel:nth-child(3) {
    grid-column: 2;
    grid-row: 2 / span 2;
    position: sticky;
    top: 1rem;
  }

  .daily-grid:not(.daily-grid--short) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .daily-grid--short {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .day-form-summary {
    flex-direction: row;
    gap: 1rem;
  }

  .day-form-summary .day-balance,
  .day-form-summary .day-total {
    flex: 1;
    margin: 0;
  }

  .day-form-actions .btn-primary,
  .form-actions .btn-primary {
    width: auto;
    min-width: 16rem;
  }

  .chart-wrap--compact {
    height: min(420px, calc(100vh - 12rem));
  }

  /* Suivi : dashboard 12 colonnes */
  .view-layout--stats {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    align-items: start;
  }

  .view-layout--stats .dash-header,
  .view-layout--stats .dash-kpi-grid {
    grid-column: 1 / -1;
  }

  .view-layout--stats .dash-portfolio {
    grid-column: 1 / 8;
  }

  .view-layout--stats .dash-recent {
    grid-column: 8 / -1;
    max-height: min(420px, calc(100vh - 22rem));
  }

  .view-layout--stats .dash-recent .entry-list {
    overflow-y: auto;
    max-height: calc(100% - 2.5rem);
  }

  .view-layout--stats .dash-chart-main {
    grid-column: 1 / 8;
  }

  .view-layout--stats .dash-chart-side {
    grid-column: 8 / -1;
  }

  .view-layout--stats .dash-hero-total {
    font-size: var(--text-3xl);
  }

  .dash-kpi-value {
    font-size: var(--text-xl);
  }

  /* Paramètres : pleine largeur, 2 colonnes */
  .view-layout--settings {
    max-width: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .view-layout--settings .settings-header {
    grid-column: 1 / -1;
  }

  .view-layout--settings .amount-input {
    font-size: 1.75rem;
    max-width: 320px;
  }

  .view-layout--settings form > .btn-primary {
    width: auto;
    min-width: 12rem;
  }

  /* Auth & onboarding */
  .auth-screen {
    padding: 2rem;
  }

  .auth-card {
    max-width: 460px;
  }

  .auth-card--onboarding {
    max-width: 820px;
    max-height: none;
  }

  .panel form > .btn-primary:not([type="submit"]),
  .panel form > .btn-primary[type="submit"],
  .fixed-costs-total + .btn-primary,
  #fixed-costs-form .btn-primary,
  #fixed-costs-form .btn-ghost,
  #portfolio-form .btn-primary,
  #fixed-costs-edit-form .btn-primary,
  #entry-form .btn-primary {
    width: auto;
    min-width: 12rem;
  }

  #fixed-costs-form .btn-ghost {
    margin-left: 0.75rem;
  }

  #fixed-costs-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
  }

  #fixed-costs-form .onboarding-fixed-grid,
  #fixed-costs-form .fixed-costs-total,
  #fixed-costs-form .msg {
    width: 100%;
  }

  .demo-box {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    text-align: left;
    gap: 0.35rem 1rem;
  }

  .demo-box-title {
    grid-column: 1 / -1;
  }

  .demo-box-creds {
    grid-column: 1;
    grid-row: 2;
    margin-bottom: 0;
  }

  .demo-box .btn {
    width: auto;
    min-width: 10rem;
    grid-column: 2;
    grid-row: 2;
    align-self: center;
    justify-self: end;
  }

  .panel {
    padding: 1.35rem 1.5rem;
  }

  .panel-title {
    font-size: 0.75rem;
    margin-bottom: 1rem;
  }

  .day-hint {
    font-size: 0.875rem;
  }

  .daily-row {
    padding: 0.65rem 0.85rem;
  }

  .daily-row-label {
    font-size: 0.875rem;
  }
}

@media (min-width: 1280px) {
  .shell {
    max-width: min(96vw, 1520px);
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .view-layout--day {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  }

  .view-layout--stats .dash-chart-main {
    grid-column: 1 / 9;
  }

  .view-layout--stats .dash-chart-side {
    grid-column: 9 / -1;
  }

  .view-layout--stats .dash-portfolio {
    grid-column: 1 / 7;
  }

  .view-layout--stats .dash-recent {
    grid-column: 7 / -1;
  }

  .daily-grid:not(.daily-grid--short) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .onboarding-fixed-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .chart-wrap--tall,
  .dash-chart-side .chart-wrap {
    height: min(400px, calc(100vh - 18rem));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
