:root {
	--bg: #0f1216;
	--surface: #181c22;
	--surface-2: #212731;
	--border: #2b323d;
	--text: #e6e9ee;
	--muted: #8b95a3;
	--accent: #5b9dff;
	--ok: #35c46b;
	--off: #6b7280;
	--warn: #f5b03e;
	--danger: #ef4b4b;
	--radius: 10px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif;
}

* { box-sizing: border-box; }

/* The [hidden] attribute must beat display:flex rules below. */
[hidden] { display: none !important; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	-webkit-font-smoothing: antialiased;
}

.brand { font-weight: 700; letter-spacing: 0.5px; }
.muted { color: var(--muted); font-size: 0.85rem; }

/* ---------- Login ---------- */
.login-overlay {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: radial-gradient(circle at 50% 30%, #1a2029, var(--bg));
}
.login-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 2.5rem;
	width: min(360px, 90vw);
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.login-card .brand { font-size: 1.8rem; margin: 0; text-align: center; }
.login-sub { color: var(--muted); text-align: center; margin: 0 0 1.2rem; font-size: 0.85rem; }
.login-card label { font-size: 0.8rem; color: var(--muted); }
.login-error { color: var(--danger); font-size: 0.85rem; text-align: center; margin: 0.3rem 0 0; }

input {
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 8px;
	color: var(--text);
	padding: 0.7rem 0.8rem;
	font-size: 0.95rem;
	width: 100%;
}
input:focus { outline: none; border-color: var(--accent); }

button {
	cursor: pointer;
	border: none;
	border-radius: 8px;
	font-size: 0.9rem;
	font-weight: 600;
	padding: 0.7rem 1rem;
	transition: filter 0.15s, background 0.15s;
}
button:hover:not(:disabled) { filter: brightness(1.1); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.login-card button { background: var(--accent); color: #fff; margin-top: 0.8rem; }

.btn-ghost {
	background: transparent;
	color: var(--muted);
	border: 1px solid var(--border);
	padding: 0.45rem 0.7rem;
	font-weight: 500;
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-primary { background: var(--accent); color: #fff; }

/* ---------- Dropdown (Compte) ---------- */
.dropdown { position: relative; }
.caret { font-size: 0.7rem; }
.dropdown-menu {
	position: absolute;
	right: 0;
	top: calc(100% + 6px);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 10px;
	min-width: 200px;
	padding: 0.4rem;
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
	z-index: 20;
}
.dropdown-user {
	padding: 0.5rem 0.7rem;
	font-weight: 600;
	font-size: 0.85rem;
	border-bottom: 1px solid var(--border);
	margin-bottom: 0.2rem;
}
.dropdown-item {
	background: transparent;
	color: var(--text);
	text-align: left;
	padding: 0.55rem 0.7rem;
	font-weight: 500;
	border-radius: 6px;
}
.dropdown-item:hover { background: var(--surface-2); }

/* ---------- Topbar ---------- */
.topbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.9rem 1.4rem;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	position: sticky;
	top: 0;
	z-index: 10;
	flex-wrap: wrap;
	gap: 0.6rem;
}
.topbar-brand { display: flex; align-items: baseline; gap: 0.7rem; }
.topbar-brand .brand { font-size: 1.2rem; }
.topbar-sub { color: var(--muted); font-size: 0.85rem; }
.topbar-status { display: flex; align-items: center; gap: 0.8rem; }
.summary { font-weight: 600; font-size: 0.9rem; }

/* ---------- Grid ---------- */
main { padding: 1.4rem; max-width: 1400px; margin: 0 auto; }
.grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 1rem;
}
.empty { text-align: center; color: var(--muted); margin-top: 4rem; }

/* ---------- Card ---------- */
.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1.1rem;
	display: flex;
	flex-direction: column;
	gap: 0.8rem;
}
.card.offline { opacity: 0.65; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; }
.card-host { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.off { background: var(--off); }
.badge { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; padding: 0.2rem 0.5rem; border-radius: 20px; }
.badge.on { background: rgba(53, 196, 107, 0.15); color: var(--ok); }
.badge.off { background: rgba(107, 114, 128, 0.2); color: var(--off); }
.card-meta { font-size: 0.78rem; color: var(--muted); margin-top: 0.1rem; }

.metrics { display: flex; flex-direction: column; gap: 0.6rem; }
.metric-row { display: flex; justify-content: space-between; font-size: 0.82rem; }
.metric-row .label { color: var(--muted); }
.metric-row .value { font-variant-numeric: tabular-nums; }
.metric-row .value.alert { color: var(--danger); font-weight: 700; }

.bar { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar > span.warn { background: var(--warn); }
.bar > span.crit { background: var(--danger); }

.errors {
	background: rgba(245, 176, 62, 0.1);
	border: 1px solid rgba(245, 176, 62, 0.3);
	border-radius: 8px;
	padding: 0.5rem 0.7rem;
	font-size: 0.78rem;
	color: var(--warn);
}
.errors ul { margin: 0.3rem 0 0; padding-left: 1rem; }

/* ---------- App inventory ---------- */
.apps { border-top: 1px solid var(--border); padding-top: 0.7rem; }
.apps-head {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.8rem;
	font-weight: 600;
	margin-bottom: 0.4rem;
}
.apps-updates {
	margin-left: auto;
	font-size: 0.68rem;
	font-weight: 700;
	text-transform: uppercase;
	color: var(--warn);
	background: rgba(245, 176, 62, 0.12);
	padding: 0.15rem 0.45rem;
	border-radius: 20px;
}
.app-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.app-item {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 0.5rem;
	font-size: 0.8rem;
}
.app-name { color: var(--text); }
.app-ok { color: var(--muted); font-variant-numeric: tabular-nums; }
.app-update {
	color: var(--warn);
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

.card-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.5rem; }
.card-foot button { width: 100%; font-size: 0.82rem; padding: 0.55rem; }

/* ---------- Selection (group update) ---------- */
.card-head-left { display: flex; align-items: flex-start; gap: 0.6rem; }
.select-machine {
	width: 16px;
	height: 16px;
	margin-top: 0.2rem;
	accent-color: var(--accent);
	cursor: pointer;
	flex-shrink: 0;
}
.selection-bar {
	position: fixed;
	bottom: 1.2rem;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 0.7rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 0.6rem 1rem;
	box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
	z-index: 30;
	font-size: 0.88rem;
	flex-wrap: wrap;
	justify-content: center;
	max-width: 95vw;
}
#selection-count { font-weight: 600; }

.modal-title-neutral { color: var(--text) !important; }
.update-list {
	margin: 0;
	padding-left: 1.2rem;
	font-size: 0.88rem;
	line-height: 1.6;
	max-height: 180px;
	overflow-y: auto;
}

/* ---------- Modal ---------- */
.modal-overlay {
	position: fixed; inset: 0;
	background: rgba(0, 0, 0, 0.6);
	display: flex; align-items: center; justify-content: center;
	z-index: 50; padding: 1rem;
}
.modal {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1.8rem;
	width: min(440px, 95vw);
	display: flex; flex-direction: column; gap: 0.9rem;
}
.modal h2 { margin: 0; font-size: 1.15rem; color: var(--danger); }
#pw-modal h2 { color: var(--text); } /* password change isn't a danger action */
#pw-modal label { font-size: 0.8rem; color: var(--muted); }
.modal p { margin: 0; font-size: 0.9rem; line-height: 1.5; }
.modal-instruction code, .modal code {
	background: var(--surface-2); padding: 0.1rem 0.4rem; border-radius: 4px;
	font-size: 0.85rem; color: var(--accent);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.4rem; }

/* ---------- Reset options (soft / hard) ---------- */
.reset-option {
	display: flex;
	gap: 0.6rem;
	align-items: flex-start;
	padding: 0.7rem 0.8rem;
	border: 1px solid var(--border);
	border-radius: 8px;
	cursor: pointer;
}
.reset-option:has(input:checked) { border-color: var(--accent); background: var(--surface-2); }
.reset-option input { width: auto; margin-top: 0.15rem; accent-color: var(--accent); flex-shrink: 0; }
.reset-option-title { font-weight: 600; font-size: 0.9rem; }
.reset-option-desc { font-size: 0.8rem; color: var(--muted); line-height: 1.4; margin-top: 0.15rem; }

/* ---------- Toast ---------- */
.toast {
	position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
	background: var(--surface-2); border: 1px solid var(--border);
	color: var(--text); padding: 0.7rem 1.2rem; border-radius: 8px;
	font-size: 0.88rem; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); }
