/* Components of the EMS cloud on top of app.css. */
body.login .card.wide { width: min(420px, 100%); }
.qr svg { width: 220px; height: 220px; display: block; margin: 4px auto; background: #fff; }
code.secret { font-size: 15px; letter-spacing: 1px; user-select: all; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
          font-size: 13px; white-space: nowrap; border: 1px solid var(--rule); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-2); }
.status.online::before { background: var(--accent); }
.status.offline, .status.emma { color: var(--err-text); border-color: var(--err); }
.status.offline::before, .status.emma::before { background: var(--err); }
tr.problem td:first-child { border-left: 3px solid var(--err); padding-left: 10px; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
tr.flag td { background: color-mix(in srgb, var(--warn) 25%, transparent); }
.ranges { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.ranges a { text-decoration: none; }
.bars { width: 100%; height: auto; display: block; }
.bars .tariff { fill: var(--c-grid); }
.bars .spot { fill: var(--c-batt); }
.bars text { font-size: 10px; fill: var(--ink-2); }
.legend { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px;
                       margin-right: 6px; border-radius: 50%; background: var(--c, var(--ink-2)); }
.legend .k-pv::before, .legend .k-self::before { background: var(--c-pv); }
.legend .k-feed::before { background: var(--c-feed); }
.legend .k-imp::before, .legend .k-grid::before { background: var(--c-grid); }
.legend .k-load::before { background: var(--c-load); }
.legend .k-batt::before { background: var(--c-batt); }
.legend .tariff::before { background: var(--c-grid); }
.legend .spot::before { background: var(--c-batt); }
.scroll { overflow-x: auto; }
.oneshot { background: var(--warn); color: #000; padding: 10px; border-radius: 8px; word-break: break-all; }
details.edit summary, details.more summary { cursor: pointer; color: var(--ink-2); }
form.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px;
            align-items: end; margin-top: 12px; }

/* Plant head and tabs */
.planthead { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 18px; }
.planthead h1 { margin: 0; }
.planthead .where { color: var(--ink-2); font-size: 14px; }
.planthead .seg { margin-left: auto; }
.crumb { font-size: 13px; color: var(--ink-2); text-decoration: none; display: inline-block;
         margin-bottom: 6px; }

/* Overview: scene on the left, numbers of today on the right */
.hero { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 16px;
        margin-bottom: 16px; align-items: stretch; }
.side { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; align-content: start; }
.side .tile { min-height: 96px; }
.side .wide { grid-column: 1 / -1; }

.scene { position: relative; background: var(--stage); border-radius: var(--radius);
         overflow: hidden; aspect-ratio: 1920 / 1072; border: 1px solid var(--card-line);
         container-type: inline-size; }
.scene img, .scene svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.scene img { object-fit: cover; }
.scene img.s-nacht, .scene img.s-plan { display: none; }
:root[data-design="nacht"] .scene img.s-tag, :root[data-design="plan"] .scene img.s-tag { display: none; }
:root[data-design="nacht"] .scene img.s-nacht, :root[data-design="plan"] .scene img.s-plan { display: block; }
.scene .track, .scene .flow { stroke-linejoin: round; }
.scene .track { fill: none; stroke: var(--ink); stroke-opacity: .16; stroke-width: 5; stroke-linecap: round; }
.scene .flow { fill: none; stroke-width: 11; stroke-linecap: round; stroke-dasharray: 0 30;
               opacity: 0; stroke: var(--accent); }
.scene .flow.to { opacity: 1; animation: dots-to 1.5s linear infinite; }
.scene .flow.from { opacity: 1; animation: dots-from 1.5s linear infinite; }
.scene .flow[data-edge="grid"] { stroke: var(--c-grid); }
.scene .flow[data-edge="battery"] { stroke: var(--c-batt); }
.scene.stale .flow { opacity: 0; animation: none; }
@keyframes dots-to { to { stroke-dashoffset: -30; } }
@keyframes dots-from { to { stroke-dashoffset: 30; } }
:root[data-design="plan"] .scene .flow { stroke: var(--ink); stroke-width: 8; }
:root[data-design="plan"] .scene .track { stroke-opacity: .35; stroke-width: 3; stroke-dasharray: 2 9; }

.chip { position: absolute; transform: translate(-50%, -50%); background: var(--chip);
        border: 1px solid var(--chip-line); border-radius: var(--radius); padding: .5cqw 1cqw;
        text-decoration: none; line-height: 1.15; min-width: 9cqw; backdrop-filter: blur(6px);
        font-size: clamp(9px, 1.25cqw, 14px); }
/* Positions in percent of the picture (the CSP allows no inline styles). */
.chip.c-pv { left: 30%; top: 10%; }
.chip.c-house { left: 61%; top: 13%; }
.chip.c-battery { left: 13%; top: 55%; }
.chip.c-grid { left: 89%; top: 30%; }
.chip.c-wallbox { left: 82%; top: 76%; }
.chip:hover { outline: 2px solid var(--accent); }
.chip .l { display: block; color: var(--ink-2); }
.chip .v { display: block; font-weight: 700; font-size: 1.9em; font-variant-numeric: tabular-nums;
           white-space: nowrap; }
.chip .v small { font-size: .5em; font-weight: 500; color: var(--ink-2); margin-left: .25em; }
.chip .d { display: block; color: var(--accent-text); min-height: 1.15em; }
.scene.stale .chip .v { color: var(--ink-2); }
.scene .stamp { position: absolute; left: 1.2cqw; bottom: 1cqw; font-size: clamp(9px, 1.1cqw, 13px);
                color: var(--ink-2); }

/* Share of self-supply as a bar */
.meter { display: grid; gap: 6px; }
.meter svg { width: 100%; height: 10px; display: block; border-radius: 5px; }
.meter .base { fill: var(--rule-soft); }
.meter .own { fill: var(--accent); }
.meter .ends { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); }
.meter b { font-size: 26px; font-variant-numeric: tabular-nums; }

/* Devices */
.devgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px;
           margin-bottom: 16px; }
.dev { background: var(--paper); border-radius: var(--radius); border: 1px solid var(--card-line);
       padding: 12px; text-decoration: none; display: grid; gap: 8px; position: relative; }
.dev:hover { outline: 2px solid var(--accent); }
.dev .pic, .devpic { background: var(--devstage); border-radius: calc(var(--radius) - 2px);
                     aspect-ratio: 4 / 3; overflow: hidden; display: block; }
.dev .pic img, .devpic img { width: 100%; height: 100%; object-fit: cover; display: none; }
:root:not([data-design]) img.i-tag, :root[data-design="tag"] img.i-tag,
:root[data-design="nacht"] img.i-nacht, :root[data-design="plan"] img.i-plan { display: block; }
.dev .n { font-family: var(--head); font-size: 18px; line-height: 1.2; }
.dev .v { font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; }
.dev .v small { font-size: .6em; font-weight: 500; color: var(--ink-2); margin-left: 4px; }
.dev .s { font-size: 13px; color: var(--ink-2); }
.dev .dot { position: absolute; top: 20px; right: 20px; width: 10px; height: 10px; border-radius: 50%;
            background: var(--ink-2); opacity: .5; }
.dev.on .dot { background: var(--accent); opacity: 1; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }

.devhead { display: grid; grid-template-columns: minmax(220px, 360px) minmax(0, 1fr); gap: 16px;
           margin-bottom: 16px; }
.devhead .devpic { aspect-ratio: 1; border: 1px solid var(--card-line); }
.devhead .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; align-content: start; }

/* Three cards in a row: earnings, climate, control */
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.trio .card { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.trio .big { font-size: 34px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.trio .big small { font-size: .45em; font-weight: 500; color: var(--ink-2); margin-left: 6px; }
.trio .rows { display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; font-size: 14px;
              margin-top: 4px; }
.trio .rows span:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }
.trio .card .button { margin-top: auto; align-self: start; }

/* Statistics */
.statbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 16px; }
.when { display: inline-flex; align-items: center; gap: 8px; font-family: var(--head);
                 font-size: 19px; }
.when a { text-decoration: none; display: inline-flex; width: 34px; height: 34px;
                   align-items: center; justify-content: center; border-radius: 4px;
                   box-shadow: inset 0 0 0 1px var(--ink); }
.when a[aria-disabled="true"] { opacity: .25; pointer-events: none; }
.rings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.ring { display: grid; grid-template-columns: minmax(0, 1fr) 132px minmax(0, 1fr); align-items: center;
        gap: 14px; }
.ring svg { width: 132px; height: 132px; }
.ring circle { fill: none; stroke-width: 13; }
.ring .base { stroke: var(--rule-soft); }
.ring .mid { text-anchor: middle; fill: var(--ink); font-weight: 700; font-size: 21px;
             font-variant-numeric: tabular-nums; }
.ring .unit { text-anchor: middle; fill: var(--ink-2); font-size: 11px; }
.ring .part b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.ring .part b small { font-size: .6em; font-weight: 500; color: var(--ink-2); }
.ring .part span { font-size: 13px; color: var(--ink-2); }
.ring .part::before { content: ""; display: block; width: 22px; height: 5px; border-radius: 3px;
                      background: var(--ink-2); margin-bottom: 6px; }
.ring .part.r { text-align: right; }
.ring .part.r::before { margin-left: auto; }
.colchart { width: 100%; height: auto; display: block; }
.colchart .self { fill: var(--c-pv); }
.colchart .feed { fill: var(--c-feed); }
.colchart .imp { fill: var(--c-grid); }
.colchart .axis { stroke: var(--ink); stroke-width: 1; }
.colchart text { font-size: 9px; fill: var(--ink-2); text-anchor: middle; font-family: var(--body); }
.ring .part.k-self::before { background: var(--c-pv); }
.ring .part.k-feed::before { background: var(--c-feed); }
.ring .part.k-imp::before { background: var(--c-grid); }
.ring .a-self { stroke: var(--c-pv); }
.ring .a-feed { stroke: var(--c-feed); }
.ring .a-imp { stroke: var(--c-grid); }

/* Control */
.orderlist { list-style: none; margin: 0 0 12px; padding: 0; counter-reset: rank; }
.orderlist li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 6px;
                border: 1px solid var(--rule); border-radius: 6px; counter-increment: rank; }
.orderlist li::before { content: counter(rank); font-weight: 700; width: 1.5em; color: var(--ink-2); }
.orderlist .mv { margin-left: auto; display: flex; gap: 6px; }
.orderlist .mv button { min-height: 32px; padding: 0 10px; }
.switchline { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.switchline form { margin-left: auto; }
.setgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.setgrid .card { margin: 0 0 16px; }
form.set { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px;
           align-items: end; }
form.set .full { grid-column: 1 / -1; }
form.set input:not([type="checkbox"]), form.set select, form.grid input, form.grid select { width: 100%; min-width: 0; }
.locked form.set, .locked .orderlist .mv, .locked .switchline form, .locked form.cmd { display: none; }

@media (max-width: 1000px) {
  .hero, .devhead { grid-template-columns: minmax(0, 1fr); }
  .trio, .rings, .setgrid { grid-template-columns: minmax(0, 1fr); }
  .devhead .devpic { max-width: 320px; }
}
@media (max-width: 600px) {
  .devgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .ring { grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr); gap: 8px; }
  .ring svg { width: 96px; height: 96px; }
  .ring .part b { font-size: 17px; }
  .planthead .seg { margin-left: 0; }
  .chip { font-size: 8px; padding: 2px 5px; }
}

/* Variant "nacht": the scene takes the full width, today's numbers follow as one row */
@media (min-width: 1001px) {
  :root[data-design="nacht"] .hero { grid-template-columns: minmax(0, 1fr); }
  :root[data-design="nacht"] .side { grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.7fr); }
  :root[data-design="nacht"] .side .wide { grid-column: auto; margin: 0; }
  :root[data-design="nacht"] .scene { max-height: 78vh; margin: 0 auto; width: 100%;
                                      max-width: calc(78vh * 1920 / 1072); }
}
:root[data-design="nacht"] .hero { background: var(--stage); border-radius: var(--radius); }
:root[data-design="nacht"] .side { padding: 0 16px 16px; }
@media (max-width: 1000px) { :root[data-design="nacht"] .side { padding: 0 10px 10px; } }
:root[data-design="nacht"] .dev.on { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent); }

/* Variant "plan": drawing sheet with frames instead of filled cards */
:root[data-design="plan"] .card, :root[data-design="plan"] .tile, :root[data-design="plan"] .dev {
  background: transparent; }
:root[data-design="plan"] .tile { border-style: dashed; }
:root[data-design="plan"] .tile.blk { background: var(--ink); color: var(--paper); border-style: solid; }
:root[data-design="plan"] h1, :root[data-design="plan"] h2, :root[data-design="plan"] h3,
:root[data-design="plan"] .dev .n { text-transform: uppercase; letter-spacing: .04em; }
:root[data-design="plan"] h1 { font-size: 26px; }
:root[data-design="plan"] h2 { font-size: 17px; }
:root[data-design="plan"] .dev .n { font-size: 15px; }
:root[data-design="plan"] .dev .pic, :root[data-design="plan"] .devpic { background: transparent; }
:root[data-design="plan"] .status, :root[data-design="plan"] .hint { border-radius: 2px; }
