/* ============================================================
   base.css — Flexus Portal shared styles
   All portal pages load this. Page-specific additions go in
   their own folder CSS files.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ────────────────────────────────────────── */
:root {
	/* Backgrounds */
	--bg:       #0f1117;
	--surface:  #1a1d27;
	--surface2: #232636;
	--surface3: #2a2e42;

	/* Borders */
	--border:   #2e3347;
	--border2:  #3d4460;

	/* Accent / brand */
	--accent:   #4f8ef7;
	--accent-hover: #6ba3ff;

	/* Production bars — hue anchored to --accent (#4f8ef7 = hsl(217 91% 64%)).
	   Intensity rises with BOTH saturation and lightness: quiet buckets are
	   muted and dim, peak buckets vivid and bright. "peak" keeps the native
	   64% lightness; lower grades step down so they read clearly darker. */
	--bar-h: 217;
	--bar-l-low:    40%;
	--bar-l-normal: 50%;
	--bar-l-high:   58%;
	--bar-l-peak:   64%;
	--bar-s-low:    28%;
	--bar-s-normal: 55%;
	--bar-s-high:   78%;
	--bar-s-peak:   100%;
	/* Zero-value bars: same hue as the production bars but very low saturation
	   and a lightness just above the card background, so empty buckets read as a
	   faint blue-grey in the same colour family rather than a neutral grey. */
	--bar-zero: hsl(var(--bar-h) 15% 30%);

	/* Semantic colours */
	--green:    #3ecf8e;
	--amber:    #f5a623;
	--red:      #e85d5d;
	--purple:   #a78bfa;
	--cyan:     #22d3ee;

	/* Typography */
	--text:     #e2e6f0;
	--muted:    #9aa0b8;
	--mono:     'JetBrains Mono', 'Cascadia Code', 'Consolas', 'Courier New', monospace;
	--sans:     'Inter', system-ui, sans-serif;

	/* Layout */
	--radius:   10px;
	--radius-sm: 6px;
	--gap:      20px;
	--header-h: 52px;

	/* Per-app card accent colours (landing page + header badges) */
	--clr-display:   #3ecf8e;
	--clr-dashboard: #4f8ef7;
	--clr-terminal:  #3ecf8e;
	--clr-logviewer: #f5a623;
	--clr-errorlog:  #a78bfa;
	--clr-balelog:   #34d399;
	--clr-rut956:    #22d3ee;
	--clr-docs:      #f472b6;
	--clr-system:    #fb923c;
	--clr-backup:    #e879f9;
	--clr-nodered:   #ef4444;
}

/* ── High-contrast mode ───────────────────────────────────── */
body.hc {
	--bg:       #080a10;
	--surface:  #13161f;
	--surface2: #1c1f2e;
	--surface3: #252840;
	--border:   #3d4460;
	--border2:  #555d80;
	--accent:   #6ba3ff;
	--accent-hover: #89b8ff;

	/* Production bars in high-contrast: brighter base lightness (71%, matching
	   this theme's accent), same saturation-as-intensity axis with headroom. */
	--bar-h: 217;
	--bar-l-low:    50%;
	--bar-l-normal: 58%;
	--bar-l-high:   65%;
	--bar-l-peak:   71%;
	--bar-s-low:    40%;
	--bar-s-normal: 62%;
	--bar-s-high:   82%;
	--bar-s-peak:   100%;
	--bar-zero: hsl(var(--bar-h) 20% 38%);
	--green:    #4edd9f;
	--amber:    #fbb93a;
	--red:      #f07070;
	--text:     #f0f4ff;
	--muted:    #c2c8de;
}

/* ── Base ─────────────────────────────────────────────────── */
html {
	/* scroll-behavior: smooth; -- removed, known to cause iOS Safari freeze */
	overscroll-behavior: none;

	/* Always reserve space for the vertical scrollbar so the layout
	   doesn't shift horizontally between short (no scrollbar) and tall
	   (scrollbar) pages — e.g. switching Error Log tabs. Inert on iOS
	   Safari's overlay scrollbars; ignored by very old browsers. */
	scrollbar-gutter: stable;
}

body {
	overscroll-behavior: none; /* Belt-and-suspenders for iOS Safari bounce fix */
	overflow-x: hidden; /* No element (e.g. full-bleed header) may widen the layout viewport */
	background: var(--bg);
	color: var(--text);
	font-family: var(--sans);
	font-size: 14px;
	line-height: 1.5;
	min-height: 100vh;
	-webkit-font-smoothing: antialiased;
}

/* ── Typography ───────────────────────────────────────────── */
h1 { font-size: 1.35rem; font-weight: 700; }
h2 {
	font-size: .78rem;
	font-weight: 600;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: .08em;
	margin-bottom: 14px;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ── Page layout ──────────────────────────────────────────── */
.page-wrap {
	padding: 0 var(--gap) var(--gap);
}
.page-body {
	padding-top: var(--gap);
	max-width: 1400px;
	margin: 0 auto;
}

/* ── Site header ──────────────────────────────────────────── */
.site-header {
	position: sticky;
	top: 0;
	z-index: 400;
	height: var(--header-h);
	background: rgba(15, 17, 23, .95);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 0 var(--gap);
	/* Break out of .page-wrap padding on all sizes */
	margin-left: calc(-1 * var(--gap));
	margin-right: calc(-1 * var(--gap));
}

/* Left zone */
.header-left {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1;
	min-width: 0;
}

/* Centre zone */
.header-centre {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
}

/* Right zone */
.header-right {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-shrink: 0;
}

/* ── Header: home button ──────────────────────────────────── */
.header-home {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: var(--radius-sm);
	color: var(--muted);
	text-decoration: none;
	transition: background .15s, color .15s;
	flex-shrink: 0;
}
.header-home svg { width: 21px; height: 21px; }
.header-home:hover { background: var(--surface2); color: var(--text); }

/* ── Header: page title ───────────────────────────────────── */
.header-title {
	font-size: .9rem;
	font-weight: 600;
	color: var(--text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	min-width: 0;
	flex-shrink: 1;
}

/* ── Header: badges ───────────────────────────────────────── */
.header-badge {
	display: inline-flex;
	align-items: center;
	background: var(--surface2);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	color: var(--muted);
	font-size: .75rem;
	font-weight: 600;
	padding: 2px 9px;
	text-decoration: none;
	white-space: nowrap;
	transition: border-color .15s, color .15s;
	letter-spacing: .03em;
}
.header-badge:hover,
a.header-badge:hover { border-color: var(--accent); color: var(--text); }
.header-badge--active {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}
a.header-badge--active:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ── Header: icon buttons (cog, sign out) ─────────────────── */
.header-icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: var(--radius-sm);
	background: none;
	border: none;
	color: var(--muted);
	cursor: pointer;
	text-decoration: none;
	transition: background .15s, color .15s;
	flex-shrink: 0;
}
.header-icon-btn svg { width: 18px; height: 18px; }
.header-icon-btn:hover { background: var(--surface2); color: var(--text); }
.header-signout:hover { color: var(--red); }

/* ── Settings panel ───────────────────────────────────────── */
.header-cog-wrap {
	position: relative;
}
.settings-panel {
	position: absolute;
	top: calc(100% + 4px);
	right: 0;
	width: 240px;
	background: var(--surface2);
	border-radius: var(--radius);
	padding: 4px 0;
	box-shadow: 0 8px 32px rgba(0, 0, 0, .6);
	z-index: 400;
}
.settings-panel[hidden] { display: none; }

.settings-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 6px 14px;
}
.settings-row + .settings-row {
	border-top: 1px solid var(--border);
}

/* Dimming overlay shown behind settings panel */
.settings-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, .85);
	z-index: 390;
	cursor: default;
}
.settings-overlay[hidden] { display: none; }

/* Cog highlighted when panel is open */
#settings-toggle.is-active {
	background: var(--surface2);
	color: var(--accent);
}
.settings-row-label {
	font-size: .78rem;
	color: var(--muted);
	white-space: nowrap;
}
.settings-select {
	appearance: none;
	background: var(--surface2);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	color: var(--text);
	font-size: .78rem;
	font-family: inherit;
	padding: 3px 22px 3px 8px;
	cursor: pointer;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%237a8099'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 6px center;
	transition: border-color .2s;
}
.settings-select:hover,
.settings-select:focus { border-color: var(--accent); outline: none; }

/* ── iOS-style toggle ─────────────────────────────────────── */
.ios-toggle {
	position: relative;
	display: inline-flex;
	align-items: center;
	cursor: pointer;
	flex-shrink: 0;
}
.ios-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.ios-toggle-track {
	width: 40px;
	height: 22px;
	background: var(--surface3);
	border: 1px solid var(--border);
	border-radius: 11px;
	transition: background .2s, border-color .2s;
	position: relative;
}
.ios-toggle input:checked ~ .ios-toggle-track {
	background: var(--accent);
	border-color: var(--accent);
}
.ios-toggle-thumb {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 16px;
	height: 16px;
	background: #fff;
	border-radius: 50%;
	transition: transform .2s;
	box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.ios-toggle input:checked ~ .ios-toggle-track .ios-toggle-thumb {
	transform: translateX(18px);
}

/* ── Refresh arc widget ───────────────────────────────────── */
.refresh-widget {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	cursor: pointer;
	border-radius: 50%;
	transition: background .15s;
}
.refresh-widget:hover { background: var(--surface2); }
#refresh-arc {
	width: 22px;
	height: 22px;
	transform: rotate(-90deg);
}
.refresh-track {
	fill: none;
	stroke: var(--border);
	stroke-width: 3;
}
.refresh-fill {
	fill: none;
	stroke: var(--accent);
	stroke-width: 3;
	stroke-linecap: round;
	transition: stroke-dashoffset .5s linear;
}
.refresh-widget.spinning #refresh-arc {
	animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Refresh popover */
/* refresh-popover removed -- interval now in settings panel */

/* ── Online badge ─────────────────────────────────────────── */
.online-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 3px 10px;
	border-radius: 20px;
	font-size: .78rem;
	font-weight: 600;
	border: 1px solid;
	white-space: nowrap;
	transition: background .4s, color .4s, border-color .4s;
}
.online-badge.is-online {
	background: rgba(62, 207, 142, .12);
	color: var(--green);
	border-color: rgba(62, 207, 142, .3);
}
.online-badge.is-offline {
	background: rgba(232, 93, 93, .10);
	color: var(--red);
	border-color: rgba(232, 93, 93, .25);
}
.online-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	flex-shrink: 0;
}
.is-online .online-dot {
	background: var(--green);
	box-shadow: 0 0 5px var(--green);
	animation: pulse 2s infinite;
}
.is-offline .online-dot {
	background: var(--red);
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--red) 35%, transparent);
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ── Error pill ───────────────────────────────────────────── */
.header-err-pill {
	display: inline-flex;
	align-items: center;
	border-radius: var(--radius-sm);
	padding: 2px 9px;
	font-size: .78rem;
	font-weight: 700;
	letter-spacing: .04em;
	border: 1px solid;
	white-space: nowrap;
}
.header-err-pill.hidden { display: none; }
.header-err-pill.err-level-1 {
	background: rgba(62, 207, 142, .10);
	color: #6bbf9a;
	border-color: rgba(62, 207, 142, .25);
	animation: pill-pulse-info 2.5s ease-in-out infinite;
}
.header-err-pill.err-level-2 {
	background: rgba(245, 166, 35, .12);
	color: var(--amber);
	border-color: rgba(245, 166, 35, .3);
	animation: pill-pulse-warn 2.5s ease-in-out infinite;
}
.header-err-pill.err-level-3 {
	background: rgba(232, 93, 93, .18);
	color: var(--red);
	border-color: rgba(232, 93, 93, .4);
	animation: pill-pulse-err 2.5s ease-in-out infinite;
}
@keyframes pill-pulse-info { 0%,100%{box-shadow:none}50%{box-shadow:0 0 8px rgba(62,207,142,.4)} }
@keyframes pill-pulse-warn { 0%,100%{box-shadow:none}50%{box-shadow:0 0 8px rgba(245,166,35,.5)} }
@keyframes pill-pulse-err  { 0%,100%{box-shadow:none}50%{box-shadow:0 0 8px rgba(232,93,93,.5)} }

/* ── Session expired modal ────────────────────────────────── */
.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, .65);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
	padding: var(--gap);
}
.modal-overlay[hidden] { display: none; }
.modal-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 2rem;
	width: 100%;
	max-width: 380px;
}
.modal-card h2 {
	font-size: 1.1rem;
	font-weight: 700;
	color: var(--text);
	text-transform: none;
	letter-spacing: 0;
	margin-bottom: .5rem;
}
.modal-card p {
	color: var(--muted);
	font-size: .84rem;
	margin-bottom: 1.25rem;
}
.modal-fields { margin-bottom: 1.25rem; }
.modal-error {
	background: rgba(232,93,93,.12);
	border: 1px solid rgba(232,93,93,.3);
	border-radius: var(--radius-sm);
	color: var(--red);
	font-size: .82rem;
	padding: .5rem .75rem;
	margin-top: .75rem;
}
.modal-error[hidden] { display: none; }
.modal-actions {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
	flex-wrap: wrap;
}

/* ── Form fields ──────────────────────────────────────────── */
.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field-label {
	display: block;
	font-size: .72rem;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: .06em;
	margin-bottom: .35rem;
}
.field input,
.field select,
.field textarea {
	width: 100%;
	background: var(--surface2);
	border: 1px solid var(--border);
	border-radius: 7px;
	color: var(--text);
	font-size: .9rem;
	font-family: inherit;
	padding: .5rem .7rem;
	outline: none;
	transition: border-color .2s;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--accent); }
.field-hint {
	font-size: .72rem;
	color: var(--muted);
	margin-top: .3rem;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	border-radius: 7px;
	font-size: .85rem;
	font-weight: 600;
	font-family: inherit;
	padding: .45rem .9rem;
	cursor: pointer;
	transition: opacity .15s, background .15s;
	text-decoration: none;
	border: 1px solid transparent;
}
.btn--primary {
	background: var(--accent);
	color: #fff;
	border-color: var(--accent);
}
.btn--primary:hover { opacity: .88; }
.btn--ghost {
	background: none;
	color: var(--muted);
	border-color: var(--border);
}
.btn--ghost:hover { background: var(--surface2); color: var(--text); }
.btn--danger {
	background: rgba(232,93,93,.15);
	color: var(--red);
	border-color: rgba(232,93,93,.35);
}
.btn--danger:hover { background: rgba(232,93,93,.25); }
.btn--sm { font-size: .78rem; padding: .3rem .65rem; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 15px 16px 13px;
	margin-bottom: var(--gap);
}

/* ── Stat cards ───────────────────────────────────────────── */
.grid-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: var(--gap);
	margin-bottom: var(--gap);
}
.stat-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 13px 15px;
	text-align: center;
}
.stat-card .lbl {
	color: var(--muted);
	font-size: .7rem;
	text-transform: uppercase;
	letter-spacing: .07em;
	margin-bottom: 4px;
}
.stat-card .val {
	font-size: 1.45rem;
	font-weight: 700;
	line-height: 1.2;
}
.stat-card .val-unit {
	font-size: .78rem;
	font-weight: 600;
	color: var(--muted);
	margin-left: 2px;
}
.stat-card .sub {
	display: none;
	color: var(--muted);
	font-size: .74rem;
	margin-top: 2px;
}
.stat-card.selection-active {
	box-shadow: inset 5px 0 0 var(--green), inset -5px 0 0 var(--green);
	background: color-mix(in srgb, var(--green) 12%, var(--surface));
	border-color: var(--green);
}

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap {
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	overflow: hidden;
}
table {
	width: 100%;
	border-collapse: collapse;
	font-size: .83rem;
}
thead th {
	background: var(--surface2);
	color: var(--muted);
	text-transform: uppercase;
	font-size: .68rem;
	letter-spacing: .06em;
	padding: 8px 10px;
	text-align: left;
	position: sticky;
	top: 0;
	z-index: 2;
}
tbody tr:nth-child(even) { background: rgba(35, 38, 54, .4); }
tbody tr:hover { background: var(--border); }
tbody td { padding: 7px 10px; vertical-align: middle; }
tbody tr.row-clickable { cursor: pointer; }

/* Scrollable table container */
.table-scroll {
	max-height: 340px;
	overflow-y: auto;
	-webkit-transform: translateZ(0);
	transform: translateZ(0);
}
.table-scroll::-webkit-scrollbar { width: 5px; }
.table-scroll::-webkit-scrollbar-track { background: var(--surface); }
.table-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Error code badges ────────────────────────────────────── */
.err-code-badge {
	display: inline-block;
	border-radius: 4px;
	padding: 1px 7px;
	font-weight: 700;
	font-size: .78rem;
	white-space: nowrap;
	border: 1px solid;
}
.err-code-badge.err-level-1 {
	background: rgba(62,207,142,.10);
	color: #6bbf9a;
	border-color: rgba(62,207,142,.25);
}
.err-code-badge.err-level-2 {
	background: rgba(245,166,35,.12);
	color: var(--amber);
	border-color: rgba(245,166,35,.3);
}
.err-code-badge.err-level-3,
.err-code-badge:not([class*="err-level-"]) {
	background: rgba(232,93,93,.14);
	color: var(--red);
	border-color: rgba(232,93,93,.3);
}

/* ── Collapsible section toggles ──────────────────────────── */
.section-toggle {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: none;
	border: none;
	color: var(--muted);
	font-size: .8rem;
	font-family: inherit;
	cursor: pointer;
	padding: 5px 0;
	margin-bottom: var(--gap);
	transition: color .15s;
}
.section-toggle:hover { color: var(--text); }
.section-collapsible {
	overflow: hidden;
	max-height: 9999px;
	transition: max-height .35s ease;
}
.section-collapsible.collapsed { max-height: 0 !important; }

/* ── Flash / alert messages ───────────────────────────────── */
.flash {
	border-radius: var(--radius-sm);
	padding: .65rem .9rem;
	font-size: .84rem;
	margin-bottom: var(--gap);
}
.flash--success {
	background: rgba(62,207,142,.12);
	border: 1px solid rgba(62,207,142,.3);
	color: var(--green);
}
.flash--error {
	background: rgba(232,93,93,.12);
	border: 1px solid rgba(232,93,93,.3);
	color: var(--red);
}
.flash--info {
	background: rgba(79,142,247,.10);
	border: 1px solid rgba(79,142,247,.25);
	color: var(--accent);
}

/* ── No-data placeholder ──────────────────────────────────── */
.no-data {
	color: var(--muted);
	font-size: .84rem;
	padding: 20px;
	text-align: center;
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
	color: var(--muted);
	font-size: .72rem;
	margin-top: 28px;
	text-align: center;
	padding-bottom: 12px;
}

/* ── Tooltip ──────────────────────────────────────────────── */
#tip {
	position: fixed;
	background: var(--surface2);
	border: 1px solid var(--border);
	border-radius: 7px;
	padding: 6px 11px;
	font-size: .76rem;
	pointer-events: none;
	opacity: 0;
	transition: opacity .1s;
	z-index: 2000;
	line-height: 1.6;
	box-shadow: 0 4px 16px rgba(0,0,0,.45);
	max-width: 240px;
}
#tip .tip-date  { font-size: .7rem; color: var(--muted); display: block; }
#tip .tip-count { font-size: .95rem; font-weight: 700; color: var(--accent); }

/* ── Utility classes ──────────────────────────────────────── */
.text-muted  { color: var(--muted); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-amber  { color: var(--amber); }
.text-accent { color: var(--accent); }
.mono        { font-family: var(--mono); }
.hidden      { display: none !important; }
.sr-only {
	position: absolute;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden;
	clip: rect(0,0,0,0);
	white-space: nowrap;
	border: 0;
}

/* ── Responsive ───────────────────────────────────────────── */
/* ── Responsive show/hide helpers ──────────────────────────────── */
/* Used by machine list table to hide columns on small screens */
.show-sm-only { display: none; }
@media (max-width: 640px) {
	.hide-sm { display: none; }
	.show-sm-only { display: block; }
}
@media (max-width: 380px) {
	.hide-xs { display: none; }
}

/* ── Machine list: All button row ─────────────────────────── */
.list-all-row {
	margin-bottom: 1rem;
}
.list-all-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

@media (max-width: 640px) {
	:root { --gap: 12px; --header-h: 48px; }
	/* Solid header on mobile -- backdrop-filter is GPU-intensive on iOS */
	.site-header {
		backdrop-filter: none;
		-webkit-backdrop-filter: none;
		background: var(--bg);
		gap: 8px;
		padding: 0 10px;
		/* Full-bleed fixed header: span the true viewport edges, not the padded page-wrap */
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		/* left/right:0 already pins it to the viewport edges — cancel the base
		   negative margins so it doesn't extend *past* the edges. */
		margin-left: 0;
		margin-right: 0;
		-webkit-transform: translateZ(0);
		transform: translateZ(0);
	}
	/* Offset content so it isn't hidden under the fixed header */
	.page-wrap { padding-top: var(--header-h); }
	.header-left { gap: 8px; }
	.header-centre { gap: 8px; }
	.header-right { gap: 0px; }
	.header-icon-btn { width: 28px; height: 28px; }
	.header-icon-btn svg { width: 16px; height: 16px; }
	.header-badge { padding: 2px 6px; font-size: .72rem; }
	.header-home { width: 26px; height: 26px; }
	.header-home svg { width: 19px; height: 19px; }

	.header-title { font-size: .82rem; }
	/* Hide error pill on mobile -- space is at a premium */
	#header-err-pill { display: none !important; }

	/* (Animation-disable guard removed — the freeze was the canvas/listener
	   architecture, not CSS animations. Refresh arc, dot pulse, and err-pill
	   all animate normally on mobile again.) */
	/* On mobile: hide regular badges; keep active (machine ID) and nav (All/List) */
	.header-badge { display: none; }
	.header-badge--active { display: inline-flex; }
	.header-badge--nav { display: inline-flex; }

	/* Tighter card padding */
	.card { padding: 11px 12px 9px; }
	/* Tighter h2 margin in cards */
	.card h2 { margin-bottom: 6px; }

	/* Header online badge: dot only on mobile */
	/* Single-machine: dot only (no meaningful text) */
	#online-badge:not([data-has-count]) .online-badge-text { display: none; }
	#online-badge:not([data-has-count]) { padding: 3px 5px; gap: 0; border-radius: 50%; width: 20px; height: 20px; justify-content: center; }
	/* All-view: show n/i count, keep pill shape */
	#online-badge[data-has-count] { font-size: .72rem; font-weight: 700; }

	.grid-stats {
		grid-template-columns: repeat(2, 1fr);
	}
	.stat-card .val { font-size: 1.2rem; }

	/* Settings panel full-width on mobile */
	.settings-panel {
		position: fixed;
		top: var(--header-h);
		left: 0;
		right: 0;
		width: 100%;
		border-radius: 0 0 var(--radius) var(--radius);
	}
	/* Overlay covers from top on mobile too */
	.settings-overlay {
		top: var(--header-h);
	}
}

@media (max-width: 420px) {
	/* Keep 2 columns even on very narrow screens */
	.grid-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
	/* Crowded headers (set $headerBusy in the page) run out of room
	   sooner, so hide their title earlier than the 360px default.
	   The .site-header--busy prefix raises specificity above the plain
	   .header-title rule, so this wins wherever both apply. */
	.site-header--busy .header-title { display: none; }
}

@media (max-width: 360px) {
	/* Hide page title — machine ID badge is enough */
	.header-title { display: none; }
}
