/* Casca v3 (DESIGN-V3.md §7): barra inferior abaixo de 1024 px; coluna lateral de 248 px com o logótipo,
   o cartão da instalação e a assinatura a partir de 1024; painéis de superfície em todas as larguras;
   largura útil até 1400 px. As margens por largura vêm de tokens.css (20 / 32 / 40 / 56 px). */

.shell { min-height: 100dvh; }
.main { display: flex; flex-direction: column; min-height: 100dvh; width: 100%; min-width: 0; }

.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-2);
}
.site-select { border: 0; background: transparent; min-height: var(--touch); cursor: pointer; text-overflow: ellipsis; }

.banner {
	display: flex; align-items: center; gap: var(--space-3);
	margin: 0 var(--page-pad); 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);
}

.page {
	flex: 1; width: 100%; max-width: calc(1400px + 2 * var(--page-pad)); margin: 0 auto;
	display: flex; flex-direction: column; gap: var(--space-5);
	padding: var(--space-3) var(--page-pad) calc(var(--nav-height) + env(safe-area-inset-bottom) + var(--space-7));
	outline: none;
}

.nav {
	position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
	padding-bottom: env(safe-area-inset-bottom);
	background: var(--surface);
	border-top: 1px solid var(--hairline);
}
.nav .nav-head, .nav .nav-foot { display: none; }
.nav-list { display: flex; max-width: 720px; margin: 0 auto; }
.nav-item { flex: 1; }
.nav-link {
	position: relative;
	display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
	min-height: var(--nav-height);
	color: var(--text-muted); font-size: var(--fs-label); line-height: 16px; text-decoration: none;
}
.nav-link[aria-current="page"] { color: var(--text); font-weight: 600; }
.nav-link[aria-current="page"] .icon { stroke: var(--accent); }
.nav-badge { position: absolute; top: 12px; left: calc(50% + 8px); width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }

/* Painéis em todas as larguras (v3): raio 20, sem contorno nem sombra. */
.panel { background: var(--surface); border-radius: var(--panel-radius); padding: var(--space-5); min-width: 0; }
.section.panel { border-top: 0; padding-top: var(--space-5); }
.grid-2 { display: flex; flex-direction: column; gap: var(--space-4); }
/* Coluna de painéis empilhados dentro de uma grelha (Início: «Hoje» e a origem da energia). */
.stack-panels { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.desktop-only { display: none !important; }

@media (min-width: 768px) {
	.grid-2-even { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

@media (min-width: 1024px) {
	.shell { display: grid; grid-template-columns: var(--rail-width) minmax(0, 1fr); }
	.nav {
		position: sticky; top: 0; bottom: auto; height: 100dvh;
		display: flex; flex-direction: column; gap: var(--space-6);
		padding: var(--space-6) var(--space-4);
		border-top: 0; border-right: 1px solid var(--hairline);
	}
	.nav .nav-head { display: flex; padding: 0 var(--space-3); }
	.nav-head .logo { height: 34px; }
	.nav-list { flex-direction: column; gap: var(--space-1); margin: 0; max-width: none; }
	.nav-link {
		flex-direction: row; justify-content: flex-start; gap: var(--space-3);
		min-height: 48px; padding: 0 var(--space-3); border-radius: var(--radius);
		font-size: var(--fs-small);
	}
	.nav-link[aria-current="page"] { background: var(--surface-2); }
	.nav-badge { position: static; margin-left: auto; }
	.nav .nav-foot { display: flex; flex-direction: column; gap: var(--space-3); margin-top: auto; }
	/* O logótipo vive na coluna; a barra de cima só fica para o seletor quando há várias instalações. */
	.topbar { justify-content: flex-end; padding-top: var(--space-5); }
	.topbar .logo-link { display: none; }
	.topbar .site-chip:not(:has(select)) { display: none; }
	.page { padding-top: var(--space-6); padding-bottom: var(--space-8); }

	.desktop-only { display: grid !important; }
	.panel { padding: var(--space-6); }
	.grid-2 { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--space-5); align-items: stretch; }
	.grid-2-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
	.grid-main { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; }
	.grid-2 > .panel { height: 100%; }
	.grid-main > .panel { height: auto; }
	.stack-panels { gap: var(--space-5); }
	.field input, .field select { background: var(--bg); }
}

/* 1024–1279 px: a coluna 5/6 dos ecrãs da v2 empilha (revisão #4). O Início (7/5) mantém-se. */
@media (min-width: 1024px) and (max-width: 1279px) {
	.grid-2:not(.grid-2-even):not(.grid-main) { grid-template-columns: minmax(0, 1fr); }
}
