/* iHome Energia. Só tokens de tokens.css: nenhuma cor escrita aqui. */

*, *::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, dl, dd, figure, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
[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;
}

.icon {
	width: 24px; height: 24px;
	flex-shrink: 0;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* ---------- Arranque ---------- */

.boot {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100dvh;
	font-family: var(--font-serif);
	font-size: var(--fs-title);
	letter-spacing: 0.04em;
	color: var(--text-muted);
}

.boot-message { padding: var(--page-pad); }

/* ---------- Casca ---------- */

.app {
	display: flex;
	flex-direction: column;
	max-width: var(--page-max);
	min-height: 100dvh;
	margin: 0 auto;
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-4);
	min-height: 56px;
	padding: calc(env(safe-area-inset-top) + var(--space-3)) var(--page-pad) var(--space-3);
}

.brand {
	display: flex;
	flex-shrink: 0;
	align-items: baseline;
	gap: var(--space-2);
}

.wordmark {
	font-family: var(--font-serif);
	font-size: 22px;
	line-height: 28px;
	letter-spacing: 0.02em;
}

.product, .site-name {
	font-size: var(--fs-label);
	line-height: 18px;
	letter-spacing: var(--tracking-label);
	text-transform: uppercase;
	color: var(--text-muted);
}

.site-name {
	max-width: 50%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	text-transform: none;
	letter-spacing: 0;
	font-size: var(--fs-small);
}

.site { display: flex; justify-content: flex-end; min-width: 0; }

.site-select {
	width: 100%;
	max-width: 200px;
	min-height: var(--touch);
	padding: 0 var(--space-1);
	border: 0;
	background: transparent;
	color: var(--text-muted);
	font-size: 16px;
	text-align: right;
	text-overflow: ellipsis;
	cursor: pointer;
}

.banner {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	margin: 0 var(--page-pad);
	padding: var(--space-3) var(--space-4);
	border-top: 1px solid var(--hairline);
	border-bottom: 1px solid var(--hairline);
	font-size: var(--fs-small);
	line-height: var(--lh-small);
}

.page {
	flex: 1;
	padding: var(--space-5) var(--page-pad) calc(var(--nav-height) + env(safe-area-inset-bottom) + var(--space-7));
	outline: none;
}

.tabbar {
	position: fixed;
	left: 0; right: 0; bottom: 0;
	display: flex;
	justify-content: center;
	padding-bottom: env(safe-area-inset-bottom);
	background: var(--bg);
	border-top: 1px solid var(--hairline);
}

.tab {
	display: flex;
	flex: 1;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 2px;
	max-width: calc(var(--page-max) / 5);
	min-height: var(--nav-height);
	color: var(--text-muted);
	font-size: var(--fs-label);
	line-height: 16px;
	text-decoration: none;
}

.tab[aria-current="page"] { color: var(--text); }
.tab[aria-current="page"] .icon { stroke: var(--accent); }

/* ---------- Texto comum ---------- */

.eyebrow, .fact dt, .phase dt {
	font-size: var(--fs-label);
	line-height: 18px;
	letter-spacing: var(--tracking-label);
	text-transform: uppercase;
	color: var(--text-muted);
	font-weight: 500;
}

.title {
	font-family: var(--font-serif);
	font-size: var(--fs-title);
	line-height: 34px;
	font-weight: 400;
}

.subtitle, .meta, .compare, .block-text, .version {
	font-size: var(--fs-small);
	line-height: var(--lh-small);
	color: var(--text-muted);
}

.compare { color: var(--text); }

.empty { color: var(--text-muted); padding-top: var(--space-6); }

.dot {
	display: inline-block;
	flex-shrink: 0;
	width: 8px; height: 8px;
	border-radius: 50%;
	background: var(--text-muted);
}

.dot-ok { background: var(--ok); }
.dot-info { background: var(--accent); }
.dot-warning { background: var(--warning); }
.dot-critical { background: var(--critical); }

/* ---------- Agora ---------- */

.now {
	display: flex;
	flex-direction: column;
	gap: var(--space-3);
	padding-top: var(--space-6);
}

.reading { display: flex; flex-direction: column; gap: var(--space-2); }

.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: 200;
	letter-spacing: -0.02em;
}

.hero-unit, .display-unit {
	font-size: 20px;
	line-height: 24px;
	color: var(--text-muted);
}

.hero.is-stale { opacity: 0.45; }

.status {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	min-height: 22px;
	font-size: var(--fs-small);
	line-height: var(--lh-small);
}

.row-link {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	min-height: 56px;
	color: var(--text);
	text-decoration: none;
	border-top: 1px solid var(--hairline);
	border-bottom: 1px solid var(--hairline);
}

.now .row-link { margin-top: var(--space-6); }

.row-link > span:first-child { flex: 1; }

.row-value {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	font-variant-numeric: tabular-nums;
}

.row-chevron { color: var(--text-muted); width: 20px; height: 20px; }

.gap-mark { width: 18px; height: 18px; color: var(--warning); }

.technical summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-height: var(--touch);
	color: var(--text-muted);
	font-size: var(--fs-small);
	list-style: none;
	cursor: pointer;
}

.technical summary::-webkit-details-marker { display: none; }
.technical summary::after { content: "+"; font-size: 20px; }
.technical[open] summary::after { content: "−"; }

.phases { display: flex; flex-direction: column; gap: var(--space-2); padding-bottom: var(--space-3); }
.phase { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; font-size: var(--fs-small); }

/* ---------- Dia e Mês ---------- */

.period { display: flex; flex-direction: column; gap: var(--space-3); }

.period-nav {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	padding-bottom: var(--space-4);
}

.period-heading { flex: 1; text-align: center; }

.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;
	cursor: pointer;
}

.icon-button:disabled { opacity: 0.25; cursor: default; }

.display-value {
	font-size: var(--fs-display);
	line-height: 1;
	font-weight: 200;
	letter-spacing: -0.02em;
}

.notice {
	display: flex;
	align-items: flex-start;
	gap: var(--space-3);
	padding: var(--space-3) 0;
	border-top: 1px solid var(--hairline);
	border-bottom: 1px solid var(--hairline);
	font-size: var(--fs-small);
	line-height: var(--lh-small);
}

.notice .icon { color: var(--warning); width: 20px; height: 20px; margin-top: 1px; }

.segmented {
	display: flex;
	align-self: flex-start;
	margin-top: var(--space-5);
	padding: 2px;
	border: 1px solid var(--hairline);
	border-radius: 999px;
}

.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(--primary); color: var(--on-primary); }

.chart-figure { display: flex; flex-direction: column; gap: var(--space-2); padding-top: var(--space-4); }

.chart { width: 100%; height: auto; display: block; touch-action: manipulation; cursor: pointer; }

/* As barras com lacuna pintam-se pelo atributo fill (padrão SVG): o CSS não as pode tapar. */
.chart .bar:not(.bar-gap) { fill: var(--bar); }
.chart .bar.is-selected:not(.bar-gap) { fill: var(--bar-selected); }
.chart .bar-gap, .legend-swatch .bar-gap { stroke: var(--bar); stroke-width: 1; }
.chart .bar-gap.is-selected { stroke: var(--bar-selected); }
.hatch-bg { fill: var(--bg); }
.hatch-line { stroke: var(--bar); stroke-width: 2; }
.chart .grid { stroke: var(--hairline); stroke-dasharray: 2 4; }
.chart .baseline { stroke: var(--hairline); }
.chart .axis-label { fill: var(--text-muted); font-size: 12px; font-family: var(--font-sans); }
.chart .chart-empty { fill: var(--text-muted); font-size: 14px; font-family: var(--font-sans); }

.chart-caption {
	min-height: var(--lh-small);
	font-size: var(--fs-small);
	line-height: var(--lh-small);
	font-variant-numeric: tabular-nums;
	color: var(--text-muted);
}

.chart-legend { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-label); color: var(--text-muted); }
.legend-swatch { width: 14px; height: 14px; }

.facts { display: flex; flex-direction: column; padding-top: var(--space-5); }

.fact {
	display: flex;
	flex-direction: column;
	gap: var(--space-1);
	padding: var(--space-4) 0;
	border-top: 1px solid var(--hairline);
}

.fact dd { font-variant-numeric: tabular-nums; }

/* ---------- Alertas ---------- */

.alerts { display: flex; flex-direction: column; gap: var(--space-4); }

.alert-list { display: flex; flex-direction: column; }

.alert-item {
	display: flex;
	gap: var(--space-4);
	padding: var(--space-5) 0;
	border-top: 1px solid var(--hairline);
}

.alert-item .dot { margin-top: 9px; }
.alert-text { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.alert-title { font-weight: 500; }
.alert-body { font-size: var(--fs-small); line-height: var(--lh-small); }
.alert-status { font-size: var(--fs-label); line-height: 18px; color: var(--text-muted); }
.alert-item:not(.is-ongoing) .alert-title { font-weight: 400; color: var(--text-muted); }
.alert-item:not(.is-ongoing) .dot { background: transparent; box-shadow: inset 0 0 0 1px var(--text-muted); }

/* ---------- Conta ---------- */

.account { display: flex; flex-direction: column; gap: var(--space-6); }

.block { display: flex; flex-direction: column; gap: var(--space-3); padding-top: var(--space-5); border-top: 1px solid var(--hairline); }
.block-title { font-family: var(--font-serif); font-size: 20px; line-height: 26px; font-weight: 400; }
.account-name { font-family: var(--font-serif); font-size: 22px; line-height: 28px; }
.account .row-link { border-bottom: 0; min-height: var(--touch); }
.version { text-align: center; }

/* ---------- Formulários ---------- */

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field label { font-size: var(--fs-small); color: var(--text-muted); }

.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 */
}

.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 0 var(--space-5);
	border-radius: var(--radius);
	border: 1px solid transparent;
	font-size: var(--fs-body);
	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); }

.form-error { min-height: var(--lh-small); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--critical); }

/* ---------- Entrar ---------- */

.login {
	display: flex;
	flex-direction: column;
	gap: var(--space-7);
	min-height: 100dvh;
	padding: calc(env(safe-area-inset-top) + var(--space-8)) var(--page-pad) var(--space-6);
}

.login-brand { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding-top: var(--space-6); }
.wordmark-large { font-size: 44px; line-height: 52px; }
.login-product { font-size: var(--fs-label); letter-spacing: 0.3em; text-transform: uppercase; color: var(--text-muted); }
.login-form { display: flex; flex-direction: column; gap: var(--space-5); }
.login-help { margin-top: auto; text-align: center; font-size: var(--fs-small); color: var(--text-muted); }

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