@font-face { font-family: "Quicksand"; src: url("../fonts/Quicksand-Regular-4zWyAXs.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Quicksand"; src: url("../fonts/Quicksand-Medium-F5O8RF4.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Quicksand"; src: url("../fonts/Quicksand-SemiBold-rbvIoDU.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Quicksand"; src: url("../fonts/Quicksand-Bold-SfZH26L.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* Charte Chronovet (cvetheme, contexte back-office) : rose principal, bleu secondaire, Quicksand. */
:root {
    color-scheme: light;
    --cvet-primary: #cd479b; --cvet-primary-light: #fce4f4; --cvet-secondary: #1c6586; --cvet-secondary-dark: #0f4257;
    --page: #f4f6f7; --surface: #fff; --surface-2: #e8f1f5;
    --ink: #1a1a1a; --ink-2: #4a4a5e; --muted: #6b6b85;
    --grid: #eef0f2; --axis: #d3d8db; --ring: #e4e7ea;
    --s1: #cd479b; --s2: #2a78d6; --s3: #eda100; --s4: #1baf7a;
    --up: #2e7d32; --down: #c62828;
    --accent: var(--cvet-primary);
    --radius: 14px; --gap: 20px; --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06); --spark: #94a3b8;
    font-family: "Quicksand", system-ui, sans-serif;
}
/* Mode sombre : suit le système (auto) sauf choix explicite, ou forcé par data-theme="dark". */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --page: #0f1418; --surface: #171d22; --surface-2: #1f2a31;
        --ink: #eef1f3; --ink-2: #c3ccd2; --muted: #8c99a3;
        --grid: #222b33; --axis: #33414b; --ring: #26313a; --spark: #64748b; --shadow: none;
        --s1: #d95aa8; --s2: #3987e5; --s3: #c98500; --s4: #199e70;
        --up: #4caf50; --down: #ef5350;
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --page: #0f1418; --surface: #171d22; --surface-2: #1f2a31;
    --ink: #eef1f3; --ink-2: #c3ccd2; --muted: #8c99a3;
    --grid: #222b33; --axis: #33414b; --ring: #26313a; --spark: #64748b; --shadow: none;
    --s1: #d95aa8; --s2: #3987e5; --s3: #c98500; --s4: #199e70;
    --up: #4caf50; --down: #ef5350;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }

/* Cadre */
.app { display: grid; grid-template-columns: 248px 1fr; align-items: start; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px; padding: 18px 14px; background: linear-gradient(180deg, var(--cvet-secondary) 0%, var(--cvet-secondary-dark) 100%); color: #fff; }
.brand { display: flex; align-items: center; justify-content: center; padding: 12px 14px; border-radius: 10px; background: #fff; }
.brand img { display: block; width: 100%; max-width: 170px; height: auto; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-title { padding: 0 10px 6px; color: rgba(255, 255, 255, .55); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: rgba(255, 255, 255, .8); font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a.active { background: rgba(255, 255, 255, .14); color: #fff; font-weight: 700; box-shadow: inset 3px 0 0 var(--cvet-primary); }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cvet-primary); }
.account { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 12px 10px 0; border-top: 1px solid rgba(255, 255, 255, .14); font-size: 12px; color: rgba(255, 255, 255, .65); overflow-wrap: anywhere; }
.account a { color: #fff; font-weight: 600; }
.account a:hover { color: var(--cvet-primary-light); }
/* Interrupteur de thème : trois positions, une pastille glisse sous l'option active */
.theme-switch { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; margin-bottom: 8px; border-radius: 999px; background: rgba(0, 0, 0, .22); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
.theme-switch::before { content: ""; position: absolute; top: 3px; left: 3px; width: calc((100% - 6px) / 3); height: 28px; border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transform: translateX(calc(var(--theme-index, 2) * 100%)); transition: transform .2s ease; }
.theme-switch button { position: relative; display: grid; place-items: center; height: 28px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: rgba(255, 255, 255, .7); cursor: pointer; transition: color .2s ease; }
.theme-switch button:hover { color: #fff; }
.theme-switch button:focus-visible { outline: 2px solid var(--cvet-primary); outline-offset: 1px; }
.theme-switch button[aria-pressed="true"] { color: var(--cvet-secondary); }

.content { display: flex; flex-direction: column; gap: var(--gap); padding: 0 32px 48px; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 0 -32px; padding: 20px 32px 16px; background: color-mix(in srgb, var(--page) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid transparent; }
.topbar h1 { margin: 0; font-size: 22px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.subtitle { color: var(--muted); font-size: 12px; }

/* Filtres */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--ring); box-shadow: var(--shadow); }
.segmented a { padding: 6px 14px; border-radius: 999px; color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.segmented a:hover { color: var(--ink); }
.segmented-divider { align-self: center; width: 1px; height: 18px; margin: 0 4px; background: var(--ring); }
.segmented a.active { background: var(--cvet-secondary); color: #fff; font-weight: 600; }
.range { display: inline-flex; align-items: center; gap: 6px; padding: 3px 3px 3px 14px; border-radius: 999px; border: 1px solid var(--ring); background: var(--surface); box-shadow: var(--shadow); }
.range input { border: 0; background: transparent; font-size: 13px; }
.range button { padding: 6px 14px; border: 0; border-radius: 999px; background: var(--cvet-primary); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; }

/* Chiffres clés : un héros, puis quatre chiffres de contexte */
.kpis { display: grid; grid-template-columns: minmax(360px, 2fr) repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.tile { gap: 4px; }
.tile-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.tile-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.tile-unit { margin: 0 2px; color: var(--muted); font-size: 16px; font-weight: 600; }
.tile-foot { margin-top: auto; color: var(--muted); font-size: 12px; }
.delta { font-size: 12px; font-weight: 700; color: var(--muted); }
.delta.good { color: var(--up); }
.delta.bad { color: var(--down); }
.delta span { color: var(--muted); font-weight: 500; }
.muted-delta { font-weight: 500; }
.spark { height: 40px; margin-top: auto; }
.hero { gap: 14px; background: linear-gradient(160deg, var(--surface) 55%, color-mix(in srgb, var(--cvet-primary) 7%, var(--surface))); }
.hero-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; }
.hero-value { font-size: 52px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.stack { display: flex; gap: 2px; height: 10px; }
.stack span { border-radius: 5px; }
.breakdown { display: flex; flex-direction: column; gap: 6px; margin: 0; font-size: 13px; }
.breakdown div { display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; }
.breakdown dt { color: var(--ink-2); }
.breakdown dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.breakdown i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; }

/* Cartes */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: stretch; gap: var(--gap); }
.card { display: flex; flex-direction: column; gap: 16px; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--ring); box-shadow: var(--shadow); min-width: 0; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; } .span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.card-head h2 { display: flex; align-items: baseline; gap: 10px; margin: 0; font-size: 15px; font-weight: 700; }
.head-figure { color: var(--muted); font-size: 12px; font-weight: 500; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--ink-2); font-size: 12px; }
.legend i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; vertical-align: 0; }
.chart { position: relative; }
.h-280 { height: 280px; } .h-220 { height: 220px; }

/* Phrases de synthèse et encadré */
.insight { display: flex; flex-direction: column; gap: 2px; margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.55; }
.chart.grow { flex: 1; }
.insight b { color: var(--ink); }
.callout { flex-direction: row; align-items: center; gap: 20px; border-left: 4px solid var(--cvet-primary); }
.callout p { display: flex; flex-direction: column; gap: 2px; margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.55; }
.callout b { color: var(--ink); }
.callout-figure { color: var(--cvet-primary); font-size: 34px; font-weight: 700; white-space: nowrap; }

/* Tableaux */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 0 0 10px; color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; border-bottom: 1px solid var(--grid); }
td { padding: 10px 0; border-bottom: 1px solid var(--grid); }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
tr:last-child td { border-bottom: 0; }
.muted-cell { color: var(--muted); }
table.compact td { padding: 6px 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.split { display: flex; gap: 2px; width: 120px; height: 8px; margin-left: auto; }
.more summary { color: var(--cvet-secondary); font-size: 13px; font-weight: 600; cursor: pointer; }
.more table { margin-top: 8px; table-layout: fixed; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .more summary { color: var(--ink-2); } }
:root[data-theme="dark"] .more summary { color: var(--ink-2); }
.split span { border-radius: 4px; }
.empty { padding: 40px 0; color: var(--muted); text-align: center; }
.c1 { background: var(--s1); } .c2 { background: var(--s2); } .c3 { background: var(--s3); } .c4 { background: var(--s4); }

/* Connexion : reprend la page de connexion du back-office Chronovet */
.login { display: grid; place-items: center; min-height: 100vh; padding: 32px 16px; background:
    radial-gradient(ellipse 70% 55% at 80% 100%, rgba(205, 71, 155, .20), transparent 70%),
    radial-gradient(ellipse 60% 50% at 10% 0%, rgba(202, 222, 230, .16), transparent 70%),
    linear-gradient(135deg, #1c6586 0%, #17567a 50%, #0f4257 100%); }
.login-stack { display: flex; flex-direction: column; gap: 20px; width: 100%; max-width: 420px; }
.login-logo { display: flex; align-items: center; justify-content: center; min-height: 96px; padding: 20px 32px; border-radius: 14px; background: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.login-logo img { width: 260px; height: auto; }
.login-box { display: flex; flex-direction: column; gap: 18px; padding: 34px 32px 30px; border-radius: 14px; background: #fff; color: #1a1a1a; box-shadow: 0 18px 50px rgba(0, 0, 0, .22); }
.login-box h1 { margin: 0; color: #1c6586; font-size: 19px; font-weight: 700; text-align: center; }
.login-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { color: #6b6b85; font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.field input { height: 46px; padding: 0 14px; border: 1px solid #d3d8db; border-radius: 8px; background: #fff; color: #1a1a1a; font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.field input:focus { outline: none; border-color: #1c6586; box-shadow: 0 0 0 3px rgba(28, 101, 134, .18); }
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; height: 46px; padding: 0 16px; border-radius: 8px; border: 1px solid #d3d8db; background: #fff; color: #1a1a1a; font-weight: 600; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.btn:hover { border-color: #1c6586; box-shadow: 0 0 0 3px rgba(28, 101, 134, .18); }
.btn-primary { border-color: #cd479b; background: #cd479b; color: #fff; }
.btn-primary:hover { border-color: #b2428d; background: #b2428d; box-shadow: 0 0 0 3px rgba(205, 71, 155, .25); }
.btn-ghost { border-style: dashed; color: #6b6b85; font-weight: 500; }
.alert { padding: 10px 12px; border-radius: 8px; background: #ffebee; color: #c62828; font-size: 13px; text-align: center; }

@media (max-width: 1280px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .hero { grid-column: span 2; } }
@media (max-width: 1024px) {
    .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; }
}
@media (max-width: 760px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 12px 16px; }
    .nav, .account { display: none; }
    .content { padding: 16px; }
    .kpis { grid-template-columns: 1fr; } .hero { grid-column: auto; }
    .topbar { margin: 0 -16px; padding: 16px; }
}
