:root {
  /* Tailwind Blue */
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-300: #93c5fd;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --blue-900: #1e3a8a;
  --blue-950: #172554;

  /* Tailwind Slate */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* Tailwind Emerald */
  --emerald-50: #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-200: #a7f3d0;
  --emerald-300: #6ee7b7;
  --emerald-400: #34d399;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-800: #065f46;
  --emerald-900: #064e3b;

  /* Tailwind Amber */
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-200: #fde68a;
  --amber-300: #fcd34d;
  --amber-400: #fbbf24;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-700: #b45309;
  --amber-800: #92400e;
  --amber-900: #78350f;

  /* Tailwind Red */
  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-200: #fecaca;
  --red-300: #fca5a5;
  --red-400: #f87171;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --red-700: #b91c1c;
  --red-800: #991b1b;
  --red-900: #7f1d1d;

  /* Sémantique */
  --bg: var(--slate-100);
  --surface: #ffffff;
  --border: var(--slate-200);
  --text: var(--slate-900);
  --text-heading: var(--slate-700);
  --muted: var(--slate-500);
  --primary: var(--blue-600);
  --primary-hover: var(--blue-700);
  --primary-soft: var(--blue-50);
  --brand-navy: var(--blue-800);
  --brand-green: var(--emerald-500);
  --danger: var(--red-600);
  --danger-hover: var(--red-700);
  --success: var(--emerald-600);
  --warn: var(--amber-600);

  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

h1, h2, h3, h4, .card h2, .modal-header h2 {
  color: var(--text-heading);
}

header.app-header h1 {
  color: var(--text-heading);
}

header.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

header.app-header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
}

.app-header-nav {
  display: flex;
  align-items: center;
  flex: 1 1 20rem;
  min-width: 0;
  gap: 0.75rem;
}

.app-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
  margin-left: auto;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.app-brand:hover .app-brand-title {
  color: var(--brand-navy);
}

.app-logo-wrap {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  padding: 4px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.app-logo {
  flex-shrink: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
}

.app-logo--help {
  width: 56px;
  height: 56px;
}

.app-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.app-brand-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.01em;
  transition: color var(--transition-fast);
}

.app-brand-tagline {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
}

.header-selection {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  max-width: min(24rem, 48vw);
  text-align: right;
}

.header-selection .header-selection-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
}

.header-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--slate-50);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast), box-shadow var(--transition-fast),
    transform var(--transition-fast);
}

.header-icon-btn:hover,
.header-icon-btn:focus {
  background: var(--blue-50);
  border-color: var(--primary);
  color: var(--primary);
  outline: 2px solid var(--blue-200);
  outline-offset: 1px;
}

.header-icon-btn:active {
  transform: scale(0.96);
}

.account-actions {
  margin-top: 0.75rem;
}

.header-selection-kicker {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

#header-selection-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}

.help-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.help-toc-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.help-toc-brand h2 {
  margin: 0;
  font-size: 1.05rem;
}

.app-logo--toc {
  width: 40px;
  height: 40px;
}

.app-loading-logo {
  display: block;
  margin: 0 auto 0.75rem;
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 14px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.file-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  pointer-events: none;
}

.file-drop-overlay.hidden {
  display: none;
}

.file-drop-overlay-box {
  max-width: 28rem;
  width: 100%;
  padding: 1.75rem 1.5rem;
  border: 2px dashed rgba(255, 255, 255, 0.85);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  text-align: center;
}

.file-drop-overlay-title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brand-navy, var(--slate-800));
}

.file-drop-overlay-hint {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--muted);
}

.app-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.app-footer-text {
  margin: 0;
  line-height: 1.6;
}

.app-footer a {
  color: var(--brand-navy);
  font-weight: 500;
}

.app-footer a:hover {
  color: var(--primary);
}

.save-status-badge {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: default;
  background: var(--blue-50);
  color: var(--primary);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.save-status-badge:not(:disabled) {
  cursor: pointer;
}

.save-status-badge:not(:disabled):hover {
  filter: brightness(0.97);
}

.save-status-saved {
  background: var(--emerald-100);
  color: var(--emerald-800);
  border-color: var(--emerald-200);
}

.save-status-pending {
  background: var(--blue-100);
  color: var(--blue-800);
  border-color: var(--blue-200);
}

.save-status-needs-setup,
.save-status-local {
  background: var(--amber-100);
  color: var(--amber-800);
  border-color: var(--amber-200);
}

.save-status-error {
  background: var(--red-100);
  color: var(--red-800);
  border-color: var(--red-200);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
}

.app-loading {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 252, 0.92);
}

.app-loading.hidden {
  display: none;
}

.app-loading-box {
  text-align: center;
  color: var(--muted);
}

.app-loading-box p {
  margin: 0.75rem 0 0;
}

.app-loading-spinner {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: app-spin 0.8s linear infinite;
}

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

.setup-intro {
  margin: 0 0 1rem;
  color: var(--muted);
}

.setup-steps {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  color: var(--text);
}

.setup-steps li {
  margin-bottom: 0.5rem;
}

.setup-steps code,
.setup-hint code {
  font-size: 0.88em;
  background: var(--slate-100);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.setup-hint {
  margin: 0 0 1.25rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.modal-box-narrow {
  max-width: 480px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-actions .btn {
  width: 100%;
}

.corrupt-file-steps {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.corrupt-file-steps li {
  margin-bottom: 0.35rem;
}

nav.tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}

nav.tabs button {
  border: 1px solid transparent;
  background: transparent;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast), transform var(--transition-fast);
}

nav.tabs button:active:not(.active) {
  transform: scale(0.98);
}

nav.tabs button .tab-icon {
  font-size: 0.88em;
  opacity: 0.85;
}

nav.tabs button.active .tab-icon {
  opacity: 1;
}

nav.tabs button.active {
  background: var(--primary);
  color: white;
}

nav.tabs button:hover:not(.active) {
  background: var(--blue-50);
  color: var(--primary);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.settings-intro-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(11rem, 13.5rem) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.settings-nav {
  position: sticky;
  top: 1rem;
  align-self: start;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 0.85rem 0.75rem;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.settings-nav-title {
  margin: 0 0 0.55rem;
  padding: 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--slate-500);
}

.settings-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.settings-nav-link {
  display: block;
  padding: 0.42rem 0.55rem;
  border-radius: calc(var(--radius) - 2px);
  color: var(--slate-700);
  text-decoration: none;
  font-size: 0.88rem;
  line-height: 1.3;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.settings-nav-link:hover,
.settings-nav-link:focus-visible {
  background: var(--slate-100);
  color: var(--text);
  outline: none;
}

.settings-nav-link.is-active {
  background: var(--blue-50);
  color: var(--blue-800);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--blue-200);
}

.settings-content {
  min-width: 0;
}

.settings-content .card,
.settings-content .grid-2,
.settings-content .settings-intro-row {
  scroll-margin-top: 1rem;
}

#settings-section-lease,
#settings-section-parties,
#settings-section-emitters,
#settings-section-prices,
#settings-templates-section,
#settings-section-recipients,
#settings-mail-oauth,
#settings-mail-smtp,
#settings-backup-json,
#settings-data-section,
#settings-account {
  scroll-margin-top: 1rem;
}

.settings-intro-row .card-intro {
  flex: 1;
  margin: 0;
}

.settings-intro-row .help-trigger {
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.dashboard-period-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  align-items: start;
}

.dashboard-period-grid .card {
  margin-bottom: 0;
}

.card-dashboard-payments {
  min-width: 0;
}

.card-dashboard-payments .table-hint {
  margin: -0.35rem 0 0.75rem;
}

.payments-table-scroll--dashboard {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--slate-50);
  padding: 0.15rem 0.35rem 0.35rem;
}

.data-table-dashboard-payments {
  min-width: 0;
  width: 100%;
  margin: 0;
}

.data-table-dashboard-payments thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--slate-100);
  font-size: 0.82rem;
  text-transform: none;
  letter-spacing: 0;
  padding: 0.5rem 0.55rem;
  white-space: nowrap;
}

.data-table-dashboard-payments tbody td {
  padding: 0.5rem 0.55rem;
  vertical-align: middle;
  font-size: 0.88rem;
}

.data-table-dashboard-payments tbody tr:last-child td {
  border-bottom: none;
}

.data-table-dashboard-payments .payment-label {
  max-width: 180px;
}

.data-table-dashboard-payments .payment-ref {
  max-width: 100px;
}

.data-table-dashboard-payments .payment-comment {
  max-width: 120px;
}

.data-table-dashboard-payments td:first-child {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.84rem;
}

.data-table-dashboard-payments td:nth-child(2) {
  font-weight: 500;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .data-table-dashboard-payments .col-pay-ref,
  .data-table-dashboard-payments td.payment-ref {
    display: none;
  }
}

@media (max-width: 900px) {
  .data-table-dashboard-payments .col-pay-comment,
  .data-table-dashboard-payments td.payment-comment {
    display: none;
  }
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.card-header-row h2 {
  margin: 0;
}

.card-header-title {
  flex: 1;
  min-width: 0;
}

.card-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.btn-report-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius);
  background: #fff;
  color: var(--slate-500);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  flex-shrink: 0;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-report-export:hover:not(:disabled),
.btn-report-export:focus-visible:not(:disabled) {
  color: var(--primary);
  background: var(--blue-50);
  border-color: var(--blue-300);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
  outline: none;
}

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

.modal .report-field {
  display: none;
}

.report-print-banner {
  display: none;
}

.report-full-card {
  margin-top: 0.25rem;
}

.report-full-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
}

.report-full-hint {
  flex: 1 1 220px;
  margin: 0;
}

.report-export-host {
  display: none;
}

table.data-table tr.row-selected td {
  background: var(--blue-50);
  font-weight: 600;
}

table.data-table tr.row-clickable {
  cursor: pointer;
}

table.data-table tr.row-clickable td {
  transition: background var(--transition-fast);
}

table.data-table tr.row-clickable:hover td {
  background: var(--slate-100);
}

table.data-table tr.row-clickable.row-selected:hover td {
  background: var(--blue-100);
}

.table-hint {
  margin: -0.5rem 0 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Bouton flottant paramètres */
.fab-save {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.fab-save.fab-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.fab-save:hover {
  background: var(--primary-hover);
}

.fab-save.fab-save-dirty {
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45), 0 0 0 2px rgba(251, 191, 36, 0.85);
}

/* Notifications */
.notify-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(360px, calc(100vw - 2rem));
  pointer-events: none;
}

.notify-toast {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  pointer-events: auto;
  animation: notify-in 0.25s ease;
}

.notify-toast.notify-out {
  animation: notify-out 0.2s ease forwards;
}

@keyframes notify-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes notify-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

.notify-msg {
  flex: 1;
  font-size: 0.92rem;
}

.notify-close {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
}

.notify-info { border-left: 4px solid var(--primary); }
.notify-success { border-left: 4px solid var(--success); }
.notify-error { border-left: 4px solid var(--danger); }
.notify-warn { border-left: 4px solid var(--amber-600); }

.notify-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.notify-confirm {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.notify-confirm-msg {
  margin: 0 0 1rem;
}

.notify-confirm-detail {
  margin: -0.5rem 0 1rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.notify-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.notify-confirm-wide {
  max-width: 440px;
}

.notify-confirm-actions-stack {
  flex-direction: column;
  align-items: stretch;
}

.notify-confirm-actions-stack .btn {
  width: 100%;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden {
  display: none;
}

.modal:not(.hidden) .modal-backdrop {
  animation: fade-in 0.2s ease;
}

.modal:not(.hidden) .modal-box {
  animation: modal-in 0.22s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 440px;
  padding: 1.25rem;
  z-index: 1;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  flex: 1;
  min-width: 0;
}

.modal-header .btn-report-export {
  margin-left: auto;
}

.modal-header .help-trigger {
  flex-shrink: 0;
}

.modal-header .modal-close {
  flex-shrink: 0;
  margin-left: 0;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
}

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

.modal-box-wide {
  max-width: min(960px, calc(100vw - 2rem));
}

.modal-actions {
  margin-top: 1rem;
}

.csv-import-summary {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.csv-import-toolbar {
  margin-bottom: 0.75rem;
}

.csv-import-select-all {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.csv-import-table-wrap {
  max-height: min(420px, 55vh);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.csv-import-table-wrap .data-table {
  margin: 0;
}

.csv-import-table-wrap .col-check {
  width: 2.5rem;
  text-align: center;
}

.csv-import-table-wrap .csv-label {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.csv-import-table-wrap .csv-ref {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  white-space: nowrap;
}

.csv-import-table-wrap tr.csv-row-duplicate {
  opacity: 0.65;
  background: var(--slate-50);
}

.emitter-profile {
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--slate-50);
}

.emitter-profile textarea {
  min-height: 4.5rem;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
}

.data-file-status {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.data-file-status-ok {
  background: var(--emerald-100);
  color: var(--emerald-800);
}

.data-file-status-warn {
  background: var(--amber-100);
  color: var(--amber-800);
}

.payments-table-scroll {
  overflow-x: auto;
  margin: 0 -0.25rem;
  padding: 0 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.table-scroll-hint {
  display: none;
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.data-table-payments {
  min-width: 860px;
}

.data-table-payments .payment-label {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table-payments .payment-ref {
  max-width: 140px;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table-payments .payment-comment {
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 0.9rem;
}

.payment-status {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.payment-status-importe {
  background: var(--blue-100);
  color: var(--blue-800);
}

.payment-status-manuel {
  background: var(--slate-100);
  color: var(--slate-600);
}

.payment-status-verifie {
  background: var(--emerald-100);
  color: var(--emerald-800);
}

.payment-status-empty {
  background: transparent;
  color: var(--muted);
  font-weight: 400;
  padding: 0;
}

#modal-payment .modal-box-wide {
  max-width: min(640px, calc(100vw - 2rem));
}

#modal-payment textarea {
  min-height: 4rem;
  resize: vertical;
}

/* Éditeur Quill (quittance) */
.editor-card {
  padding: 0;
  overflow: hidden;
}

.quill-editor-host.is-plain-html {
  border: none;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1rem;
}

.quill-editor-host.is-plain-html .ql-editor {
  padding: 1rem;
  min-height: 0;
  line-height: 1.35;
}

.quill-editor-host .plain-html-toolbar-ghost {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

#quittance-preview-wrap .quill-editor-host.is-plain-html .ql-editor {
  min-height: 280px;
}

.quill-editor-host .ql-toolbar.ql-snow {
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--slate-50);
  font-family: 'Segoe UI', system-ui, sans-serif;
  padding: 0.5rem;
}

/* Aperçu mois : pas de barre d'outils (quittance + mail) */
#quittance-preview-wrap .ql-toolbar,
#mail-tab-preview-wrap .ql-toolbar {
  display: none !important;
}

.quill-editor-host .ql-container.ql-snow {
  border: none;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1rem;
}

.quill-editor-host .ql-editor {
  padding: 1.5rem;
  min-height: 420px;
  line-height: 1.5;
}

.quill-editor-host .ql-editor.ql-blank::before {
  color: var(--muted);
  font-style: normal;
}

.quill-editor-host .ql-editor div.quittance-header {
  display: flex !important;
  flex-direction: row !important;
  justify-content: space-between !important;
  align-items: flex-start !important;
  gap: 1rem !important;
  width: 100% !important;
  margin-bottom: 0.65rem !important;
}

.quill-editor-host .ql-editor table.quittance-header {
  display: table !important;
  width: 100% !important;
  border-collapse: collapse !important;
  border: none !important;
  margin-bottom: 0.65rem !important;
}

.quill-editor-host .ql-editor table.quittance-header td {
  border: none !important;
  padding: 0 !important;
  vertical-align: top !important;
}

.quill-editor-host .ql-editor div.quittance-header .quittance-party {
  flex: 1 1 45% !important;
  min-width: 180px !important;
}

.quill-editor-host .ql-editor table.quittance-header .quittance-party {
  flex: none !important;
  min-width: 0 !important;
  width: 50% !important;
}

.quill-editor-host .ql-editor .quittance-party-bailleur {
  text-align: left !important;
}

.quill-editor-host .ql-editor .quittance-party-locataire,
.quill-editor-host .ql-editor .quittance-header .quittance-party:last-child {
  text-align: right !important;
}

.quill-editor-host .ql-editor .quittance-party-bailleur {
  text-align: left;
}

.quill-editor-host .ql-editor .quittance-party-locataire {
  text-align: right;
}

.quill-editor-host .ql-editor .quittance-footer {
  margin-top: 0.65rem;
  text-align: right;
}

.quill-editor-host .ql-editor .quittance-party .quittance-party-label,
.quill-editor-host .ql-editor .quittance-party h3 {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 0.08rem !important;
  padding: 0 !important;
  line-height: 1.1;
  color: var(--muted);
}

.quill-editor-host .ql-editor .quittance-party .quittance-party-lines,
.quill-editor-host .ql-editor .quittance-party p:not(.quittance-party-label) {
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.15 !important;
}

.quill-editor-host .ql-editor .quittance-title {
  text-align: center;
  margin: 0.35rem 0 0.45rem;
}

.quill-editor-host .ql-editor .quittance-list {
  white-space: pre-wrap;
  font-family: inherit;
  background: var(--slate-50);
  padding: 0.3rem 0.45rem;
  border-radius: var(--radius);
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.35;
}

.quill-editor-host .ql-editor .quittance-footer {
  margin-top: 0.65rem;
  text-align: right;
}

.quill-editor-host .ql-editor .quittance-footer > p {
  margin: 0;
}

.quill-editor-host .ql-editor .quittance-signature {
  margin-top: 0.75rem;
  font-weight: 600;
  text-align: right;
}

.quill-editor-host .ql-editor .quittance-signature-img,
.quill-editor-host .ql-editor .quittance-footer img {
  width: 250px !important;
  height: auto !important;
  max-width: 250px !important;
  display: block;
  margin-top: 0.5rem;
  margin-left: auto;
  object-fit: contain;
}

.quill-editor-host .ql-editor .quittance-signature-name {
  margin-top: 0.75rem;
  margin-bottom: 0;
  font-weight: 600;
  text-align: right;
}

.signature-preview {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: var(--slate-50);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  min-height: 60px;
}

.signature-preview-img {
  max-height: 100px;
  max-width: 220px;
  display: block;
}

.signature-upload #btn-remove-signature {
  margin-top: 0.5rem;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.form-row label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

input, select, textarea {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  cursor: pointer;
  background: var(--primary);
  color: white;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast), box-shadow var(--transition-fast),
    transform var(--transition-fast), opacity var(--transition-fast);
}

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

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

.btn:focus-visible {
  outline: 2px solid var(--blue-300);
  outline-offset: 2px;
}

.btn-secondary {
  background: var(--slate-200);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--slate-300);
  color: var(--slate-900);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

.btn:disabled:hover,
.btn[disabled]:hover {
  background: var(--primary);
}

.btn-secondary:disabled,
.btn-secondary[disabled] {
  background: var(--slate-200);
  color: var(--slate-400);
}

.btn-secondary:disabled:hover,
.btn-secondary[disabled]:hover {
  background: var(--slate-200);
}

.template-mode-btn:disabled,
.template-mode-btn[disabled] {
  border-color: var(--border);
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

table.data-table th,
table.data-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

table.data-table th {
  background: var(--slate-50);
  font-weight: 600;
  color: var(--muted);
}

table.data-table tr:hover td {
  background: var(--slate-50);
}

.num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.positive { color: var(--success); }
.negative { color: var(--danger); }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.filters .form-row {
  margin-bottom: 0;
  min-width: 140px;
}

.chart-wrap {
  position: relative;
  height: 320px;
  margin-bottom: 1rem;
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-box {
  flex: 1;
  min-width: 140px;
  background: var(--slate-50);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.stat-box .label {
  font-size: 0.8rem;
  color: var(--muted);
}

.stat-box .value {
  font-size: 1.25rem;
  font-weight: 700;
}

.dash-kpis .stat-box {
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
}

.period-bar {
  background: linear-gradient(180deg, var(--slate-50) 0%, #fff 100%);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.period-bar-inner {
  max-width: var(--max-width, 1200px);
  margin: 0 auto;
}

.period-picker-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.65rem;
}

.period-inputs-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.45rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.55rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.period-month-field {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin: 0;
}

.period-month-field-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding-left: 0.15rem;
}

.period-month-input,
.period-range-to {
  border: 1px solid var(--border);
  background: var(--slate-50);
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  padding: 0.35rem 0.5rem;
  min-width: 9.5rem;
}

.period-month-input:focus,
.period-range-to:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  border-color: var(--blue-300);
  background: #fff;
}

.period-range-sep-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  align-self: flex-end;
}

.period-range-sep-wrap .period-month-field-label {
  visibility: hidden;
}

.period-range-sep {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 2.05rem;
  padding: 0 0.2rem;
}

.period-range-toggle {
  align-self: flex-end;
  white-space: nowrap;
  opacity: 0.92;
  font-size: 0.82rem;
  padding: 0.35rem 0.65rem;
}

.period-range-toggle[aria-pressed="true"] {
  background: var(--blue-50);
  border-color: var(--blue-300);
  color: var(--blue-800);
}

.period-picker-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 12rem;
  justify-content: flex-end;
}

.period-bar-help {
  flex-shrink: 0;
}

.period-status-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem 0.5rem;
  flex: 1;
  min-width: 0;
}

.period-legend-badge {
  cursor: pointer;
  font-size: 0.72rem;
  position: relative;
}

.period-legend-badge:focus {
  outline: 2px solid rgba(37, 99, 235, 0.4);
}

.period-nav-btn,
.timeline-scroll-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--slate-50);
  color: var(--blue-800);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  align-self: flex-end;
}

.period-nav-btn:hover:not(:disabled),
.timeline-scroll-btn:hover {
  background: var(--blue-50);
  border-color: var(--blue-300);
}

.period-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.period-timeline-row {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
}

.period-timeline-scroll {
  flex: 1;
  overflow-x: auto;
  overflow-y: visible;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding: 1.75rem 0 0.35rem;
  mask-image: linear-gradient(90deg, transparent, var(--slate-950) 1.5rem, var(--slate-950) calc(100% - 1.5rem), transparent);
}

.period-timeline-track {
  display: flex;
  gap: 3px;
  min-width: min-content;
  padding: 0 0.25rem;
}

.timeline-segment {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 2.6rem;
  height: 2.75rem;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  padding: 0.15rem 0.25rem;
  flex-shrink: 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.timeline-segment:hover,
.timeline-segment:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.15);
  z-index: 2;
}

.timeline-segment-label {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.1;
  color: rgba(15, 23, 42, 0.85);
}

.timeline-segment-year {
  font-size: 0.58rem;
  opacity: 0.75;
  color: rgba(15, 23, 42, 0.7);
}

.timeline-segment-tip,
.heatmap-cell-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 8rem;
  max-width: 12rem;
  padding: 0.45rem 0.55rem;
  background: var(--slate-900);
  color: var(--slate-50);
  border-radius: 6px;
  font-size: 0.72rem;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
  white-space: normal;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.timeline-segment-tip strong,
.heatmap-cell-tip strong {
  display: block;
  font-size: 0.78rem;
  margin-bottom: 0.15rem;
  color: #fff;
}

.timeline-segment-tip span,
.heatmap-cell-tip span {
  display: block;
  opacity: 0.9;
}

.timeline-segment:hover .timeline-segment-tip,
.timeline-segment:focus-visible .timeline-segment-tip,
.heatmap-btn:hover .heatmap-cell-tip,
.heatmap-btn:focus-visible .heatmap-cell-tip {
  display: block;
}

.timeline-segment.timeline-selected {
  border-color: var(--blue-800);
  box-shadow: 0 0 0 2px rgba(30, 64, 175, 0.25);
}

.timeline-segment.timeline-in-range {
  border-color: rgba(30, 64, 175, 0.45);
}

.timeline-segment.timeline-range-from {
  border-color: var(--blue-800);
  box-shadow: inset 0 -3px 0 var(--blue-800);
}

.timeline-segment.timeline-range-to {
  border-color: var(--blue-800);
  box-shadow: inset 0 3px 0 var(--blue-800);
}

.timeline-segment.month-status-paye { background: var(--emerald-200); }
.timeline-segment.month-status-avance { background: var(--blue-200); }
.timeline-segment.month-status-partiel { background: var(--amber-200); }
.timeline-segment.month-status-impaye { background: var(--red-200); }
.timeline-segment.month-status-en_cours { background: var(--slate-300); }

.period-picker--compact .period-timeline-row,
.period-picker--compact .period-status-legend,
.period-picker--compact .period-range-toggle,
.period-picker--compact .period-to-wrap,
.period-picker--compact .period-range-sep-wrap {
  display: none !important;
}

.period-picker--compact .period-picker-top {
  margin-bottom: 0;
  justify-content: center;
}

.period-picker--compact .period-inputs-row {
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 0;
}

.dashboard-viz-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  align-items: start;
}

.dashboard-viz-grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  align-items: start;
}

.dashboard-balance-card {
  margin-bottom: 1.25rem;
}

.dashboard-overview-card {
  margin-bottom: 1.25rem;
}

.dashboard-overview-card .chart-wrap--overview {
  width: 100%;
  height: min(420px, 55vh);
  min-height: 280px;
  margin-bottom: 0;
}

.dashboard-overview-card .chart-wrap--overview canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
}

#dash-chart-year-nav.hidden {
  display: none;
}

.dashboard-balance-card .chart-wrap {
  width: 100%;
  height: 340px;
  margin-bottom: 0;
}

.dashboard-balance-card .chart-wrap canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
}

.dashboard-heatmap-card {
  min-width: 0;
}

.chart-wrap--compact {
  min-height: 220px;
}

table.data-table tr.row-in-range td {
  background: var(--blue-50);
}

table.data-table tr.row-focused td {
  background: var(--blue-100);
}

@media (max-width: 960px) {
  .dashboard-viz-grid,
  .dashboard-viz-grid-2 {
    grid-template-columns: 1fr;
  }

  .header-selection {
    display: none;
  }
}

@media (max-width: 640px) {
  .period-bar {
    padding: 0.65rem 0.75rem;
  }

  .period-picker-top {
    flex-direction: column;
    align-items: stretch;
  }

  .period-inputs-row {
    justify-content: center;
  }

  .period-picker-meta {
    justify-content: center;
    flex-wrap: wrap;
  }

  .period-status-legend {
    justify-content: center;
  }

  .dashboard-analytics-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-viz-grid,
  .dashboard-viz-grid-2 {
    grid-template-columns: 1fr;
  }
}

.month-status {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.month-status-paye { background: var(--emerald-100); color: var(--emerald-800); }
.month-status-avance { background: var(--blue-100); color: var(--blue-700); }
.month-status-partiel { background: var(--amber-100); color: var(--amber-800); }
.month-status-impaye { background: var(--red-100); color: var(--red-800); }
.month-status-en_cours { background: var(--slate-200); color: var(--slate-600); }
.month-status-hors_periode { background: transparent; color: var(--muted); }

.month-delay-hint {
  font-size: 0.75rem;
  color: var(--danger);
  font-weight: 600;
}

.dashboard-heatmap {
  overflow-x: auto;
  margin-bottom: 0;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: auto repeat(12, minmax(1.75rem, 2.35rem));
  gap: 0.35rem 0.25rem;
  align-items: start;
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
}

.heatmap-corner {
  min-width: 2rem;
}

.heatmap-col-label {
  text-align: center;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
  padding-bottom: 0.15rem;
}

.heatmap-row-label {
  font-weight: 600;
  text-align: right;
  padding-right: 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
  align-self: center;
}

.heatmap-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.heatmap-empty {
  background: transparent;
  min-height: 1.75rem;
}

.heatmap-btn {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  max-width: 2.35rem;
  margin: 0 auto;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.heatmap-btn:hover,
.heatmap-btn:focus-visible {
  transform: scale(1.06);
  z-index: 1;
}

.heatmap-btn.heatmap-in-range {
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.35);
}

.heatmap-btn.heatmap-focused {
  border-color: var(--blue-700);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.heatmap-btn.month-status-paye { background: var(--emerald-400); }
.heatmap-btn.month-status-avance { background: var(--blue-400); }
.heatmap-btn.month-status-partiel { background: var(--amber-400); }
.heatmap-btn.month-status-impaye { background: var(--red-400); }
.heatmap-btn.month-status-en_cours { background: var(--slate-400); }

.heatmap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.heatmap-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.heatmap-swatch {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 3px;
}

.heatmap-swatch.month-status-paye { background: var(--emerald-400); }
.heatmap-swatch.month-status-avance { background: var(--blue-400); }
.heatmap-swatch.month-status-partiel { background: var(--amber-400); }
.heatmap-swatch.month-status-impaye { background: var(--red-400); }
.heatmap-swatch.month-status-en_cours { background: var(--slate-400); }


.quittance-doc .quittance-signature {
  margin-top: 2rem;
  font-weight: 600;
}

.subsection-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1rem 0 0.5rem;
  color: var(--muted);
}

.inline-actions button {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  margin-right: 0.25rem;
}

.hidden { display: none !important; }

#panel-settings {
  padding-bottom: 5rem;
}

.empty-msg {
  color: var(--muted);
  font-style: italic;
  padding: 1rem 0;
}

@media print {
  header.app-header,
  nav.tabs,
  .period-bar,
  .fab-save,
  .ql-toolbar,
  .help-trigger,
  .help-popover,
  .skip-link,
  #panel-help,
  .app-footer,
  .table-scroll-hint,
  .screen-only,
  .btn-report-export,
  .report-full-card,
  .settings-nav,
  .gdpr-consent-banner,
  #app-loading,
  .file-drop-overlay,
  .modal-backdrop,
  .field-hint,
  .table-hint,
  .card-header-actions,
  .modal-actions,
  .notify-container {
    display: none !important;
  }

  .col-row-action,
  th.col-row-action,
  td.col-row-action {
    display: none !important;
  }

  main {
    padding: 0;
    max-width: none;
  }

  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid var(--slate-300);
  }

  .report-print-banner {
    display: none !important;
  }

  body.report-print-active .report-print-banner {
    display: block !important;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--slate-300);
  }

  body.report-print-viz .dashboard-period-grid {
    display: none !important;
  }

  body.report-print-summary .dashboard-period-grid {
    display: grid !important;
  }

  body.report-print-viz .dashboard-heatmap-card,
  body.report-print-full .dashboard-heatmap-card {
    display: none !important;
  }

  #month-detail-payments-table th:last-child,
  #month-detail-payments-table td:last-child {
    display: none !important;
  }

  .report-print-banner h1 {
    margin: 0 0 0.35rem;
    font-size: 1.25rem;
  }

  .report-print-banner p {
    margin: 0.15rem 0;
    color: var(--slate-600);
    font-size: 0.9rem;
  }

  .report-print-date {
    font-size: 0.82rem !important;
  }

  .panel {
    display: none !important;
  }

  #panel-dashboard {
    display: block !important;
  }

  body.report-print-active .report-printable {
    display: none !important;
  }

  body.report-print-summary .report-printable[data-report-print~='summary'],
  body.report-print-month .report-printable[data-report-print~='month'],
  body.report-print-payments .report-printable[data-report-print~='payments'],
  body.report-print-viz .report-printable[data-report-print~='viz'],
  body.report-print-full .report-printable[data-report-print~='full'] {
    display: block !important;
  }

  body.report-print-viz .chart-wrap,
  body.report-print-full .chart-wrap {
    display: block !important;
    height: auto !important;
    min-height: 220px;
    page-break-inside: avoid;
  }

  body.report-print-viz .dashboard-viz-grid,
  body.report-print-full .dashboard-viz-grid {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  body.report-print-modal-month #panel-dashboard,
  body.report-print-modal-payment #panel-dashboard {
    display: none !important;
  }

  body.report-print-modal-month #modal-month-detail,
  body.report-print-modal-payment #modal-payment {
    display: block !important;
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    background: transparent !important;
  }

  body.report-print-modal-month #modal-month-detail .modal-box,
  body.report-print-modal-payment #modal-payment .modal-box {
    box-shadow: none !important;
    max-width: none !important;
    width: 100% !important;
    padding: 0 !important;
  }

  body.report-print-modal-month .report-field,
  body.report-print-modal-payment .report-field {
    display: block !important;
    margin-bottom: 0.75rem;
  }

  body.report-print-modal-month .report-field-label,
  body.report-print-modal-payment .report-field-label {
    font-size: 0.78rem;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  body.report-print-modal-month .report-field-value,
  body.report-print-modal-payment .report-field-value {
    font-weight: 600;
    margin-top: 0.15rem;
  }

  .heatmap-cell-tip {
    display: none !important;
  }
}

@media (max-width: 900px) {
  .dashboard-period-grid {
    grid-template-columns: 1fr;
  }

  .settings-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .settings-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }

  .settings-nav-list {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.35rem;
    width: max-content;
    min-width: 100%;
  }

  .settings-nav-link {
    white-space: nowrap;
    font-size: 0.82rem;
  }

  .settings-nav-title {
    display: none;
  }

  .dashboard-period-grid .card {
    margin-bottom: 1.25rem;
  }

  .dashboard-period-grid .card:last-child {
    margin-bottom: 0;
  }
}

@media (max-width: 640px) {
  main {
    padding: 1rem;
  }

  header.app-header {
    padding: 0.75rem 1rem;
    flex-direction: column;
    align-items: stretch;
  }

  .app-header-nav {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .app-header-actions {
    margin-left: 0;
    align-self: flex-end;
  }

  .app-brand-title {
    font-size: 1.05rem;
  }

  .app-brand-tagline {
    display: none;
  }

  nav.tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
  }

  nav.tabs button {
    padding: 0.5rem 0.4rem;
    font-size: 0.82rem;
    text-align: center;
  }

  .card {
    padding: 1rem;
  }

  .card-header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .card-header-row h2 {
    width: 100%;
  }

  .card-header-row .btn-group {
    width: 100%;
  }

  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filters .form-row {
    width: 100%;
    min-width: 0;
  }

  .filters select {
    width: 100%;
  }

  .stat-box {
    min-width: calc(50% - 0.5rem);
    flex: 1 1 calc(50% - 0.5rem);
  }

  .chart-wrap {
    height: 240px;
  }

  #panel-quittance .card.no-print .btn-group,
  #panel-settings .card .btn-group:not(.modal-actions) {
    flex-direction: column;
    align-items: stretch;
  }

  #panel-quittance .card.no-print .btn-group .btn,
  #panel-settings .card .btn-group:not(.modal-actions) .btn,
  #panel-settings .card .btn-group:not(.modal-actions) label.btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .fab-save {
    bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    right: max(1rem, env(safe-area-inset-right, 0px));
    left: max(1rem, env(safe-area-inset-left, 0px));
    width: auto;
    border-radius: var(--radius);
  }

  #panel-settings {
    padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
  }

  .notify-container {
    top: auto;
    bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
    left: 1rem;
    right: 1rem;
    max-width: none;
  }

  .help-popover {
    left: 1rem !important;
    right: 1rem !important;
    max-width: none !important;
    width: auto;
  }

  .modal-box,
  .modal-box-wide,
  #modal-payment .modal-box-wide {
    max-width: none;
    width: calc(100vw - 1.5rem);
    margin: 0 0.75rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }

  .payments-table-scroll {
    margin: 0 -0.5rem;
    padding: 0 0.5rem 0.25rem;
  }

  .payments-table-scroll--dashboard {
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
  }

  .data-table-dashboard-payments thead {
    display: none;
  }

  .data-table-dashboard-payments tbody tr {
    display: block;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .data-table-dashboard-payments tbody tr:last-child {
    margin-bottom: 0;
  }

  .data-table-dashboard-payments tbody td {
    display: grid;
    grid-template-columns: minmax(5.5rem, 34%) 1fr;
    gap: 0.35rem 0.75rem;
    align-items: start;
    padding: 0.35rem 0;
    border-bottom: none;
    text-align: left !important;
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  .data-table-dashboard-payments tbody td::before {
    content: attr(data-label);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
  }

  .data-table-dashboard-payments tbody td.col-row-action {
    display: block;
    padding-bottom: 0.5rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
  }

  .data-table-dashboard-payments tbody td.col-row-action::before {
    display: none;
  }

  .data-table-dashboard-payments tbody td.payment-ref,
  .data-table-dashboard-payments tbody td.payment-comment {
    display: grid;
  }

  .data-table-dashboard-payments tbody td.num {
    font-weight: 600;
    color: var(--text);
  }

  .data-table-dashboard-payments tbody td:empty {
    display: none;
  }

  .data-table-dashboard-payments .empty-msg {
    display: block;
    padding: 1rem;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--slate-50);
  }

  .data-table-dashboard-payments tbody tr.payments-empty-row td {
    display: block;
    grid-template-columns: 1fr;
  }

  .data-table-dashboard-payments tbody tr.payments-empty-row td::before {
    display: none;
  }

  .card-dashboard-payments .table-scroll-hint {
    display: none !important;
  }

  .table-scroll-hint {
    display: block;
  }

  table.data-table {
    font-size: 0.85rem;
  }

  table.data-table th,
  table.data-table td {
    padding: 0.45rem 0.5rem;
  }

  .quill-editor-host .ql-editor div.quittance-header {
    flex-direction: column !important;
  }

  .quill-editor-host .ql-editor table.quittance-header .quittance-party-locataire,
  .quill-editor-host .ql-editor div.quittance-header .quittance-party-locataire,
  .quill-editor-host .ql-editor .quittance-header .quittance-party:last-child {
    text-align: left !important;
  }
}

/* Accessibilité — lien d'évitement */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 3000;
  padding: 0.75rem 1rem;
  background: var(--primary);
  color: white;
  text-decoration: none;
  border-radius: var(--radius);
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* Aide contextuelle */
.heading-with-help,
.label-with-help {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.label-with-help {
  margin-bottom: 0.35rem;
}

.label-with-help label {
  margin: 0;
}

.label-secondary {
  color: var(--text-muted, var(--slate-500));
  font-weight: 400;
}

.account-passphrase-form {
  margin: 1rem 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border, var(--slate-200));
}

.account-passphrase-form .subsection-title {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.help-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--slate-50);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  vertical-align: middle;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.help-trigger[aria-expanded="true"] {
  transform: scale(1.08);
  background: var(--blue-50);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--blue-200);
}

.help-trigger:hover,
.help-trigger:focus {
  background: var(--blue-50);
  border-color: var(--primary);
  outline: 2px solid var(--blue-200);
  outline-offset: 1px;
}

.help-popover {
  position: absolute;
  z-index: 1300;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
  padding: 0.85rem 2rem 0.85rem 0.85rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
  animation: help-popover-in 0.18s ease;
}

@keyframes help-popover-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.help-popover-text {
  margin: 0;
}

.help-popover-close {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

.help-popover-close:hover,
.help-popover-close:focus {
  color: var(--text);
  background: var(--slate-100);
}

.field-hint {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.card-intro {
  margin: -0.25rem 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

/* Onglet Aide */
.help-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.help-toc {
  position: sticky;
  top: 1rem;
}

.help-toc h2 {
  margin-top: 0;
  font-size: 1rem;
}

.help-toc ol {
  margin: 0;
  padding-left: 1.2rem;
}

.help-toc li {
  margin-bottom: 0.45rem;
}

.help-toc a {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.92rem;
}

.help-toc a:hover,
.help-toc a:focus {
  text-decoration: underline;
}

.help-article {
  scroll-margin-top: 1rem;
}

.help-article h2 {
  margin-top: 0;
}

.help-article h3 {
  margin-top: 1.25rem;
  font-size: 1.05rem;
}

.help-article p,
.help-article li {
  line-height: 1.55;
}

.help-article ol,
.help-article ul {
  padding-left: 1.35rem;
}

.help-article li {
  margin-bottom: 0.4rem;
}

.help-step-badge {
  display: inline-block;
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.help-callout {
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 1rem 0;
  font-size: 0.92rem;
}

.help-callout-warn {
  background: var(--amber-50);
  border-color: var(--amber-200);
}

.help-folder-tree {
  background: var(--surface-2, var(--slate-50));
  border: 1px solid var(--border, var(--slate-200));
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 0.75rem 0 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  overflow-x: auto;
  white-space: pre;
}

.help-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.help-goto {
  font-size: 0.88rem;
}

.template-block {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.template-block:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.template-mode-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.template-mode-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.template-mode-btn {
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.template-mode-btn:active {
  transform: scale(0.98);
}

.template-mode-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.template-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(240px, 32%);
  gap: 1rem;
  align-items: start;
}

.template-editor-layout.is-preview {
  grid-template-columns: 1fr;
}

.template-editor-layout.is-preview .template-placeholder-sidebar {
  display: none;
}

.template-editor-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.template-page-card {
  width: 100%;
  max-width: 210mm;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(15, 23, 42, 0.04);
}

.template-page-a4 .ql-editor {
  min-height: 297mm;
  max-height: 80vh;
  overflow-y: auto;
}

#template-mail-editor-card.template-page-card .ql-editor {
  min-height: 320px;
}

.template-subject-row {
  width: 100%;
  max-width: 210mm;
}

.template-placeholder-sidebar {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: 0.75rem;
  background: var(--slate-50);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.placeholder-sidebar-title {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
}

.placeholder-sidebar-hint {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.placeholder-sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.placeholder-sidebar-btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.placeholder-sidebar-btn:hover,
.placeholder-sidebar-btn:focus {
  border-color: var(--primary);
  background: var(--blue-50);
  outline: none;
}

.placeholder-sidebar-btn code {
  font-size: 0.78rem;
  background: var(--slate-100);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  word-break: break-all;
}

.placeholder-sidebar-label {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.3;
}

.template-editor-card:not(.template-page-card) .ql-editor {
  min-height: 280px;
}

.quill-editor-host.is-readonly .ql-toolbar,
.template-editor-card.is-readonly .ql-toolbar {
  display: none;
}

.template-editor-card.hidden {
  display: none;
}

#mail-preview-wrap.hidden {
  display: none;
}

.template-registry-list {
  list-style: none;
  margin: 0.75rem 0;
  padding: 0;
}

.template-registry-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.template-registry-item:last-child {
  border-bottom: none;
}

.template-registry-name {
  flex: 1 1 160px;
}

.template-default-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  background: var(--blue-50);
  color: var(--accent, var(--blue-600));
}

.template-protected-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  background: var(--slate-100);
  color: var(--muted);
}

.template-registry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.btn-sm {
  padding: 0.25rem 0.55rem;
  font-size: 0.85rem;
}

@media (max-width: 900px) {
  .template-editor-layout {
    grid-template-columns: 1fr;
  }

  .template-placeholder-sidebar {
    position: static;
    max-height: none;
  }

  .template-page-a4 .ql-editor {
    min-height: 420px;
    max-height: none;
  }
}

@media (max-width: 800px) {
  .help-layout {
    grid-template-columns: 1fr;
  }

  .help-toc {
    position: static;
  }
}

/* OAuth, historique, RGPD v1.0 */
.oauth-status-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.oauth-provider-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.oauth-provider-row:last-child {
  border-bottom: none;
}

.oauth-provider-name {
  font-weight: 600;
  min-width: 5rem;
}

.oauth-connected-email {
  color: var(--text-muted, var(--slate-500));
  font-size: 0.95rem;
}

.oauth-active-status {
  margin: 0 0 0.5rem;
}

.oauth-redirect-details {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.oauth-redirect-details code {
  word-break: break-all;
  font-size: 0.85rem;
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
}

.activity-log-body {
  margin-top: 1rem;
  overflow-x: auto;
}

.activity-log-table {
  width: 100%;
  font-size: 0.9rem;
}

.activity-status-ok {
  color: var(--success, var(--emerald-700));
}

.activity-status-error {
  color: var(--danger, var(--red-700));
}

.activity-error-cell {
  max-width: 12rem;
  font-size: 0.85rem;
  color: var(--text-muted, var(--slate-500));
}

.mail-other-menu {
  position: relative;
  display: inline-block;
}

.mail-other-menu summary {
  list-style: none;
  cursor: pointer;
}

.mail-other-menu summary::-webkit-details-marker {
  display: none;
}

.mail-other-menu-panel {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 10rem;
  margin-top: 0.25rem;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.gdpr-consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  padding: 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

.gdpr-consent-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.gdpr-consent-inner p {
  margin: 0;
  flex: 1 1 280px;
  font-size: 0.95rem;
}

.field-hint-warn {
  color: var(--warn, var(--amber-700));
}

.help-trigger-inline {
  width: 1.15rem;
  height: 1.15rem;
  font-size: 0.72rem;
  margin-left: 0.25rem;
}

.dash-kpis-heading,
.dash-month-stats-heading {
  margin: 0.75rem 0 0.35rem;
}

.dash-month-stats-heading .subsection-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.login-oauth-hint {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  text-align: center;
}

.help-inline-trigger {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 0.15rem;
}

.period-legend-badge {
  transition: box-shadow 0.12s ease, transform 0.12s ease;
}

.period-legend-badge:active {
  transform: scale(0.97);
}

/* ——— Page de connexion ——— */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--slate-100);
  padding: 1.5rem;
}

.login-main {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: var(--card-bg, #fff);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  padding: 2rem 1.75rem;
}

.login-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-brand h1 {
  font-size: 1.35rem;
  margin: 0.75rem 0 0.25rem;
}

.login-subtitle {
  color: var(--text-muted, var(--slate-500));
  font-size: 0.95rem;
  margin: 0;
}

.login-logo {
  border-radius: 12px;
}

.login-form .form-row {
  margin-bottom: 1rem;
}

.login-submit {
  width: 100%;
  margin-top: 0.5rem;
}

.login-error {
  background: var(--red-50);
  color: var(--red-700);
  border: 1px solid var(--red-200);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.login-oauth-sep {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-muted, var(--slate-500));
  font-size: 0.85rem;
  margin: 1.25rem 0;
}

.login-oauth-sep::before,
.login-oauth-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border, var(--slate-200));
}

/* ——— Page 404 ——— */
.error-page-code {
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-muted, var(--slate-500));
  margin: 0 0 0.35rem;
  line-height: 1;
}

.error-page-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.error-page-actions .btn {
  width: 100%;
  text-align: center;
  text-decoration: none;
}

.login-oauth-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.login-oauth-btn {
  width: 100%;
}

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

.login-backup-intro {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  text-align: center;
}

.login-backup-btn {
  width: 100%;
}

.login-backup-pending {
  background: var(--emerald-50);
  color: var(--emerald-700);
  border: 1px solid var(--emerald-200);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.login-backup-pending strong {
  display: block;
  margin-bottom: 0.25rem;
}

.form-row-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ——— Mode démonstration ——— */
.demo-banner {
  background: var(--amber-100);
  color: var(--amber-800);
  border-bottom: 1px solid var(--amber-300);
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  text-align: center;
}

.demo-banner-link {
  color: var(--amber-700);
  font-weight: 600;
  margin-left: 0.35rem;
}

.demo-mode .header-icon-btn#btn-header-logout {
  display: none !important;
}

/* Éléments réservés au mode démo : masqués par défaut, visibles si body.demo-mode */
[data-demo-only] {
  display: none !important;
}

.demo-mode [data-demo-only] {
  display: block !important;
}

.demo-csv-sample {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-radius: var(--radius);
}

.demo-csv-sample-text {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--slate-800);
}

.demo-csv-sample-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

/* ——— Paiements : tags, montants négatifs, filtres ——— */
.payment-tag {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.payment-tag-virement {
  background: var(--blue-100);
  color: var(--blue-700);
}

.payment-tag-espece {
  background: var(--amber-100);
  color: var(--amber-700);
}

.payment-tag-nature {
  background: var(--emerald-100);
  color: var(--emerald-700);
}

.payment-tag-autre {
  background: var(--slate-100);
  color: var(--slate-700);
}

.num.num-negative {
  color: var(--red-600);
  font-weight: 600;
}

.month-note-indicator {
  margin-left: 0.25rem;
  font-size: 0.85em;
  cursor: help;
}

.payments-filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.65rem 1rem;
  margin-bottom: 0.65rem;
}

.payments-filters-actions {
  margin-bottom: 0.35rem;
}

.payments-table-scroll--modal {
  max-height: 18rem;
}

/* Boutons ronds en début de ligne (tableaux mois / paiements) */
.col-row-action {
  width: 2.75rem;
  padding-left: 0.35rem !important;
  padding-right: 0.15rem !important;
  text-align: center;
  vertical-align: middle;
}

.btn-row-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--slate-300);
  border-radius: 50%;
  background: #fff;
  color: var(--slate-500);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.btn-row-icon:hover,
.btn-row-icon:focus-visible {
  color: var(--primary);
  background: var(--blue-50);
  border-color: var(--blue-300);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
  outline: none;
}

.btn-row-icon:active {
  transform: scale(0.96);
}

#modal-month-detail {
  z-index: 1000;
}

#modal-payment {
  z-index: 1100;
}

.payment-tag-select {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.2rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--slate-300);
  max-width: 100%;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.payment-tag-select:focus {
  outline: none;
  border-color: var(--blue-400);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.payment-tag-select-virement {
  background: var(--blue-100);
  color: var(--blue-700);
  border-color: var(--blue-300);
}

.payment-tag-select-espece {
  background: var(--amber-100);
  color: var(--amber-700);
  border-color: var(--amber-300);
}

.payment-tag-select-nature {
  background: var(--emerald-100);
  color: var(--emerald-700);
  border-color: var(--emerald-300);
}

.payment-tag-select-autre {
  background: var(--slate-100);
  color: var(--slate-700);
  border-color: var(--slate-300);
}
