/* ═══════════════════════════════════════════════════════════
   ByCobra Gestion — thème "violet nocturne et or"
   Les couleurs sont des variables (--xxx) : change-les ici
   et tout le panel suit.
   ═══════════════════════════════════════════════════════════ */
:root {
  color-scheme: dark;
  --bg: #0f0b17;
  --surface: #17121f;
  --surface-2: #1f1830;
  --border: #2e2545;
  --text: #f1edf8;
  --text-2: #bdb3d1;
  --muted: #8a80a0;
  --gold: #e3b341;
  --gold-ink: #1a1206;
  --violet: #9b7bff;
  /* couleurs des graphiques (validées daltonisme sur fond sombre) */
  --s-ca: #c98500;
  --s-net: #9085e9;
  --s-dep: #199e70;
  --s-cotis: #d95926;
  --s-ref: #6f6787;
  --grid: #2a2240;
  /* statuts (réservés aux alertes) */
  --ok: #2fbf71;
  --info: #5b9dff;
  --warn: #f0a020;
  --danger: #ff5c5c;
  --radius: 14px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f1f9;
  --surface: #fbf9fd;
  --surface-2: #f0ebf7;
  --border: #ddd4ea;
  --text: #1b1426;
  --text-2: #4b4060;
  --muted: #776d8a;
  --gold: #b07c00;
  --gold-ink: #ffffff;
  --violet: #6250d6;
  --s-ca: #eda100;
  --s-net: #6250d6;
  --s-dep: #1baf7a;
  --s-cotis: #eb6834;
  --s-ref: #a69fb5;
  --grid: #e8e1f1;
  --ok: #138a4c;
  --info: #2a6fd6;
  --warn: #a86400;
  --danger: #c62828;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h3 { font-size: 1rem; font-weight: 600; }
a { color: var(--violet); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num, .table td.n, .kpi-value { font-variant-numeric: tabular-nums; }

/* ─── Boutons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid transparent; border-radius: 10px;
  padding: .55rem 1rem; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: filter .15s, background .15s;
}
.btn:focus-visible, input:focus-visible, select:focus-visible, nav button:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.btn-gold { background: var(--gold); color: var(--gold-ink); }
.btn-gold:hover { filter: brightness(1.08); }
.btn-outline { border-color: var(--gold); color: var(--gold); background: transparent; }
.btn-ghost { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: transparent; padding: .3rem .5rem; }
.btn-small { padding: .3rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: wait; }

/* ─── Formulaires ─── */
input, select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: .55rem .7rem;
}
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; font-size: .9rem; color: var(--text-2); }
label.check { flex-direction: row; align-items: center; gap: .6rem; }
label.check input { width: auto; }
.form { display: flex; flex-direction: column; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row > select { flex: 1; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; }
.msg { margin: 0; min-height: 1.2em; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }

/* ─── Connexion ─── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 30% 20%, rgba(155,123,255,.18), transparent 50%), var(--bg); }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 2rem; display: flex; flex-direction: column; gap: 1rem; text-align: center; }
.login-card h1 span { color: var(--gold); }
.login-logo { width: 72px; height: 72px; margin: 0 auto; }

/* ─── Mise en page ─── */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh;
  background: linear-gradient(to right, var(--surface) 240px, var(--border) 240px 241px, var(--bg) 241px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 1.2rem .9rem;
  display: flex; flex-direction: column; gap: 1.2rem; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: .7rem; align-items: center; padding: 0 .4rem; }
.brand img { width: 40px; height: 40px; }
.brand strong { display: block; font-size: 1.1rem; }
.brand small { color: var(--gold); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: .7rem; }
#nav { display: flex; flex-direction: column; gap: .2rem; }
#nav button { text-align: left; background: none; border: 0; color: var(--text-2); font: inherit;
  padding: .6rem .8rem; border-radius: 10px; cursor: pointer; }
#nav button:hover { background: var(--surface-2); color: var(--text); }
#nav button.active { background: var(--surface-2); color: var(--text); box-shadow: inset 3px 0 0 var(--gold); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: .5rem; }

.main { padding: 1.4rem clamp(16px, 3vw, 2.2rem) 3rem; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.topbar h2 { font-size: 1.5rem; }
.topbar-right { display: flex; gap: .8rem; align-items: center; }
.year { flex-direction: row; align-items: center; gap: .5rem; }
.year select { width: auto; }
.view { display: flex; flex-direction: column; gap: 1.2rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .9rem; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }

/* ─── Chiffres clés ─── */
.kpis { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .2rem; }
.kpi-label { color: var(--text-2); font-size: .85rem; }
.kpi-value { font-size: 1.6rem; font-weight: 700; }
.kpi-sub { color: var(--muted); font-size: .8rem; }
.kpi-hero { background: linear-gradient(135deg, var(--surface-2), var(--surface)); border-color: var(--gold); }
.kpi-hero .kpi-value { font-size: 2.2rem; color: var(--gold); }

/* ─── Barre "où part ton CA" ─── */
.split { display: flex; height: 22px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--surface); }
.split i { display: block; height: 100%; min-width: 2px; }
.split-legend { list-style: none; padding: 0; margin: .8rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .4rem 1rem; }
.split-legend li { display: flex; align-items: center; gap: .5rem; font-size: .88rem; color: var(--text-2); }
.split-legend li b { color: var(--text); margin-left: auto; font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* ─── Graphiques ─── */
.chart-box { position: relative; height: 260px; }
.gauges { display: flex; flex-direction: column; gap: .7rem; margin-top: 1rem; }
.gauge-top { display: flex; justify-content: space-between; font-size: .85rem; color: var(--text-2); }
.gauge-top em { color: var(--muted); font-style: normal; }
.gauge-top b { color: var(--text); font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--s-ca); border-radius: 4px; transition: width .4s; }
.bar i.warn { background: var(--warn); }
.bar i.danger { background: var(--danger); }

/* ─── Alertes ─── */
.alerts { display: flex; flex-direction: column; gap: .5rem; }
.alert { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .9rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); border-left: 4px solid var(--info); }
.alert.warn { border-left-color: var(--warn); }
.alert.danger { border-left-color: var(--danger); }

/* ─── Tableaux ─── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: .8rem; padding: .5rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); }
.table td.n, .table th.n { text-align: right; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--border); }
.empty { color: var(--muted); text-align: center; padding: 1.5rem; margin: 0; }
.pill { font-size: .78rem; padding: .2rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.err { color: var(--danger); border-color: var(--danger); }
.pill.warn { color: var(--warn); border-color: var(--warn); }

/* ─── Facture ─── */
.lignes { display: flex; flex-direction: column; gap: .6rem; }
.ligne { display: grid; grid-template-columns: 3fr 1fr 1.2fr 1.2fr auto; gap: .5rem; align-items: end; }
.total-row { font-size: 1.1rem; }
.total-row strong { color: var(--gold); }

/* ─── Toast ─── */
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--surface-2); border: 1px solid var(--border);
  padding: .7rem 1rem; border-radius: 10px; opacity: 0; transform: translateY(10px); transition: .25s; pointer-events: none; max-width: calc(100vw - 40px); }
.toast.show { opacity: 1; transform: none; }

/* ─── Mobile ─── */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); background: var(--bg); }
  .sidebar, #nav { min-width: 0; }
  .sidebar { position: static; height: auto; padding: .8rem 16px; }
  #nav { flex-direction: row; overflow-x: auto; }
  #nav button { white-space: nowrap; }
  .sidebar-foot { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot .btn { width: auto; flex: 1; }
  .main { padding: 1rem 16px 3rem; }
  .kpis { grid-template-columns: 1fr; }
  .ligne { grid-template-columns: 1fr 1fr; }
  .ligne label:first-child { grid-column: 1 / -1; }
}
