:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f8fafc; --border: #dde3ea; --text: #1d2733; --muted: #607080;
  --accent: #1f4e79; --accent-2: #2e6da4; --accent-soft: #e6eef7; --ok: #1e7b4f; --ok-soft: #e3f4ea;
  --warn: #9a6200; --warn-soft: #fff4dc; --danger: #b42318; --danger-soft: #fdecea; --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12171d; --surface: #1a2129; --surface-2: #202832; --border: #2e3946; --text: #e4e9ef; --muted: #93a1b0;
    --accent: #6ea8dc; --accent-2: #8fbce6; --accent-soft: #1f3247; --ok: #5cc493; --ok-soft: #173327;
    --warn: #e7b453; --warn-soft: #3a2e14; --danger: #f2877c; --danger-soft: #3d1d1a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Mise en page */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: #0d2b45; color: #dbe6f2; padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.sidebar .marque { font-weight: 700; font-size: 15px; padding: 4px 10px 16px; color: #fff; line-height: 1.3; }
.sidebar .marque small { display: block; font-weight: 400; color: #9fb6cc; font-size: 12px; }
.sidebar nav a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 6px; color: #dbe6f2; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.sidebar nav a.actif { background: rgba(255,255,255,.16); color: #fff; }
.sidebar nav .sep { margin: 12px 10px 4px; font-size: 11px; text-transform: uppercase; color: #8aa3bb; letter-spacing: .06em; }
.sidebar .user { margin-top: 20px; padding: 10px; font-size: 12px; color: #9fb6cc; border-top: 1px solid rgba(255,255,255,.1); }
.main { padding: 20px 28px 60px; min-width: 0; }
.entete { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.entete .sous { color: var(--muted); font-size: 13px; margin-top: 3px; }
.menu-mobile { display: none; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 30% 0 0; z-index: 20; transform: translateX(-105%); transition: transform .2s; }
  .sidebar.ouvert { transform: none; }
  .menu-mobile { display: inline-flex; }
  .main { padding: 14px 16px 60px; }
}

/* Composants */
.carte { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.grille-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .lib { color: var(--muted); font-size: 12px; }
.kpi .val { font-size: 22px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.deux-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .deux-col { grid-template-columns: 1fr; } }

button, .btn { font: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primaire { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primaire:hover { background: var(--accent-2); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(1.08); background: var(--ok); }
.btn-danger { color: var(--danger); }
.btn-petit { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { width: auto; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 14px; }
.form .large { grid-column: span 2; }
.form .pleine { grid-column: 1 / -1; }
.check { display: flex; gap: 6px; align-items: center; color: var(--text); font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:hover { background: var(--surface-2); }
tr.cliquable { cursor: pointer; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.table-scroll { overflow-x: auto; }
tr.sous td:first-child { padding-left: 24px; color: var(--muted); }
tr.total td { font-weight: 650; border-bottom: none; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.BROUILLON { background: var(--warn-soft); color: var(--warn); }
.badge.VALIDE { background: var(--ok-soft); color: var(--ok); }
.badge.TRANSFORME { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.avalider { background: var(--warn-soft); color: var(--warn); }
.alerte { padding: 10px 12px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; }
.alerte.warn { background: var(--warn-soft); color: var(--warn); }
.alerte.erreur { background: var(--danger-soft); color: var(--danger); }
.alerte.info { background: var(--accent-soft); color: var(--accent); }

.onglets { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.onglets a { padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--muted); }
.onglets a.actif { color: var(--accent); border-color: var(--accent); }
.onglets a:hover { text-decoration: none; color: var(--text); }
.filtres { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filtres input, .filtres select { width: auto; min-width: 160px; }

/* Saisie des lignes */
.saisie { border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-bottom: 8px; background: var(--surface-2); }
.saisie .ligne1 { display: grid; grid-template-columns: 2fr 110px 2fr auto; gap: 8px; align-items: end; }
.saisie .options { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 8px; }
@media (max-width: 700px) { .saisie .ligne1 { grid-template-columns: 1fr 1fr; } }
.apercu-totaux { display: grid; grid-template-columns: auto auto; justify-content: end; gap: 4px 24px; margin-top: 10px; font-variant-numeric: tabular-nums; }
.apercu-totaux .ttc { font-weight: 700; font-size: 16px; }

/* Connexion */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.connexion .carte { width: 360px; max-width: 100%; }
.connexion h1 { margin-bottom: 4px; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: #1d2733; color: #fff; padding: 10px 14px; border-radius: 6px; box-shadow: var(--shadow); max-width: 420px; font-size: 13px; }
.toast.erreur { background: var(--danger); }
.modale-fond { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modale { background: var(--surface); border-radius: var(--radius); padding: 18px; width: 560px; max-width: 100%; max-height: 90vh; overflow: auto; }
.barre { height: 150px; display: flex; align-items: stretch; gap: 6px; padding-top: 4px; border-bottom: 1px solid var(--border); }
.barre .colonne { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.barre .baton { width: 100%; max-width: 42px; background: var(--accent); border-radius: 3px 3px 0 0; }
.barre .montant { font-size: 10px; color: var(--muted); white-space: nowrap; margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.barre-lib { display: flex; gap: 6px; font-size: 11px; color: var(--muted); }
.barre-lib span { flex: 1; text-align: center; }

/* Identité du logiciel (Escalis) */
.produit { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 8px 10px; margin-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,.12); }
.produit-nom { font-weight: 700; font-size: 17px; letter-spacing: .02em; color: #fff; }
.produit .version { font-size: 11px; background: #0f8b8d; color: #fff; padding: 2px 8px; border-radius: 10px; text-decoration: none; }
.logo-produit { width: 44px; height: 44px; border-radius: 10px; background: #0d2b45; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 22px; border-bottom: 4px solid #0f8b8d; margin-bottom: 10px; }
.pied-connexion { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); line-height: 1.5; }
.manuel { max-width: 900px; line-height: 1.6; }
.manuel h2 { margin-top: 28px; padding-top: 8px; border-top: 1px solid var(--border); }
.manuel h3 { text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); }
.manuel ol, .manuel ul { padding-left: 22px; }
.manuel .astuce { background: var(--accent-soft); border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 4px; margin: 10px 0; }
.manuel kbd { background: var(--surface-2); border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; font-size: 12px; }
.sommaire { position: sticky; top: 16px; }
.sommaire a { display: block; padding: 3px 0; }
.aide-grille { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .aide-grille { grid-template-columns: 1fr; } .sommaire { position: static; } }
@media print { .sidebar, .sommaire, .entete .actions { display: none !important; } .layout { display: block; } }
.manuel section:first-of-type h2 { margin-top: 0; padding-top: 0; border-top: 0; }

/* v0.4 — TimeSheet ligne à ligne */
.ts-lignes { width: 100%; border-collapse: collapse; font-size: .85rem; }
.ts-lignes th, .ts-lignes td { padding: 3px 4px; vertical-align: top; }
.ts-lignes input, .ts-lignes select { padding: 4px 5px; font-size: .85rem; }
.ts-lignes select { min-width: 110px; max-width: 240px; }
.ts-lignes input:not([type]) { width: 100%; min-width: 120px; }
.ts-lignes :disabled, .carte .form :disabled { background: #f1f4f8; color: #2a3340; opacity: 1; }
.ts-lignes input[type="time"] { min-width: 88px; }
.ts-lignes input[type="checkbox"] { width: auto; }
.ts-lignes .num input { text-align: right; min-width: 64px; }
.ts-lignes tr.ts-detail td { border-top: none; padding-top: 0; padding-bottom: 8px; background: var(--fond-doux, rgba(0,0,0,.025)); }
.ts-lignes tr.ts-detail textarea { width: 100%; min-height: 34px; font-family: ui-monospace, monospace; font-size: .8rem; }
@media (max-width: 720px) { .ts-lignes { font-size: .8rem; } .ts-lignes input[type="time"] { min-width: 72px; } }
