/* =====================================================================
   DevHub Finances — Feuille de style principale
   DA reprise de dev-hub.fr : noir & blanc, Archivo étendu, lignes fines,
   boutons pilule, accent dégradé vert → teal utilisé avec parcimonie.
   Les graphiques sont dans charts.css (.ch-*), les pages dans pages.css (.pg-*).
   ===================================================================== */

/* ---------- 1. Variables ---------- */
:root {
  --bg: #0a0a0a;
  --bg-elev: #111111;
  --bg-card: #141414;
  --bg-hover: #1a1a1a;
  --bg-input: #0d0d0d;

  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);

  --text: #f5f5f5;
  --text-2: #a3a3a3;
  --text-3: #6b6b6b;

  /* Couleurs du logo DevHub */
  --accent: #86d36f;
  --accent-2: #2bb3a3;
  --accent-soft: rgba(134, 211, 111, 0.1);
  --accent-line: rgba(134, 211, 111, 0.32);
  --accent-grad: linear-gradient(90deg, var(--accent), var(--accent-2));

  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;

  /* Séries de données (palette validée daltonisme sur fond sombre) */
  --c-revenu: #2aa898;
  --c-depense: #e5674f;
  --c-virement: #3987e5;
  --c-net: #86d36f;

  --font-display: "Archivo", "Arial Black", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --header-h: 68px;
  --gutter: clamp(16px, 4vw, 40px);

  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);
  --shadow-pop: 0 18px 48px rgba(0, 0, 0, 0.55);

  color-scheme: dark;
}

/* ---------- 2. Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

html.has-modal {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 700;
  line-height: 1.15;
}

p {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--text);
  color: var(--bg);
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.icon {
  flex-shrink: 0;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

/* ---------- 3. Typographie ---------- */
.display {
  font-family: var(--font-display);
  font-stretch: 125%;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  line-height: 0.95;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}

.eyebrow::before {
  content: "";
  width: 24px;
  height: 1px;
  background: currentColor;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  font-family: var(--font-display);
  font-stretch: 112%;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-2);
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: var(--font-mono); }
.num { font-variant-numeric: tabular-nums; }

.grad-text {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  color: var(--text-3);
  white-space: nowrap;
}

/* ---------- 4. Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(10, 10, 10, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.app-header-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand tabs actions";
  align-items: center;
  gap: 24px;
  height: var(--header-h);
  max-width: none;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}

.brand-logo {
  width: 32px;
  height: auto;
}

.brand-name {
  font-family: var(--font-display);
  font-stretch: 125%;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
}

.app-tabs {
  grid-area: tabs;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.app-tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  position: relative;
  display: block;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.tab:hover {
  color: var(--text);
}

.tab[aria-current="page"] {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.header-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Sélecteur d'année */
.year-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 3px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
}

.year-step {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.year-step:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.year-step:disabled {
  opacity: 0.28;
  cursor: default;
}

.year-current {
  height: 30px;
  padding: 0 6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  font-family: var(--font-display);
  font-stretch: 118%;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--text);
  cursor: pointer;
}

.year-current:hover {
  color: var(--accent);
}

.year-menu {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  min-width: 200px;
}

/* Avatar + menu utilisateur */
.user-menu {
  position: relative;
}

.avatar-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--bg-hover);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s var(--ease);
}

.avatar-btn:hover,
.avatar-btn[aria-expanded="true"] {
  border-color: var(--text);
}

.avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Menus déroulants génériques */
.menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 1100;
  min-width: 240px;
  padding: 6px;
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  animation: fadeInUp 0.16s var(--ease);
}

.menu-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.menu-head strong {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-head span {
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.menu-item:hover,
.menu-item:focus-visible {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.menu-item[aria-checked="true"] {
  color: var(--text);
}

.menu-item .kbd,
.menu-item .menu-meta {
  margin-left: auto;
}

.menu-meta {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.menu-check {
  width: 16px;
  color: var(--accent);
}

.menu-item.is-danger {
  color: #ff8a8a;
}

.menu-item.is-danger:hover {
  background: rgba(248, 113, 113, 0.08);
  color: #ffa3a3;
}

.menu-sep {
  height: 1px;
  margin: 6px 0;
  background: var(--line);
}

/* ---------- 5. Contenu principal ---------- */
.app-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 0 var(--gutter) 72px;
  overflow-x: clip;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view > * {
  min-width: 0;
}

.view-enter {
  animation: fadeInUp 0.38s var(--ease) both;
}

.app-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  max-width: none;
  width: 100%;
  margin: 0 auto;
  padding: 20px var(--gutter) 28px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
}

/* ---------- 6. Tête de page ---------- */
.page-head {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "eyebrow eyebrow"
    "title actions";
  align-items: end;
  gap: 22px 32px;
  padding: clamp(36px, 5.5vw, 72px) 0 clamp(20px, 2.5vw, 32px);
  margin-bottom: 8px;
}

.page-head::before {
  content: "";
  position: absolute;
  z-index: -2;
  top: -40%;
  right: -10%;
  width: min(720px, 80vw);
  height: 140%;
  background: radial-gradient(closest-side, rgba(43, 179, 163, 0.07), transparent);
  pointer-events: none;
}

.page-head > .eyebrow {
  grid-area: eyebrow;
}

.page-head > .title-bar {
  grid-area: title;
  justify-self: start;
}

.page-head > .page-actions {
  grid-area: actions;
}

.page-head > :not(.eyebrow):not(.title-bar):not(.page-actions):not(.watermark) {
  grid-column: 1 / -1;
}

.page-title {
  font-size: clamp(38px, 6.4vw, 84px);
}

.page-lead {
  max-width: 620px;
  font-size: 16px;
  color: var(--text-2);
}

.page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.title-bar {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  max-width: 100%;
}

.title-bar > .display {
  padding-bottom: 0.1em;
  border-bottom: clamp(3px, 0.45vw, 6px) solid var(--text);
}

.title-bar-caption {
  margin-top: 10px;
  align-self: flex-end;
  text-align: right;
  font-family: var(--font-display);
  font-stretch: 110%;
  font-weight: 500;
  font-size: clamp(11px, 1.1vw, 13px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}

.watermark {
  position: absolute;
  z-index: -1;
  top: clamp(4px, 1.5vw, 20px);
  right: -0.02em;
  font-family: var(--font-display);
  font-stretch: 125%;
  font-weight: 900;
  font-size: clamp(88px, 17vw, 250px);
  line-height: 0.82;
  letter-spacing: -0.03em;
  white-space: nowrap;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0) 78%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  pointer-events: none;
  user-select: none;
}

/* ---------- 7. Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease), opacity 0.2s var(--ease);
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.btn-primary:hover:not(:disabled) {
  background: transparent;
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--text);
}

.btn-danger {
  background: transparent;
  color: #ff8a8a;
  border-color: rgba(248, 113, 113, 0.35);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.65);
  color: #ffa3a3;
}

.btn-sm {
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--text-3);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-primary.is-loading::after {
  border-color: rgba(10, 10, 10, 0.25);
  border-top-color: var(--bg);
}

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  flex-shrink: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.btn-icon:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--text);
}

.btn-icon:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-icon.is-danger:hover:not(:disabled) {
  color: #ff8a8a;
  border-color: rgba(248, 113, 113, 0.6);
  background: rgba(248, 113, 113, 0.08);
}

.btn-add .btn-add-label {
  display: inline;
}

/* ---------- 8. Cartes & grilles ---------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 24px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.25s var(--ease);
}

.card:hover {
  border-color: var(--line-strong);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
}

.card-head > :first-child {
  min-width: 0;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

.card-sub {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-2);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-body {
  min-width: 0;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid > * {
  min-width: 0;
}

.cols-2   { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3   { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4   { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.cols-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- 9. KPI ---------- */
.kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 20px 22px;
  overflow: hidden;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.25s var(--ease);
}

.kpi:hover {
  border-color: var(--line-strong);
}

.kpi-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.kpi-value {
  font-family: var(--font-display);
  font-stretch: 105%;
  font-weight: 700;
  font-size: clamp(24px, 2.3vw, 30px);
  letter-spacing: -0.01em;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.kpi-delta.is-up   { color: var(--ok);  background: rgba(74, 222, 128, 0.09); }
.kpi-delta.is-down { color: var(--err); background: rgba(248, 113, 113, 0.09); }
.kpi-delta.is-flat { color: var(--text-2); background: rgba(255, 255, 255, 0.05); }
/* Sens « bon / mauvais » explicite (ex. dépenses en hausse = mauvais) */
.kpi-delta.is-good { color: var(--ok);  background: rgba(74, 222, 128, 0.09); }
.kpi-delta.is-bad  { color: var(--err); background: rgba(248, 113, 113, 0.09); }

.kpi-foot {
  font-size: 12px;
  color: var(--text-3);
}

.kpi-spark {
  height: 36px;
  margin-top: auto;
}

/* ---------- 10. Contrôles ---------- */
.seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  padding: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--bg-elev);
}

.seg::-webkit-scrollbar {
  display: none;
}

.seg button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.seg button:hover {
  color: var(--text);
}

.seg button[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
}

.input,
.select,
.textarea {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: var(--bg-input);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  color-scheme: dark;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: rgba(255, 255, 255, 0.26);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.07);
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: rgba(248, 113, 113, 0.7);
}

.textarea {
  height: auto;
  min-height: 92px;
  padding: 12px 14px;
  resize: vertical;
}

.select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a3a3a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  cursor: pointer;
}

.select option {
  background: var(--bg-card);
  color: var(--text);
}

input[type="date"].input {
  font-variant-numeric: tabular-nums;
}

input[type="date"].input::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
  opacity: 0.7;
  cursor: pointer;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.field > label,
.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-2);
}

.field-optional {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-3);
}

.field-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
  font-size: 12.5px;
  color: var(--text-3);
}

.field-hint.is-error {
  color: var(--err);
}

.field-hint.is-ok {
  color: var(--text-2);
}

.field-hint .icon {
  color: var(--accent);
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 220px;
}

.search > svg {
  position: absolute;
  left: 14px;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
}

.search > .input {
  height: 40px;
  padding-left: 40px;
  border-radius: var(--radius-pill);
}

input.search {
  height: 40px;
  padding-left: 40px;
  border-radius: var(--radius-pill);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
  background-size: 16px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: transparent;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.chip:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.32);
}

.chip.is-active,
.chip[aria-pressed="true"] {
  color: var(--text);
  border-color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

/* ---------- 11. Données ---------- */
.dot {
  display: inline-block;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot, var(--text-3));
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 24px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot, var(--text-3));
}

.badge-revenu   { --dot: var(--c-revenu); }
.badge-depense  { --dot: var(--c-depense); }
.badge-virement { --dot: var(--c-virement); }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card .table-wrap {
  background: transparent;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table td.num,
.table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table tr.is-clickable {
  cursor: pointer;
}

.table tr.is-clickable td {
  transition: background-color 0.15s var(--ease);
}

.table tr.is-clickable:hover td {
  background: var(--bg-hover);
}

.table tfoot td {
  border-top: 1px solid var(--line-strong);
  border-bottom: 0;
  font-weight: 600;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-2);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card .empty,
.empty.is-bare {
  background: transparent;
  border: 0;
  padding: 32px 16px;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  border: 1px solid var(--accent-line);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.empty h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.empty p {
  max-width: 380px;
  font-size: 14px;
}

.empty .btn {
  margin-top: 6px;
}

.view-error .empty-icon {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
  color: var(--err);
}

/* ---------- 12. Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.modal-backdrop.is-open {
  opacity: 1;
}

.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 580px;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow: hidden;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.65);
  transform: translateY(14px) scale(0.985);
  transition: transform 0.26s var(--ease);
}

.modal:focus {
  outline: none;
}

.modal-sm { max-width: 440px; }
.modal-lg { max-width: 780px; }

.modal-backdrop.is-open .modal {
  transform: none;
}

.modal-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.modal-head::after {
  content: "";
  position: absolute;
  left: 24px;
  bottom: -1px;
  width: 48px;
  height: 2px;
  background: var(--accent-grad);
}

.modal-title {
  min-width: 0;
  font-family: var(--font-display);
  font-stretch: 115%;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-close {
  width: 34px;
  height: 34px;
  border-color: transparent;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}

.modal-foot .spacer {
  flex: 1;
}

.confirm-text {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.6;
}

/* ---------- 13. Toasts ---------- */
.toast-root {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
  max-width: 420px;
  padding: 12px 16px 12px 12px;
  background: #161616;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  font-size: 14px;
  color: var(--text);
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
}

.toast.is-in {
  opacity: 1;
  transform: none;
}

.toast-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
}

.toast-success .toast-icon { color: var(--accent); background: var(--accent-soft); }
.toast-error .toast-icon   { color: var(--err); background: rgba(248, 113, 113, 0.1); }
.toast-info .toast-icon    { color: var(--text); background: rgba(255, 255, 255, 0.08); }

/* ---------- 14. Combobox ---------- */
.combo-list {
  position: fixed;
  z-index: 2600;
  max-height: 264px;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  list-style: none;
  background: #151515;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  animation: fadeIn 0.12s var(--ease);
}

.combo-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
}

.combo-option.is-active {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.combo-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.combo-option mark {
  background: none;
  color: var(--text);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.combo-hint {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
}

.combo-create {
  justify-content: flex-start;
  gap: 10px;
  color: var(--text);
}

.combo-create .icon {
  color: var(--accent);
}

.combo-option + .combo-create {
  margin-top: 4px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
}

/* ---------- 15. Formulaire d'opération ---------- */
.op-form,
.client-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.op-type {
  align-self: flex-start;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 16px;
}

.form-grid .span-2 {
  grid-column: 1 / -1;
}

.amount-input {
  position: relative;
}

.amount-input .input {
  padding-right: 38px;
  font-family: var(--font-display);
  font-stretch: 105%;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.01em;
}

.amount-suffix {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  font-weight: 600;
  color: var(--text-3);
  pointer-events: none;
}

.form-error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: var(--radius);
  background: rgba(248, 113, 113, 0.08);
  font-size: 14px;
  color: #fca5a5;
}

.form-error .icon {
  margin-top: 2px;
}

.foot-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
}

/* ---------- 16. Chargement & erreurs ---------- */
.boot {
  display: grid;
  place-items: center;
  min-height: calc(100vh - var(--header-h) - 160px);
  animation: fadeIn 0.3s var(--ease);
}

.boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.boot-logo {
  width: 46px;
  animation: bootPulse 1.6s ease-in-out infinite;
}

.boot-text {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

.boot-bar {
  position: relative;
  width: 168px;
  height: 2px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--line);
}

.boot-bar::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  background: var(--accent-grad);
  animation: bootSlide 1.15s var(--ease) infinite;
}

.boot .empty {
  max-width: 460px;
}

@keyframes bootPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.94); }
}

@keyframes bootSlide {
  from { transform: translateX(-100%); }
  to   { transform: translateX(260%); }
}

/* ---------- 17. Page de connexion (volontairement minimale) ---------- */
.login-shell {
  flex: 1 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 420px);
  place-content: center;
  padding: 48px var(--gutter);
}

.login-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 22px;
  width: 100%;
  max-width: 420px;
  padding: clamp(28px, 6vw, 40px);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  animation: fadeInUp 0.5s var(--ease) both;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.login-brand img {
  width: 34px;
  height: auto;
}

.login-title {
  font-size: clamp(32px, 9vw, 44px);
  padding-bottom: 0.14em;
  border-bottom: 4px solid var(--text);
}

.login-google {
  align-self: stretch;
  display: flex;
  align-items: center;
  min-height: 44px;
  margin-top: 6px;
}

.login-google-fallback {
  font-size: 13px;
  color: var(--text-3);
}

.login-status {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-2);
}

.login-status.is-error {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
  color: #fca5a5;
}

.login-status.is-success {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--text);
}

.login-status .icon {
  margin-top: 2px;
}

/* ---------- 18. Responsive ---------- */
@media (max-width: 1180px) {
  .app-header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "tabs tabs";
    gap: 0 16px;
    height: auto;
    padding-top: 12px;
  }

  .app-tabs {
    justify-self: stretch;
    margin: 10px calc(-1 * var(--gutter)) 0;
    padding: 0 var(--gutter) 10px;
  }

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

@media (max-width: 900px) {
  .cols-2,
  .cols-3,
  .cols-2-1,
  .cols-1-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-head {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "eyebrow"
      "title"
      "actions";
  }

  .page-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .brand-tag,
  .btn-add .btn-add-label {
    display: none;
  }

  .btn-add {
    width: 38px;
    height: 38px;
    padding: 0;
  }

  .header-actions {
    gap: 8px;
  }

  .card {
    padding: 18px;
  }

  .kpi {
    padding: 16px 18px;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-width: none !important;
    max-height: 94dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(40px);
  }

  .modal-head,
  .modal-body,
  .modal-foot {
    padding-left: 18px;
    padding-right: 18px;
  }

  .modal-head::after {
    left: 18px;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .op-type {
    align-self: stretch;
  }

  .op-type button {
    flex: 1;
  }

  .foot-hint {
    display: none;
  }

  .toast-root {
    left: 16px;
    right: 16px;
    bottom: 16px;
    align-items: stretch;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }

  .search {
    min-width: 0;
    flex: 1 1 100%;
  }
}

@media (max-width: 480px) {
  .cols-4 { grid-template-columns: minmax(0, 1fr); }

  .brand-name {
    font-size: 15px;
  }

  .brand-logo {
    width: 28px;
  }
}

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