/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --ink: #0a1f0d;
  --muted: #4a7c59;
  --line: #bbf7d0;
  --soft: #f0fdf4;
  --panel: #ffffff;
  --accent: #16a34a;
  --accent-strong: #15803d;
  --accent-glow: rgba(22,163,74,0.12);
  --nav-active-bar: #4ade80;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: #fef3c7;
}

/* ── Mode sombre ─────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  color-scheme: dark;
  --ink: #dcfce7;
  --muted: #6bbf7a;
  --line: #14532d;
  --soft: #0d2818;
  --panel: #102014;
  --accent: #4ade80;
  --accent-strong: #86efac;
  --accent-glow: rgba(74,222,128,0.15);
  --nav-active-bar: #86efac;
}
[data-theme="dark"] body { background: linear-gradient(135deg,rgba(22,163,74,.1),transparent 34%),linear-gradient(315deg,rgba(21,128,61,.08),transparent 40%),#040d06; }
[data-theme="dark"] .sidebar { background: #060d08; border-right-color: rgba(255,255,255,.04); }
[data-theme="dark"] .topbar { background: #091a0c; border-bottom-color: var(--line); }
[data-theme="dark"] .panel, [data-theme="dark"] .app-card { background: var(--panel); }
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] select { background: var(--soft); color: var(--ink); border-color: var(--line); }
[data-theme="dark"] h1,[data-theme="dark"] h2,[data-theme="dark"] h3,[data-theme="dark"] h4,
[data-theme="dark"] strong,[data-theme="dark"] label { color: var(--ink); }
[data-theme="dark"] .stat-card { background: var(--panel); border-color: var(--line); }

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh;
  color: var(--ink);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  background:
    linear-gradient(135deg, rgba(22,163,74,.14), transparent 34%),
    linear-gradient(315deg, rgba(74,222,128,.10), transparent 40%),
    #f0fdf4;
  display: grid;
  grid-template-columns: 256px minmax(0,1fr);
}
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
h1,h2,h3,p { margin-top: 0; }

/* ── Login ───────────────────────────────────────────────────────────────── */
body.login-page {
  display: grid; place-items: center; padding: 24px;
  background: linear-gradient(135deg,rgba(22,163,74,.12),transparent 40%),#f0fdf4;
  min-height: 100vh;
}
.login-panel {
  width: min(420px,100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 32px; display: grid; gap: 16px;
  box-shadow: 0 18px 60px rgba(22,163,74,.12), 0 2px 8px rgba(22,163,74,.08);
}
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand strong { display: block; font-size: 1.05rem; }
.login-brand small { color: var(--muted); font-size: 0.75rem; }
.google-signin-button {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 11px 20px; border: 1px solid #dadce0; border-radius: 8px;
  background: var(--panel); color: #3c4043; font-size: .95rem; font-weight: 500;
  text-decoration: none; transition: background .15s, box-shadow .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.google-signin-button:hover { background: #f8f9fa; box-shadow: 0 2px 6px rgba(0,0,0,.14); }
.login-toggle { font-size: .8rem; color: var(--muted); text-decoration: underline; background: none; border: none; cursor: pointer; padding: 0; justify-self: center; }
.password-login-form { display: grid; gap: 12px; }
.password-login-form.hidden { display: none; }
.password-login-form label { display: grid; gap: 4px; font-size: .875rem; font-weight: 600; }
.danger-text { color: var(--danger); font-size: .84rem; min-height: 1.2em; }

/* ── Login overlay (within main app) ────────────────────────────────────── */
.login-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  padding: 24px; background: #f0fdf4;
}
.login-overlay.hidden { display: none; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  background: #0a1a0e;
  color: #dcfce7;
  min-height: 100vh;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  border-right: 1px solid rgba(255,255,255,.05);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; border-radius: 10px; display: block; object-fit: cover; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: .9rem; }
.brand small { color: #6bbf7a; margin-top: 2px; font-size: .73rem; }

/* ── Nav ─────────────────────────────────────────────────────────────────── */
.nav { display: grid; gap: 4px; }
.nav-separator { height: 1px; background: rgba(255,255,255,.07); margin: 4px 0; }

.nav-button {
  text-align: left; padding: 0 12px 0 14px;
  background: transparent; color: #86efac;
  display: flex; align-items: center; gap: 9px;
  font-size: .875rem; font-weight: 500;
  min-height: 40px; border-radius: 8px;
  border-left: 3px solid transparent;
  transition: background 160ms, color 160ms;
}
.nav-button svg { flex-shrink: 0; opacity: .7; transition: opacity 160ms; }
.nav-button:hover { background: rgba(255,255,255,.06); color: #dcfce7; border-left-color: rgba(74,222,128,.35); }
.nav-button:hover svg { opacity: 1; }
.nav-button.active { background: rgba(74,222,128,.12); color: #ffffff; font-weight: 600; border-left-color: var(--nav-active-bar); }
.nav-button.active svg { opacity: 1; }

/* ── Side actions ────────────────────────────────────────────────────────── */
.side-actions {
  margin-top: auto; display: grid; gap: 8px;
  padding-top: 14px; border-top: 1px solid rgba(255,255,255,.07);
}
.side-actions button { text-align: center; width: 100%; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.primary-button {
  background: var(--accent); color: white; padding: 0 16px;
  font-weight: 700; min-height: 40px; border-radius: 8px;
  box-shadow: 0 1px 3px rgba(22,163,74,.3), 0 4px 12px rgba(22,163,74,.15);
  transition: background 150ms, transform 150ms;
}
.primary-button:hover { background: var(--accent-strong); transform: translateY(-1px); }
.secondary-button {
  background: var(--soft); color: var(--accent-strong); padding: 0 16px;
  font-weight: 600; min-height: 40px; border-radius: 8px;
  border: 1px solid var(--line); transition: background 150ms;
}
.secondary-button:hover { background: var(--line); }
.ghost-button {
  background: transparent; color: var(--muted); padding: 0 14px;
  font-weight: 500; min-height: 40px; border-radius: 8px;
  transition: background 150ms, color 150ms;
}
.ghost-button:hover { background: var(--soft); color: var(--ink); }
.danger-button {
  background: var(--danger-bg); color: var(--danger); padding: 0 16px;
  font-weight: 600; min-height: 38px; border-radius: 8px;
  border: 1px solid rgba(220,38,38,.2); transition: background 150ms;
}
.danger-button:hover { background: #fecaca; }
.icon-button {
  background: transparent; color: var(--muted); padding: 6px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 150ms, color 150ms; min-height: 30px; min-width: 30px;
}
.icon-button:hover { background: var(--soft); color: var(--ink); }
.icon-button.danger:hover { background: var(--danger-bg); color: var(--danger); }
.hidden { display: none !important; }

/* ── Main shell ──────────────────────────────────────────────────────────── */
.app-shell { min-width: 0; padding: 28px; }

.topbar {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 24px;
  padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.topbar > div:first-child { min-width: 0; }
.eyebrow {
  margin: 0 0 4px; color: var(--accent); font-size: .75rem;
  text-transform: uppercase; font-weight: 800; letter-spacing: .05em;
}
h1 { margin-bottom: 0; font-size: 1.75rem; font-weight: 800; color: var(--ink); }

/* ── Views ───────────────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Panels ──────────────────────────────────────────────────────────────── */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px 24px; margin-bottom: 18px;
  box-shadow: 0 1px 4px rgba(22,163,74,.06);
}
.panel h3 { margin: 0 0 14px; font-size: 1rem; }

/* ── RGPD banner ─────────────────────────────────────────────────────────── */
.rgpd-banner {
  display: flex; align-items: center; gap: 8px;
  background: rgba(22,163,74,.07); border: 1px solid rgba(22,163,74,.18);
  border-radius: 8px; padding: 9px 14px; margin-bottom: 16px;
  font-size: .78rem; color: var(--accent-strong);
}

/* ── Import banner ───────────────────────────────────────────────────────── */
.import-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--soft); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 16px;
  font-size: .84rem; color: var(--muted);
}
.import-banner span { flex: 1; min-width: 0; }

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar label { display: grid; gap: 4px; font-size: .82rem; font-weight: 600; }

/* ── Form elements ───────────────────────────────────────────────────────── */
input, select, textarea {
  border: 1px solid var(--line); border-radius: 7px;
  padding: 8px 10px; background: var(--soft);
  color: var(--ink); width: 100%;
  transition: border-color 150ms, box-shadow 150ms;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-row label { flex: 1; min-width: 120px; display: grid; gap: 4px; font-size: .82rem; font-weight: 600; }

/* ── Stat cards ──────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(22,163,74,.06);
}
.stat-card .stat-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 800; color: var(--ink); margin-bottom: 4px; }
.stat-card .stat-sub   { font-size: .78rem; color: var(--muted); }
.stat-card.stat-positive .stat-value { color: var(--success); }
.stat-card.stat-negative .stat-value { color: var(--danger); }
.stat-card.stat-neutral  .stat-value { color: var(--accent); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table thead th {
  text-align: left; padding: 8px 12px; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); background: var(--soft);
  border-bottom: 1px solid var(--line);
}
.data-table tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--soft); }
.data-table tfoot td { padding: 10px 12px; font-weight: 700; background: var(--soft); border-top: 2px solid var(--line); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge { display: inline-block; border-radius: 20px; font-size: .72rem; font-weight: 700; padding: 2px 9px; white-space: nowrap; }
.badge-cash    { background: var(--success-bg); color: var(--success); }
.badge-check   { background: #dbeafe; color: #1d4ed8; }
.badge-paid    { background: var(--success-bg); color: var(--success); }
.badge-pending { background: var(--warn-bg); color: var(--warn); }
.badge-sortie    { background: #ede9fe; color: #5b21b6; }
.badge-spectacle { background: #fce7f3; color: #9d174d; }
.badge-cinema    { background: #fff3cd; color: #854d0e; }
.badge-autre     { background: var(--soft); color: var(--muted); border: 1px solid var(--line); }

/* ── Students list ───────────────────────────────────────────────────────── */
.student-list { display: grid; gap: 8px; margin-bottom: 16px; }
.student-item { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.student-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg,#86efac,#16a34a); color: white; display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.student-name { flex: 1; font-weight: 600; }
.empty-state { color: var(--muted); font-size: .88rem; text-align: center; padding: 24px; }

/* ── Sheet cards ─────────────────────────────────────────────────────────── */
.sheet-grid { display: grid; gap: 14px; }
.sheet-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 20px; cursor: pointer; transition: box-shadow 160ms, transform 160ms;
  display: flex; align-items: center; gap: 14px;
}
.sheet-card:hover { box-shadow: 0 4px 16px rgba(22,163,74,.12); transform: translateY(-1px); }
.sheet-card-info { flex: 1; min-width: 0; }
.sheet-card-title { font-weight: 700; font-size: .95rem; margin: 0 0 4px; }
.sheet-card-meta  { font-size: .78rem; color: var(--muted); }
.sheet-progress   { font-size: .82rem; font-weight: 600; color: var(--accent); white-space: nowrap; }

/* ── Sheet detail ────────────────────────────────────────────────────────── */
.sheet-detail-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.sheet-detail-header h3 { margin: 0; font-size: 1.1rem; }
.sheet-detail-header .sheet-meta { font-size: .82rem; color: var(--muted); margin-top: 4px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  padding: 24px; background: rgba(0,0,0,.4);
}
.modal-overlay.hidden { display: none; }
.modal-panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; width: min(480px,100%);
  display: grid; gap: 16px;
  box-shadow: 0 20px 60px rgba(22,163,74,.15);
  max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { margin: 0; font-size: 1rem; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ── Settings ────────────────────────────────────────────────────────────── */
.settings-section { margin-bottom: 12px; }
.settings-section h3 { font-size: .95rem; margin-bottom: 10px; }

/* ── Mode selector ───────────────────────────────────────────────────────── */
.mode-toggle { display: flex; gap: 8px; margin-bottom: 12px; }
.mode-btn {
  flex: 1; padding: 10px 14px; border-radius: 8px; border: 2px solid var(--line);
  background: var(--soft); color: var(--muted); font-weight: 600;
  cursor: pointer; transition: all 160ms; text-align: center;
}
.mode-btn.active { border-color: var(--accent); background: var(--accent-glow); color: var(--accent-strong); }

/* ── Acompte info box ────────────────────────────────────────────────────── */
.acompte-box {
  background: var(--accent-glow); border: 1px solid rgba(22,163,74,.25);
  border-radius: 10px; padding: 14px 18px; margin-bottom: 16px;
  display: grid; gap: 8px;
}
.acompte-row { display: flex; justify-content: space-between; align-items: center; font-size: .88rem; }
.acompte-row.total { font-weight: 800; font-size: 1rem; border-top: 1px solid rgba(22,163,74,.2); padding-top: 8px; }

/* ── CGU ─────────────────────────────────────────────────────────────────── */
.cgu-panel { max-width: 520px !important; }
.cgu-body { max-height: 300px; overflow-y: auto; font-size: .85rem; line-height: 1.7; color: var(--muted); }
.cgu-body h3 { font-size: .9rem; color: var(--ink); margin: 14px 0 6px; }
.consent-checkbox-label { display: flex; align-items: center; gap: 10px; font-size: .85rem; cursor: pointer; }

/* ── Overlay fullscreen (CGU / Auth) ─────────────────────────────────────── */
.overlay-fullscreen {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 24px;
  background: rgba(0,0,0,.52); backdrop-filter: blur(4px);
}
.overlay-fullscreen.hidden { display: none !important; }
.overlay-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 32px; width: min(480px,100%); display: grid; gap: 16px;
  box-shadow: 0 24px 80px rgba(22,163,74,.18);
  max-height: 90vh; overflow-y: auto;
}
.login-card { width: min(420px,100%); }
.cgu-text { font-size: .88rem; line-height: 1.7; color: var(--muted); }
.cgu-text ul { padding-left: 1.2em; }
.overlay-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ── App shell layout ────────────────────────────────────────────────────── */
/* body is NOT a grid — the shell contains sidebar+main */
body { display: block; }
.app-shell {
  display: grid;
  grid-template-columns: 256px minmax(0,1fr);
  grid-template-areas: "sidebar main";
  min-height: 100vh;
}
.app-shell.hidden { display: none !important; }
.sidebar { grid-area: sidebar; min-height: 100vh; }
.main-content { grid-area: main; padding: 28px; min-width: 0; }

/* Mobile header / pill nav → hidden on desktop */
.mobile-header { display: none; }
.mobile-nav { display: none; }

/* ── Sidebar brand + nav (aliases) ──────────────────────────────────────── */
.sidebar-brand { display: flex; align-items: center; gap: 12px; }
.sidebar-brand strong { display: block; font-size: .9rem; color: #dcfce7; }
.sidebar-brand small { color: #6bbf7a; font-size: .73rem; }
.sidebar-nav { display: grid; gap: 4px; flex: 1; }
.sidebar-actions {
  margin-top: auto; display: flex; flex-direction: column; gap: 8px;
  padding-top: 14px; border-top: 1px solid rgba(255,255,255,.07);
}
.nav-btn {
  text-align: left; padding: 0 12px 0 14px;
  background: transparent; color: #86efac;
  display: flex; align-items: center; gap: 9px;
  font-size: .875rem; font-weight: 500;
  min-height: 40px; border-radius: 8px;
  border-left: 3px solid transparent;
  border: 0; cursor: pointer;
  transition: background 160ms, color 160ms;
}
.nav-btn svg { flex-shrink: 0; opacity: .7; transition: opacity 160ms; }
.nav-btn:hover { background: rgba(255,255,255,.06); color: #dcfce7; border-left-color: rgba(74,222,128,.35); }
.nav-btn.active { background: rgba(74,222,128,.12); color: #ffffff; font-weight: 600; border-left: 3px solid var(--nav-active-bar); }
.nav-btn.active svg { opacity: 1; }
.side-action-btn {
  background: rgba(255,255,255,.07); color: #86efac; border: 0; cursor: pointer;
  padding: 7px 10px; border-radius: 7px; font-size: .8rem;
  display: flex; align-items: center; gap: 6px; width: 100%; justify-content: center;
  transition: background 150ms, color 150ms;
}
.side-action-btn:hover { background: rgba(255,255,255,.12); color: #dcfce7; }

/* ── Mobile header + pill nav ────────────────────────────────────────────── */
.mobile-header {
  position: sticky; top: 0; z-index: 30;
  background: #0a1a0e; padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.mobile-brand { display: flex; align-items: center; gap: 8px; color: #dcfce7; font-weight: 700; font-size: .95rem; }
.mobile-header-actions { display: flex; gap: 8px; }
.mobile-nav {
  position: sticky; top: 48px; z-index: 29;
  background: #0a1a0e; border-bottom: 1px solid rgba(255,255,255,.06);
  padding: 6px 12px 8px;
}
.pill-nav-scroll {
  display: flex; gap: 6px; overflow-x: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.pill-nav-scroll::-webkit-scrollbar { display: none; }
.pill-btn {
  flex: 0 0 auto; white-space: nowrap; border: 0; cursor: pointer;
  background: rgba(255,255,255,.07); color: #86efac;
  border-radius: 999px; padding: 6px 14px; font-size: .82rem; font-weight: 500;
  transition: background 150ms, color 150ms;
}
.pill-btn.active { background: rgba(74,222,128,.18); color: #4ade80; font-weight: 700; }
.pill-btn:hover { background: rgba(255,255,255,.12); color: #dcfce7; }

/* ── Icon button ─────────────────────────────────────────────────────────── */
.icon-btn {
  background: transparent; color: var(--muted); padding: 5px 7px;
  border: 0; cursor: pointer; border-radius: 6px; font-size: .9rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 150ms, color 150ms; min-height: 28px; min-width: 28px;
}
.icon-btn:hover { background: var(--soft); color: var(--ink); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ── View header ─────────────────────────────────────────────────────────── */
.view-header {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.view-header h1 { margin: 0; font-size: 1.75rem; font-weight: 800; flex: 1; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Section blocks ──────────────────────────────────────────────────────── */
.section-block { margin-bottom: 24px; }
.section-title { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }

/* ── Dashboard ops ───────────────────────────────────────────────────────── */
.recent-ops { display: grid; gap: 4px; }
.recent-op-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: 8px; font-size: .88rem;
  background: var(--panel); border: 1px solid var(--line);
}
.op-date { color: var(--muted); font-size: .8rem; white-space: nowrap; min-width: 70px; }
.op-label { flex: 1; font-weight: 500; }
.op-amount { font-weight: 700; white-space: nowrap; }
.op-amount.positive { color: var(--success); }
.op-amount.negative { color: var(--danger); }
.positive { color: var(--success); }
.negative { color: var(--danger); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* ── Import bar ──────────────────────────────────────────────────────────── */
.import-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--soft); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 18px; font-size: .84rem;
}
.import-label { color: var(--muted); font-weight: 600; }

/* ── Students grid ───────────────────────────────────────────────────────── */
.students-grid {
  display: flex; flex-wrap: wrap; gap: 10px;
}
.student-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px 6px 8px;
  transition: box-shadow 150ms;
}
.student-chip:hover { box-shadow: 0 2px 8px rgba(22,163,74,.1); }
/* .student-avatar defined above */
.student-chip .student-avatar { width: 28px; height: 28px; font-size: .78rem; }
.student-chip .student-name { font-size: .88rem; font-weight: 600; }

/* ── Toolbar search/select ───────────────────────────────────────────────── */
.search-input { max-width: 240px; min-width: 140px; }
.select-input { max-width: 180px; min-width: 120px; }

/* ── Sheets grid ─────────────────────────────────────────────────────────── */
.sheets-grid { display: grid; gap: 14px; }
/* override old sheet-card to allow block layout */
.sheet-card {
  display: block; padding: 18px 20px;
}
.sheet-card-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  margin-bottom: 4px;
}
.sheet-card-header h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.sheet-card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.sheet-card-desc { font-size: .83rem; color: var(--muted); margin: 0 0 8px; }
.sheet-card-meta { display: flex; gap: 14px; font-size: .82rem; color: var(--muted); margin-bottom: 10px; }
.progress-bar { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s ease; }
.progress-label { font-size: .78rem; color: var(--muted); }
.sheet-progress { margin-bottom: 12px; }
.sheet-open-btn { margin-top: 8px; font-size: .84rem; min-height: 34px; }

/* ── Sheet detail ────────────────────────────────────────────────────────── */
.sheet-info-bar {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  background: var(--soft); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 16px; margin-bottom: 18px; font-size: .88rem; color: var(--muted);
}
.stat-inline { color: var(--ink); }
.stat-inline strong { color: var(--accent-strong); }
.sheet-totals { margin-top: 12px; }
.totals-row {
  display: flex; flex-wrap: wrap; gap: 20px;
  background: var(--soft); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 16px; font-size: .9rem;
}
.totals-row strong { color: var(--accent-strong); }
.row-paid td { background: rgba(22,163,74,.04); }
.actions-cell { white-space: nowrap; text-align: right; }

/* ── Table wrapper ───────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 16px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 24px;
  background: rgba(0,0,0,.44); backdrop-filter: blur(3px);
}
.modal-backdrop.hidden { display: none !important; }
.modal {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; width: min(480px,100%);
  box-shadow: 0 24px 80px rgba(22,163,74,.18);
  max-height: 90vh; display: flex; flex-direction: column;
}
.modal--wide { width: min(560px,100%); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0; flex-shrink: 0;
}
.modal-header h2 { margin: 0; font-size: 1.05rem; }
.modal-close {
  background: none; border: 0; cursor: pointer; font-size: 1.3rem;
  color: var(--muted); padding: 4px 8px; border-radius: 6px;
  transition: background 150ms; line-height: 1;
}
.modal-close:hover { background: var(--soft); color: var(--ink); }
.modal-body {
  padding: 16px 24px; overflow-y: auto; flex: 1;
  display: grid; gap: 12px;
}
.modal-body label { display: grid; gap: 4px; font-size: .875rem; font-weight: 600; }
.modal-body small { font-weight: 400; }
.modal-subtitle { margin: 0; font-size: .9rem; color: var(--accent-strong); font-weight: 600; }
.modal-footer {
  padding: 12px 24px 20px; display: flex; justify-content: flex-end; gap: 10px;
  border-top: 1px solid var(--line); flex-shrink: 0;
}

/* ── Expense totals ──────────────────────────────────────────────────────── */
.expense-totals { margin-top: 0; }
.acompte-balance-info {
  background: var(--accent-glow); border: 1px solid rgba(22,163,74,.2);
  border-radius: 8px; padding: 8px 12px; font-size: .88rem; font-weight: 600;
}
.acompte-row { display: flex; justify-content: space-between; align-items: center; font-size: .88rem; flex-wrap: wrap; gap: 8px; }

/* ── Settings ────────────────────────────────────────────────────────────── */
.settings-sections { display: grid; gap: 18px; max-width: 640px; }
.settings-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px 24px; display: grid; gap: 14px;
  box-shadow: 0 1px 4px rgba(22,163,74,.05);
}
.settings-card h2 { margin: 0; font-size: 1rem; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: .9rem; flex-wrap: wrap; }
.settings-row label { font-weight: 600; }
.settings-input { max-width: 240px; }
.settings-desc { font-size: .85rem; color: var(--muted); line-height: 1.6; margin: 0; }
.success-text { color: var(--success); font-size: .84rem; }
.muted-text { color: var(--muted); }

/* ── Badges extra ────────────────────────────────────────────────────────── */
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warn-bg); color: var(--warn); }
.badge-neutral { background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.badge-info    { background: #dbeafe; color: #1d4ed8; }

/* ── Stat card variants ──────────────────────────────────────────────────── */
.stat-card--accent { border-top: 3px solid var(--accent); }
.stat-card--accent .stat-value { color: var(--accent-strong); }
.stat-card--positive .stat-value { color: var(--success); }
.stat-card--negative .stat-value { color: var(--danger); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  background: var(--ink); color: var(--panel);
  padding: 12px 20px; border-radius: 10px; font-size: .88rem; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  transition: opacity .25s;
  max-width: 320px;
}
.toast--success { background: var(--success); color: white; }
.toast--error   { background: var(--danger); color: white; }
.toast--info    { background: var(--accent-strong); color: white; }
.toast.hidden   { display: none !important; }

/* ── Acompte dashboard rows ──────────────────────────────────────────────── */
.acompte-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .88rem; flex-wrap: wrap; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.acompte-row:last-child { border-bottom: none; }

/* ── Print ───────────────────────────────────────────────────────────────── */
@media print {
  body { display: block; background: white; }
  .sidebar,.topbar,.toolbar,.side-actions,.modal-overlay,.rgpd-banner,.import-banner { display: none !important; }
  .app-shell { padding: 0; }
  .view { display: block !important; }
  .view:not(.print-active) { display: none !important; }
  .data-table { font-size: 10pt; }
  .panel { box-shadow: none; border: 1px solid #ccc; }
  @page { size: A4 portrait; margin: 1.5cm; }
}

/* ── Mobile 980px ────────────────────────────────────────────────────────── */
@media (max-width: 980px) {
  body { display: block; overflow-x: hidden; }

  /* Layout : sidebar → caché, mobile-header + pill-nav → visibles */
  .app-shell { display: block; }
  .sidebar { display: none; }
  .mobile-header { display: flex; }
  .mobile-nav { display: block; }
  .main-content { padding: 14px 16px; }

  /* Vieille nav si elle existe encore */
  .nav { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-separator { display: none; }
  .nav-button { flex: 0 0 auto; white-space: nowrap; border-left: 0; border-radius: 999px; padding: 0 12px; min-height: 32px; font-size: .8rem; background: rgba(255,255,255,.06); }
  .nav-button svg { display: none; }
  .nav-button.active { background: rgba(74,222,128,.18); border-left: 0; }

  /* Vue header */
  .view-header { flex-direction: column; align-items: flex-start; }
  .view-header h1 { font-size: 1.3rem; }
  .header-actions { width: 100%; justify-content: flex-start; }

  /* Toolbar */
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .search-input, .select-input { max-width: 100%; }
  .form-row { flex-direction: column; }
  .form-row label { min-width: 0; width: 100%; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .table-wrap, .table-wrapper { margin: 0 -4px; border-radius: 6px; }
  .panel { padding: 14px; }
  .modal { width: min(480px,94vw); }
  .import-bar { flex-direction: column; align-items: flex-start; }
  .settings-row { flex-direction: column; align-items: flex-start; }
  .settings-input { max-width: 100%; }
}

@media (max-width: 600px) {
  .mobile-header { padding: 8px 12px; }
  .stat-grid { grid-template-columns: 1fr; }
  .stat-card .stat-value { font-size: 1.3rem; }
  .data-table { font-size: .78rem; }
  .data-table thead th, .data-table tbody td { padding: 7px 8px; }
  .main-content { padding: 10px 12px; }
  .view-header h1 { font-size: 1.1rem; }
  .recent-op-row { flex-wrap: wrap; }
  .op-date { min-width: 0; }
  .totals-row { flex-direction: column; gap: 6px; }
  .sheet-info-bar { flex-direction: column; align-items: flex-start; gap: 6px; }
  .modal-header { padding: 16px 16px 0; }
  .modal-body { padding: 12px 16px; }
  .modal-footer { padding: 10px 16px 16px; }
}

/* ── Sidebar user card ───────────────────────────────────────────────────── */
.sidebar-user-card {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.07); border-radius: 10px;
  padding: 9px 12px; margin-bottom: 4px;
}
.user-dot {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg,#86efac,#16a34a);
  color: white; font-weight: 800; font-size: .85rem;
  display: grid; place-items: center;
}
.user-details { flex: 1; min-width: 0; }
.user-details span { display: block; font-size: .82rem; font-weight: 700; color: #dcfce7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-details small { font-size: .7rem; color: #6bbf7a; }
.user-logout-btn {
  background: none; border: 0; cursor: pointer; color: #6bbf7a;
  padding: 4px; border-radius: 5px; font-size: .9rem; flex-shrink: 0;
  transition: color 150ms, background 150ms;
}
.user-logout-btn:hover { color: #f87171; background: rgba(220,38,38,.15); }

/* ── Admin tab badge ─────────────────────────────────────────────────────── */
.nav-btn--admin { border-top: 1px solid rgba(255,255,255,.08); margin-top: 6px; padding-top: 6px; }
.badge-admin { background: rgba(74,222,128,.2); color: #4ade80; font-size: .68rem; padding: 1px 7px; border-radius: 20px; font-weight: 700; margin-left: auto; }

/* ── Admin view ──────────────────────────────────────────────────────────── */
.admin-grid { display: grid; gap: 18px; max-width: 720px; }
.admin-user-row { display: flex; align-items: center; gap: 14px; }
.admin-user-avatar { width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(135deg,#86efac,#16a34a); color: white; font-weight: 800; font-size: 1.3rem; display: grid; place-items: center; flex-shrink: 0; }
.admin-user-info strong { display: block; font-size: 1rem; }
.admin-user-info small { color: var(--muted); font-size: .84rem; }
.linked-apps { display: flex; flex-wrap: wrap; gap: 10px; }
.app-link { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--accent-strong); font-weight: 600; font-size: .9rem; transition: background 150ms, box-shadow 150ms; }
.app-link:hover { background: var(--line); box-shadow: 0 2px 8px rgba(22,163,74,.1); }

/* ── Mobile connexion pill ───────────────────────────────────────────────── */
.pill-btn--connexion { background: rgba(74,222,128,.15); color: #4ade80 !important; font-weight: 700; }
