/* P2C Energia (v3): base (reset, texto, comandos, linhas). Só tokens de tokens.css: nenhuma cor escrita aqui.
   Sem serifa (a marca P2C é geométrica, Manual 7.B): títulos a 600–650, números a 300 e tabulares. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
	margin: 0;
	min-height: 100vh;
	min-height: 100dvh;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-sans);
	font-size: var(--fs-body);
	line-height: var(--lh-body);
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
}
p, h1, h2, h3, dl, dd, figure, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
select:disabled { opacity: .6; cursor: not-allowed; }
[hidden] { display: none !important; }
a { color: var(--accent-text); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums lining-nums; }

.icon {
	width: 24px; height: 24px; flex-shrink: 0;
	fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 18px; height: 18px; }

.boot { display: block; height: 36px; width: auto; margin: 45dvh auto 0; }
.boot-message { padding: var(--page-pad); }

/* ---------- Texto ---------- */

.eyebrow {
	font-size: var(--fs-label); line-height: 18px; letter-spacing: var(--tracking-label);
	text-transform: uppercase; color: var(--text-muted); font-weight: 600;
}
.title { font-size: var(--fs-title); line-height: 32px; font-weight: 650; letter-spacing: -0.01em; }
.section-title { font-size: var(--fs-section); line-height: 26px; font-weight: 650; letter-spacing: -0.005em; }
.lede, .meta, .subtitle { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--text-muted); }
.sentence { font-size: var(--fs-body); line-height: var(--lh-body); }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-small); line-height: var(--lh-small); }
.strong { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Números ---------- */

.hero, .display { display: flex; align-items: baseline; gap: var(--space-2); font-variant-numeric: tabular-nums lining-nums; transition: opacity 300ms ease; }
.hero-value { font-size: var(--fs-hero); line-height: 1; font-weight: 300; letter-spacing: -0.03em; font-variant-numeric: tabular-nums lining-nums; }
.hero-unit { font-size: 24px; line-height: 28px; color: var(--text-muted); font-weight: 400; letter-spacing: 0; }
.display-value { font-size: var(--fs-display); line-height: 1; font-weight: 300; letter-spacing: -0.02em; }
.display-unit, .unit { font-size: 18px; line-height: 22px; color: var(--text-muted); }
.figure-value { font-size: var(--fs-figure); line-height: 1; font-weight: 300; letter-spacing: -0.02em; }
.hero.is-stale { opacity: 0.45; }

.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.stack-tight { display: flex; flex-direction: column; gap: var(--space-2); }
.section { display: flex; flex-direction: column; gap: var(--space-4); padding-top: var(--space-5); border-top: 1px solid var(--hairline); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); }

/* ---------- Comandos ---------- */

.segmented { display: inline-flex; padding: 4px; gap: 4px; border-radius: 999px; background: var(--surface-2); flex-shrink: 0; }
.segment {
	min-height: var(--touch); min-width: var(--touch); padding: 0 var(--space-4);
	border: 0; border-radius: 999px; background: transparent; color: var(--text-muted);
	font-size: var(--fs-small); cursor: pointer;
}
.segment[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; }
.segmented-sm .segment { padding: 0 var(--space-3); }

.icon-button {
	display: inline-flex; align-items: center; justify-content: center;
	width: var(--touch); height: var(--touch); flex-shrink: 0;
	padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text); cursor: pointer;
}
.icon-button:disabled { opacity: 0.25; cursor: default; }

.chip {
	display: inline-flex; align-items: center; gap: var(--space-2);
	min-height: var(--touch); padding: 0 var(--space-3);
	border: 1px solid var(--hairline); border-radius: 999px; background: transparent;
	color: var(--text); font-size: var(--fs-small); cursor: pointer;
}
.chip[aria-pressed="false"] { color: var(--text-muted); }
.chip-line { width: 18px; height: 0; border-top: 2px dashed var(--ghost); flex-shrink: 0; }

.button {
	display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
	min-height: 52px; padding: 0 var(--space-5);
	border-radius: 999px; border: 1px solid transparent;
	font-size: var(--fs-body); font-weight: 650; text-decoration: none; cursor: pointer;
}
.button-primary { background: var(--primary); color: var(--on-primary); }
.button-primary:disabled { opacity: 0.6; cursor: default; }
.button-quiet { background: transparent; border-color: var(--control-border); color: var(--text); }
.link { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--touch); font-size: var(--fs-small); }

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field label { font-size: var(--fs-small); font-weight: 600; color: var(--text); }
.field input, .field select {
	min-height: 48px; padding: 0 var(--space-4);
	border: 1px solid var(--control-border); border-radius: var(--radius); background: var(--surface);
	font-size: 16px; /* 16 px evita o zoom do iOS ao focar */
}
.form-error { min-height: var(--lh-small); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--critical); }

/* Interruptor (revisão #5): desenhado com tokens, alvo de 44 px; o input continua a ser a caixa nativa (teclado, leitores). */
.switch {
	appearance: none; -webkit-appearance: none; position: relative; flex-shrink: 0;
	width: 44px; height: 26px; margin: 9px 0; border-radius: 999px; cursor: pointer;
	background: var(--hairline); border: 1px solid var(--control-border); transition: background 150ms ease;
}
.switch::after {
	content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
	background: var(--surface); box-shadow: 0 0 0 1px var(--control-border); transition: transform 150ms ease;
}
.switch:checked { background: var(--primary); border-color: var(--primary); }
.switch:checked::after { transform: translateX(18px); background: var(--on-primary); box-shadow: none; }
.switch:disabled { opacity: 0.5; cursor: default; }
.switch-row { cursor: pointer; }

/* ---------- Linhas com faixas (lanes) ---------- */

.rows { display: flex; flex-direction: column; }
.row {
	display: flex; align-items: center; gap: var(--space-3);
	min-height: 56px; padding: var(--space-3) 0;
	border-top: 1px solid var(--hairline);
	color: var(--text); text-decoration: none;
}
.rows > .row:last-child { border-bottom: 1px solid var(--hairline); }
.row-lead { width: 24px; flex-shrink: 0; display: flex; justify-content: center; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-label { font-size: var(--fs-body); line-height: 22px; overflow-wrap: anywhere; }
.row-sub { font-size: var(--fs-small); line-height: 20px; color: var(--text-muted); }
.row-value { flex-shrink: 0; text-align: right; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; align-items: flex-end; }
.row-trail { width: 20px; flex-shrink: 0; color: var(--text-muted); display: flex; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.dot-ok { background: var(--ok); }
.dot-live { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 18%, transparent); }
.dot-warning { background: var(--warning); }
.dot-info { background: var(--accent); }
.dot-critical { background: var(--critical); }

/* ---------- Avisos, factos, detalhes ---------- */

.notice {
	display: flex; align-items: flex-start; gap: var(--space-3);
	padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--surface-2);
	font-size: var(--fs-small); line-height: var(--lh-small);
}
.notice .icon { color: var(--warning); width: 20px; height: 20px; margin-top: 1px; }
.notice-info .icon { color: var(--accent); }

.facts { display: flex; flex-direction: column; }
.fact { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) 0; border-top: 1px solid var(--hairline); }
.fact:first-child { border-top: 0; } /* v3: o painel já separa; sem linha dupla no topo. */
.fact dt { font-size: var(--fs-small); color: var(--text-muted); flex-shrink: 0; max-width: 45%; }
.fact dd { font-variant-numeric: tabular-nums; text-align: right; }
.fact-sub { display: block; font-size: var(--fs-small); line-height: 20px; color: var(--text-muted); }

details.more { border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); }
details.more summary { display: flex; align-items: center; justify-content: space-between; min-height: 56px; list-style: none; cursor: pointer; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: "+"; font-size: 20px; color: var(--text-muted); width: 20px; text-align: center; }
details.more[open] summary::after { content: "\2212"; }
details.more.row-sub { border: 0; }
details.more.row-sub summary { min-height: var(--touch); justify-content: flex-start; gap: var(--space-2); }
details[open] .short { display: none; }

.skeleton { background: var(--hairline); border-radius: 6px; }
.sk-hero { width: 180px; height: 64px; }
.sk-line { width: 220px; height: 16px; }
.sk-chart { width: 100%; height: 160px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
