/* Valgus — kandiline, minimalistlik. Värvid: dataviz-viitepalett (valideeritud hele/tume). */
:root {
  color-scheme: light;
  --page: #f4f4f1; --surface: #fcfcfb; --surface-2: #f0efec;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --line: #e1e0d9; --axis: #c3c2b7; --ring: rgba(11,11,11,.10);
  --s0: #b9b8b0; --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --on: #eda100; --good: #0ca30c; --bad: #d03b3b;
  --day: #eda100; --night: #2a78d6; --night-band: rgba(42,120,214,.07);
  --unk: repeating-linear-gradient(135deg, #c3c2b7 0 2px, transparent 2px 5px);
  --tl-name: 150px;
  --gap: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --line: #2c2c2a; --axis: #383835; --ring: rgba(255,255,255,.10);
    --s0: #5d5c57; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --on: #fab219; --night: #3987e5; --night-band: rgba(57,135,229,.10);
    --unk: repeating-linear-gradient(135deg, #4a4a46 0 2px, transparent 2px 5px);
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; text-decoration-color: var(--axis); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 6px; font-weight: 650; }
h2 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; margin: 0; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.fine { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; max-width: 72ch; }
code { font: 13px ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--surface-2); padding: 1px 5px; word-break: break-all; }
code.block { display: block; padding: 8px 10px; margin: 6px 0 12px; }

.i { width: 18px; height: 18px; flex: none; vertical-align: -4px; }

/* ---------- raam */
.top { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1120px; margin: 0 auto; padding: 0 16px; display: flex; align-items: stretch; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -.01em; text-decoration: none; padding: 14px 0; }
.brand .i { color: var(--on); width: 22px; height: 22px; }
.top nav { display: flex; }
.top nav a { display: flex; align-items: center; gap: 7px; padding: 0 14px; text-decoration: none; color: var(--ink-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 14px; }
.top nav a:hover { color: var(--ink); }
.top nav a.on { color: var(--ink); border-bottom-color: var(--ink); }
main { max-width: 1120px; margin: 0 auto; padding: 24px 16px 8px; }
footer { max-width: 1120px; margin: 0 auto; padding: 16px 16px 32px; display: flex; justify-content: space-between; gap: 16px;
  font-size: 12.5px; color: var(--muted); }
footer span, footer a { display: inline-flex; align-items: center; gap: 6px; }
footer .i { width: 14px; height: 14px; }
.pagehead { margin-bottom: 20px; }
.pagehead p { margin: 0; max-width: 70ch; }

/* ---------- paneelid */
.panel { background: var(--surface); border: 1px solid var(--line); padding: 20px; margin-bottom: var(--gap); }
.panel.flush { padding: 0; }
.panel.flush .ph { padding: 20px 20px 0; }
.ph { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.ph .muted { font-size: 13px; }
.cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--gap); }
.cols2 > .panel { margin-bottom: 0; }
.cols2 + .panel, .panel + .cols2 { margin-top: var(--gap); }

/* ---------- filtrid */
.filters { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: var(--gap); }
.chips { display: flex; flex-wrap: wrap; border: 1px solid var(--line); background: var(--surface); }
.chips a { padding: 7px 14px; text-decoration: none; color: var(--ink-2); font-size: 14px; border-right: 1px solid var(--line); }
.chips a:last-child { border-right: 0; }
.chips a:hover { color: var(--ink); background: var(--surface-2); }
.chips a.on { background: var(--ink); color: var(--surface); }
.range { display: flex; align-items: center; gap: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); }
.seg a { padding: 3px 10px; font-size: 13px; text-decoration: none; color: var(--ink-2); }
.seg a.on { background: var(--ink); color: var(--surface); }

/* ---------- vormid */
input, button, select { font: inherit; color: inherit; border-radius: 0; }
input[type=text], input:not([type]), input[type=email], input[type=url], input[type=password], input[type=number], input[type=date], input[type=datetime-local] {
  width: 100%; background: var(--surface); border: 1px solid var(--axis); padding: 8px 10px; min-height: 38px; }
.range input { width: auto; min-height: 34px; padding: 5px 8px; }
input:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible, .col:focus-visible { outline: 2px solid var(--s1); outline-offset: 1px; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; min-height: 38px;
  padding: 0 16px; background: var(--surface); border: 1px solid var(--ink); font-weight: 550; }
button:hover { background: var(--surface-2); }
button.primary { background: var(--ink); color: var(--surface); }
button.primary:hover { opacity: .88; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.ghost { border-color: var(--line); min-height: 34px; }
button.ghost.on { border-color: var(--ink); }
button.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--muted); font-weight: 400; text-decoration: underline; text-underline-offset: 3px; }
button.icon { border: 0; background: none; padding: 0; min-height: 0; width: 32px; height: 32px; color: var(--muted); }
button.icon:hover { color: var(--bad); }
.f { display: grid; gap: 12px; }
.f label { display: grid; gap: 5px; font-size: 13px; color: var(--ink-2); }
.f .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.f label.check, .f label.radio { display: flex; align-items: flex-start; gap: 9px; color: var(--ink); font-size: 14px; }
.f fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.f > button { justify-self: start; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--ink); flex: none; }
.f.row { grid-template-columns: 110px 80px 1fr 200px auto; align-items: end; }
.f.row label.check { align-self: center; }

/* ---------- teated */
.note, .alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; margin-bottom: var(--gap);
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--on); font-size: 14px; }
.note.ok { border-left-color: var(--good); }
.alert { border-left-color: var(--bad); }
.alert .i { color: var(--bad); }
.badge { font-size: 12px; padding: 2px 8px; border: 1px solid var(--line); color: var(--muted); }
.badge.ok { color: var(--good); border-color: currentColor; }

/* ---------- KPI */
.kpis { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr 1fr; gap: 0; margin-bottom: var(--gap);
  background: var(--surface); border: 1px solid var(--line); }
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--line); min-width: 0; }
.kpi:last-child { border-right: 0; }
.lbl { font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.val { font-size: 34px; font-weight: 650; letter-spacing: -.03em; line-height: 1.1; }
.kpi.hero .val { font-size: 44px; }
.val small { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 5px; letter-spacing: 0; }
.val.sm { font-size: 26px; }
.sub { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; margin-top: auto; }
.sub .i { width: 14px; height: 14px; }
.split { display: flex; gap: 18px; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.split span { display: inline-flex; align-items: center; gap: 6px; }
.split span:first-child .i { color: var(--day); }
.split span:last-child .i { color: var(--night); }
.bar2 { display: flex; height: 6px; gap: 2px; margin: 4px 0 2px; }
.bar2 i { display: block; }
.bar2 .d { background: var(--day); }
.bar2 .n { background: var(--night); flex: 1; }

/* ---------- seeriate värvid */
.s0 { background: var(--s0); } .s1 { background: var(--s1); } .s2 { background: var(--s2); } .s3 { background: var(--s3); }
.s4 { background: var(--s4); } .s5 { background: var(--s5); } .s6 { background: var(--s6); } .s7 { background: var(--s7); } .s8 { background: var(--s8); }
.sw { display: inline-block; width: 10px; height: 10px; flex: none; margin-right: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 14px; font-size: 13px; color: var(--ink-2); align-items: center; }
.legend > span { display: inline-flex; align-items: center; }
.key { display: inline-block; width: 12px; height: 8px; margin-right: 7px; }
.key.on { background: var(--ink-2); }
.key.unk { background: var(--unk); outline: 1px solid var(--axis); outline-offset: -1px; }
.key.night { background: var(--night-band); outline: 1px solid var(--line); outline-offset: -1px; }

/* ---------- ajajoon */
.tl { position: relative; }
.tl-rows { position: relative; }
.tl-row { display: flex; align-items: center; height: 34px; }
.tl-name { width: var(--tl-name); flex: none; padding-right: 12px; font-size: 13.5px; display: flex; align-items: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-track { position: relative; flex: 1; height: 100%; border-bottom: 1px solid var(--line); }
.tl-row:first-child .tl-track { border-top: 1px solid var(--line); }
.tl-night i { position: absolute; top: 0; bottom: 0; background: var(--night-band); }
.tl-track b { position: absolute; top: 9px; height: 16px; min-width: 2px; }
.tl-track b.unk { background: var(--unk); }
.tl-now { position: absolute; top: -4px; bottom: 0; width: 0; border-left: 1px solid var(--ink); }
.tl-now::before { content: ""; position: absolute; top: 0; left: -3px; width: 5px; height: 5px; background: var(--ink); }
.tl-axis { display: flex; height: 22px; }
.tl-ticks { position: relative; flex: 1; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-ticks span { position: absolute; top: 4px; transform: translateX(-50%); }
.tl-ticks span:first-child { transform: none; }
.tl-ticks span:last-child { transform: translateX(-100%); }

/* ---------- 30 päeva tulbad */
.bars { display: flex; height: 230px; }
.bars .y { display: flex; flex-direction: column; justify-content: space-between; width: 40px; flex: none; padding-bottom: 22px;
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; padding-right: 8px; }
.bars .y span { line-height: 0; }
.cols { flex: 1; display: grid; grid-template-columns: repeat(30, 1fr); position: relative;
  background: linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% calc((100% - 22px) / 4) no-repeat,
              linear-gradient(var(--line) 1px, transparent 1px) 0 calc((100% - 22px) / 4) / 100% 1px no-repeat,
              linear-gradient(var(--line) 1px, transparent 1px) 0 calc((100% - 22px) / 2) / 100% 1px no-repeat,
              linear-gradient(var(--line) 1px, transparent 1px) 0 calc((100% - 22px) * .75) / 100% 1px no-repeat; }
.col { display: flex; flex-direction: column; min-width: 0; outline: none; }
.col .stack { flex: 1; display: flex; flex-direction: column-reverse; gap: 2px; padding: 0 2px; border-bottom: 1px solid var(--axis); }
.col .stack i { display: block; flex: none; min-height: 1px; }
.col.we .stack { background: var(--surface-2); }
.col:hover .stack, .col:focus-visible .stack { background: var(--line); }
.col .x { height: 22px; font-size: 11px; color: var(--muted); text-align: center; padding-top: 4px; white-space: nowrap; overflow: visible; font-variant-numeric: tabular-nums; }
.col.today .x { color: var(--ink); }

/* ---------- tabel */
.tablewrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding-top: 14px; }
.tbl td.r, .tbl th.r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl th:first-child, .tbl td:first-child { padding-left: 20px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tfoot td { font-weight: 650; border-bottom: 0; }
.tbl .name { display: flex; align-items: center; text-decoration: none; font-weight: 550; }
.tbl .meta { display: block; font-size: 12px; color: var(--muted); margin: 2px 0 6px 18px; }
.share { display: block; height: 3px; margin-left: 18px; max-width: 180px; background: var(--surface-2); }
.share i { display: block; height: 100%; }
.state { display: inline-flex; align-items: center; gap: 5px; font-weight: 550; }
.state .i { width: 15px; height: 15px; }
.state.on { color: var(--ink); }
.state.on .i { color: var(--on); }
.state.unk { color: var(--muted); font-style: italic; font-weight: 400; }
.state.ok { color: var(--good); } .state.bad { color: var(--bad); }

/* ---------- valgustid */
.lights { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: var(--gap); }
.light { background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; scroll-margin-top: 80px; }
.light:target { border-color: var(--ink); }
.light.off { opacity: .6; }
.light > header { display: flex; align-items: flex-start; gap: 4px; padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.light > header .sw { margin-top: 6px; }
.light .lt { flex: 1; min-width: 0; }
.light h2 { font-size: 17px; text-transform: none; letter-spacing: -.01em; }
.watt { font-size: 14px; color: var(--muted); white-space: nowrap; }
.watt b { font-size: 26px; color: var(--ink); font-weight: 650; letter-spacing: -.02em; }
.bulbs { list-style: none; margin: 0; padding: 0; }
.bulbs li { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 18px; border-bottom: 1px solid var(--line); position: relative; }
.bulbs li.empty { color: var(--muted); font-size: 14px; padding: 14px 18px; }
.bi { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--on); flex: none; }
.bt { flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 14px; min-width: 0; }
.bt .muted { flex-basis: 100%; }
details.act > summary { list-style: none; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
details.act > summary::-webkit-details-marker { display: none; }
details.act > summary:hover, details.act[open] > summary { color: var(--ink); background: var(--surface-2); }
.pop { position: absolute; right: 8px; top: calc(100% - 4px); z-index: 5; width: min(320px, calc(100vw - 48px)); background: var(--surface);
  border: 1px solid var(--ink); padding: 16px; display: grid; gap: 14px; box-shadow: 6px 6px 0 var(--ring); }
.pop .subtle { padding-top: 10px; border-top: 1px solid var(--line); }
details.add, details.hist { border-bottom: 1px solid var(--line); }
details.add:last-child, details.hist:last-child { border-bottom: 0; }
details.add > summary, details.hist > summary { list-style: none; cursor: pointer; padding: 12px 18px; display: flex; align-items: center; gap: 8px; font-size: 14px; }
details.add > summary::-webkit-details-marker, details.hist > summary::-webkit-details-marker { display: none; }
details.add > summary { font-weight: 600; }
details.hist > summary { color: var(--muted); font-size: 13px; }
details.add > summary:hover, details.hist > summary:hover { background: var(--surface-2); }
details.add[open] > summary .i { transform: rotate(45deg); }
details.add > form, details.hist > form { padding: 0 18px 18px; }
.light .f.row { grid-template-columns: 1fr 72px; }
.light .f.row .l, .light .f.row .d { grid-column: 1 / -1; }
.light .f.row > button { grid-column: 1 / -1; justify-self: stretch; }
details.hist ul { list-style: none; margin: 0; padding: 0 18px 12px; font-size: 13px; }
details.hist li { display: flex; align-items: center; gap: 10px; padding: 4px 0; border-top: 1px solid var(--line); }
details.hist li span:first-child { flex: 1; }

/* ---------- logi */
.log { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.log li { display: flex; gap: 12px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); }
.log li:last-child { border-bottom: 0; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 13px; }
.dot { width: 7px; height: 7px; flex: none; align-self: center; }
.dot.ok { background: var(--good); } .dot.bad { background: var(--bad); }

.steps { padding-left: 20px; } .steps li { margin-bottom: 8px; }

/* ---------- kohtspikker */
#tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--surface); font-size: 12.5px;
  padding: 7px 10px; white-space: pre-line; max-width: 260px; line-height: 1.45; font-variant-numeric: tabular-nums; }

/* ---------- mobiil */
@media (max-width: 860px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi:nth-child(2) { border-right: 0; }
  .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .kpi.hero .val { font-size: 36px; }
}
@media (max-width: 640px) {
  :root { --tl-name: 96px; --gap: 12px; }
  .top-in { padding: 0 8px; }
  .brand span { display: none; }
  .top nav a { padding: 0 10px; }
  .top nav a span { display: none; }
  .top nav a .i { width: 20px; height: 20px; }
  main { padding: 16px 12px 8px; }
  h1 { font-size: 24px; }
  .panel { padding: 16px; }
  .panel.flush .ph { padding: 16px 16px 0; }
  .kpi { padding: 14px; }
  .val { font-size: 26px; } .kpi.hero .val { font-size: 32px; }
  .split { font-size: 18px; gap: 12px; }
  .hide-s { display: none; }
  .tbl th, .tbl td { padding: 10px 8px; }
  .tbl th:first-child, .tbl td:first-child { padding-left: 16px; }
  .tbl th:last-child, .tbl td:last-child { padding-right: 16px; }
  .lights { grid-template-columns: 1fr; }
  .f .pair { grid-template-columns: 1fr; }
  .range { width: 100%; }
  .range input { flex: 1; min-width: 0; }
  .bars { height: 190px; }
  .bars .y { width: 32px; }
  .col .stack { padding: 0 1px; gap: 1px; }
}
