/* Design profile "Dygnet": one dark theme, flat surfaces on #121212, the day as a timeline; Space Grotesk. */
:root {
  --font: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --num: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --radius: 10px;
  /* The flow diagrams read these: their values must not change (see AI_CONTEXT). */
  --bg: #11171d; --fg: #e3e9ef; --fg-2: #8f9ba7; --edge: #222c36;
  --card: #18212a; --card-edge: #25303b; --shadow: none;
  --nav-bg: #0b1015; --nav-fg: #a9b5c1; --nav-active: #1c2733; --nav-active-fg: #ffffff;
  --accent: #4b8ff0; --accent-ink: #ffffff; --act: #1d2731; --track: #25303b;
  --ok: #4cc27f; --ok-bg: #143324; --warn: #f0b547; --warn-bg: #3a2c10; --bad: #ff6b6b; --bad-bg: #3d1717;
  --muted-bg: #1a232c;
  /* The profile: background, surface, lines, text in three steps, Nu (orange) and Larm (red). */
  --hg-bg: #121212; --hg-surface: #1e1e1d; --hg-line: #2e2e2c; --hg-line-2: #5a5852; --hg-rail: #3a3a38;
  --hg-text: #f2f0eb; --hg-text-2: #b5b1a8; --hg-text-3: #8f8b83;
  --hg-now: #ff7a3d; --hg-now-text: #ff8a52; --hg-alarm: #ff6b5e; --hg-alarm-text: #ff8a7e;
  --focus: var(--hg-now);
  /* Surfaces (named glass from the earlier design; flat now). */
  --glass: var(--hg-surface); --glass-edge: var(--hg-line); --glass-strong: #262624;
  --blur: 0px; --radius-lg: 18px; --radius-pill: 999px;
  --text-dim: var(--hg-text-2); --ink-on-light: var(--hg-bg);
  --sig-from: #121212; --sig-to: #121212; --sig-glow: #121212; --sig-accent: var(--hg-now);
  color-scheme: dark;
}

/* The flow diagrams keep the faces they were laid out in: their labels are placed by measure. */
.heat-flow, .flow, .valve-flow, .hw-tank { --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif; --num: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace; font-family: var(--font); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--hg-bg); color: var(--hg-text); font: 15px/1.4 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }
a { color: var(--hg-text); }
[hidden] { display: none !important; }

/* Backdrop: fixed behind everything, so it does not scroll (iOS Safari too). */
.backdrop {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(120% 60% at 85% 0%, var(--sig-glow) 0%, transparent 60%), linear-gradient(180deg, var(--sig-from) 0%, var(--sig-to) 100%);
}

/* Shell layout: a bar of words along the bottom on phones, a plain list down the side from 760 px. */
.app { display: grid; grid-template-columns: 1fr; min-height: 100%; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--hg-bg); border-top: 1px solid var(--hg-line); color: var(--hg-text-2);
}
.nav a, .nav button.more {
  flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; min-height: 60px; padding: 0 2px;
  color: inherit; text-decoration: none; font: 400 0.8125rem var(--font); border: 0; background: none; cursor: pointer; position: relative;
}
.nav .label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav .cap { display: none; }
.nav [aria-current="page"] { color: var(--link-accent, var(--hg-now-text)); font-weight: 700; }
.nav a[href="/"][aria-current="page"] { color: var(--hg-now-text); }
.nav .dot { position: absolute; top: 14px; left: calc(50% + 18px); width: 7px; height: 7px; border-radius: 50%; background: var(--hg-alarm); }
.nav .brand, .nav .spacer, .nav .desk { display: none; }
.main { --page-x: 20px; overflow-x: clip; padding: 0 var(--page-x) calc(92px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 16px; align-content: start; min-width: 0; outline: none; }
.main > .head:first-child, .main > :first-child > .head:first-child { padding-top: 22px; }
@media (min-width: 760px) {
  .app { grid-template-columns: 220px minmax(0, 1fr); }
  .nav {
    position: sticky; top: 0; left: auto; right: auto; bottom: auto; height: 100vh; padding: 22px 12px;
    flex-direction: column; justify-content: flex-start; border-top: 0; border-right: 1px solid var(--hg-line); overflow-y: auto;
  }
  .nav .brand { display: block; padding: 0 12px 22px; color: var(--hg-text); font-size: 1.125rem; font-weight: 600; }
  .nav a { flex: 0 0 auto; justify-content: flex-start; min-height: 44px; padding: 0 12px; border-radius: 10px; font-size: 0.9375rem; }
  .nav a.desk { display: flex; }
  .nav a:hover { color: var(--hg-text); }
  .nav .spacer { display: block; flex: 1; }
  .nav button.more { display: none; }
  .nav .dot { top: 18px; left: auto; right: 12px; }
  .main { --page-x: 40px; padding: 0 var(--page-x) 40px; max-width: 1100px; }
}

/* Mer: a sheet from below with the departments that do not fit, Väder and Inställningar. */
.more-sheet {
  margin: auto auto 0; width: 100%; max-width: 520px; border: 1px solid var(--hg-line); border-bottom: 0; border-radius: 18px 18px 0 0;
  padding: 12px 12px calc(24px + env(safe-area-inset-bottom, 0px)); background: var(--hg-bg); color: var(--hg-text);
}
.more-sheet::backdrop { background: rgb(0 0 0 / 0.6); }
.more-sheet a, .more-sheet button {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 10px 12px; border-radius: 14px;
  color: inherit; text-decoration: none; font: 400 1rem var(--font); background: none; border: 0; border-radius: 12px; cursor: pointer; text-align: left;
}
.more-sheet a:hover, .more-sheet button:hover, .more-sheet [aria-current="page"] { background: var(--glass-strong); }
.more-sheet svg { display: none; }
.more-sheet .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--hg-alarm); margin-left: auto; }
.more-sheet .close { justify-content: center; color: var(--text-dim); }
.leave-sheet h2 { margin: 4px 12px 0; font-size: 1.1rem; }
.leave-sheet .hint { margin: 4px 12px 12px; }
.leave-sheet .discard { color: #ffb0b0; }
.alarm-link { display: block; color: inherit; text-decoration: none; }

/* Page head: title and status on one line, a hero value under it, then the subline. */
.head { display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 1.375rem; font-weight: 600; text-wrap: balance; }
/* The profile has no status with a dot beside a page's title; the page itself says how things are. */
.head > .pill { display: none; }
.head .sub { color: var(--text-dim); font-size: 0.85rem; flex-basis: 100%; }
.head > .btn { white-space: nowrap; }
.head .hero { flex-basis: 100%; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding-top: 6px; }
.head .hero .k { font-size: 0.76rem; color: var(--text-dim); }
.head .hero .big { font-family: var(--num); font-size: 4rem; font-weight: 500; line-height: 1; letter-spacing: -0.02em; white-space: nowrap; }
.head .hero .side { display: grid; gap: 4px; text-align: right; font-size: 0.78rem; color: var(--text-dim); padding-bottom: 6px; }
.head .hero .side span { white-space: nowrap; }
.head .hero.stale .big { opacity: 0.45; }
.head .hero .side b { color: var(--fg); font-family: var(--num); font-weight: 500; }

/* Cards and grids */
.card {
  background: var(--hg-bg); border: 1px solid var(--hg-line); border-radius: var(--radius-lg); padding: 16px; min-width: 0;
}
.card > h2, .hw-head h2 { margin: 0 0 12px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--hg-text-2); font-weight: 600; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.module-card { display: grid; gap: 12px; text-decoration: none; color: inherit; }
.module-card:hover { border-color: var(--glass-strong); }
.module-card .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.module-card .title { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.module-card .title svg { width: 22px; height: 22px; color: var(--accent); }
.kv { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.86rem; color: var(--text-dim); }
.kv b { color: var(--fg); font-family: var(--num); font-weight: 500; }
.empty { color: var(--text-dim); font-size: 0.9rem; margin: 0; }

/* Status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; white-space: nowrap; background: var(--ok-bg); color: var(--ok); }
.pill::before { content: none; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.unknown { background: var(--muted-bg); color: var(--text-dim); }

/* Alarm banner */
.alarms { display: grid; gap: 8px; }
.alarm {
  display: flex; gap: 10px; align-items: start; background: var(--hg-bg); color: var(--hg-text); border: 1px solid var(--hg-alarm);
  border-radius: var(--radius-lg); padding: 14px 16px; font-size: 0.9rem;
}
.alarm svg { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--hg-alarm); }
.alarm small { display: block; color: var(--hg-text-2); }

/* Lists and tables */
.table-wrap { overflow-x: auto; }
/* System sheet (Konto): a section per subject, title and purpose beside its card of rows on a wide screen. */
.sys { display: grid; gap: 28px; min-width: 0; }
.sys-section { display: grid; gap: 10px; min-width: 0; }
.sys-intro h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.sys-intro p { margin: 4px 0 0; color: var(--text-dim); font-size: 0.85rem; max-width: 46ch; }
.sys-cards { display: grid; gap: 14px; min-width: 0; }
.sys-card { padding: 0; overflow: hidden; }
.sys-row .v.num { font-family: var(--num); font-variant-numeric: tabular-nums; color: var(--fg); white-space: nowrap; }
.sys-row .v small { display: block; color: var(--text-dim); font-family: var(--font); }
.sys-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid rgb(255 255 255 / 0.07); }
.sys-head h3 { margin: 0; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.04em; color: var(--text-dim); }
.sys-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.sys-sum > div { display: grid; gap: 4px; padding: 16px; border-left: 1px solid rgb(255 255 255 / 0.07); }
.sys-sum > div:first-child { border-left: 0; }
.sys-sum .k { font-size: 0.78rem; color: var(--text-dim); }
.sys-sum .big { font: 500 1.5rem var(--num); letter-spacing: -0.02em; white-space: nowrap; }
.sys-sum .big small { font-size: 0.85rem; color: var(--text-dim); margin-left: 4px; letter-spacing: 0; }
.sys-sum .n { font-size: 0.78rem; color: var(--text-dim); }
.sys-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 16px; min-height: 56px; padding: 12px 16px; border-top: 1px solid rgb(255 255 255 / 0.07); }
.sys-card > .sys-row:first-child, .sys-rows > .sys-row:first-child, .sys-card > :first-child > .sys-row:first-child { border-top: 0; }
.sys-row .l { display: grid; gap: 2px; min-width: 0; }
.sys-row .t { font-size: 0.92rem; overflow-wrap: anywhere; }
.sys-row small { color: var(--text-dim); font-size: 0.78rem; overflow-wrap: anywhere; }
.sys-row .v { color: var(--text-dim); font-size: 0.92rem; text-align: right; overflow-wrap: anywhere; }
.sys-row.input { grid-template-columns: minmax(160px, 1fr) minmax(0, 420px); }
.sys-row.input input { width: 100%; }
.sys-row.end { grid-template-columns: minmax(0, 1fr) auto; }
.sys-row.end .form-error { grid-column: 1; }
.sys-row.end .btn { grid-column: 2; }
.sys-inline { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.sys-inline input { flex: 1; min-width: 0; }
.sys-key { grid-template-columns: minmax(0, 1fr); }
.sys-key code { display: block; padding: 10px 12px; border-radius: 10px; background: rgb(255 255 255 / 0.05); border: 1px solid var(--glass-edge); font-family: var(--num); font-size: 0.82rem; overflow-wrap: anywhere; user-select: all; }
.sys-add > .form-error { padding: 0 16px 12px; }
.qr { width: 184px; max-width: 100%; justify-self: end; }
.qr svg { display: block; width: 100%; height: auto; border-radius: 10px; }
@media (max-width: 640px) {
  .sys-row.input { grid-template-columns: minmax(0, 1fr); }
  /* A row with several controls (role, usage, buttons) puts them on their own line under the text. */
  .sys-row:not(.input):has(> .sys-inline:not(.tight) > :nth-child(2)) { grid-template-columns: minmax(0, 1fr); }
  .sys-row:not(.input) > .sys-inline:not(.tight) { justify-content: flex-start; flex-wrap: wrap; }
  .sys-row:not(.input) > .sys-inline:not(.tight) > .v { text-align: left; margin-right: auto; }
  /* A job's last good run goes under its name. */
  .sys-fold li > .sys-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .sys-fold li > .sys-row > .v { text-align: left; }
  .sys-fold li > .sys-row > .v small { text-align: left; }
}
@media (min-width: 1200px) {
  .sys-section:has(> .sys-intro) { grid-template-columns: minmax(200px, 280px) minmax(0, 1fr); gap: 32px; align-items: start; }
  .sys-intro { padding-top: 14px; }
}
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { white-space: nowrap; text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); font-weight: 600; padding: 0 10px 8px 0; }
td { padding: 10px 10px 10px 0; border-top: 1px solid var(--glass-edge); vertical-align: middle; }
td.actions { text-align: right; white-space: nowrap; }
td.row-actions { text-align: right; white-space: nowrap; }
td.row-actions .btn + .btn { margin-left: 6px; }

/* Forms and buttons */
.form { display: grid; gap: 12px; max-width: 420px; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
label { display: grid; gap: 5px; font-size: 0.82rem; font-weight: 500; color: var(--text-dim); }
input, select { width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--hg-line-2); background: var(--hg-surface); color: var(--hg-text); font-size: 1rem; }
input:focus-visible, select:focus-visible { outline: 2px solid var(--hg-now); outline-offset: -1px; border-color: transparent; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--hg-line-2); background: transparent; color: var(--hg-text); font-weight: 500; font-size: 0.875rem; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--hg-text-3); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--hg-now); border-color: var(--hg-now); color: var(--hg-bg); font-weight: 700; }
.btn-primary:hover:not(:disabled) { border-color: var(--hg-now-text); background: var(--hg-now-text); }
.btn-danger { color: var(--hg-alarm-text); }
.btn-small { min-height: 36px; padding: 6px 12px; font-size: 0.8rem; }
.form-error { margin: 0; color: var(--hg-alarm-text); font-size: 0.875rem; }
.hint { margin: 0; color: var(--text-dim); font-size: 0.82rem; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 20; background: var(--hg-text); color: var(--hg-bg); padding: 10px 16px; border-radius: 12px; font-size: 0.9rem; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--hg-alarm); color: var(--hg-bg); }
@media (min-width: 760px) { .toast { bottom: 24px; } }

/* The sonar on the dot that marks "now" (and the door): one calm ring. */
@keyframes hg-sonar { 0% { transform: scale(1); opacity: 0.6; } 70%, 100% { transform: scale(3); opacity: 0; } }
.hg-sonar { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid currentColor; animation: hg-sonar 3.6s ease-out infinite; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .hg-sonar { opacity: 0; } }

/* Login: a line from the top of the page down to the big dot, the name beside it, the form under. */
.login-page { min-height: 100%; overflow: hidden; }
.login { position: relative; min-height: 100vh; min-height: 100dvh; max-width: 390px; margin: 0 auto; padding: 0 20px; display: flex; flex-direction: column; justify-content: center; }
.login-head { display: grid; grid-template-columns: 48px 20px 1fr; column-gap: 10px; min-height: 70px; }
.login-head::before { content: ""; }
.login-rail { position: relative; display: flex; justify-content: center; background: linear-gradient(var(--hg-now), var(--hg-now)) center bottom / 2px 60% no-repeat; }
.login-rail::before { content: ""; position: absolute; left: 50%; margin-left: -1px; bottom: calc(100% - 12px); width: 2px; height: 100vh; background: linear-gradient(to top, var(--hg-now) 0, var(--hg-now) 50px, var(--hg-rail) 190px); }
.login-dot { position: relative; width: 16px; height: 16px; margin-top: 8px; border-radius: 50%; background: var(--hg-now); color: var(--hg-now); }
.login-title { display: flex; flex-direction: column; padding-bottom: 14px; }
.login-title .name { font-size: 1.875rem; font-weight: 600; line-height: 1.1; }
.login-title .sub { font-size: 0.8125rem; color: var(--hg-text-2); }
.login-card { position: relative; display: grid; gap: 16px; border: 1px solid var(--hg-now); border-radius: 18px; padding: 22px 16px 16px; }
.login-card-dot { position: absolute; left: 63px; top: -5px; width: 10px; height: 10px; border-radius: 50%; background: var(--hg-now); }
.login-fields { display: grid; gap: 6px; }
.login-fields label { font-size: 0.8125rem; font-weight: 400; color: var(--hg-text-2); }
.login-fields input + label { margin-top: 6px; }
.login-fields input { font-weight: 500; }
.login-card .btn { width: 100%; }
.code-boxes { margin: 0; padding: 0; border: 0; min-width: 0; }
.code-boxes legend { padding: 0; margin-bottom: 10px; font-size: 0.8125rem; color: var(--hg-text-2); }
.code-row { display: grid; grid-template-columns: repeat(3, 46px) 8px repeat(3, 46px); justify-content: space-between; align-items: center; }
.code-row input { width: 46px; height: 58px; padding: 0; border-radius: 12px; text-align: center; font: 600 1.625rem var(--font); caret-color: var(--hg-now); }
.code-row input:focus-visible { outline: 0; border: 2px solid var(--hg-now); }
.code-dash { width: 8px; height: 2px; border-radius: 1px; background: var(--hg-line-2); }
.login-links { display: flex; justify-content: space-between; gap: 12px; }
.login-links button { min-height: 44px; padding: 0; border: 0; background: none; color: var(--hg-text-2); font: 400 0.8125rem var(--font); cursor: pointer; }
.login-links button:hover { color: var(--hg-text); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* The page's backdrop is the profile's flat background everywhere; Hem draws its own sky band. */
.backdrop.sky { background: var(--hg-bg); }
.stars { display: none; }

/* Hem's sky: a band at the top that fades into the background (sky.js Band). */
.main { position: relative; }
.home-sky { position: absolute; top: 0; left: calc(-1 * var(--page-x)); right: calc(-1 * var(--page-x)); height: 680px; overflow: hidden; z-index: -1; pointer-events: none; }
.home-sky.night { background: linear-gradient(#070a1a 0, #0b102a 200px, #0d1124 420px, var(--hg-bg) 640px); }
.home-sky.dawn { background: linear-gradient(#2a1f3e 0, #5a3a4a 180px, #2a2238 400px, var(--hg-bg) 640px); }
.home-sky.dusk { background: linear-gradient(#241c3c 0, #5e3444 170px, #22203a 400px, var(--hg-bg) 640px); }
.home-sky.day { background: linear-gradient(#1c4a7c 0, #2a5d92 150px, #1d3a5c 380px, var(--hg-bg) 640px); }
.home-sky.overcast.day { background: linear-gradient(#3a4552 0, #36404c 200px, #252a31 420px, var(--hg-bg) 640px); }
.home-sky.overcast.night { background: linear-gradient(#11141c 0, #161a22 220px, #141619 420px, var(--hg-bg) 640px); }
.home-sky .sky-fade { position: absolute; inset: 0; background: linear-gradient(rgb(18 18 18 / 0) 0, rgb(18 18 18 / 0) 330px, var(--hg-bg) 640px); }
.sky-filters { position: absolute; }
.sky-night, .sky-dust, .sky-stars { position: absolute; inset: 0; }
.sky-dust { width: 100%; height: 100%; opacity: 0.55; }
@media (max-resolution: 1.5dppx) { .sky-dust { opacity: 0.28; } }
.sky-gas { position: absolute; left: -30%; width: 160%; top: 150px; height: 230px; transform: rotate(-17deg);
  -webkit-mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 0%, rgb(0 0 0 / 0.55) 45%, transparent 100%);
  mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 0%, rgb(0 0 0 / 0.55) 45%, transparent 100%); }
.sky-gas span { position: absolute; inset: 0; background: radial-gradient(ellipse 50% 50% at 50% 50%, rgb(86 104 176 / 0.34) 0%, rgb(70 86 160 / 0.14) 55%, transparent 100%); }
.sky-gas svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sky-stars { inset: 0 -36px; animation: hg-drift 140s linear infinite alternate; }
.sky-stars.partly { opacity: 0.55; }
.sky-stars span { position: absolute; left: 36px; top: 0; width: 1px; height: 1px; border-radius: 50%; }
.sky-stars i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #dce6ff; animation: hg-twinkle 7s ease-in-out infinite; }
@keyframes hg-drift { to { transform: translateX(-18px); } }
@keyframes hg-twinkle { 0%, 100% { opacity: 0.12; } 50% { opacity: 0.75; } }
.sky-day i { position: absolute; top: -120px; width: 90px; height: 760px; transform-origin: 50% 0; background: linear-gradient(rgb(255 236 200 / 0.16), rgb(255 236 200 / 0) 78%); filter: blur(14px); animation: hg-shaft 18s ease-in-out infinite alternate; }
.sky-day i:nth-child(1) { left: 58%; transform: rotate(24deg); }
.sky-day i:nth-child(2) { left: 72%; width: 50px; transform: rotate(30deg); animation-delay: -6s; opacity: 0.7; }
.sky-day i:nth-child(3) { left: 86%; width: 120px; transform: rotate(20deg); animation-delay: -11s; opacity: 0.5; }
@keyframes hg-shaft { 0% { opacity: 0.35; } 100% { opacity: 1; } }
.sky-clouds i { position: absolute; border-radius: 50%; background: radial-gradient(closest-side, rgb(200 210 225 / 0.20), rgb(200 210 225 / 0)); filter: blur(6px); animation: hg-cloud 90s linear infinite; }
.sky-clouds i:nth-child(1) { top: 40px; left: -40%; width: 320px; height: 110px; }
.sky-clouds i:nth-child(2) { top: 140px; left: -60%; width: 420px; height: 140px; animation-delay: -30s; animation-duration: 120s; }
.sky-clouds i:nth-child(3) { top: 250px; left: -50%; width: 360px; height: 120px; animation-delay: -60s; animation-duration: 105s; }
.sky-clouds i:nth-child(4) { top: 10px; left: -70%; width: 480px; height: 160px; animation-delay: -80s; animation-duration: 140s; }
.sky-clouds.overcast i { background: radial-gradient(closest-side, rgb(170 178 190 / 0.30), rgb(170 178 190 / 0)); }
.night .sky-clouds i { background: radial-gradient(closest-side, rgb(90 100 120 / 0.22), rgb(90 100 120 / 0)); }
@keyframes hg-cloud { to { transform: translateX(220%); } }
@media (prefers-reduced-motion: reduce) { .home-sky * { animation: none !important; } }

/* Hem: the date, then the day as a timeline down a rail to Just nu and on. */
.home { position: relative; z-index: 1; display: grid; min-width: 0; max-width: 560px; }
.home-top { padding: 22px 0 14px; }
.home-top h1 { margin: 0; font-size: 1.375rem; font-weight: 600; }
.timeline { display: flex; flex-direction: column; }
.tl-row { display: grid; grid-template-columns: 48px 20px minmax(0, 1fr); column-gap: 10px; min-height: 44px; }
.tl-time { padding-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-rail { display: flex; justify-content: center; background: linear-gradient(var(--hg-rail), var(--hg-rail)) center / 2px 100% no-repeat; }
.tl-dot { width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; box-sizing: border-box; background: var(--hg-bg); border: 2px solid #6e6b64; }
.tl-text { display: flex; flex-direction: column; padding-bottom: 14px; min-width: 0; overflow-wrap: anywhere; }
.tl-sub { font-size: 0.8125rem; color: var(--hg-text-2); }
.tl-row.past { color: var(--hg-text-2); }
.tl-row.past.is-alarm .tl-time, .tl-row.past.is-alarm .tl-text { color: var(--hg-alarm-text); }
.tl-row.past.is-alarm .tl-dot { border-color: var(--hg-alarm); }
.tl-row.now { min-height: 62px; }
.tl-row.now .tl-time { font-weight: 700; color: var(--hg-now-text); }
.tl-row.now .tl-rail { background-image: linear-gradient(var(--hg-now), var(--hg-now)); }
.tl-row.now .tl-dot { position: relative; width: 16px; height: 16px; margin-top: 2px; border: 0; background: var(--hg-now); color: var(--hg-now); }
.tl-row.now .tl-dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid currentColor; animation: hg-sonar 3.6s ease-out infinite; }
.tl-row.now .tl-text strong { font-size: 1.125rem; font-weight: 600; line-height: 1.2; }
.tl-row.now.is-alarm .tl-time { color: var(--hg-alarm-text); }
.tl-row.now.is-alarm .tl-rail { background-image: linear-gradient(var(--hg-alarm), var(--hg-alarm)); }
.tl-row.now.is-alarm .tl-dot { background: var(--hg-alarm); color: var(--hg-alarm); }
.tl-row.now.is-alarm .tl-dot::after { animation-duration: 2.4s; }
.tl-row.later .tl-rail { background: repeating-linear-gradient(var(--hg-line-2) 0 4px, transparent 4px 8px) center / 2px 100% no-repeat; }
.tl-row.later.last .tl-rail { background-size: 2px 12px; background-position: center top; }
.tl-row.later .tl-dot { border: 0; background: var(--hg-text); }
.tl-hours { position: relative; height: 34px; display: flex; justify-content: space-between; padding: 6px 1px 0; font-size: 0.6875rem; color: var(--hg-text-2); }
.tl-hours::before, .tl-gap::before { content: ""; position: absolute; left: 67px; top: 0; bottom: 0; width: 2px; background: repeating-linear-gradient(var(--hg-line-2) 0 4px, transparent 4px 8px); }
.tl-gap { position: relative; height: 22px; }
@media (prefers-reduced-motion: reduce) { .tl-row.now .tl-dot::after { opacity: 0; } }

/* Just nu: the frame. Its dots sit on the rail, top and bottom. */
.now-card { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 18px 16px 0; border: 1px solid var(--hg-now); border-radius: 18px; background: rgb(18 18 18 / 0.86); }
.now-card-dot { position: absolute; left: 63px; width: 10px; height: 10px; border-radius: 50%; background: var(--hg-now); }
.now-card-dot.top { top: -5px; }
.now-card-dot.bottom { bottom: -5px; z-index: 1; box-shadow: 0 0 0 2px var(--hg-bg); }
.now-card-end { display: block; height: 2px; }
.now-card.is-alarm { border-color: var(--hg-alarm); animation: hg-alarm 2.4s ease-in-out infinite; }
.now-card.is-alarm .now-card-dot { background: var(--hg-alarm); }
@keyframes hg-alarm {
  0%, 100% { box-shadow: 0 0 0 0 rgb(255 107 94 / 0), inset 0 0 0 0 rgb(255 107 94 / 0); border-color: rgb(255 107 94 / 0.5); }
  50% { box-shadow: 0 0 24px 2px rgb(255 107 94 / 0.36), inset 0 0 22px 0 rgb(255 107 94 / 0.10); border-color: var(--hg-alarm); }
}
@media (prefers-reduced-motion: reduce) { .now-card.is-alarm { animation: none; } }
.now-weather { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.now-out { display: flex; flex-direction: column; }
.now-out .k { font-size: 0.75rem; color: var(--hg-text-2); }
.now-out .v { font-size: 4rem; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.now-side { display: flex; flex-direction: column; font-size: 0.8125rem; color: var(--hg-text-2); text-align: right; }
.now-alarms { display: grid; gap: 6px; }
.now-alarm { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 12px; background: var(--hg-surface); text-decoration: none; color: var(--hg-text); }
.now-alarm .t { color: var(--hg-alarm-text); font-weight: 600; }
.now-alarm .s { font-size: 0.8125rem; color: var(--hg-text-2); }
.now-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(68px, 1fr)); gap: 6px; }
.now-tile { min-height: 64px; padding: 10px 8px; border-radius: 12px; background: var(--hg-surface); border: 1px solid transparent; text-decoration: none; color: var(--hg-text);
  display: flex; flex-direction: column; justify-content: space-between; align-items: center; text-align: center; min-width: 0; }
.now-tile .k { font-size: 0.6875rem; color: var(--tile-accent, var(--hg-text-2)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.now-tile .v { font-size: 1.125rem; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.now-tile.bad { border-color: var(--hg-alarm); }
.now-tile.bad .k { color: var(--hg-alarm-text); }
.now-tile.unknown .v { color: var(--hg-text-3); }
.now-tile:hover { border-color: var(--hg-line-2); }
.now-price { margin: 0 -16px; padding: 4px 0 0; border: 0; background: transparent; color: var(--hg-text); font: 400 0.875rem var(--font); text-align: left; cursor: pointer;
  display: flex; flex-direction: column; -webkit-tap-highlight-color: transparent; user-select: none; }
.now-price-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding: 0 16px 12px; }
.now-price-now { display: flex; flex-direction: column; gap: 4px; }
.now-price-label { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; color: var(--hg-now-text); }
.now-price-dots { display: flex; gap: 4px; }
.now-price-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--hg-line-2); }
.now-price-dots i.on { background: var(--hg-now); }
.now-price-value { font-size: 2rem; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.now-price-value small { font-size: 0.875rem; font-weight: 500; }
.now-price-side { font-size: 0.8125rem; color: var(--hg-text-2); text-align: right; }
.now-price-day { position: relative; display: block; height: 72px; border-radius: 0 0 17px 17px; overflow: hidden; }
.now-price-day svg { display: block; width: 100%; height: 72px; }
.now-price-dot { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--hg-text); }
.now-card.is-alarm .now-price-label, .now-card.is-alarm .now-price-dots i.on { color: var(--hg-now-text); }

/* A department's Dygnet: Hem's rail and frame in the department's colour, alarms still red. */
.dept-day { --hg-now: var(--sig-accent); --hg-now-text: var(--sig-accent); max-width: 560px; padding-top: 4px; }
.dept-frame { padding-bottom: 16px; }
.dept-frame .now-card-end { display: none; }
.dept-frame .now-out .v { font-size: 3.5rem; }
.dept-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 6px; }
.dept-tile { display: flex; flex-direction: column; padding: 10px 8px; border-radius: 12px; background: var(--hg-surface); min-width: 0; }
.dept-tile .k { font-size: 0.6875rem; color: var(--hg-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dept-tile .v { font-size: 1.125rem; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dept-why { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 12px; background: var(--hg-surface); }
.dept-why .t { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sig-accent); }
.dept-acts { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.dept-acts button { min-height: 48px; border-radius: 12px; border: 1px solid var(--hg-line-2); background: transparent; color: var(--hg-text); font: 500 0.875rem var(--font); cursor: pointer; }
.dept-acts button[aria-pressed="true"], .dept-acts button.primary { border-color: var(--sig-accent); background: var(--sig-accent); color: var(--hg-bg); font-weight: 600; }
.dept-acts button:disabled { opacity: 0.5; cursor: default; }
.dept-acts button small { display: block; font-size: 0.6875rem; font-weight: 500; opacity: 0.8; }
.dept-link { align-self: center; min-height: 44px; display: inline-flex; align-items: center; border: 0; background: transparent; color: var(--hg-text-2); font: 500 0.8125rem var(--font); text-decoration: underline; cursor: pointer; }
.dept-band { display: grid; gap: 6px; }
.dept-band .bar { position: relative; height: 10px; border-radius: 5px; background: var(--hg-line); }
.dept-band .ok { position: absolute; top: 0; bottom: 0; border-radius: 5px; background: color-mix(in srgb, var(--sig-accent) 40%, var(--hg-line)); }
.dept-band .mark { position: absolute; top: -4px; width: 4px; height: 18px; margin-left: -2px; border-radius: 2px; background: var(--sig-accent); }
.dept-band .scale { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--hg-text-2); }

/* Alla vyer: the older views, grouped, one row each. */
.dept-views { display: grid; gap: 18px; max-width: 560px; }
.dept-views-intro { margin: 0; font-size: 0.8125rem; color: var(--hg-text-2); }
.dept-views-group h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sig-accent); }
.dept-views-list { display: flex; flex-direction: column; border: 1px solid var(--hg-line); border-radius: 18px; overflow: hidden; }
.dept-views-list a { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 16px; text-decoration: none; color: var(--hg-text); }
.dept-views-list a + a { border-top: 1px solid var(--hg-line); }
.dept-views-list a:hover { background: var(--hg-surface); }
.dept-views-list .txt { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.dept-views-list .what { font-size: 0.8125rem; color: var(--hg-text-2); }
.dept-views-list .chev { color: var(--hg-text-2); font-size: 1.25rem; }
.dept-people { display: grid; gap: 6px; }
.dept-person { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px; border-radius: 12px; background: var(--hg-surface); }
.dept-person .name { font-weight: 600; }
.dept-person .what { font-size: 0.8125rem; color: var(--hg-text-2); text-align: right; }
.dept-person.is-home .name { color: var(--sig-accent); }
.dept-person.is-unknown .what { color: var(--hg-text-3); }

/* Reglage and Analys: sections with the title in the department's colour, a period switch, plain charts. */
.dept-page { display: grid; gap: 12px; max-width: 560px; min-width: 0; }
.reglage-intro { margin: 0; font-size: 0.8125rem; color: var(--hg-text-2); max-width: 560px; }
.dept-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--hg-line); border-radius: 18px; min-width: 0; }
.dept-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.dept-card-head h2, .f-group.f-flat .f-flat-title { margin: 0; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sig-accent); }
.dept-card-head span, .f-flat-title small { font-size: 0.75rem; color: var(--hg-text-2); text-transform: none; letter-spacing: 0; font-weight: 400; }
.f-flat-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 0 0 4px; }
.f-flat-title span:first-child { flex: 1; }
.dept-card .hint, .dept-card .note { margin: 0; font-size: 0.8125rem; color: var(--hg-text-2); }
.dept-seg { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 14px; background: var(--hg-surface); }
.dept-seg button { min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--hg-text-2); font: 500 0.875rem var(--font); cursor: pointer; }
.dept-seg button[aria-pressed="true"] { background: var(--hg-text); color: var(--hg-bg); font-weight: 700; }
.dept-card .dept-seg button[aria-pressed="true"] { background: var(--sig-accent); }
.dept-seg button:disabled { cursor: default; }
.dept-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.dept-stats .dept-tile { padding: 12px 10px; }
.dept-stats .dept-tile .v { font-size: 1.375rem; }
.dept-chart svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font); }
.dept-chart .grid { stroke: var(--hg-line); stroke-width: 1; }
.dept-chart .tick, .dept-chart .mark { fill: var(--hg-text-2); font-size: 11px; }
.dept-chart .band { fill: color-mix(in srgb, var(--sig-accent) 18%, transparent); }
.dept-chart .line { fill: none; stroke: var(--sig-accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dept-chart .dot { fill: var(--sig-accent); stroke: var(--hg-bg); stroke-width: 2; }
.dept-chart .last { fill: var(--hg-text); font-size: 12px; font-weight: 600; }
.dept-chart .dept-bar { fill: color-mix(in srgb, var(--sig-accent) 55%, transparent); }
.dept-chart .dept-bar.today { fill: var(--sig-accent); }
.dept-chart .limit { stroke: var(--hg-text-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
.dept-x { display: flex; justify-content: space-between; padding-left: 30px; font-size: 0.6875rem; color: var(--hg-text-2); }
.dept-sum { margin: 0; font-size: 0.8125rem; color: var(--hg-text-2); }
.dept-sum b { color: var(--hg-text); font-weight: 600; }
.dept-more { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 16px; border: 1px solid var(--hg-line); border-radius: 18px; text-decoration: none; color: var(--hg-text); }
.dept-more:hover { background: var(--hg-surface); }
.dept-rows { display: flex; flex-direction: column; }
.dept-rows > * { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.dept-rows > * + * { border-top: 1px solid var(--hg-line); }
.dept-rows .when { width: 98px; flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.dept-rows .txt { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.dept-rows .what { font-size: 0.75rem; color: var(--hg-text-2); }
.dept-rows .val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.f-group.f-flat { padding: 16px; border-radius: 18px; }
.dept-save-bar { position: sticky; bottom: 0; }
.dept-stats .dept-tile .k { white-space: normal; overflow: visible; }
