/* Energy's cockpit (Client\Apps\Energy\CockpitPage.razor, EnGauge, EnStat): ONE screen, the whole width, no scroll (the owner,
   2026-11-04). From 1200 px wide and 720 px high the page fills the window under the app bar (--em-cp-top: the app bar, the
   tabs and the toolbar) and only the side's alerts scroll inside their card; narrower or lower, the same blocks stack.
   Status colours are the app's tokens and always come with their word; the load's line is the palette's first slot. */

.en-frame.en-frame-wide { gap: 8px; }

.em-cp {
  --em-cp-top: 246px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 25%);
  grid-template-rows: auto auto auto minmax(0, 1fr);
  grid-template-areas: "verdict side" "gauges side" "stats side" "charts side";
  gap: 10px;
}
.em-cp > .panel, .em-cp-side > .panel, .em-cp-charts > .panel { margin: 0; }
.em-cp .panel { padding: 10px 14px; }
.em-cp .panel-head { margin-bottom: 4px; }
.em-cp .panel h3 { margin: 0; font-size: 0.92rem; display: flex; align-items: center; gap: 6px; }
.em-cp-verdict { grid-area: verdict; }
.em-cp-gauges { grid-area: gauges; }
.em-cp-stats { grid-area: stats; }
.em-cp-charts { grid-area: charts; }
.em-cp-side { grid-area: side; }

@media (min-width: 1200px) and (min-height: 720px) {
  .em-cp { height: calc(100dvh - var(--em-cp-top)); min-height: 600px; }
  .em-cp-side, .em-cp-charts { min-height: 0; }
}
@media (max-width: 1199px), (max-height: 719px) {
  .em-cp { grid-template-columns: minmax(0, 1fr); grid-template-areas: "verdict" "gauges" "stats" "side" "charts"; }
}

/* ---- The verdict ---- */
.em-cp-verdict { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-left: 6px solid var(--chip); }
.em-cp-verdict.em-cp-good { border-left-color: var(--good); }
.em-cp-verdict.em-cp-watch { border-left-color: var(--warn); }
.em-cp-verdict.em-cp-bad { border-left-color: var(--bad); }
.em-cp-verdict-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.em-cp-badge { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--chip); color: var(--muted); flex: none; }
.em-cp-badge .mud-icon-root { font-size: 30px; }
.em-cp-badge-good { background: var(--good-soft); color: var(--good-text); }
.em-cp-badge-watch { background: var(--warn-soft); color: var(--warn); }
.em-cp-badge-bad { background: var(--bad-soft); color: var(--bad); }
.em-cp-verdict-title { font-size: 1.3rem; font-weight: 900; line-height: 1.2; display: flex; align-items: center; gap: 6px; }
.em-cp-verdict-sub { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.em-cp-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.em-cp-chips .en-chip { text-decoration: none; }
.em-cp-chips .en-chip.en-watch { background: var(--warn-soft); }
.em-cp-now { display: flex; gap: 26px; flex-wrap: wrap; }
.em-cp-now-item { display: grid; gap: 1px; text-align: right; }
.em-cp-now-item .label { font-size: 0.74rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.em-cp-now-value { font-size: 1.55rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.em-cp-now-value small { font-size: 0.85rem; color: var(--muted); font-weight: 700; }

/* ---- The gauges ---- */
.em-cp-gauges { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; padding: 8px 10px; }
@media (max-width: 760px) { .em-cp-gauges { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.em-gauge { display: grid; justify-items: center; gap: 0; padding: 4px 6px 6px; border-radius: 10px; color: inherit; text-decoration: none; min-width: 0; }
.em-gauge-link:hover { background: var(--panel-2); }
.em-gauge-label { font-size: 0.78rem; font-weight: 800; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.em-gauge svg { width: 100%; max-width: 190px; height: auto; display: block; }
.em-gauge-track { fill: none; stroke: var(--chip); stroke-width: 14; stroke-linecap: round; }
.em-gauge-fill { fill: none; stroke: var(--muted); stroke-width: 14; stroke-linecap: round; }
.em-gauge-good { stroke: var(--good); }
.em-gauge-watch { stroke: var(--warn); }
.em-gauge-bad { stroke: var(--bad); }
.em-gauge-target { stroke: var(--text); stroke-width: 2; stroke-dasharray: 3 2; }
.em-gauge-value { fill: var(--text); font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.em-gauge-unit { fill: var(--muted); font-size: 11px; font-weight: 700; }
.em-gauge-end { fill: var(--muted); font-size: 9.5px; }
.em-gauge-foot { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.em-gauge-sub { font-size: 0.74rem; text-align: center; }
.em-gauge-none { font-size: 0.8rem; }

/* ---- The figures ---- */
.em-cp-stats { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 0; padding: 6px 4px; }
@media (max-width: 1199px) { .em-cp-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 600px) { .em-cp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.em-stat { display: flex; flex-direction: column; gap: 1px; padding: 4px 10px; color: inherit; text-decoration: none; border-right: 1px solid var(--rule); min-width: 0; }
.em-stat:last-child { border-right: 0; }
.em-stat-link:hover { background: var(--panel-2); border-radius: 8px; }
.em-stat-label { font-size: 0.72rem; font-weight: 800; color: var(--muted); line-height: 1.2; }
.em-stat-value { font-size: 1.12rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.em-stat-value small { font-size: 0.75rem; color: var(--muted); font-weight: 700; }
.em-stat-sub { font-size: 0.72rem; color: var(--muted); line-height: 1.25; }

/* ---- The charts ---- */
.em-cp-charts { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 10px; }
@media (max-width: 900px) { .em-cp-charts { grid-template-columns: 1fr; } }
.em-cp-load, .em-cp-sectors { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.em-cp-load-tall, .em-cp-load-short { flex: 1; min-height: 0; }
.em-cp-load-short { display: none; }
.em-cp-sectors .em-hbars { overflow: hidden; }
.em-cp-sectors .em-hbar { padding: 2px 0; }

/* ---- The side ---- */
.em-cp-side { display: grid; grid-template-rows: fit-content(64%) minmax(0, 1fr); gap: 10px; min-width: 0; }
.em-cp-ai { display: flex; flex-direction: column; min-height: 0; background: linear-gradient(180deg, var(--accent-soft), var(--panel) 60%); }
.em-cp-ai-icon { color: var(--accent-strong); }
.em-cp-ai-body { overflow: auto; min-height: 0; }
.em-cp-ai-lead { margin: 4px 0 6px; font-weight: 700; font-size: 0.92rem; line-height: 1.35; }
.em-cp-ai-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 0.86rem; line-height: 1.35; }
.em-cp-ai-list li.em-cp-ai-plain { list-style: none; margin-left: -18px; color: var(--muted); }
.em-cp-ai-foot { margin-top: 6px; font-size: 0.72rem; }
.em-cp-ai-wait { display: grid; gap: 6px; padding: 4px 0; }
.em-cp-ai-wait span { height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--chip), var(--panel-2), var(--chip)); background-size: 200% 100%; animation: em-cp-shimmer 1.4s linear infinite; }
.em-cp-ai-wait span:nth-child(2) { width: 85%; }
.em-cp-ai-wait span:nth-child(3) { width: 60%; }
@keyframes em-cp-shimmer { from { background-position: 200% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .em-cp-ai-wait span { animation: none; } }
.em-cp-alerts { display: flex; flex-direction: column; min-height: 0; }
.em-cp-alerts .em-alerts { overflow: auto; min-height: 0; padding-right: 2px; }
.em-cp-alerts .em-alert { padding: 6px 10px; font-size: 0.84rem; }
.em-cp-alerts .em-alert .em-status { min-width: 0; white-space: nowrap; }

/* A lower window (a laptop): smaller gauges and figures, so the load keeps its height */
@media (min-width: 1200px) and (max-height: 1000px) {
  .em-gauge svg { max-width: 132px; }
  .em-cp-load-tall { display: none; }
  .em-cp-load-short { display: block; }
  .em-gauge-sub { font-size: 0.7rem; }
  .em-cp-verdict-title { font-size: 1.15rem; }
  .em-cp-badge { width: 40px; height: 40px; }
  .em-cp-now-value { font-size: 1.3rem; }
  .em-cp-ai-list { font-size: 0.82rem; }
  .em-cp-ai-lead { font-size: 0.86rem; }
}
