/* Compta Assos - style compact, thèmes clair / sombre */
:root {
  --bg: #ffffff;
  --fg: #1c1f23;
  --muted: #6b7280;
  --line: #e3e6ea;
  --head: #f1f3f6;
  --panel: #f8f9fb;
  --accent: #2457c5;
  --accent-fg: #ffffff;
  --danger: #b42318;
  --ok: #16794c;
  --warn: #a15c00;
  --hover: #eef3fd;
  --sel: #e3ecfc;
  --ombre: 0 8px 28px rgba(0, 0, 0, 0.18);
  --lateral: 168px;
  color-scheme: light;
}
[data-theme="sombre"] {
  --bg: #14171a;
  --fg: #e6e8eb;
  --muted: #98a2ad;
  --line: #2a2f35;
  --head: #1c2025;
  --panel: #181b1f;
  --accent: #6c9bff;
  --accent-fg: #0b1220;
  --danger: #ff7b72;
  --ok: #4cc38a;
  --warn: #e3a008;
  --hover: #1d2638;
  --sel: #22304d;
  --ombre: 0 8px 28px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body, #racine { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 16px; margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.petit { font-size: 11.5px; }
.gros { font-size: 18px; font-weight: 600; margin: 2px 0 4px; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12.5px; }
.erreur { color: var(--danger); }
.espace { flex: 1; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Champs et boutons */
input, select, textarea, button {
  font: inherit;
  color: inherit;
}
input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 6px;
  min-height: 24px;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
input[type="checkbox"] { min-height: 0; }
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; }
textarea { width: 100%; resize: vertical; }
button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 10px;
  min-height: 24px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--hover); }
button:disabled { opacity: 0.55; cursor: default; }
button.primaire { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
button.primaire:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
button.lien { background: none; border: 0; padding: 0 4px; color: var(--accent); min-height: 0; }
button.lien:hover:not(:disabled) { background: none; text-decoration: underline; }
button.danger { color: var(--danger); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

.case { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.barre { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* Mise en page */
.app {
  display: grid;
  grid-template-columns: var(--lateral) minmax(0, 1fr);
  grid-template-rows: 34px minmax(0, 1fr);
  grid-template-areas: "entete entete" "lateral contenu";
  height: 100%;
}
.app.reduit { --lateral: 44px; }
.entete {
  grid-area: entete;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: var(--head);
  border-bottom: 1px solid var(--line);
}
.entete select { max-width: 280px; }
.marque { margin-right: 4px; }
.lateral {
  grid-area: lateral;
  display: flex;
  flex-direction: column;
  padding: 6px 4px;
  gap: 1px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: auto;
}
.lateral a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.lateral a:hover { background: var(--hover); }
.lateral a.actif { background: var(--sel); font-weight: 600; }
.lateral .court {
  display: inline-block;
  width: 22px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}
.reduit .lateral .long { display: none; }
.contenu { grid-area: contenu; overflow: auto; padding: 10px 14px; }
.centre { display: grid; place-items: center; height: 100%; padding: 16px; }

.page-tete { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.carte {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}
.connexion { width: min(340px, 100%); display: flex; flex-direction: column; gap: 8px; }
.grille-cartes { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; margin-bottom: 10px; }

/* Formulaires */
.champ { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.champ-label { font-weight: 600; font-size: 12px; }
.grille-champs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 14px; align-items: start; }
.formulaire { max-width: 980px; }
.logo { max-height: 42px; max-width: 120px; border: 1px solid var(--line); border-radius: 3px; background: #fff; }

/* Tableaux denses */
.tableau-defile { overflow: auto; max-height: calc(100vh - 150px); border: 1px solid var(--line); border-radius: 4px; }
table.dense { width: 100%; border-collapse: collapse; }
table.dense th, table.dense td { padding: 2px 6px; border-bottom: 1px solid var(--line); text-align: left; height: 22px; }
table.dense th {
  position: sticky;
  top: 0;
  background: var(--head);
  font-weight: 600;
  font-size: 12px;
  z-index: 1;
}
table.dense tbody tr:hover { background: var(--hover); }
table.dense tr.selection { background: var(--sel); }
table.dense tr.inactif td { color: var(--muted); }
table.dense td.actions { text-align: right; white-space: nowrap; }
.etiquette { display: inline-block; border: 1px solid var(--line); border-radius: 10px; padding: 0 7px; margin: 1px 4px 1px 0; font-size: 11.5px; background: var(--panel); }

.pastille { display: inline-block; border: 1px solid var(--line); border-radius: 9px; padding: 0 7px; font-size: 11px; color: var(--muted); margin-left: 4px; }
.pastille.ok { color: var(--ok); border-color: var(--ok); }
.pastille.warn { color: var(--warn); border-color: var(--warn); }

/* Modales */
.voile { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.42); display: grid; place-items: center; padding: 14px; z-index: 50; }
.modal { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--ombre); width: min(440px, 100%); max-height: 92vh; display: flex; flex-direction: column; }
.modal.large { width: min(720px, 100%); }
.modal-tete { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.modal-corps { padding: 12px; overflow: auto; }
.modal-pied { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); }

/* Menu utilisateur */
.menu-utilisateur { position: relative; }
.menu { position: absolute; right: 0; top: 28px; display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--ombre); z-index: 40; min-width: 210px; padding: 3px; }
.menu button { text-align: left; border: 0; background: none; padding: 5px 8px; }

.droits { display: flex; flex-direction: column; gap: 6px; }
.ligne-droit { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* Notifications */
.notifs { position: fixed; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 80; max-width: min(420px, 90vw); }
.notif { background: var(--fg); color: var(--bg); padding: 6px 10px; border-radius: 6px; box-shadow: var(--ombre); }
.notif.ok { background: var(--ok); color: #fff; }
.notif.erreur { background: var(--danger); color: #fff; }

@media (max-width: 760px) {
  .app { --lateral: 44px; }
  .lateral .long { display: none; }
  .marque { display: none; }
}

/* Saisie des mouvements */
.ok { color: var(--ok); }
.danger { color: var(--danger); }
.bandeau-info { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--warn); padding: 4px 10px; margin: 0 0 8px; border-radius: 4px; }
.filtres { margin: 0 0 6px; }
.cliquable { cursor: pointer; user-select: none; }
table.dense th.cliquable:hover { background: var(--hover); }
table.dense tr.detail:hover { background: none; }
table.dense tr.detail > td { background: var(--panel); padding: 2px 6px 4px; }
table.dense.interne { margin: 0; }
table.dense.interne td { border-bottom: 1px dotted var(--line); height: 20px; }
.modal:has(.editeur) { width: min(1120px, 100%); }
.editeur .entete-mouvement { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 4px; }
.editeur .champ { margin-bottom: 4px; }
.editeur .champ.grand { flex: 1; min-width: 260px; }
.editeur .champ.grand input { width: 100%; }
.piece-num { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 60px; }
table.dense.lignes td { padding: 1px 3px; }
table.dense.lignes tfoot td { border-bottom: 0; padding-top: 5px; }
.lignes input.plein, .lignes select.plein { width: 100%; min-height: 22px; padding: 1px 4px; }
.lignes input.num { text-align: right; font-variant-numeric: tabular-nums; }
.cellule-compte { white-space: nowrap; }
.cellule-compte .libelle-compte { display: inline-block; max-width: 190px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; margin-left: 4px; }
.champ-compte { position: relative; display: inline-block; }
.champ-compte input { width: 72px; padding: 1px 4px; min-height: 22px; }
input.invalide { border-color: var(--danger); }
.suggestions { position: absolute; z-index: 30; top: 100%; left: 0; margin: 0; padding: 2px; list-style: none; min-width: 340px; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; box-shadow: var(--ombre); }
.suggestions li { padding: 2px 6px; cursor: pointer; white-space: nowrap; border-radius: 3px; }
.suggestions li.actif, .suggestions li:hover { background: var(--sel); }

/* Lettrage / pointage */
.cases { width: 26px; }
table.dense tr.cochee { background: var(--sel); }
.barre-selection { position: sticky; bottom: 0; background: var(--head); border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; margin-top: 6px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tag-lettre { font-weight: 700; color: var(--accent); }
.editeur { min-height: 330px; }

/* ---- Restitutions ---- */
.titre-compte th { background: var(--panel); text-align: left; font-weight: 600; position: static; }
table.dense .total-compte td { font-weight: 600; border-top: 1px solid var(--line); }
table.dense tfoot th { background: var(--head); font-weight: 700; }
.bloc-compte + .bloc-compte .titre-compte th { border-top: 6px solid transparent; }
.etat-duo { display: grid; gap: 10px; margin-top: 6px; }
.etat-duo.cote-a-cote { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.etat .tableau-defile, .etat-duo .tableau-defile { max-height: none; }
.etat-duo table.dense .ligne-classe td, .etat-duo table.dense .niveau-0 td { font-weight: 700; }
.etat-duo table.dense .ligne-groupe td { font-weight: 600; }
.etat-duo table.dense .ligne-compte td { color: var(--muted); }
.etat-duo table.dense .ligne-resultat td { font-style: italic; }
.resultat-final { margin: 8px 0; }
.sous-titre { font-size: 14px; margin: 14px 0 4px; }

/* ---- Import / export ---- */
.deux-colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 12px; align-items: start; }
.liste-export { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.liste-export li { display: flex; gap: 10px; align-items: baseline; }
.liste-export button { min-width: 72px; }
.apercu-import { margin-top: 6px; }
.erreurs-import { max-height: 260px; margin: 4px 0 6px; }
