/* ===========================================================================
   Cloud osk - feuille partagee (hub + page de connexion).

   Couleurs de serie validees contre leur surface reelle :
   #2563eb sur #ffffff et #3987e5 sur #16181d passent la bande de luminosite,
   le plancher de chroma et le contraste >= 3:1. Le bleu d'interface #5b9bff
   (mode sombre) sert aux liens et boutons, jamais aux traces.
   =========================================================================== */

:root {
	color-scheme: light;
	--page: #f6f7f9;
	--surface: #ffffff;
	--text: #111827;
	--muted: #6b7280;
	--border: #e4e7ec;
	--grid: #eceef1;
	--accent: #2563eb;
	--accent-hover: #1d4ed8;
	--accent-soft: #eff4ff;
	--on-accent: #ffffff;
	--series: #2563eb;
	--series-fill: rgba(37, 99, 235, .12);
	--good: #0ca30c;
	--warning-ink: #8a6000;
	--critical: #d03b3b;
	--critical-soft: #fdf2f2;
	--shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
	--shadow-lg: 0 4px 6px -2px rgba(16,24,40,.03), 0 12px 16px -4px rgba(16,24,40,.08);
	--ring: rgba(37, 99, 235, .18);
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		color-scheme: dark;
		--page: #0f1115;
		--surface: #16181d;
		--text: #e6e8ec;
		--muted: #9aa1ad;
		--border: #272b33;
		--grid: #21242b;
		--accent: #5b9bff;
		--accent-hover: #7fb2ff;
		--accent-soft: #16202f;
		--on-accent: #0b1220;
		--series: #3987e5;
		--series-fill: rgba(57, 135, 229, .16);
		--warning-ink: #fab219;
		--critical-soft: #2a1618;
		--shadow: 0 1px 2px rgba(0,0,0,.4);
		--shadow-lg: 0 12px 24px -8px rgba(0,0,0,.55);
		--ring: rgba(91, 155, 255, .28);
	}
}

:root[data-theme="dark"] {
	color-scheme: dark;
	--page: #0f1115;
	--surface: #16181d;
	--text: #e6e8ec;
	--muted: #9aa1ad;
	--border: #272b33;
	--grid: #21242b;
	--accent: #5b9bff;
	--accent-hover: #7fb2ff;
	--accent-soft: #16202f;
	--on-accent: #0b1220;
	--series: #3987e5;
	--series-fill: rgba(57, 135, 229, .16);
	--warning-ink: #fab219;
	--critical-soft: #2a1618;
	--shadow: 0 1px 2px rgba(0,0,0,.4);
	--shadow-lg: 0 12px 24px -8px rgba(0,0,0,.55);
	--ring: rgba(91, 155, 255, .28);
}

* { box-sizing: border-box; }

body {
	margin: 0;
	min-height: 100vh;
	background: var(--page);
	color: var(--text);
	font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	-webkit-font-smoothing: antialiased;
	letter-spacing: -.005em;
}

/* ============================ page de connexion ========================== */
body.login { display: flex; align-items: center; justify-content: center; padding: 24px; }

.card {
	width: 100%; max-width: 380px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	box-shadow: var(--shadow-lg);
	padding: 32px 28px 26px;
}

.card .brand { text-align: center; margin-bottom: 22px; }
.card .brand img { width: 52px; height: 52px; display: block; margin: 0 auto 12px; }
.card .brand h1 { margin: 0; font-size: 1.4rem; font-weight: 650; letter-spacing: -.025em; }
.card .brand p { margin: 4px 0 0; color: var(--muted); font-size: .85rem; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 5px; }

.field input {
	width: 100%; padding: 10px 12px;
	background: var(--surface); color: var(--text);
	border: 1px solid var(--border); border-radius: 9px;
	font: inherit; font-size: .94rem;
	transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--ring);
}

button.primary {
	width: 100%; margin-top: 6px; padding: 11px 14px;
	background: var(--accent); color: var(--on-accent);
	border: 1px solid var(--accent); border-radius: 9px;
	font: inherit; font-size: .94rem; font-weight: 600; cursor: pointer;
	transition: background-color .15s ease, border-color .15s ease;
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.error {
	display: flex; align-items: center; gap: 8px;
	margin-bottom: 16px; padding: 10px 12px;
	background: var(--critical-soft);
	border: 1px solid var(--critical); border-radius: 9px;
	color: var(--critical); font-size: .84rem;
}
.error svg { width: 15px; height: 15px; flex: none; }
[hidden] { display: none !important; }

.card footer { margin-top: 18px; text-align: center; color: var(--muted); font-size: .76rem; }
.lock { display: inline-flex; align-items: center; gap: 5px; }
.lock svg { width: 12px; height: 12px; }

/* ================================= hub =================================== */
body.hub { padding: 28px 20px 40px; }
.wrap { width: 100%; max-width: 880px; margin: 0 auto; }

.top { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.top img { width: 40px; height: 40px; }
.top h1 { margin: 0; font-size: 1.28rem; font-weight: 650; letter-spacing: -.025em; }
.top .sub { margin: 1px 0 0; color: var(--muted); font-size: .84rem; }
.top .spacer { flex: 1; }

.badge {
	display: inline-flex; align-items: center; gap: 6px;
	padding: 5px 11px; border-radius: 999px;
	background: var(--surface); border: 1px solid var(--border);
	font-size: .78rem; color: var(--muted); white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); flex: none; }

.logout {
	padding: 6px 12px; border-radius: 999px;
	background: var(--surface); border: 1px solid var(--border);
	color: var(--muted); font: inherit; font-size: .78rem; cursor: pointer;
	transition: border-color .15s ease, color .15s ease;
}
.logout:hover { border-color: var(--accent); color: var(--accent); }
.logout:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 26px; }

.tile {
	background: var(--surface); border: 1px solid var(--border);
	border-radius: 12px; box-shadow: var(--shadow);
	padding: 14px 15px 12px; min-width: 0;
}
.tile .lbl {
	display: flex; align-items: center; justify-content: space-between; gap: 8px;
	color: var(--muted); font-size: .76rem; font-weight: 600;
	text-transform: uppercase; letter-spacing: .045em;
}
.tile .val { margin-top: 5px; font-size: 1.62rem; font-weight: 650; letter-spacing: -.03em; line-height: 1.1; }
.tile .val small { font-size: .96rem; font-weight: 550; color: var(--muted); margin-left: 2px; letter-spacing: 0; }
.tile .note { color: var(--muted); font-size: .78rem; margin-top: 1px; min-height: 1.2em; }

/* Statut : toujours icone + libelle, jamais la couleur seule. */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 600; letter-spacing: 0; text-transform: none; }
.chip svg { width: 12px; height: 12px; flex: none; }
.chip.good { color: var(--good); }
.chip.warning { color: var(--warning-ink); }
.chip.critical { color: var(--critical); }

.spark { position: relative; margin-top: 8px; height: 46px; }
.spark svg { display: block; width: 100%; height: 46px; overflow: hidden; }
.spark .hit { position: absolute; inset: 0; cursor: crosshair; }

.tip {
	position: absolute; z-index: 5; pointer-events: none;
	background: var(--surface); color: var(--text);
	border: 1px solid var(--border); border-radius: 8px;
	box-shadow: var(--shadow-lg);
	padding: 5px 9px; font-size: .76rem; white-space: nowrap;
	transform: translate(-50%, -114%); opacity: 0; transition: opacity .1s ease;
}
.tip .t { color: var(--muted); }

/* Jauge : forme juste pour un ratio contre une limite. */
.meter { margin-top: 14px; height: 46px; display: flex; flex-direction: column; justify-content: center; gap: 7px; }
.meter .track { height: 8px; border-radius: 999px; background: var(--grid); overflow: hidden; }
.meter .fill { height: 100%; border-radius: 999px; background: var(--series); min-width: 3px; transition: width .4s ease; }
.meter .scale { display: flex; justify-content: space-between; color: var(--muted); font-size: .7rem; font-variant-numeric: tabular-nums; }

h2 { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .045em; color: var(--muted); margin: 0 0 10px; }
nav { display: flex; flex-direction: column; gap: 10px; }

a.link {
	display: flex; align-items: center; gap: 14px;
	padding: 15px 17px;
	background: var(--surface); border: 1px solid var(--border);
	border-radius: 12px; box-shadow: var(--shadow);
	color: inherit; text-decoration: none;
	transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
a.link:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
a.link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.ico svg { width: 20px; height: 20px; }
.txt { flex: 1; min-width: 0; }
.txt strong { display: block; font-weight: 600; font-size: .96rem; }
.txt span { display: block; color: var(--muted); font-size: .84rem; margin-top: 1px; }
.chev { flex: none; color: var(--muted); }
a.link:hover .chev { color: var(--accent); }

details { margin-top: 20px; }
summary { cursor: pointer; color: var(--muted); font-size: .8rem; width: max-content; }
summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .8rem; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }

body.hub > .wrap > footer { margin-top: 26px; text-align: center; color: var(--muted); font-size: .76rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
