@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Mono:wght@300;400&family=DM+Sans:wght@400;500;600;700&display=swap');

strong, b, .nav-group-hdr {
  font-family: 'DM Sans', sans-serif;
}

:root {
  --ink: #0F0F14;
  --ink-2: #1C1C24;
  --ink-3: #28282F;
  --gold: #D4A843;
  --gold-dim: #8A6B26;
  --cream: #F5F0E8;
  --cream-2: #EDE8DE;
  --muted: #6B6B78;
  --muted-2: #48484F;
  --green: #2A7A4B;
  --green-bg: #0E2B1A;
  --amber: #B87333;
  --amber-bg: #2B1A0A;
  --red: #A03030;
  --red-bg: #2B0E0E;
  --blue: #2A5A8A;
  --blue-bg: #0A1E30;
  --r: 10px;
  --r-lg: 16px;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
}

/* ── Light theme ─────────────────────────────────────────────── */
[data-theme="light"] {
  --ink:      #F4F1EA;
  --ink-2:    #FFFFFF;
  --ink-3:    #E5E1D8;
  --gold:     #96680E;
  --gold-dim: #C49228;
  --cream:    #171720;
  --cream-2:  #2D2D3A;
  --muted:    #7A7A8A;
  --muted-2:  #ACACB8;
  --green:    #1A6B3C;
  --green-bg: #E6F7EE;
  --amber:    #7A4810;
  --amber-bg: #FEF3E0;
  --red:      #882020;
  --red-bg:   #FEE8E8;
  --blue:     #1A4875;
  --blue-bg:  #E8F0FA;
  --shadow:   0 2px 12px rgba(0,0,0,0.1);
}
[data-theme="light"] ::-webkit-scrollbar-thumb           { background: var(--muted-2); }
[data-theme="light"] .form-input,
[data-theme="light"] .form-select                        { border-color: rgba(0,0,0,0.12); }
[data-theme="light"] .inv-row                            { border-bottom-color: rgba(0,0,0,0.06); }
[data-theme="light"] .inv-row:hover,
[data-theme="light"] table.inv-table tbody tr:hover      { background: rgba(0,0,0,0.025); }
[data-theme="light"] .badge-muted                        { border-color: rgba(0,0,0,0.12); }
[data-theme="light"] .badge-green                        { color: var(--green); }
[data-theme="light"] .badge-amber                        { color: var(--amber); }
[data-theme="light"] .badge-red                          { color: var(--red); }
[data-theme="light"] .badge-blue                         { color: var(--blue); }
[data-theme="light"] .cra-cal-cell                       { border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .cra-cal-cell.we                    { background: rgba(0,0,0,0.02); }
[data-theme="light"] .cra-totals                         { border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .pagination                         { border-top-color: rgba(0,0,0,0.06); }
[data-theme="light"] .pagination-controls select,
[data-theme="light"] .page-btn                           { border-color: rgba(0,0,0,0.12); }
[data-theme="light"] .conv-item                          { border-bottom-color: rgba(0,0,0,0.06); }
[data-theme="light"] .gl-block-head                      { border-bottom-color: rgba(0,0,0,0.08); }
[data-theme="light"] .gl-row > div                       { border-bottom-color: rgba(0,0,0,0.04); }

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

html { height: 100%; }

body {
  font-family: 'DM Mono', monospace;
  background: var(--ink);
  color: var(--cream);
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--ink-2); }
::-webkit-scrollbar-thumb { background: var(--ink-3); border-radius: 2px; }

/* ── Layout ── */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--ink-2);
  border-right: 1px solid var(--ink-3);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--ink-3);
}
.sidebar-logo .wordmark {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  color: var(--gold);
  letter-spacing: -0.3px;
}
.sidebar-logo .tagline {
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }

.sidebar-switcher {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ink-3);
}
.switcher-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  margin-bottom: 4px;
  border-radius: var(--r);
  border: 1px solid transparent;
  background: transparent;
  color: var(--cream-2);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  overflow: hidden;
}
.switcher-btn:hover { background: var(--ink-3); }
.switcher-btn.active {
  background: rgba(212,168,67,.12);
  border-color: rgba(212,168,67,.3);
  color: var(--gold);
}
.switcher-badge {
  font-size: 10px;
  color: var(--gold);
  background: rgba(212,168,67,.1);
  border: 1px solid rgba(212,168,67,.25);
  border-radius: 20px;
  padding: 2px 8px;
  margin-top: 4px;
  text-align: center;
  letter-spacing: .04em;
}

.nav-section-label {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 2px solid transparent;
  position: relative;
}
.nav-item:hover { color: var(--cream); background: var(--ink-3); }
.nav-item.active {
  color: var(--gold);
  background: rgba(212,168,67,0.06);
  border-left-color: var(--gold);
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--gold);
  color: var(--ink);
  font-size: 9px;
  font-family: 'DM Sans', sans-serif; font-weight: 500;
  padding: 1px 6px;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--ink-3);
}
.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-family: 'DM Sans', sans-serif; font-weight: 500;
  color: var(--ink);
  flex-shrink: 0;
}
.user-name { font-size: 12px; color: var(--cream); }
.user-plan { font-size: 10px; color: var(--muted); }

/* ── Main content ── */
.main {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--ink);
  border-bottom: 1px solid var(--ink-3);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title { font-family: 'DM Serif Display', serif; font-size: 18px; color: var(--cream); }
.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: var(--r);
  padding: 7px 14px;
  width: 260px;
}
.topbar-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--cream);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  width: 100%;
}
.topbar-search input::placeholder { color: var(--muted); }
.topbar-search svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  text-decoration: none;
}
.btn-primary {
  background: var(--gold);
  color: var(--ink);
  font-family: 'DM Sans', sans-serif; font-weight: 500;
}
.btn-primary:hover { background: #E8BF58; }
.btn-ghost {
  background: var(--ink-2);
  color: var(--cream);
  border: 1px solid var(--ink-3);
}
.btn-ghost:hover { border-color: var(--muted-2); }
.btn-danger {
  background: var(--red-bg);
  color: #F08080;
  border: 1px solid var(--red);
}
.btn-danger:hover { background: #3D1010; }
.btn svg { width: 14px; height: 14px; }

/* ── Page content ── */
.page { display: none; padding: 28px; }
.page.active { display: block; }

/* ── Stats row ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: var(--r-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 60px; height: 60px;
  border-radius: 0 var(--r-lg) 0 60px;
  opacity: 0.06;
}
.stat-card.gold::before { background: var(--gold); }
.stat-card.green::before { background: #2A7A4B; }
.stat-card.amber::before { background: var(--amber); }
.stat-card.blue::before { background: #2A5A8A; }

.stat-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.stat-icon.gold { background: rgba(212,168,67,0.12); color: var(--gold); }
.stat-icon.green { background: var(--green-bg); color: #5CC98A; }
.stat-icon.amber { background: var(--amber-bg); color: #E8A050; }
.stat-icon.blue { background: var(--blue-bg); color: #5090C8; }
.stat-icon svg { width: 18px; height: 18px; }

.stat-value {
  font-family: 'DM Serif Display', serif;
  font-size: 26px;
  color: var(--cream);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-delta { font-size: 10px; margin-top: 8px; }
.stat-delta.up { color: #5CC98A; }
.stat-delta.down { color: #F08080; }

/* ── Month filter ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-label { font-size: 11px; color: var(--muted); margin-right: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.month-chip {
  padding: 6px 16px;
  border-radius: 20px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid var(--ink-3);
  background: var(--ink-2);
  color: var(--muted);
}
.month-chip:hover { border-color: var(--muted-2); color: var(--cream); }
.month-chip.active { background: rgba(212,168,67,0.1); border-color: var(--gold-dim); color: var(--gold); }
.filter-spacer { flex: 1; }

/* ── Table ── */
.table-wrap {
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.table-header {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--ink-3);
  justify-content: space-between;
}
.table-title { font-size: 13px; color: var(--cream); font-family: 'DM Sans', sans-serif; font-weight: 500; }
.table-count { font-size: 11px; color: var(--muted); }

.inv-table { width: 100%; border-collapse: collapse; }
table.inv-table thead th {
  padding: 10px 16px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  background: var(--ink-2);
  border-bottom: 1px solid var(--ink-3);
  font-family: 'DM Sans', sans-serif; font-weight: 500;
  white-space: nowrap;
}
table.inv-table tbody tr { border-bottom: 1px solid var(--ink-3); }
table.inv-table tbody tr:hover { background: rgba(255,255,255,0.03); }
table.inv-table tbody td { color: var(--cream); }
table.inv-table tfoot td { border-top: 2px solid var(--ink-3); padding: 10px 16px; font-size: 12px; }
.inv-thead, .inv-row {
  display: grid;
  grid-template-columns: 1fr 100px 120px 100px 110px 90px;
  align-items: center;
}
.inv-thead { border-bottom: 1px solid var(--ink-3); }
.inv-th {
  padding: 10px 20px;
  text-align: left;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 400;
}
.inv-row {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.12s;
  cursor: pointer;
}
.inv-row:last-child { border-bottom: none; }
.inv-row:hover { background: rgba(255,255,255,0.03); }
.inv-cell { padding: 14px 20px; font-size: 12px; color: var(--cream-2); }
.inv-row-empty { padding: 40px 20px; }

.td-thumb {
  width: 38px; height: 38px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.td-name { font-size: 13px; color: var(--cream); font-family: 'DM Sans', sans-serif; font-weight: 500; }
.td-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 10px;
  font-family: 'DM Sans', sans-serif; font-weight: 500;
  letter-spacing: 0.02em;
}
.badge-green { background: var(--green-bg); color: #5CC98A; border: 1px solid rgba(42,122,75,0.4); }
.badge-amber { background: var(--amber-bg); color: #E8A050; border: 1px solid rgba(184,115,51,0.4); }
.badge-red   { background: var(--red-bg);   color: #F08080; border: 1px solid rgba(160,48,48,0.4); }
.badge-blue  { background: var(--blue-bg);  color: #5090C8; border: 1px solid rgba(42,90,138,0.4); }
.badge-muted { background: var(--ink-3); color: var(--muted); border: 1px solid rgba(255,255,255,0.08); }

.td-amount { font-family: 'DM Mono', monospace; font-size: 13px; color: var(--cream); }
.td-actions { display: flex; gap: 6px; opacity: 0; transition: opacity 0.15s; }
.inv-row:hover .td-actions { opacity: 1; }

@media (max-width: 640px) {
  /* Hide header row — replaced by card layout */
  .inv-thead { display: none; }

  /* Each row becomes a self-contained card */
  .inv-row {
    display: flex !important;      /* overrides inline grid-template-columns */
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    padding: 12px 16px !important;
  }

  /* ── .inv-cell tables (supplier invoices, clients, CRA) ── */
  .inv-cell { padding: 2px 0 !important; }

  /* First cell = main identifier, full width */
  .inv-row > .inv-cell:first-child {
    flex: 0 0 100%;
    padding-bottom: 6px !important;
  }
  /* Secondary cells = compact, side-by-side */
  .inv-row > .inv-cell:not(:first-child):not(.inv-col-actions) {
    flex: 1;
    min-width: 70px;
    font-size: 11px;
    color: var(--muted);
  }
  /* Supplier invoice: keep amount readable */
  .inv-col-amount { color: var(--cream) !important; font-size: 12px !important; }
  /* Hide category — not useful at small size */
  .inv-col-cat { display: none !important; }

  /* ── .inv-col cells (facturation / client invoices) ── */
  .inv-col { padding: 2px 0 !important; }

  /* N° — inline before client name */
  .inv-row > .inv-col:first-child {
    flex: 0 0 auto !important;
    font-size: 10px !important;
    color: var(--muted) !important;
    padding-right: 6px !important;
  }
  /* Client name — prominent */
  .inv-row > .inv-col:nth-child(2) {
    flex: 1 0 0 !important;
    font-size: 13px !important;
    color: var(--cream) !important;
    font-family: 'DM Sans', sans-serif; font-weight: 500 !important;
    padding-bottom: 4px !important;
  }
  /* Secondary info */
  .inv-row > .inv-col:not(:first-child):not(:nth-child(2)):not(.inv-col-actions) {
    flex: 1;
    min-width: 70px;
    font-size: 11px;
    color: var(--muted) !important;
    text-align: left !important;
  }

  /* ── Actions (all tables) ── */
  .inv-col-actions {
    flex: 0 0 100% !important;
    display: flex !important;
    justify-content: flex-end;
    padding-top: 6px !important;
  }
  .td-actions { opacity: 1; }
}
.icon-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--ink-3);
  border: none;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.12s;
}
.icon-btn:hover { background: var(--ink); color: var(--cream); }
.icon-btn.danger:hover { background: var(--red-bg); color: #F08080; }
.icon-btn svg { width: 13px; height: 13px; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-icon {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: var(--ink-3);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
}
.empty-icon svg { width: 28px; height: 28px; color: var(--muted); }
.empty-title { font-family: 'DM Serif Display', serif; font-size: 18px; color: var(--cream); margin-bottom: 8px; }
.empty-sub { font-size: 12px; color: var(--muted); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-head {
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-family: 'DM Serif Display', serif; font-size: 20px; color: var(--cream); }
.modal-body { padding: 20px 24px 24px; }

/* Upload area */
.upload-zone {
  border: 2px dashed var(--ink-3);
  border-radius: var(--r-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 20px;
  position: relative;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--gold-dim); background: rgba(212,168,67,0.04); }
.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-icon { font-size: 36px; margin-bottom: 12px; }
.upload-title { font-size: 14px; color: var(--cream); margin-bottom: 4px; }
.upload-sub { font-size: 11px; color: var(--muted); }

.upload-preview {
  display: none;
  align-items: center;
  gap: 12px;
  background: var(--ink-3);
  border-radius: var(--r);
  padding: 12px 16px;
  margin-bottom: 20px;
}
.upload-preview.show { display: flex; }
.preview-icon { font-size: 28px; }
.preview-info .name { font-size: 13px; color: var(--cream); }
.preview-info .size { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Form */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.form-input, .form-select {
  background: var(--ink-3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--r);
  padding: 10px 14px;
  color: var(--cream);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.form-input:focus, .form-select:focus { border-color: var(--gold-dim); }
.form-input::placeholder { color: var(--muted); }
.form-select option { background: var(--ink-2); }
.form-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--ink-3); }

/* Sharing */
.share-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--ink-2); border-radius: var(--r); margin-bottom: 8px; }
.share-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--ink-3); display: flex; align-items: center; justify-content: center; font-size: 14px; font-family: 'DM Sans', sans-serif; font-weight: 500; color: var(--gold); flex-shrink: 0; }
.share-info { flex: 1; min-width: 0; }
.share-email { font-size: 13px; color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-meta  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.share-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 24px 0 12px; }

/* Permission management */
.perm-details { margin-top: 10px; }
.perm-details summary { font-size: 11px; color: var(--muted); cursor: pointer; user-select: none; outline: none; }
.perm-details summary:hover { color: var(--cream); }
.perm-grid { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 8px; }
.perm-toggle { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--cream); cursor: pointer; }
.perm-toggle input[type=checkbox] { accent-color: var(--gold); width: 14px; height: 14px; cursor: pointer; }
.perm-list { display: flex; flex-direction: column; gap: 0; margin-top: 8px; }
.perm-row { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 4px; }
.perm-row:hover { background: var(--ink-3); }
.perm-row-label { font-size: 12px; color: var(--cream); flex: 1; }
.nav-item-locked { opacity: 0.35; pointer-events: none; }

/* Facturation clients — modal line items */
#ci-lines-body tr { transition: background 0.1s; }
#ci-lines-body tr:hover { background: var(--ink-3); }
#ci-lines-body input, #ci-lines-body select { background: transparent; border-color: transparent; }
#ci-lines-body input:focus, #ci-lines-body select:focus { background: var(--ink); border-color: var(--muted-2); }

.ci-suggestions {
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: var(--r);
  z-index: 200;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.ci-sugg-item {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--cream);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.ci-sugg-item:hover { background: var(--ink-3); }

/* ── CRA Calendar ── */
.cra-cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 12px;
}
.cra-cal-hd {
  text-align: center;
  font-size: 10px;
  font-family: 'DM Sans', sans-serif; font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 4px 0;
}
.cra-cal-empty { height: 52px; }
.cra-cal-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 52px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.06);
  background: var(--ink-2);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
}
.cra-cal-cell:hover:not(.we) { border-color: var(--gold); background: rgba(212,168,67,0.08); }
.cra-cal-cell.we {
  background: rgba(255,255,255,0.02);
  cursor: default;
  opacity: 0.4;
}
.cra-cal-cell.holiday {
  background: rgba(192,57,43,0.12);
  border-color: rgba(192,57,43,0.35) !important;
  cursor: default;
}
.cra-cal-cell.holiday .cra-day-n { color: #e07060; }
.cra-cal-cell.full { background: rgba(212,168,67,0.2); border-color: var(--gold); }
.cra-cal-cell.half { background: rgba(42,90,138,0.25); border-color: #5090C8; }
.cra-day-n { font-size: 12px; color: var(--cream-2); font-family: 'DM Sans', sans-serif; font-weight: 500; line-height: 1; }
.cra-day-m { font-size: 11px; font-family: 'DM Sans', sans-serif; font-weight: 500; line-height: 1; margin-top: 3px; }
.cra-cal-cell.full .cra-day-m { color: var(--gold); }
.cra-cal-cell.half .cra-day-m { color: #5090C8; }
/* ── Shared / read-only view ── */
.shared-view .nav-item[data-page="sharing"] {
  opacity: 0.35;
  pointer-events: none;
}
.shared-view .topbar-right .btn-primary { display: none; }

.cra-totals {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  background: var(--ink-2);
  border-radius: var(--r);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--cream-2);
  border: 1px solid rgba(255,255,255,0.06);
}

/* Download page */
.dl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.dl-card {
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s;
}
.dl-card:hover { border-color: var(--muted-2); }
.dl-month { font-family: 'DM Serif Display', serif; font-size: 18px; color: var(--cream); }
.dl-year { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.dl-stats { display: flex; gap: 16px; }
.dl-stat .val { font-size: 14px; color: var(--gold); font-family: 'DM Sans', sans-serif; font-weight: 500; }
.dl-stat .lbl { font-size: 10px; color: var(--muted); margin-top: 1px; }
.dl-actions { display: flex; gap: 8px; }

/* Notification toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-left: 3px solid var(--gold);
  border-radius: var(--r);
  padding: 12px 18px;
  font-size: 12px;
  color: var(--cream);
  z-index: 999;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 300px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-left-color: #2A7A4B; }
.toast.error { border-left-color: var(--red); }
.toast.info { border-left-color: #3A7DC8; }

/* ── Cash Flow ── */
.cf-num { text-align:right; font-family:'DM Mono',monospace; font-size:12px; padding:10px 16px; }
.cf-in  { color:#4CAF50; }
.cf-out { color:#E05555; }
.cf-layout { display:grid; grid-template-columns:1fr 300px; gap:20px; align-items:start; }
.cf-side { background:var(--ink-2); border:1px solid var(--ink-3); border-radius:var(--r); padding:16px; min-width:0; }
.cf-proj-item {
  display:flex; align-items:center; gap:8px;
  padding:8px 10px;
  overflow:hidden;
  background:var(--ink); border:1px solid var(--ink-3); border-radius:var(--r);
}
.cf-proj-badge {
  font-size:12px; font-weight:400; width:18px; text-align:center; flex-shrink:0;
}
.cf-row-current { background: rgba(212,168,67,.07); border-left: 2px solid var(--gold) !important; }
.cf-now-badge {
  display:inline-block; font-size:9px; font-weight:400; letter-spacing:.05em;
  text-transform:uppercase; color:var(--gold); background:rgba(212,168,67,.15);
  border:1px solid rgba(212,168,67,.3); border-radius:3px; padding:1px 5px;
  vertical-align:middle; margin-left:6px;
}
@media (max-width:800px) {
  .cf-layout { grid-template-columns:1fr; }
}

/* ── Mobile hamburger ── */
.hamburger { display: none; background: none; border: none; cursor: pointer; color: var(--cream); padding: 4px; }
.hamburger svg { width: 22px; height: 22px; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 99; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.04);
  flex-wrap: wrap;
  gap: 8px;
}
.pagination-info { font-size: 12px; color: var(--muted); }
.pagination-controls { display: flex; align-items: center; gap: 5px; }
.pagination-controls select {
  background: var(--ink-3);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--cream-2);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--r);
  cursor: pointer;
  margin-right: 4px;
}
.page-btn {
  min-width: 28px; height: 28px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
  background: transparent;
  color: var(--cream-2);
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.page-btn:hover:not(:disabled) { background: var(--ink-3); color: var(--cream); }
.page-btn.active { background: var(--gold); color: var(--ink-1); border-color: var(--gold); font-family: 'DM Sans', sans-serif; font-weight: 500; }
.page-btn:disabled { opacity: 0.3; cursor: default; }
.page-ellipsis { font-size: 12px; color: var(--muted); padding: 0 3px; line-height: 28px; }

/* ── Charts page ── */
.chart-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 20px; }
.chart-card {
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: var(--r-lg);
  padding: 20px;
}
.chart-card-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 20px; }
.bar-chart { display: flex; align-items: stretch; gap: 8px; height: 160px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }
.bar-col-inner { height: 120px; flex-shrink: 0; }
.bar-label { font-size: 9px; color: var(--muted); text-transform: uppercase; }
.bar-val { font-size: 9px; color: var(--gold); }
.bar {
  width: 100%;
  background: var(--ink-3);
  border-radius: 4px 4px 0 0;
  position: relative;
  transition: background 0.15s;
  cursor: pointer;
}
.bar:hover { background: rgba(212,168,67,0.2); }
.bar-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, var(--gold), var(--gold-dim));
  border-radius: 4px 4px 0 0;
  transition: height 0.6s cubic-bezier(0.34,1.56,0.64,1);
}

.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.donut-legend { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-val { margin-left: auto; color: var(--cream); font-size: 11px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dl-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .topbar-search { width: 180px; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dl-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
  .page { padding: 16px; }

  /* ── Stats page — bar chart ── */
  /* 12 bars × ~18px each: hide amount labels that would overlap */
  .bar-val { display: none; }
  /* Tighter gaps + shorter height → more room per bar */
  .bar-chart { gap: 3px; height: 90px; }
  .bar-col { gap: 2px; }
  .bar-col-inner { height: 68px; }   /* bar area inside mobile chart */
  /* Micro month labels */
  .bar-label { font-size: 7px; letter-spacing: 0; }
  /* Chart card: less padding on small screens */
  .chart-card { padding: 14px; }
  .chart-card-title { margin-bottom: 14px; }
}

/* ── Mailbox ── */
.mailbox-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 130px);
  border: 1px solid var(--ink-3);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--ink-2);
}
.conv-sidebar {
  border-right: 1px solid var(--ink-3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.conv-sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--ink-3);
  flex-shrink: 0;
}
.conv-list { flex: 1; overflow-y: auto; }
.conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.12s;
}
.conv-item:hover, .conv-item.active { background: var(--ink-3); }
.conv-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-family: 'DM Sans', sans-serif; font-weight: 500;
  flex-shrink: 0;
}
.conv-info { flex: 1; min-width: 0; }
.conv-name { font-size: 12px; color: var(--cream); font-family: 'DM Sans', sans-serif; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-last { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-unread {
  background: var(--gold); color: var(--ink);
  font-size: 9px; font-family: 'DM Sans', sans-serif; font-weight: 500;
  padding: 2px 6px; border-radius: 10px; flex-shrink: 0;
}
.msg-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.msg-panel-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--ink-3);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.msg-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg-bubble { max-width: 72%; }
.msg-sent {
  align-self: flex-end;
  background: var(--gold);
  color: var(--ink);
  padding: 9px 13px;
  border-radius: 14px 14px 2px 14px;
}
.msg-recv {
  align-self: flex-start;
  background: var(--ink-3);
  color: var(--cream);
  padding: 9px 13px;
  border-radius: 14px 14px 14px 2px;
}
.msg-body { font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg-time { font-size: 9px; opacity: 0.6; }
.msg-del-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  font-size: 9px; color: inherit; opacity: 0.5; padding: 0 2px; line-height: 1;
}
.msg-del-btn:hover { opacity: 1; }
.msg-bubble:hover .msg-del-btn { display: inline; }
.msg-file-attach {
  display: flex; align-items: center; gap: 6px;
  margin-top: 6px; padding: 6px 10px;
  background: rgba(0,0,0,0.18); border-radius: 6px;
  cursor: pointer; font-size: 11px; max-width: 220px;
  transition: opacity 0.12s;
}
.msg-file-attach:hover { opacity: 0.75; }
.msg-file-attach span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-compose {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--ink-3);
  align-items: flex-end;
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .mailbox-layout { grid-template-columns: 1fr; height: calc(100vh - 100px); }
  .conv-hidden { display: none; }
  .msg-panel-hidden { display: none; }
}

/* ── CF opening toggle ── */
.cf-opening-toggle { display: flex; border: 1px solid var(--ink-3); border-radius: var(--r); overflow: hidden; }
.cf-opening-btn {
  padding: 4px 10px;
  font-size: 11px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.cf-opening-btn:hover { background: var(--ink-3); color: var(--cream); }
.cf-opening-btn.active { background: var(--ink-3); color: var(--cream); font-family: 'DM Sans', sans-serif; font-weight: 500; }

/* ── IR estimator ── */
.cf-ir-card {
  margin-top: 24px;
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.cf-ir-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--ink-3);
}
.cf-ir-tmi {
  font-size: 11px;
  font-family: 'DM Sans', sans-serif; font-weight: 500;
  background: rgba(224,85,85,.15);
  color: var(--red);
  padding: 3px 10px;
  border-radius: 20px;
}
.cf-ir-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.cf-ir-controls {
  display: grid;
  gap: 14px;
  padding: 16px 20px;
  border-right: 1px solid var(--ink-3);
}
.cf-ir-result {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 14px;
}
.cf-ir-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.cf-ir-val   { font-size: 14px; font-weight: 500; color: var(--cream); font-family: 'DM Sans', sans-serif; }
.cf-ir-brackets { display: flex; flex-direction: column; gap: 6px; }
.ir-bracket-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-family: 'DM Mono', monospace;
}
.ir-bracket-rate  { background: rgba(200,150,80,.12); color: var(--gold); padding: 2px 7px; border-radius: 4px; flex-shrink: 0; font-size: 11px; font-family: 'DM Sans', sans-serif; font-weight: 500; }
.ir-bracket-slice { color: var(--muted); flex: 1; }
.ir-bracket-tax   { color: var(--red); flex-shrink: 0; }
.cf-ir-total { border-top: 1px solid var(--ink-3); padding-top: 12px; }
.cf-ir-amount { font-size: 26px; font-weight: 500; font-family: 'DM Sans', sans-serif; margin: 4px 0; }
.cf-ir-monthly { font-size: 11px; color: var(--muted); }
.cf-ir-disclaimer {
  font-size: 10px;
  color: var(--muted);
  padding: 10px 20px;
  border-top: 1px solid var(--ink-3);
  font-style: italic;
}
@media (max-width: 768px) {
  .cf-ir-body { grid-template-columns: 1fr; }
  .cf-ir-controls { border-right: none; border-bottom: 1px solid var(--ink-3); }
}

/* ── RGPD banner ── */
.gdpr-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 48px);
  max-width: 680px;
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: var(--r-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  z-index: 10000;
  animation: gdpr-in .25s ease;
}
@keyframes gdpr-in {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.gdpr-body {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
}
.gdpr-text { flex: 1; min-width: 0; }
.gdpr-text strong { font-size: 13px; color: var(--cream); display: block; margin-bottom: 4px; }
.gdpr-text p { font-size: 11px; color: var(--muted); margin: 0; line-height: 1.5; }
.gdpr-actions { display: flex; gap: 8px; flex-shrink: 0; }
@media (max-width: 600px) {
  .gdpr-body { flex-direction: column; align-items: stretch; }
  .gdpr-actions { justify-content: flex-end; }
}

/* ── Grand Livre ────────────────────────────────────────────── */
.gl-block {
  background: var(--ink-2);
  border: 1px solid var(--ink-3);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 20px;
}
.gl-block-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--ink-3);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.gl-acc-num {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--gold);
  min-width: 44px;
}
.gl-acc-lbl  { font-size: 13px; font-family: 'DM Sans', sans-serif; font-weight: 500; color: var(--cream); flex: 1; }
.gl-acc-count{ font-size: 11px; color: var(--muted); }
.gl-cols-head, .gl-row, .gl-subtot, .gl-grand {
  display: grid;
  grid-template-columns: 90px 90px 1fr 120px 120px 120px;
}
.gl-cols-head {
  padding: 0 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--ink-3);
}
.gl-cols-head > div { padding: 6px 12px; }
.gl-row > div       { padding: 9px 12px; font-size: 12px; color: var(--cream-2); border-bottom: 1px solid rgba(255,255,255,.03); }
.gl-row:last-of-type > div { border-bottom: none; }
.gl-piece { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted) !important; }
.gl-lbl   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-num   { text-align: right; font-family: 'DM Mono', monospace; }
.gl-dc    { font-size: 9px; opacity: .7; margin-left: 3px; }
.gl-d     { color: #5CC98A; }
.gl-c     { color: #E8A050; }
.gl-subtot {
  background: var(--ink-3);
  font-size: 12px;
  font-family: 'DM Sans', sans-serif; font-weight: 500;
  color: var(--cream);
}
.gl-subtot > div { padding: 8px 12px; }
.gl-grand {
  background: var(--ink-2);
  border: 1px solid var(--gold);
  border-radius: var(--r);
  font-size: 13px;
  font-family: 'DM Sans', sans-serif; font-weight: 500;
  color: var(--cream);
  margin-bottom: 32px;
}
.gl-grand > div { padding: 12px 12px; }

/* ── GL tab navigation ──────────────────────────────────────── */
.gl-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--ink-3);
  padding-bottom: 0;
}
.gl-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif; font-weight: 500;
  padding: 8px 16px;
  margin-bottom: -1px;
  border-radius: 6px 6px 0 0;
  transition: color .15s, border-color .15s;
}
.gl-tab:hover { color: var(--cream); }
.gl-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ── Digital signature ──────────────────────────────────────── */
.sig-canvas-wrap {
  background: #fff;
  border: 1.5px solid var(--ink-3);
  border-radius: 8px;
  overflow: hidden;
}
.icon-btn-signed {
  color: #5CC98A;
}
.icon-btn-signed:hover {
  color: #5CC98A;
  background: rgba(92,201,138,.12);
}
.co-sig-preview {
  background: var(--ink-3);
  border-radius: 8px;
  padding: 12px;
  display: inline-block;
}
