/* VITL dashboard - design tokens, layout, components, motion.
   Dark "Nordic energy" theme by default; light theme via [data-theme="light"] or OS preference. */

:root {
	color-scheme: dark;
	--bg: #0a1020;
	--bg-2: #0e1628;
	--surface: #121b2e;
	--surface-2: #182339;
	--surface-glass: rgba(18, 27, 46, 0.72);
	--border: rgba(255, 255, 255, 0.08);
	--border-strong: rgba(255, 255, 255, 0.16);
	--ink: #f2f5fa;
	--ink-2: #b7c0d1;
	--muted: #7e8aa3;
	--grid: #22304a;
	--axis: #2e3d5a;
	--accent: #3fd08f;
	--accent-ink: #062416;
	--accent-soft: rgba(63, 208, 143, 0.14);
	--nav-active: #0f6a48;
	--focus: #7cc4ff;

	/* Series (validated for the dark surface #121b2e) */
	--c-water: #3987e5;
	--c-wind: #008300;
	--c-other: #9085e9;
	--c-oil: #d95926;
	--c-green: #199e70;
	--c-brown: #d95926;
	--c-total: #b7c0d1;
	--c-actual: #f2f5fa;

	/* Status (fixed, never themed) */
	--s-good: #0ca30c;
	--s-warn: #fab219;
	--s-serious: #ec835a;
	--s-critical: #d03b3b;

	--radius: 16px;
	--radius-sm: 10px;
	--shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
	--gutter: 16px;
	--maxw: 1280px;
	--font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="light"] {
	color-scheme: light;
	--bg: #f4f6fa;
	--bg-2: #eef1f7;
	--surface: #ffffff;
	--surface-2: #f6f8fc;
	--surface-glass: rgba(255, 255, 255, 0.78);
	--border: rgba(11, 18, 32, 0.08);
	--border-strong: rgba(11, 18, 32, 0.18);
	--ink: #0b1220;
	--ink-2: #3b4658;
	--muted: #6b768a;
	--grid: #e6eaf1;
	--axis: #cfd6e2;
	--accent: #0f8a5f;
	--accent-ink: #ffffff;
	--accent-soft: rgba(15, 138, 95, 0.12);
	--nav-active: #0f6a48;
	--focus: #1d6fd6;
	--c-water: #2a78d6;
	--c-wind: #008300;
	--c-other: #4a3aa7;
	--c-oil: #eb6834;
	--c-green: #1baf7a;
	--c-brown: #eb6834;
	--c-total: #3b4658;
	--c-actual: #0b1220;
	--shadow: 0 10px 30px rgba(11, 18, 32, 0.08);
}

@media (prefers-color-scheme: light) {
	:root:not([data-theme="dark"]):not([data-theme="light"]) {
		color-scheme: light;
		--bg: #f4f6fa;
		--bg-2: #eef1f7;
		--surface: #ffffff;
		--surface-2: #f6f8fc;
		--surface-glass: rgba(255, 255, 255, 0.78);
		--border: rgba(11, 18, 32, 0.08);
		--border-strong: rgba(11, 18, 32, 0.18);
		--ink: #0b1220;
		--ink-2: #3b4658;
		--muted: #6b768a;
		--grid: #e6eaf1;
		--axis: #cfd6e2;
		--accent: #0f8a5f;
		--accent-ink: #ffffff;
		--accent-soft: rgba(15, 138, 95, 0.12);
		--nav-active: #0f6a48;
		--focus: #1d6fd6;
		--c-water: #2a78d6;
		--c-wind: #008300;
		--c-other: #4a3aa7;
		--c-oil: #eb6834;
		--c-green: #1baf7a;
		--c-brown: #eb6834;
		--c-total: #3b4658;
		--c-actual: #0b1220;
		--shadow: 0 10px 30px rgba(11, 18, 32, 0.08);
	}
}

/* ----- Base ----- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
	margin: 0;
	font-family: var(--font);
	font-size: 16px;
	line-height: 1.5;
	color: var(--ink);
	background: var(--bg);
	-webkit-font-smoothing: antialiased;
	min-height: 100vh;
	overflow-x: hidden;
}
body::before {
	/* Aurora backdrop */
	content: "";
	position: fixed;
	inset: -20vh -10vw auto -10vw;
	height: 70vh;
	pointer-events: none;
	z-index: 0;
	background:
		radial-gradient(60% 50% at 20% 20%, rgba(63, 208, 143, 0.16), transparent 70%),
		radial-gradient(50% 45% at 80% 10%, rgba(57, 135, 229, 0.16), transparent 70%),
		radial-gradient(40% 40% at 55% 60%, rgba(144, 133, 233, 0.10), transparent 70%);
	filter: blur(30px);
	animation: aurora 24s var(--ease) infinite alternate;
}
:root[data-theme="light"] body::before { opacity: 0.6; }
@keyframes aurora {
	from { transform: translate3d(0, 0, 0) scale(1); }
	to { transform: translate3d(3vw, 2vh, 0) scale(1.06); }
}

h1, h2, h3 { margin: 0 0 0.35em; line-height: 1.2; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.4rem); }
h2 { font-size: clamp(1.2rem, 1rem + 0.8vw, 1.5rem); }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75em; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.tabular { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ----- Shell ----- */

.topbar {
	position: sticky;
	top: 0;
	z-index: 20;
	backdrop-filter: blur(14px) saturate(140%);
	-webkit-backdrop-filter: blur(14px) saturate(140%);
	background: var(--surface-glass);
	border-bottom: 1px solid var(--border);
}
.topbar-inner {
	max-width: var(--maxw);
	margin: 0 auto;
	padding: 10px var(--gutter);
	padding-top: calc(10px + env(safe-area-inset-top, 0px));
	display: flex;
	align-items: center;
	gap: 14px;
}
.topbar .menu-btn, .topbar .menu-backdrop { display: none; }
.nav-icon { display: none; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; letter-spacing: 0.02em; }
.brand-mark {
	width: 34px; height: 34px; border-radius: 10px; position: relative; overflow: hidden;
	background: linear-gradient(135deg, var(--c-water), var(--accent) 60%, var(--c-other));
	box-shadow: 0 6px 18px rgba(63, 208, 143, 0.25);
}
.brand-mark::after {
	content: ""; position: absolute; inset: 0;
	background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.45) 50%, transparent 70%);
	transform: translateX(-100%);
	animation: shine 6s var(--ease) infinite;
}
@keyframes shine { 0%, 60% { transform: translateX(-100%); } 80%, 100% { transform: translateX(100%); } }
.brand-text small { display: block; font-weight: 500; font-size: 0.7rem; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }

.nav { display: flex; gap: 2px; margin-left: 6px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
	padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--ink-2); white-space: nowrap;
	font-weight: 550; font-size: 0.95rem; transition: color 0.2s, background 0.2s;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a.active { color: #ffffff; background: var(--nav-active); }
.nav a.active:hover { color: #ffffff; background: var(--nav-active); }

.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.live-wrap { display: inline-flex; align-items: center; gap: 8px; }
.pill-btn {
	border: 1px solid var(--border-strong); background: transparent; border-radius: 999px;
	padding: 6px 12px; cursor: pointer; font-size: 0.85rem; font-weight: 600; color: var(--ink-2);
	transition: background 0.2s, color 0.2s, transform 0.2s;
	display: inline-flex; align-items: center; gap: 6px;
}
.pill-btn:hover { background: var(--surface-2); color: var(--ink); }
.pill-btn:active { transform: scale(0.97); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--s-good); box-shadow: 0 0 0 0 rgba(12,163,12,0.6); animation: pulse 2.4s ease-out infinite; }
.live-dot.stale { background: var(--s-warn); animation: none; }
.live-dot.down { background: var(--s-critical); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(12,163,12,0.55); } 70% { box-shadow: 0 0 0 10px rgba(12,163,12,0); } 100% { box-shadow: 0 0 0 0 rgba(12,163,12,0); } }

main { position: relative; z-index: 1; max-width: var(--maxw); margin: 0 auto; padding: 22px var(--gutter) 60px; }
.page { animation: rise 0.5s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head p { color: var(--ink-2); max-width: 64ch; margin: 0; }

.footer { max-width: var(--maxw); margin: 0 auto; padding: 24px var(--gutter) 40px; color: var(--muted); font-size: 0.85rem; display: flex; flex-wrap: wrap; gap: 8px 20px; }

/* ----- Grid & cards ----- */

.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 12; }
.col-6 { grid-column: span 12; }
.col-4 { grid-column: span 12; }
.col-3 { grid-column: span 6; }
@media (min-width: 720px) {
	.col-6 { grid-column: span 6; }
	.col-4 { grid-column: span 6; }
	.col-3 { grid-column: span 3; }
}
@media (min-width: 1024px) {
	.col-8 { grid-column: span 8; }
	.col-4 { grid-column: span 4; }
}

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 18px;
	box-shadow: var(--shadow);
	position: relative;
	animation: rise 0.6s var(--ease) both;
	animation-delay: var(--d, 0ms);
	min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-sub { color: var(--muted); font-size: 0.875rem; margin: -4px 0 12px; }
.card.loading > :not(.skeleton) { opacity: 0.55; transition: opacity 0.3s; }

/* ----- Stat tiles ----- */

.tile { display: flex; flex-direction: column; gap: 4px; }
.tile-label { color: var(--muted); font-size: 0.85rem; display: flex; align-items: center; gap: 6px; }
.tile-value { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; display: flex; align-items: baseline; gap: 6px; }
.tile-value .unit { font-size: 0.55em; color: var(--muted); font-weight: 500; }
.tile-delta { font-size: 0.85rem; color: var(--ink-2); display: inline-flex; align-items: center; gap: 4px; }
.tile-delta.up { color: var(--s-good); }
.tile-delta.down { color: var(--s-serious); }
.tile-spark { height: 36px; margin-top: 6px; }
.tile-spark svg { width: 100%; height: 100%; display: block; overflow: visible; }

.hero-figure { font-size: clamp(3rem, 2rem + 5vw, 5.5rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.hero-figure .unit { font-size: 0.35em; color: var(--muted); font-weight: 500; margin-left: 4px; }

/* Swatch keys */
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--k, var(--muted)); vertical-align: middle; margin-right: 6px; }
.key.line { width: 16px; height: 3px; border-radius: 2px; }
.key.dashed { background: repeating-linear-gradient(90deg, var(--k) 0 4px, transparent 4px 7px); }

/* Meter */
.meter { height: 8px; border-radius: 999px; background: color-mix(in oklab, var(--k, var(--accent)) 22%, transparent); overflow: hidden; }
.meter > i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--k, var(--accent)); transition: width 1.2s var(--ease); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 0.9rem; }
.chip b { font-weight: 650; }
.chip .key { margin: 0; }

/* Status badge */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; border: 1px solid var(--border-strong); color: var(--ink-2); }
.badge[data-state="good"] { border-color: var(--s-good); color: var(--s-good); }
.badge[data-state="warn"] { border-color: var(--s-warn); color: var(--s-warn); }
.badge[data-state="serious"] { border-color: var(--s-serious); color: var(--s-serious); }
.badge[data-state="critical"] { border-color: var(--s-critical); color: var(--s-critical); }
.badge[data-state="running"] { border-color: var(--c-water); color: var(--c-water); }
.badge[data-state="running"]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Controls ----- */

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; cursor: pointer; color: var(--ink-2); font-weight: 550; font-size: 0.875rem; transition: background 0.2s, color 0.2s; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.btn { border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--ink); border-radius: var(--radius-sm); padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: 0.9rem; transition: transform 0.15s, background 0.2s, box-shadow 0.2s; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { background: var(--surface); box-shadow: var(--shadow); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
:root:not([data-theme="light"]) .btn.primary { color: #06231a; }
.btn.danger { border-color: var(--s-critical); color: var(--s-critical); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; padding: 0; justify-content: center; }

/* ----- Charts ----- */

.chart-wrap { position: relative; height: 320px; }
.chart-wrap.tall { height: 400px; }
.chart-wrap.short { height: 220px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; color: var(--ink-2); margin: 8px 0 0; padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; }
.table-wrap { overflow: auto; max-height: 420px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.data { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
table.data th, table.data td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data th:first-child, table.data td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
table.data thead th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 600; z-index: 1; }
table.data tbody tr:hover { background: var(--surface-2); }

/* ----- Hero (home) ----- */

.hero { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: stretch; }
@media (min-width: 900px) { .hero { grid-template-columns: 5fr 7fr; } }
.hero-card { overflow: hidden; }
.hero-flow { position: relative; min-height: 300px; height: 100%; }
.hero-flow canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero-flow .flow-labels { position: absolute; inset: 0; pointer-events: none; }
.flow-label { position: absolute; transform: translate(0, -50%); font-size: 0.8rem; color: var(--ink-2); display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; column-gap: 6px; row-gap: 0; white-space: nowrap; line-height: 1.25; }
.flow-label b { color: var(--ink); font-size: 0.95rem; }
.flow-label.right { transform: translate(-100%, -50%); text-align: right; }
@property --p { syntax: "<number>"; inherits: false; initial-value: 0; }
.share-ring { --p: 0; width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c-green) calc(var(--p) * 1%), color-mix(in oklab, var(--c-brown) 45%, transparent) 0); position: relative; transition: --p 1.5s; }
.share-ring::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--surface); }
.share-ring span { position: relative; font-weight: 700; font-size: 1.3rem; }

/* ----- Narrative ----- */

.story { display: grid; gap: 12px; }
@media (min-width: 720px) { .story { grid-template-columns: repeat(2, 1fr); } }
.story-item { display: flex; gap: 12px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.story-icon { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in oklab, var(--k, var(--accent)) 18%, transparent); color: var(--k, var(--accent)); }
.story-icon svg { width: 22px; height: 22px; }
.story-item h3 { font-size: 0.95rem; margin-bottom: 2px; }
.story-item p { margin: 0; color: var(--ink-2); font-size: 0.9rem; }
.callout { border-left: 3px solid var(--k, var(--s-warn)); background: color-mix(in oklab, var(--k, var(--s-warn)) 10%, transparent); padding: 10px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 0.9rem; color: var(--ink-2); }

/* ----- Weather strip ----- */

.days { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.day { padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); text-align: center; transition: transform 0.25s var(--ease), box-shadow 0.25s; }
.day:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.day .d-name { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.day .d-temp { font-size: 1.3rem; font-weight: 650; margin: 4px 0; }
.day .d-wind { color: var(--ink-2); font-size: 0.85rem; display: flex; justify-content: center; align-items: center; gap: 4px; }
.day .d-desc { color: var(--muted); font-size: 0.78rem; margin-top: 4px; min-height: 2.2em; }
.wind-arrow { display: inline-block; transition: transform 0.6s var(--ease); }

/* ----- Plants ----- */

.plant-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.plant { padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; transition: transform 0.25s var(--ease), box-shadow 0.25s; animation: rise 0.5s var(--ease) both; animation-delay: var(--d, 0ms); }
.plant:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.plant-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.plant-head h3 { font-size: 0.95rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plant-mw { font-size: 1.4rem; font-weight: 650; }
.plant-mw .unit { font-size: 0.7rem; color: var(--muted); }
.plant-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.8rem; }
.plant.offline { opacity: 0.6; }

/* ----- Ops ----- */

.pipeline { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.step { padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.step h3 { font-size: 0.95rem; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.step dl { margin: 8px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 0.85rem; }
.step dt { color: var(--muted); }
.step dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 0.9rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

/* ----- Login ----- */

.login-card { max-width: 420px; margin: 24px auto; text-align: center; }
.login-icon { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.login-form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.login-form input { font: inherit; padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--ink); }
.login-form input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.login-form .btn { justify-content: center; padding: 11px 14px; }
.login-error { margin-top: 10px; color: var(--s-critical); font-size: 0.9rem; }

/* ----- Toasts & dialogs ----- */

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface); border: 1px solid var(--border-strong); border-left: 4px solid var(--k, var(--accent)); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 0.9rem; animation: rise 0.35s var(--ease) both; max-width: min(420px, 90vw); }
dialog.modal { border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); border-radius: var(--radius); padding: 22px; max-width: min(480px, 92vw); box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(3, 6, 14, 0.6); backdrop-filter: blur(4px); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ----- Skeleton & empty ----- */

.skeleton { border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; min-height: 80px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* ----- Tooltip (custom, for Chart.js external tooltip) ----- */

.tip { position: absolute; pointer-events: none; z-index: 10; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 10px; font-size: 0.8rem; box-shadow: var(--shadow); opacity: 0; transition: opacity 0.12s; min-width: 150px; }
.tip .tip-title { color: var(--muted); margin-bottom: 4px; }
.tip .tip-row { display: flex; justify-content: space-between; gap: 12px; }
.tip .tip-row b { font-variant-numeric: tabular-nums; }
.tip .tip-row span { color: var(--ink-2); display: inline-flex; align-items: center; }

/* ----- Phone layout (<= 760px) ----- */

@media (max-width: 760px) {
	.topbar-inner { gap: 8px; padding-block: 8px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
	.brand-text small { display: none; }
	.brand-text { font-size: 1.05rem; }
	.live-text { display: none; }
	.topbar .menu-btn { display: inline-flex; }
	.pill-btn { padding: 6px 10px; }
	.icon-btn { width: 40px; height: 40px; }

	/* Navigation becomes a panel under the bar */
	.nav {
		position: absolute; left: 0; right: 0; top: 100%;
		display: none; flex-direction: column; gap: 2px;
		margin: 0; padding: 8px var(--gutter) 14px;
		background: var(--surface-glass);
		backdrop-filter: blur(14px) saturate(140%);
		-webkit-backdrop-filter: blur(14px) saturate(140%);
		border-bottom: 1px solid var(--border);
		box-shadow: var(--shadow);
		overflow: visible;
	}
	.topbar.open .nav { display: flex; animation: rise 0.25s var(--ease) both; }
	.nav a { display: flex; align-items: center; gap: 12px; padding: 13px 14px; min-height: 48px; border-radius: var(--radius-sm); font-size: 1.05rem; }
	.nav-icon { display: inline-flex; color: var(--muted); }
	.nav a.active .nav-icon { color: inherit; }
	.menu-backdrop { position: fixed; inset: 0; top: 0; z-index: -1; background: rgba(3, 6, 14, 0.45); }
	.topbar.open .menu-backdrop { display: block; }
	body.menu-open { overflow: hidden; }

	main { padding-top: 16px; }
	.card { padding: 14px; border-radius: 14px; }
	.grid { gap: 12px; }
	.page-head { margin-bottom: 14px; }
	.controls { gap: 6px; }
	.seg { flex-wrap: wrap; }
	.seg button { padding: 7px 10px; }
	.btn { padding: 10px 14px; }
	.chart-wrap { height: 260px; }
	.chart-wrap.tall { height: 320px; }
	.chart-wrap.short { height: 200px; }
	.hero-flow { min-height: 260px; }
	.share-ring { width: 100px; height: 100px; }
	.tile-value { font-size: 1.5rem; }
	.toasts { left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
	.toast { max-width: none; }
	.footer { padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 400px) {
	.days { grid-template-columns: repeat(2, 1fr); }
	.col-3 { grid-column: span 12; }
}

/* ----- Motion preferences ----- */

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
	body::before { animation: none; }
}
