/* Compta — compta.dujardin.me
 *
 * Sobre, sans police ni image tierce. Chaque teinte est déclarée en
 * light-dark(clair, sombre) : color-scheme vaut « light dark », le système
 * tranche, et les éléments natifs (champs, barres de défilement, sélecteur de
 * date) suivent sans une ligne de plus.
 */

:root {
	color-scheme: light dark;

	--fond: light-dark(#fff, #0b0b0d);
	--laterale: light-dark(#f4f4f7, #000);
	--surface: light-dark(#f1f1f5, #17181c);
	--surface-haute: light-dark(#e6e6ee, #212328);
	--bordure: light-dark(#e1e1e9, #2a2c33);
	--survol: light-dark(#eaeaf1, #131418);
	--texte: light-dark(#16171a, #f2f3f5);
	--texte-doux: light-dark(#3b3f47, #c8ccd3);
	--discret: light-dark(#62687a, #9096a0);

	--accent: light-dark(#0f766e, #5eead4);
	--accent-texte: light-dark(#fff, #0b0b0d);
	--accent-voile: light-dark(rgba(15, 118, 110, .10), rgba(94, 234, 212, .12));

	--entree: light-dark(#0f7a52, #5ddba0);
	--sortie: light-dark(#16171a, #f2f3f5);
	--erreur: light-dark(#c0272d, #ff6b6b);
	--etoile: light-dark(#b7791f, #f2c14e);

	/* Les courbes de comptes : huit teintes, espacées de clarté pour survivre au daltonisme. */
	--c0: light-dark(#0f766e, #5eead4);
	--c1: light-dark(#2563eb, #7da9ff);
	--c2: light-dark(#7b2cbf, #c589f2);
	--c3: light-dark(#c2410c, #fb923c);
	--c4: light-dark(#be185d, #f472b6);
	--c5: light-dark(#4d7c0f, #a3e635);
	--c6: light-dark(#0e7490, #67e8f9);
	--c7: light-dark(#92400e, #fcd34d);

	--ombre: light-dark(rgba(0, 0, 0, .12), rgba(0, 0, 0, .45));
	--voile-fond: light-dark(rgba(0, 0, 0, .35), rgba(0, 0, 0, .6));
	--rayon: 8px;
	--largeur-laterale: 232px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
	margin: 0;
	background: var(--fond);
	color: var(--texte);
	font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	-webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.25; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
code { font: .9em ui-monospace, Menlo, Consolas, monospace; background: var(--surface); padding: .1em .35em; border-radius: 4px; }
[hidden] { display: none !important; }

.hors-ecran {
	position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
	overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.icone {
	width: 20px; height: 20px; flex: none;
	fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* --- Le cadre ------------------------------------------------------------ */

.cadre { display: flex; min-height: 100%; }

.laterale {
	width: var(--largeur-laterale); flex: none;
	background: var(--laterale); border-right: 1px solid var(--bordure);
	display: flex; flex-direction: column; padding: 14px 10px;
	position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
}

.marque { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 650; }
.logo { width: 28px; height: 28px; display: inline-flex; }
.logo svg { width: 100%; height: 100%; }
.logo-fond { fill: var(--accent); }
.logo-trace { fill: none; stroke: var(--accent-texte); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.menu { display: flex; flex-direction: column; gap: 2px; }
.menu-titre { margin: 16px 10px 4px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--discret); }
.menu-item {
	display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--rayon);
	color: var(--texte-doux); background: none; border: 0; width: 100%; text-align: left; cursor: pointer;
}
.menu-item small { color: var(--discret); }
.menu-item:hover { background: var(--survol); color: var(--texte); }
.menu-item[aria-current="page"] { background: var(--accent-voile); color: var(--accent); font-weight: 600; }
.pied { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 2px; }
.pied form { margin: 0; }

.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.barre {
	display: flex; align-items: center; gap: 12px; padding: 12px 24px;
	border-bottom: 1px solid var(--bordure); position: sticky; top: 0; background: var(--fond); z-index: 5;
}
.titre-page { flex: 1; font-size: 1.2rem; }
.bouton-icone { display: none; background: none; border: 0; padding: 6px; border-radius: var(--rayon); cursor: pointer; }
.bouton-icone:hover { background: var(--survol); }

.vue { padding: 24px; max-width: 1100px; width: 100%; margin: 0 auto; }
.vue--nue { min-height: 100%; display: grid; place-items: center; padding: 16px; max-width: none; }
.voile { position: fixed; inset: 0; background: var(--voile-fond); z-index: 20; }

/* --- Boutons et champs --------------------------------------------------- */

.bouton {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	padding: 8px 14px; border-radius: var(--rayon); border: 1px solid var(--bordure);
	background: var(--surface); cursor: pointer; font-weight: 500;
}
.bouton:hover { background: var(--surface-haute); }
.bouton--accent { background: var(--accent); color: var(--accent-texte); border-color: transparent; }
.bouton--accent:hover { background: var(--accent); filter: brightness(1.08); }
.bouton--danger { color: var(--erreur); }
.bouton--petit { padding: 4px 10px; font-size: .85rem; }
.bouton:disabled { opacity: .5; cursor: not-allowed; }

.champ { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.champ > span { font-size: .82rem; color: var(--discret); }
input[type="text"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
	width: 100%; padding: 8px 10px; border-radius: var(--rayon);
	border: 1px solid var(--bordure); background: var(--fond);
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .bouton:focus-visible, .menu-item:focus-visible, button:focus-visible {
	outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { resize: vertical; min-height: 64px; }

.grille-champs { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.grille-champs .large { grid-column: 1 / -1; }
.case { display: flex; align-items: center; gap: 8px; }
.case input { width: 18px; height: 18px; accent-color: var(--accent); }

.bascule { display: inline-flex; border: 1px solid var(--bordure); border-radius: var(--rayon); overflow: hidden; }
.bascule button { border: 0; background: none; padding: 7px 14px; cursor: pointer; }
.bascule button[aria-pressed="true"] { background: var(--accent); color: var(--accent-texte); }

/* --- Cartes, listes ------------------------------------------------------ */

.carte {
	background: var(--surface); border: 1px solid var(--bordure); border-radius: 12px;
	padding: 20px; display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 380px;
}
.carte--large { max-width: 680px; }
.carte .marque { padding: 0; }
.accroche { margin: 0; color: var(--discret); }
.sous-carte { margin: 0; text-align: center; color: var(--discret); font-size: .85rem; }
.message { margin: 0; padding: 10px 12px; border-radius: var(--rayon); background: var(--surface-haute); }
.message--erreur { color: var(--erreur); }
.message--ok { color: var(--entree); }
.empreinte { word-break: break-all; }

.grille-cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tuile { background: var(--surface); border: 1px solid var(--bordure); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tuile .nom { color: var(--discret); font-size: .85rem; }
.tuile .solde { font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tuile .detail { color: var(--discret); font-size: .82rem; }
.tuile .etiquette { margin-top: 6px; }
.lien-discret { text-decoration: underline; text-underline-offset: 2px; }
.lien-discret:hover { color: var(--accent); }
.paliers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; font-size: .88rem; font-variant-numeric: tabular-nums; }
.paliers li { display: flex; justify-content: space-between; gap: 8px; }
.paliers .alerte { color: var(--erreur); }
.tuile--total { background: var(--accent-voile); border-color: transparent; }

.section { margin-top: 28px; display: flex; flex-direction: column; gap: 10px; }
.section-tete { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
form.section-tete input { flex: 1; min-width: 12rem; }

.liste { display: flex; flex-direction: column; border: 1px solid var(--bordure); border-radius: 12px; overflow: hidden; }
.ligne {
	display: grid; grid-template-columns: 5.2rem 1fr auto; gap: 4px 12px; align-items: center;
	padding: 10px 14px; border-top: 1px solid var(--bordure); background: var(--fond); text-align: left; width: 100%;
	border-left: 0; border-right: 0; border-bottom: 0; cursor: pointer;
}
.ligne:first-child { border-top: 0; }
.ligne:hover { background: var(--survol); }
.ligne--prevu { opacity: .78; font-style: italic; }
.ligne-cadre { display: flex; align-items: stretch; border-top: 1px solid var(--bordure); background: var(--fond); }
.liste > .ligne-cadre:first-child { border-top: 0; }
.ligne-cadre .ligne { border-top: 0; flex: 1; min-width: 0; }
.pointage {
	flex: none; width: 2.6rem; border: 0; background: none; cursor: pointer; color: var(--accent); font-size: 1.05rem; padding: 0;
	display: grid; place-items: center;
}
.pointage::before {
	content: ''; grid-area: 1 / 1; width: 1.15rem; height: 1.15rem; border: 2px solid var(--bordure); border-radius: 50%;
}
.pointage[aria-pressed="true"]::before { border-color: var(--accent); background: var(--accent-voile); }
.pointage[aria-pressed="true"]::after { content: '✓'; grid-area: 1 / 1; font-size: .85rem; line-height: 1; }
.pointage:hover::before { border-color: var(--accent); }
.pointage:disabled { opacity: .5; cursor: progress; }
.ligne .date { color: var(--discret); font-size: .85rem; font-variant-numeric: tabular-nums; }
.ligne .corps { min-width: 0; display: flex; flex-direction: column; }
.ligne .titre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne .sous { color: var(--discret); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.etoile { color: var(--etoile); display: inline-flex; vertical-align: -3px; }
.etoile .icone { width: 16px; height: 16px; fill: currentColor; }
.marque-prevu { font-size: .72rem; border: 1px solid var(--bordure); border-radius: 999px; padding: 0 6px; margin-left: 6px; color: var(--discret); font-style: normal; }

.montant { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }
.montant--pos { color: var(--entree); }
.montant--neg { color: var(--sortie); }

.vide { color: var(--discret); text-align: center; padding: 24px 0; }
.filtres { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.pagination { display: flex; justify-content: space-between; align-items: center; color: var(--discret); }

/* --- Fiche (dialogue) ---------------------------------------------------- */

dialog {
	border: 1px solid var(--bordure); border-radius: 14px; padding: 0; background: var(--fond); color: var(--texte);
	width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 10px 40px var(--ombre);
}
dialog::backdrop { background: var(--voile-fond); }
.fiche { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.fiche-pied { display: flex; gap: 8px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.fiche-pied .droite { display: flex; gap: 8px; }

/* --- Prévisions : le graphique ------------------------------------------ */

.outils-graphe { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.outils-graphe .champ { min-width: 150px; }
.pastilles { display: flex; flex-wrap: wrap; gap: 6px; }
.pastille { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--bordure); border-radius: 999px; cursor: pointer; background: none; font-size: .85rem; }
.pastille[aria-pressed="true"] { background: var(--accent-voile); border-color: var(--accent); }
.pastille i { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }

.graphe { position: relative; border: 1px solid var(--bordure); border-radius: 12px; padding: 8px; background: var(--fond); }
.graphe svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.graphe text { fill: var(--discret); font-size: 11px; font-family: inherit; }
.graphe .grille { stroke: var(--bordure); stroke-width: 1; }
.graphe .zero { stroke: var(--discret); stroke-width: 1; stroke-dasharray: 2 3; }
.graphe .avenir { fill: var(--accent-voile); }
.graphe .aujourdhui { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4 3; }
.graphe .courbe { fill: none; stroke-width: 2; stroke-linejoin: round; }
.graphe .courbe--total { stroke: var(--accent); stroke-width: 2.6; }
.graphe .courbe--c0 { stroke: var(--c0); } .graphe .courbe--c1 { stroke: var(--c1); }
.graphe .courbe--c2 { stroke: var(--c2); } .graphe .courbe--c3 { stroke: var(--c3); }
.graphe .courbe--c4 { stroke: var(--c4); } .graphe .courbe--c5 { stroke: var(--c5); }
.graphe .courbe--c6 { stroke: var(--c6); } .graphe .courbe--c7 { stroke: var(--c7); }
.graphe .repere { stroke: var(--discret); stroke-width: 1; }
.graphe .marque-etoile { fill: var(--etoile); stroke: var(--fond); stroke-width: 1.5; cursor: pointer; }
.graphe .etiquette-etoile { fill: var(--texte-doux); font-size: 11px; }
.graphe .survol-point { fill: var(--accent); stroke: var(--fond); stroke-width: 2; }
.bulle {
	position: absolute; pointer-events: none; z-index: 3; background: var(--surface-haute); border: 1px solid var(--bordure);
	border-radius: var(--rayon); padding: 6px 10px; font-size: .82rem; box-shadow: 0 4px 16px var(--ombre); max-width: 260px;
}
.bulle b { font-weight: 600; }
.resume-graphe { display: flex; gap: 20px; flex-wrap: wrap; color: var(--discret); font-size: .9rem; }

.etoiles { display: flex; flex-direction: column; gap: 4px; }

/* --- Comptes, catégories ------------------------------------------------- */

.rangee { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--bordure); }
.rangee:first-child { border-top: 0; }
.rangee .nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rangee .actions { display: flex; gap: 6px; }
.rangee--enfant { padding-left: 38px; }
.bouton-etoile { background: none; border: 0; padding: 2px 6px; border-radius: var(--rayon); cursor: pointer; font-size: 1.1rem; line-height: 1; color: var(--discret); }
.bouton-etoile:hover { background: var(--survol); }
.bouton-etoile[aria-pressed="true"] { color: var(--etoile); }
.rangee--archive { opacity: .6; }
.discret { color: var(--discret); }

/* --- Petits écrans ------------------------------------------------------- */

@media (max-width: 800px) {
	.laterale {
		position: fixed; z-index: 30; left: 0; top: 0; bottom: 0; transform: translateX(-100%);
		transition: transform .18s ease; width: min(82vw, 300px);
	}
	.laterale.ouverte { transform: none; box-shadow: 0 0 40px var(--ombre); }
	.bouton-icone { display: inline-flex; }
	.barre { padding: 10px 14px; }
	.vue { padding: 16px 14px; }
	.ligne { grid-template-columns: 1fr auto; }
	.ligne .date { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
	.laterale { transition: none; }
}
