/* =========================================================================
   AIRBNB TIMER — Styles
========================================================================= */
:root {
  /* Default UI font — overridden at runtime via setAppFont() when the admin
     picks a Google Font or uploads a custom font. */
  --app-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Theme palette (light mode defaults). Overridden under [data-theme="dark"]. */
  --bg-page: #f5f5f7;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-muted: #fafafa;
  --bg-tinted: #f5f5f7;
  --bg-row-selected: #e3f2fd;
  --bg-row-selected-text: #0071e3;
  --bg-table-foot: #f5f5f7;
  --bg-btn-secondary: #e8e8ed;
  --bg-btn-secondary-hover: #d8d8dd;
  --bg-badge: #e8e8ed;
  --bg-type-session: #e3f2fd;
  --bg-type-expense: #fff3e0;
  --bg-import-summary: #f5f5f7;
  --bg-receipt-toolbar: rgba(28,28,30,0.95);

  --text-primary: #1d1d1f;
  --text-muted: #6e6e73;
  --text-on-primary: #ffffff;
  --text-link: #0071e3;
  --text-type-expense: #ff9500;

  --border: #e5e5ea;
  --border-strong: #d2d2d7;

  --shadow-card: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-modal: 0 20px 60px rgba(0,0,0,0.2);

  --color-primary: #0071e3;
  --color-primary-hover: #0077ed;
  --color-success: #34c759;
  --color-success-hover: #30b850;
  --color-danger: #ff3b30;
  --color-danger-hover: #ff453a;
  --color-warning: #ff9500;
}

[data-theme="dark"] {
  --bg-page: #1a1a1c;
  --bg-card: #2c2c2e;
  --bg-input: #1c1c1e;
  --bg-muted: #2c2c2e;
  --bg-tinted: #232325;
  --bg-row-selected: #1c3450;
  --bg-row-selected-text: #5ea7ff;
  --bg-table-foot: #232325;
  --bg-btn-secondary: #3a3a3c;
  --bg-btn-secondary-hover: #48484a;
  --bg-badge: #3a3a3c;
  --bg-type-session: #1c3450;
  --bg-type-expense: #4a3010;
  --bg-import-summary: #232325;
  --bg-receipt-toolbar: rgba(0,0,0,0.95);

  --text-primary: #f5f5f7;
  --text-muted: #98989d;
  --text-on-primary: #ffffff;
  --text-link: #5ea7ff;
  --text-type-expense: #ffb340;

  --border: #38383a;
  --border-strong: #48484a;

  --shadow-card: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-modal: 0 20px 60px rgba(0,0,0,0.6);

  --color-primary: #0a84ff;
  --color-primary-hover: #2a94ff;
  --color-success: #30d158;
  --color-success-hover: #4ade71;
  --color-danger: #ff453a;
  --color-danger-hover: #ff6058;
  --color-warning: #ff9f0a;

  color-scheme: dark;
}

/* Auto mode: follow OS preference unless an explicit choice is set */
@media (prefers-color-scheme: dark) {
  :root[data-theme-auto="1"] {
    --bg-page: #1a1a1c;
    --bg-card: #2c2c2e;
    --bg-input: #1c1c1e;
    --bg-muted: #2c2c2e;
    --bg-tinted: #232325;
    --bg-row-selected: #1c3450;
    --bg-row-selected-text: #5ea7ff;
    --bg-table-foot: #232325;
    --bg-btn-secondary: #3a3a3c;
    --bg-btn-secondary-hover: #48484a;
    --bg-badge: #3a3a3c;
    --bg-type-session: #1c3450;
    --bg-type-expense: #4a3010;
    --bg-import-summary: #232325;
    --bg-receipt-toolbar: rgba(0,0,0,0.95);

    --text-primary: #f5f5f7;
    --text-muted: #98989d;
    --text-on-primary: #ffffff;
    --text-link: #5ea7ff;
    --text-type-expense: #ffb340;

    --border: #38383a;
    --border-strong: #48484a;

    --shadow-card: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-modal: 0 20px 60px rgba(0,0,0,0.6);

    --color-primary: #0a84ff;
    --color-primary-hover: #2a94ff;
    --color-success: #30d158;
    --color-success-hover: #4ade71;
    --color-danger: #ff453a;
    --color-danger-hover: #ff6058;
    --color-warning: #ff9f0a;

    color-scheme: dark;
  }
}

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

body {
  font-family: var(--app-font);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  transition: background 0.2s, color 0.2s;
  /* iOS PWA: respect the safe area on left/right/bottom. Top is handled
     directly on <header> so the header's background extends under the
     status bar / notch for a native-looking standalone app. */
  padding-right: env(safe-area-inset-right);
  padding-left: env(safe-area-inset-left);
  padding-bottom: env(safe-area-inset-bottom);
}

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ─── Login ─────────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}
.login-box {
  background: var(--bg-card); border-radius: 16px; padding: 40px;
  box-shadow: var(--shadow-modal);
  width: 100%; max-width: 400px;
  color: var(--text-primary);
}
.login-box h1 { font-size: 28px; margin-bottom: 8px; }
.login-box .subtitle { color: var(--text-muted); margin-bottom: 28px; font-size: 14px; }

/* ─── Forms ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; color: var(--text-primary); }
input, select, textarea {
  width: 100%;
  /* Prevent inputs from overflowing their parent (notable on iOS Safari for
     datetime-local which has intrinsic min-width above the parent's width). */
  max-width: 100%; min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  font-size: 16px; /* 16px minimum to prevent iOS Safari auto-zoom on focus */
  font-family: inherit;
  transition: border-color 0.15s, background 0.2s, color 0.2s;
  background: var(--bg-input);
  color: var(--text-primary);
}
/* iOS Safari needs box-sizing on datetime-local explicitly */
input[type="datetime-local"], input[type="date"], input[type="time"] {
  -webkit-appearance: none; appearance: none;
  box-sizing: border-box;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.18);
}
textarea { resize: vertical; min-height: 60px; }
input[type="checkbox"] { width: auto; }

/* ─── Buttons ───────────────────────────────────────────────────────── */
button, .btn, a.btn {
  padding: 10px 20px;
  border: none; border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background 0.15s, transform 0.15s; font-family: inherit;
  background: var(--color-primary); color: var(--text-on-primary);
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; line-height: 1.2;
  white-space: nowrap; /* prevent emoji/text from wrapping inside the button */
  text-decoration: none;
}
button:hover, .btn:hover, a.btn:hover { background: var(--color-primary-hover); transform: translateY(-1px); }
button:active, .btn:active, a.btn:active { transform: translateY(0); }
button:disabled { background: var(--border-strong); cursor: not-allowed; transform: none; opacity: 0.7; }
.btn-secondary { background: var(--bg-btn-secondary); color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-btn-secondary-hover); color: var(--text-primary); }
.btn-danger { background: var(--color-danger); color: var(--text-on-primary); }
.btn-danger:hover { background: var(--color-danger-hover); }
.btn-success { background: var(--color-success); color: var(--text-on-primary); }
.btn-success:hover { background: var(--color-success-hover); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-large { padding: 14px 32px; font-size: 16px; }

/* Action button groups (used in card titles and modals) */
.card-actions {
  display: flex; gap: 8px;
  /* Allow the group to shrink and to wrap onto its own row below the
     title when the viewport is too narrow. Prevents buttons from
     overflowing the card on iPhone. */
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
@media (max-width: 640px) {
  .card-actions { justify-content: flex-start; flex-basis: 100%; }
}
.modal-actions {
  display: flex; gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.modal-actions > button { flex: 0 0 auto; }
.modal-actions .spacer { flex: 1; }

/* ─── Header ────────────────────────────────────────────────────────── */
header {
  background: var(--bg-card);
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 10;
  color: var(--text-primary);
}
header h1 { font-size: 20px; }
.user-info { display: flex; align-items: center; gap: 12px; }
.user-info .badge {
  padding: 4px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600;
  background: var(--bg-badge); color: var(--text-primary);
}
.user-info .badge.admin { background: #ffd60a; color: #1d1d1f; }

/* ─── Tabs ──────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 4px;
  background: var(--bg-card); padding: 4px;
  border-radius: 10px; margin-bottom: 24px;
  border: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  flex: 1; padding: 10px 16px;
  background: transparent; color: var(--text-muted);
  border-radius: 8px; cursor: pointer;
  text-align: center; font-weight: 500;
  white-space: nowrap;
  min-width: max-content;
}
.tab.active { background: var(--color-primary); color: var(--text-on-primary); }
.tab:hover:not(.active) { background: var(--bg-tinted); color: var(--text-primary); }

/* ─── Cards ─────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border-radius: 12px;
  padding: 24px; margin-bottom: 16px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.card-title {
  font-size: 16px; font-weight: 600;
  margin-bottom: 16px; display: flex;
  justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
  /* Prevent inner buttons (e.g. "📎 ZIP") from pushing the title off the
     card on narrow viewports — every direct child can shrink down to 0. */
  min-width: 0;
}
.card-title > * { min-width: 0; }
.card-title > span { flex: 1 1 auto; min-width: 0; }

/* ─── Timer ─────────────────────────────────────────────────────────── */
.timer-display {
  text-align: center; padding: 32px;
  background: linear-gradient(135deg, var(--bg-tinted) 0%, var(--bg-btn-secondary) 100%);
  color: var(--text-primary);
  border-radius: 12px; margin-bottom: 16px;
  transition: background 0.3s;
}
.timer-display.running {
  background: linear-gradient(135deg, var(--color-success) 0%, var(--color-success-hover) 100%);
  color: white;
}
.timer-time {
  font-size: 56px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  font-feature-settings: "tnum";
}
.timer-amount {
  font-size: 24px; margin-top: 8px;
  opacity: 0.9; font-weight: 500;
}
.timer-label {
  font-size: 13px; text-transform: uppercase;
  letter-spacing: 1px; opacity: 0.7;
  margin-bottom: 8px;
}
.timer-controls {
  display: flex; gap: 12px; justify-content: center;
  margin-top: 16px;
}

/* ─── Stats ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card); padding: 20px;
  border-radius: 12px; border: 1px solid var(--border);
  color: var(--text-primary);
}
.stat-label {
  font-size: 12px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.stat-value { font-size: 26px; font-weight: 700; }
.stat-value.green { color: var(--color-success); }
.stat-value.orange { color: var(--color-warning); }
.stat-value.red { color: var(--color-danger); }
.stat-value.blue { color: var(--color-primary); }

/* ─── Tables ────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; color: var(--text-primary); }
th, td {
  padding: 12px; text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
th {
  font-weight: 600; font-size: 12px;
  text-transform: uppercase; color: var(--text-muted);
  background: var(--bg-muted);
  position: sticky; top: 0;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-muted); }
tr.selected td { background: var(--bg-row-selected) !important; }
tfoot td { background: var(--bg-table-foot); font-weight: 600; }

/* ─── Status badges ─────────────────────────────────────────────────── */
.status-badge {
  padding: 3px 10px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
  display: inline-block;
}
.status-running { background: var(--color-success); color: var(--text-on-primary); }
.status-paid { background: var(--color-success); color: var(--text-on-primary); }
.status-unpaid { background: var(--color-warning); color: var(--text-on-primary); }
.status-completed { background: var(--bg-badge); color: var(--text-primary); }
.status-pending { background: var(--color-warning); color: var(--text-on-primary); }

.type-badge {
  padding: 2px 8px; border-radius: 6px;
  font-size: 10px; font-weight: 600;
  display: inline-block;
  text-transform: uppercase;
}
.type-session { background: var(--bg-type-session); color: var(--bg-row-selected-text); }
.type-expense { background: var(--bg-type-expense); color: var(--text-type-expense); }

/* ─── Modals ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-card); border-radius: 16px;
  padding: 28px; max-width: 500px; width: 100%;
  max-height: 90vh; overflow-y: auto; overflow-x: hidden;
  color: var(--text-primary);
  box-shadow: var(--shadow-modal);
}
.modal h2 { margin-bottom: 16px; font-size: 20px; }
.modal-large { max-width: 800px; }
/* Tables inside modals must be horizontally scrollable, not overflow the modal */
.modal .table-wrap,
.modal table { max-width: 100%; }
.modal table { table-layout: auto; }
#paymentDetailContent { overflow-x: auto; }
#paymentDetailContent table { font-size: 13px; }
#paymentDetailContent table th,
#paymentDetailContent table td { padding: 8px 6px; white-space: nowrap; }
#paymentDetailContent table td:nth-child(2) { white-space: normal; word-break: break-word; }

/* ─── Empty state ───────────────────────────────────────────────────── */
.empty {
  text-align: center; padding: 40px;
  color: var(--text-muted); font-size: 14px;
}

/* ─── Filters ───────────────────────────────────────────────────────── */
.filters {
  display: flex; gap: 12px; margin-bottom: 16px;
  flex-wrap: wrap; align-items: center;
}
.filters > select, .filters > input {
  width: auto; min-width: 140px;
}

/* Date range picker (Du [date] au [date]) — compact pill */
.date-range {
  display: inline-flex; align-items: center;
  gap: 4px; flex-wrap: nowrap;
  background: var(--bg-input); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 2px 8px;
  height: 38px; /* match select height */
}
.date-range input[type="date"] {
  border: none; padding: 4px 2px;
  width: auto; min-width: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 16px; /* iOS Safari: prevents auto-zoom on focus */
  -webkit-appearance: none; appearance: none;
}
.date-range input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
}
.date-range input[type="date"]:focus {
  outline: none; box-shadow: none;
}
.date-range-label {
  font-size: 12px; color: var(--text-muted);
  font-weight: 500; padding: 0 2px;
}

/* Date inputs in modals shouldn't be 100% width on desktop — they're useless wide */
.full-date {
  max-width: 200px;
}

/* Quick ranges (one-click presets + reset) */
.quick-ranges {
  display: inline-flex; gap: 6px; flex-wrap: wrap;
  align-items: center;
}

/* ─── Receipt thumbnail ─────────────────────────────────────────────── */
.receipt-thumb {
  max-width: 60px; max-height: 50px;
  border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border);
}
.receipt-full {
  max-width: 100%; max-height: 70vh;
  border-radius: 8px;
}

/* Fullscreen receipt viewer */
.receipt-viewer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  display: none; z-index: 200;
  flex-direction: column;
}
.receipt-viewer-overlay.active { display: flex; }
.receipt-viewer-toolbar {
  background: rgba(20,20,20,0.95);
  color: white; padding: 12px 20px;
  display: flex; align-items: center; gap: 16px;
  justify-content: space-between; flex-wrap: wrap;
  border-bottom: 1px solid #333;
}
.receipt-viewer-toolbar .info { font-size: 14px; }
.receipt-viewer-toolbar .actions { display: flex; gap: 8px; }
.receipt-viewer-toolbar a, .receipt-viewer-toolbar button {
  background: #2a2a2a; color: white;
  padding: 8px 14px; border-radius: 6px;
  border: 1px solid #444; cursor: pointer;
  text-decoration: none; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
  line-height: 1.2; white-space: nowrap;
  font-family: inherit;
}
.receipt-viewer-toolbar a:hover, .receipt-viewer-toolbar button:hover {
  background: #3a3a3a; transform: none; /* override base button hover lift */
}
.receipt-viewer-toolbar .close-btn { background: #ff3b30; border-color: #ff3b30; }
.receipt-viewer-toolbar .close-btn:hover { background: #ff453a; }
.receipt-viewer-body {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: auto; padding: 16px;
}
.receipt-viewer-body img {
  max-width: 100%; max-height: 100%;
  display: block; background: white;
  border-radius: 4px;
}
.receipt-viewer-body iframe {
  width: 100%; height: 100%;
  border: none; background: white;
  border-radius: 4px;
}
.receipt-viewer-body.zoom-natural {
  align-items: flex-start; justify-content: flex-start;
}
.receipt-viewer-body.zoom-natural img {
  max-width: none; max-height: none;
}

/* Select-all bar (above payment items table) */
.select-all-bar {
  display: flex; align-items: center;
  gap: 16px; margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--bg-tinted); border-radius: 8px;
  flex-wrap: wrap;
}
.select-all-label {
  display: inline-flex; align-items: center;
  gap: 8px; cursor: pointer;
  font-weight: 500; color: var(--text-primary);
  user-select: none;
}
.select-all-label input[type="checkbox"] {
  width: 18px; height: 18px;
  cursor: pointer; margin: 0;
  accent-color: var(--color-primary);
}

/* ─── Payment tab specifics ─────────────────────────────────────────── */
.payment-total {
  background: linear-gradient(135deg, var(--color-primary) 0%, #0058b3 100%);
  color: var(--text-on-primary); padding: 20px;
  border-radius: 12px; margin: 16px 0;
  text-align: center;
}
.payment-total-label {
  font-size: 13px; opacity: 0.9;
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 4px;
}
.payment-total-amount {
  font-size: 36px; font-weight: 700;
}
.payment-actions {
  display: flex; gap: 12px;
  align-items: center; flex-wrap: wrap;
  margin-top: 16px;
}

.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1d1d1f; color: white;
  padding: 14px 20px; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  z-index: 200; opacity: 0; transform: translateY(20px);
  transition: all 0.3s;
  font-size: 14px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--color-danger); }
.toast.success { background: var(--color-success); }

/* ─── Print ─────────────────────────────────────────────────────────── */
@media print {
  @page { size: A4 portrait; margin: 10mm; }
  html, body { background: white; color: black; font-size: 10pt; }
  header, .tabs, .no-print, .filters, button, .card-actions,
  .receipt-viewer-overlay { display: none !important; }
  /* Note: .modal-overlay is intentionally NOT hidden — we want what's on screen
     to print. The dedicated "Imprimer le reçu" button uses a separate iframe
     so the entire page+modal isn't involved at all in that flow. */
  .container { max-width: 100%; padding: 0; margin: 0; }
  .card {
    box-shadow: none; border: none; padding: 0;
    margin: 0 0 8mm 0; page-break-inside: avoid;
  }
  .card-title { font-size: 12pt; margin-bottom: 6px; }
  .stat-card { border: 1px solid #ddd; padding: 6px; }
  .stats-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
    margin-bottom: 8mm;
  }
  .stat-value { font-size: 13pt !important; }
  .stat-label { font-size: 8pt !important; }
  .timer-display { display: none; }

  /* Compact tables — squeeze in more rows per page */
  table { font-size: 9pt; width: 100%; border-collapse: collapse; }
  th, td {
    padding: 3px 5px !important;
    border-bottom: 1px solid #ccc;
    line-height: 1.25;
  }
  thead { display: table-header-group; } /* repeat header on each page */
  tfoot { display: table-footer-group; }
  tr { page-break-inside: avoid; }
  th {
    background: #f0f0f0 !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
    font-weight: 600; font-size: 9pt;
  }
  .text-muted { color: #555 !important; }
  .status-badge {
    background: transparent !important;
    color: #000 !important;
    padding: 0 !important; font-size: 9pt !important;
    border: none !important;
  }
  .status-paid::before { content: "✓ "; }
  .status-unpaid::before { content: "✗ "; }
  a { color: #000; text-decoration: none; }
  .empty { padding: 8px; }
  /* Don't print the actions column */
  th:last-child, td:last-child { /* leave actions column hidden via .no-print already */ }
}
.print-only { display: none; }
@media print {
  .print-only { display: block; text-align: left; margin-bottom: 4mm; }
  .print-only h1 { font-size: 14pt; margin: 0 0 2px 0; }
  .print-only .meta { font-size: 9pt; color: #444; margin: 0; }
}

/* ─── Mobile ────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .container { padding: 12px; }
  .timer-time { font-size: 44px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  th, td { padding: 8px 6px; font-size: 13px; }
  .tab { flex: 0 0 auto; padding: 8px 12px; font-size: 13px; }
  .card { padding: 16px; }
  header { padding: 12px 16px; }
  header h1 { font-size: 16px; }
  .user-info .badge { display: none; }

  /* Modals: full-screen-ish on small viewports so content isn't cropped */
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal {
    border-radius: 0; padding: 16px 14px;
    max-width: 100%; min-height: 100%;
    max-height: 100%;
  }
  .modal-large { max-width: 100%; }
  .modal h2 { font-size: 17px; padding-right: 30px; }

  /* Tables: allow horizontal scroll if too wide */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 100%; }

  /* Date range picker stacks naturally on narrow screens */
  .date-range { width: 100%; }
  .date-range input[type="date"] { flex: 1; }
  .quick-ranges { width: 100%; justify-content: flex-start; }
  .filters > select { flex: 1 1 100%; }

  /* Payment-detail content (sessions + frais sub-tables) wraps better */
  #paymentDetailContent .card-title { font-size: 14px; }
}

/* ─── Utilities ─────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mb-2 { margin-bottom: 12px; }
.mt-2 { margin-top: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1 1 auto; min-width: 0; }
.row > button, .row > .btn, .row > a.btn { flex: 0 0 auto; }
/* On narrow viewports, stack datetime inputs vertically (iOS datetime-local
   has a wide intrinsic min-width that breaks 2-column rows). */
@media (max-width: 480px) {
  .row-datetime > .form-group { flex: 1 1 100% !important; }
}
.checkbox-cell { width: 40px; text-align: center; }
.checkbox-cell input { cursor: pointer; }
code {
  background: var(--bg-tinted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-primary);
}
a { color: var(--text-link); }

.hidden { display: none !important; }

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border-strong); border-top-color: var(--color-primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Pagination bar (datatable-style) ────────────────────────────── */
.pagination-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  margin-top: 10px;
  padding: 8px 4px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}
.pagination-info { flex: 1 1 auto; min-width: 100px; }
.pagination-controls {
  display: inline-flex; align-items: center; gap: 4px;
  flex: 0 0 auto;
}
.pagination-controls .btn-sm { padding: 4px 10px; }
.pagination-page {
  font-size: 13px; color: var(--text-primary);
  font-weight: 500;
  padding: 0 6px;
  min-width: 90px; text-align: center;
}
.pagination-size {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
}
.pagination-size select {
  width: auto; min-width: 110px;
  padding: 6px 8px; font-size: 13px;
  height: 32px;
}
@media (max-width: 640px) {
  .pagination-bar {
    flex-direction: column; align-items: stretch;
  }
  .pagination-controls { justify-content: center; }
  .pagination-size { justify-content: flex-end; }
  .pagination-page { min-width: 70px; }
}
@media print {
  .pagination-bar { display: none !important; }
}

/* ─── Server backups list ─────────────────────────────────────────── */
.server-backups-list { margin-top: 4px; }
.server-backup-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 6px; gap: 10px; flex-wrap: wrap;
  background: var(--bg-card);
}
.server-backup-row .info {
  flex: 1 1 200px; min-width: 0;
  font-size: 13px; color: var(--text-primary);
}
.server-backup-row .info .size { color: var(--text-muted); font-size: 12px; }
.server-backup-row .actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* ─── Receipt preview / import progress ───────────────────────────── */
.import-summary {
  background: var(--bg-import-summary); border-radius: 8px; padding: 10px 12px;
  font-size: 13px; line-height: 1.6;
}
.import-summary strong { color: var(--text-primary); }
.import-errors {
  margin-top: 8px; max-height: 200px; overflow-y: auto;
  font-size: 12px; color: #b03a2e; background: #fdf3f2;
  border-radius: 6px; padding: 8px 10px;
}
[data-theme="dark"] .import-errors,
:root[data-theme-auto="1"] .import-errors {
  background: #3a1d1c; color: #ff9b95;
}
