/*
 * Salons-KPI — feuille de style globale
 *
 * Extrait depuis reference/kpi-dashboard-sample.html (sample valide par Diego).
 * NE PAS modifier le sample : c'est la reference visuelle de Phase 1.
 *
 * Sections (dans l'ordre du fichier) :
 *   1. Tokens     :root variables (palette, ombres, radii, polices)
 *   2. Reset      * / html / body / button / a
 *   3. Page       .page transition (utilise par le sample, herite ici)
 *   4. Topbar     .topbar / .brand / .brand-dot / .topbar-right / .avatar
 *   5. Container  .container + media query
 *   6. Typo       h1/h2/h3 / .kicker / .lead
 *   7. Accueil    .accueil-header / .month-selector / .salons-grid / .salon-card / .mini-stats / .delta-*
 *   8. Dashboard  .breadcrumb / .dashboard-header / .tabs / .tab-pane / .kpi-row / .kpi-card / .kpi-pill
 *   9. Sections   .section-title / .section-title-line
 *  10. Objectifs  .obj-list / .obj-row / .obj-bar / .obj-status
 *  11. Layouts    .two-col / .three-col / .panel / .panel-title
 *  12. Doughnut   .doughnut-wrap / .doughnut-svg / .doughnut-legend / .legend-*
 *  13. Bars       .bars-list / .bar-row / .bar-track / .bar-fill / .bar-value
 *  14. Heatmap    .heatmap / .heat-cell / .heatmap-legend / .heatmap-gradient
 *  15. Insights   .insights-grid / .insight-card (warn / ok / alert / high / info)
 *  16. Priorites  .priorities-list / .priority / .priority-num
 *  17. Tables     .data-table / .pct-chip
 *  18. LineChart  .line-chart-wrap / .line-chart-svg / .line-chart-tooltip
 *  19. Footer     footer
 *  20. Status     .status-overall (cartes accueil)
 *
 * Sections AJOUTEES en Phase 2 (a la fin du fichier) :
 *  21. Login      .login-shell / .login-card / .login-form / .login-button / .login-error
 *  22. Auth load  .auth-loading + .page-content (anti-flash sur pages protegees)
 *  23. Topbar+    .topbar-actions / .logout-button (deconnexion sur accueil et dashboard)
 *  24. Hide-mob   .hide-mobile (utilitaire deja reference dans le sample)
 */

  :root {
    --ink:        #1A1A2E;
    --ink-2:      #5F5E5A;
    --ink-3:      #A8A6A0;
    --rose:       #E94560;
    --rose-soft:  #FBEAEE;
    --bg:         #FAFAF8;
    --surface:    #FFFFFF;
    --border:     #EAE8E2;
    --hover:      #F2F0E8;

    --ok:         #2E7D5B;
    --ok-soft:    #E6F0EA;
    --warn:       #C2691B;
    --warn-soft:  #FBEEDC;
    --danger:     #B73E3E;
    --danger-soft:#F8E5E5;
    --info:       #3A4F7A;
    --info-soft:  #ECEFF7;

    --shadow-sm: 0 1px 2px rgba(26,26,46,0.04);
    --shadow-md: 0 4px 16px rgba(26,26,46,0.06);
    --shadow-lg: 0 12px 32px rgba(26,26,46,0.08);

    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 16px;
    --r-xl: 24px;

    --font-display: 'Fraunces', Georgia, serif;
    --font-body:    'DM Sans', system-ui, sans-serif;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  html { scroll-behavior: smooth; }
  body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
  }
  button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
  a { color: inherit; text-decoration: none; }

  /* ── Page transition ──────────────────────────────────── */
  .page { display: none; animation: fadeIn .35s ease; }
  .page.active { display: block; }
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ── Top bar ──────────────────────────────────────────── */
  .topbar {
    background: var(--ink);
    color: white;
    padding: 14px 32px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid #2A2A40;
  }
  .brand {
    display: flex; align-items: center; gap: 12px;
    font-family: var(--font-display);
    font-size: 18px; font-weight: 500;
    font-style: italic;
    letter-spacing: -0.01em;
  }
  .brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rose); }
  .topbar-right { display: flex; align-items: center; gap: 16px; font-size: 13px; opacity: 0.7; }
  .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--rose); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px;
  }

  /* ── Container ──────────────────────────────────────── */
  .container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 48px 32px;
  }
  @media (max-width: 720px) {
    .topbar { padding: 12px 20px; }
    .container { padding: 24px 16px; }
  }

  /* ── Typography ──────────────────────────────────── */
  h1, h2, h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.02em; line-height: 1.15; }
  h1 { font-size: clamp(32px, 5vw, 48px); }
  h2 { font-size: clamp(24px, 3vw, 32px); margin-bottom: 8px; }
  h3 { font-size: 18px; font-weight: 500; }
  .kicker {
    font-family: var(--font-body);
    font-size: 11px; font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-2);
    margin-bottom: 8px;
  }
  .lead {
    color: var(--ink-2);
    font-size: 15px;
    max-width: 560px;
    margin-top: 12px;
  }

  /* ── ACCUEIL ────────────────────────────────────── */
  .accueil-header {
    display: flex; align-items: end; justify-content: space-between;
    margin-bottom: 40px;
    flex-wrap: wrap; gap: 24px;
  }
  .month-selector {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 10px 16px;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
  }
  .month-selector select {
    border: none; background: none;
    font-family: var(--font-body); font-size: 14px; font-weight: 500;
    color: var(--ink); padding-right: 4px;
    cursor: pointer; outline: none;
  }
  .month-selector svg { color: var(--ink-3); }

  .salons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
  }
  .salon-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    transition: all .25s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .salon-card:hover {
    border-color: var(--ink);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
  }
  .salon-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--rose);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .35s ease;
  }
  .salon-card:hover::after { transform: scaleX(1); }
  .salon-card-header {
    display: flex; align-items: start; justify-content: space-between;
    margin-bottom: 24px;
  }
  .salon-card-name {
    font-family: var(--font-display);
    font-size: 22px; font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.2;
  }
  .salon-card-tag {
    font-size: 11px; font-weight: 500;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--ink); color: white;
    letter-spacing: 0.04em; text-transform: uppercase;
    flex-shrink: 0; margin-top: 4px;
  }
  .salon-card-tag.standard { background: var(--ink-2); }
  .salon-card-meta {
    color: var(--ink-2); font-size: 13px;
    margin-bottom: 20px;
  }
  .salon-mini-stats {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
  }
  .mini-stat-label {
    font-size: 11px; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: 0.06em;
    margin-bottom: 4px;
  }
  .mini-stat-value {
    font-family: var(--font-display);
    font-size: 26px; font-weight: 500;
    letter-spacing: -0.02em;
  }
  .mini-stat-delta { font-size: 12px; font-weight: 500; margin-top: 2px; }
  .delta-pos { color: var(--ok); }
  .delta-neg { color: var(--danger); }
  .delta-warn { color: var(--warn); }

  /* ── DASHBOARD ────────────────────────────────────────── */
  .breadcrumb {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--ink-2);
    margin-bottom: 16px;
  }
  .breadcrumb a { transition: color .2s; }
  .breadcrumb a:hover { color: var(--ink); }
  .breadcrumb-sep { color: var(--ink-3); }

  .dashboard-header {
    display: flex; align-items: end; justify-content: space-between;
    margin-bottom: 32px; flex-wrap: wrap; gap: 16px;
  }
  .dashboard-header h1 { margin-bottom: 4px; }
  .dashboard-meta { color: var(--ink-2); font-size: 14px; }

  /* Tabs */
  .tabs {
    display: flex; gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 32px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tab {
    padding: 14px 20px;
    font-size: 14px; font-weight: 500;
    color: var(--ink-2);
    border-bottom: 2px solid transparent;
    transition: all .2s;
    white-space: nowrap;
    margin-bottom: -1px;
  }
  .tab:hover { color: var(--ink); }
  .tab.active { color: var(--ink); border-bottom-color: var(--rose); }

  /* Tab content */
  .tab-pane { display: none; animation: fadeIn .25s ease; }
  .tab-pane.active { display: block; }

  /* KPI cards row */
  .kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 40px;
  }
  @media (max-width: 900px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
  @media (max-width: 480px) { .kpi-row { grid-template-columns: 1fr; } }

  .kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    position: relative;
    transition: all .2s;
  }
  .kpi-card:hover { border-color: var(--ink); }
  .kpi-card::before {
    content: '';
    position: absolute;
    left: 0; top: 16px; bottom: 16px;
    width: 3px; background: var(--ink);
    border-radius: 0 2px 2px 0;
  }
  .kpi-card.accent::before { background: var(--rose); }

  .kpi-label {
    font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--ink-2);
    margin-bottom: 8px; font-weight: 500;
  }
  .kpi-value {
    font-family: var(--font-display);
    font-size: 32px; font-weight: 500;
    letter-spacing: -0.025em;
    line-height: 1; margin-bottom: 8px;
  }
  .kpi-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; }
  .kpi-pill {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600; font-size: 11px;
  }
  .kpi-pill.pos { background: var(--ok-soft); color: var(--ok); }
  .kpi-pill.neg { background: var(--danger-soft); color: var(--danger); }
  .kpi-pill.warn { background: var(--warn-soft); color: var(--warn); }
  .kpi-hint { color: var(--ink-3); }

  /* Section title */
  .section-title {
    font-family: var(--font-display);
    font-size: 13px; font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--ink);
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    margin-bottom: 20px;
    display: flex; align-items: center; gap: 12px;
  }
  .section-title-line { flex: 1; height: 1px; background: var(--border); }
  .section-title.accent { color: var(--rose); }

  /* Progress objective */
  .obj-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 40px; }
  .obj-row {
    display: grid;
    grid-template-columns: 140px 1fr 160px 110px;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
  }
  @media (max-width: 720px) {
    .obj-row { grid-template-columns: 1fr 1fr; gap: 8px 16px; }
    .obj-row .obj-label { grid-column: 1 / -1; }
    .obj-row .obj-bar { grid-column: 1 / -1; }
  }
  .obj-label { font-size: 14px; font-weight: 500; }
  .obj-bar {
    height: 8px; background: var(--border);
    border-radius: 4px; overflow: hidden; position: relative;
  }
  .obj-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width .8s cubic-bezier(.16, 1, .3, 1);
  }
  .obj-bar-fill.ok    { background: var(--ok); }
  .obj-bar-fill.warn  { background: var(--warn); }
  .obj-bar-fill.danger{ background: var(--danger); }
  .obj-numbers {
    text-align: right; font-size: 13px;
    color: var(--ink-2); font-variant-numeric: tabular-nums;
  }
  .obj-status {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
  }
  .obj-status.ok    { background: var(--ok-soft); color: var(--ok); }
  .obj-status.warn  { background: var(--warn-soft); color: var(--warn); }
  .obj-status.danger{ background: var(--danger-soft); color: var(--danger); }

  /* Layouts */
  .two-col {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
    margin-bottom: 40px;
  }
  .three-col {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
    margin-bottom: 40px;
  }
  @media (max-width: 900px) {
    .two-col { grid-template-columns: 1fr; }
    .three-col { grid-template-columns: 1fr; }
  }

  .panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 24px;
  }
  .panel-title {
    font-family: var(--font-display);
    font-size: 16px; font-weight: 500;
    letter-spacing: -0.015em;
    margin-bottom: 16px;
  }

  /* Doughnut */
  .doughnut-wrap { display: flex; align-items: center; gap: 24px; }
  .doughnut-svg { flex-shrink: 0; }
  .doughnut-legend { display: flex; flex-direction: column; gap: 12px; flex: 1; }
  .legend-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .legend-left { display: flex; align-items: center; gap: 8px; }
  .legend-dot { width: 10px; height: 10px; border-radius: 2px; }
  .legend-label { font-size: 13px; }
  .legend-value {
    font-family: var(--font-display);
    font-size: 16px; font-weight: 500;
    font-variant-numeric: tabular-nums;
  }

  /* Bars */
  .bars-list { display: flex; flex-direction: column; gap: 10px; }
  .bar-row {
    display: grid;
    grid-template-columns: 90px 1fr 80px;
    align-items: center;
    gap: 12px;
    font-size: 13px;
  }
  .bar-track {
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
  }
  .bar-fill {
    height: 100%;
    background: var(--ink);
    border-radius: 5px;
    transition: width .8s cubic-bezier(.16, 1, .3, 1);
  }
  .bar-row.muted .bar-fill { background: var(--ink-3); }
  .bar-row .bar-fill.ok { background: var(--ok); }
  .bar-row .bar-fill.warn { background: var(--warn); }
  .bar-row .bar-fill.danger { background: var(--danger); }
  .bar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

  /* Heatmap */
  .heatmap {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
  }
  .heat-day-h {
    text-align: center;
    font-size: 10px; font-weight: 600;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 4px;
  }
  .heat-cell {
    aspect-ratio: 1;
    border-radius: 4px;
    background: var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; color: var(--ink-2);
    transition: transform .15s;
    cursor: default;
  }
  .heat-cell:hover { transform: scale(1.1); z-index: 2; box-shadow: var(--shadow-sm); }
  .heat-cell.empty { background: transparent; }

  /* Heatmap legend */
  .heatmap-legend {
    margin-top: 20px;
    display: flex; align-items: center; gap: 12px;
    font-size: 12px; color: var(--ink-2);
  }
  .heatmap-gradient {
    flex: 0 0 200px;
    height: 10px;
    border-radius: 3px;
    background: linear-gradient(to right,
      rgba(26,26,46,0.05) 0%,
      rgba(26,26,46,0.25) 25%,
      rgba(26,26,46,0.5) 60%,
      rgba(26,26,46,0.95) 100%);
  }
  .heatmap-legend-labels {
    display: flex; gap: 8px;
    font-variant-numeric: tabular-nums;
  }
  .heatmap-legend-labels span:nth-child(2) { color: var(--ink-3); }

  /* Insights */
  .insights-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 40px;
  }
  @media (max-width: 900px) { .insights-grid { grid-template-columns: 1fr; } }
  .insight-card {
    border-radius: var(--r-md);
    padding: 18px 20px;
    border-left: 3px solid;
  }
  .insight-card.warn   { background: var(--warn-soft);   border-color: var(--warn); }
  .insight-card.ok     { background: var(--ok-soft);     border-color: var(--ok); }
  .insight-card.alert  { background: var(--danger-soft); border-color: var(--danger); }
  .insight-card.high   { background: var(--rose-soft);   border-color: var(--rose); }
  .insight-card.info   { background: var(--info-soft);   border-color: var(--info); }
  .insight-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
  .insight-body { font-size: 13px; line-height: 1.5; color: var(--ink); }
  .insight-card.warn .insight-title  { color: #8a4a13; }
  .insight-card.ok .insight-title    { color: var(--ok); }
  .insight-card.alert .insight-title { color: var(--danger); }
  .insight-card.high .insight-title  { color: var(--rose); }
  .insight-card.info .insight-title  { color: var(--info); }

  /* Priorities */
  .priorities-list {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
    margin-bottom: 40px;
  }
  @media (max-width: 720px) { .priorities-list { grid-template-columns: 1fr; } }
  .priority {
    display: flex; gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 16px 20px;
    transition: all .2s;
  }
  .priority:hover { border-color: var(--ink); transform: translateX(2px); }
  .priority-num {
    flex-shrink: 0;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--ink); color: white;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-size: 14px; font-weight: 500;
  }
  .priority-text { font-size: 13px; line-height: 1.5; align-self: center; }

  /* Tables */
  .data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    font-size: 13px;
    margin-bottom: 40px;
  }
  .data-table th {
    text-align: left;
    padding: 14px 16px;
    background: var(--ink); color: white;
    font-weight: 500; font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
  .data-table th.num, .data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
  .data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }
  .data-table tr:last-child td { border-bottom: none; }
  .data-table tr:hover td { background: var(--hover); }
  .data-table tr.total td { background: var(--ink); color: white; font-weight: 600; }
  .pct-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600; font-size: 11px;
    font-variant-numeric: tabular-nums;
  }
  .pct-chip.ok { background: var(--ok-soft); color: var(--ok); }
  .pct-chip.warn { background: var(--warn-soft); color: var(--warn); }
  .pct-chip.danger { background: var(--danger-soft); color: var(--danger); }
  .pct-chip.info { background: var(--info-soft); color: var(--info); }

  /* Line chart */
  .line-chart-wrap { padding: 8px 0; }
  .line-chart-svg { width: 100%; height: 200px; }
  .line-chart-tooltip {
    position: absolute;
    background: var(--ink); color: white;
    padding: 6px 10px; border-radius: var(--r-sm);
    font-size: 12px; pointer-events: none;
    opacity: 0; transition: opacity .15s;
    white-space: nowrap; z-index: 10;
  }
  .line-chart-tooltip.show { opacity: 1; }

  /* Footer */
  footer {
    text-align: center;
    padding: 32px 16px 48px;
    color: var(--ink-3);
    font-size: 12px;
    border-top: 1px solid var(--border);
    margin-top: 48px;
  }

  /* Status overall on accueil */
  .status-overall {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
  }
  .status-overall.ok { background: var(--ok-soft); color: var(--ok); }
  .status-overall.warn { background: var(--warn-soft); color: var(--warn); }


/* ── 21. LOGIN ───────────────────────────────────── (Phase 2) */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 36px 32px;
}
.login-brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-size: 18px; font-weight: 500;
  font-style: italic;
  letter-spacing: -0.01em;
  margin-bottom: 28px;
  color: var(--ink);
}
.login-card h1 {
  font-size: 28px;
  margin-bottom: 6px;
}
.login-card .lead {
  font-size: 14px;
  margin-top: 0;
  margin-bottom: 24px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.login-field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.login-field input {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--ink);
  transition: border-color .15s, background .15s;
}
.login-field input:focus {
  outline: none;
  border-color: var(--ink);
  background: var(--surface);
}
.login-button {
  margin-top: 6px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: white;
  font-size: 14px; font-weight: 600;
  letter-spacing: 0.01em;
  transition: background .15s, transform .05s;
}
.login-button:hover { background: #2A2A40; }
.login-button:active { transform: translateY(1px); }
.login-button[disabled] { opacity: 0.5; cursor: not-allowed; }
.login-error {
  margin-top: 4px;
  padding: 10px 14px;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--r-md);
  font-size: 13px;
  display: none;
}
.login-error.visible { display: block; }

/* ── 22. ANTI-FLASH AUTH (Phase 2) ───────────────── */
.auth-loading {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  color: var(--ink-2);
  font-size: 14px;
  z-index: 9999;
}
.auth-loading::before {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--ink);
  border-radius: 50%;
  margin-right: 10px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.page-content { display: none; }
body.ready .auth-loading { display: none; }
body.ready .page-content { display: block; }

/* ── 23. TOPBAR + LOGOUT (Phase 2) ───────────────── */
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.logout-button {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  transition: background .15s, color .15s;
}
.logout-button:hover { background: rgba(255, 255, 255, 0.1); color: white; }

/* ── 24. UTILITAIRES (referenc. sample) ──────────── */
@media (max-width: 720px) {
  .hide-mobile { display: none; }
}

/* ── 25. ETATS TRANSITOIRES (Phase 2) ────────────── */
.grid-loading {
  grid-column: 1 / -1;
  padding: 32px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
}

/* ── 26. TABLE SCROLL WRAPPER (Phase 2) ───────────────────────────────────
   Wrappe les .data-table : assure un scroll horizontal proprement contenu
   dans la card et affiche des ombres "indicateur de scroll" subtiles aux
   bords gauche/droite UNIQUEMENT quand il reste du contenu hors vue.
   Mecanisme : 2 backgrounds "masques" (couleur surface, attachement local)
   collent au contenu, 2 backgrounds "ombres" (rgba sombre, attachement
   scroll) restent fixes. Quand pas de scroll, masques et ombres coincident
   -> rien de visible. Quand scroll, masques bougent -> ombres apparaissent.
*/
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 40px;
  background:
    linear-gradient(to right, var(--surface) 30%, rgba(255, 255, 255, 0)) left center,
    linear-gradient(to left, var(--surface) 30%, rgba(255, 255, 255, 0)) right center,
    radial-gradient(farthest-side at 0 50%, rgba(26, 26, 46, 0.18), rgba(0, 0, 0, 0)) left center,
    radial-gradient(farthest-side at 100% 50%, rgba(26, 26, 46, 0.18), rgba(0, 0, 0, 0)) right center,
    var(--surface);
  background-repeat: no-repeat;
  background-size: 30px 100%, 30px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
.table-scroll .data-table {
  border: none;
  border-radius: 0;
  margin-bottom: 0;
  background: transparent;
}

/* ── 27. RESPONSIVE TABLE COLUMNS (Phase 2) ──────────────────────────────
   Cacher des colonnes en fonction de la largeur d'ecran pour eviter le
   scroll horizontal forced sur les tableaux les plus larges.
   Indices nth-child : voir l'ordre des <th> dans dashboard.js.
*/
@media (max-width: 1100px) {
  /* Masse table : retirer Primes (4) et H.Supp (5) sur ecran moyen */
  #masse-table th:nth-child(4),
  #masse-table th:nth-child(5),
  #masse-table td:nth-child(4),
  #masse-table td:nth-child(5) {
    display: none;
  }
}

@media (max-width: 720px) {
  /* Masse mobile : garder uniquement Salarie (1), Cout global (7), %CoutCAHT (9).
     Cacher Poste (2), Brut (3), Charges (6), CA HT total (8).
     Primes (4) et H.Supp (5) sont deja cachees par la regle 1100px. */
  #masse-table th:nth-child(2),
  #masse-table th:nth-child(3),
  #masse-table th:nth-child(6),
  #masse-table th:nth-child(8),
  #masse-table td:nth-child(2),
  #masse-table td:nth-child(3),
  #masse-table td:nth-child(6),
  #masse-table td:nth-child(8) {
    display: none;
  }

  /* Jour mobile : garder Date (1), Visites (2), CA TTC (3), Panier (6).
     Cacher Services HT (4), Produits HT (5), Remises (7). */
  #jour-table th:nth-child(4),
  #jour-table th:nth-child(5),
  #jour-table th:nth-child(7),
  #jour-table td:nth-child(4),
  #jour-table td:nth-child(5),
  #jour-table td:nth-child(7) {
    display: none;
  }

  /* Top clients mobile : garder Client (1), Visites (2), CA TTC (3).
     Cacher Services (4), Produits (5). */
  #clients-table th:nth-child(4),
  #clients-table th:nth-child(5),
  #clients-table td:nth-child(4),
  #clients-table td:nth-child(5) {
    display: none;
  }
}

/* ── 28. PATCH iOS SAFARI — onglets dashboard (Phase 2 mobile bugfix) ─────
   Sans `touch-action: pan-x`, le scroll vertical de la page sur iOS
   intercepte le swipe horizontal des onglets : impossible de glisser la
   barre sans faire descendre la page. `pan-x` force le navigateur a
   reserver les gestes horizontaux a l'element. `overscroll-behavior-x:
   contain` empeche le rebond horizontal de "fuiter" sur la page.
   Sur ≤720px, la barre devient sticky pour rester accessible quand on
   scrolle dans un onglet long (table jour 26 lignes, etc.). */
.tabs {
  touch-action: pan-x;
  overscroll-behavior-x: contain;
}

@media (max-width: 720px) {
  .tabs {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg);
    /* Le shadow remplace la border-bottom quand on est colle (separation
       visuelle quand le contenu de l'onglet passe dessous) */
    box-shadow: 0 1px 0 var(--border);
    border-bottom: none;
    /* Etend la barre jusqu'aux bords de l'ecran (pour eviter une bande
       de bg visible sur les cotes a cause du padding du .container) */
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
}
