:root {
    --bg: #edefea;
    --surface: #fbfbf8;
    --ink: #17202b;
    --muted: #5b6672;
    --rule: #d3d8d0;
    --charge: #2f6fb0;
    --discharge: #b0780a;
    --idle: #c4cac2;
    --focus: #2f6fb0;
    --error: #a3341f;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 400 16px/1.55 Archivo, system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
}

a { color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

main {
    max-width: 62rem;
    margin: 0 auto;
    padding: 2.5rem 1.25rem 4rem;
}

/* ---------- Top ---------- */

.top {
    display: flex;
    align-items: baseline;
    gap: 1.75rem;
    max-width: 62rem;
    margin: 0 auto;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--rule);
}

.brand {
    font-weight: 700;
    font-stretch: 125%;
    text-decoration: none;
    letter-spacing: -0.01em;
}

.top nav { display: flex; gap: 1.25rem; flex: 1; }

.top nav a { color: var(--muted); text-decoration: none; padding: 0.25rem 0; }
.top nav a[aria-current] { color: var(--ink); box-shadow: inset 0 -2px var(--ink); }

button.link {
    white-space: nowrap;
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--muted);
    cursor: pointer;
}
button.link:hover { color: var(--ink); }

/* ---------- Type ---------- */

h1 {
    margin: 0 0 0.75rem;
    max-width: 22ch;
    font-size: clamp(2rem, 5.2vw, 3.25rem);
    line-height: 1.05;
    font-weight: 650;
    font-stretch: 118%;
    letter-spacing: -0.02em;
}

h2 {
    margin: 2.75rem 0 0.75rem;
    font-size: 1.25rem;
    font-weight: 650;
    font-stretch: 110%;
}

.lede { max-width: 60ch; margin: 0 0 1.5rem; color: var(--muted); font-size: 1.0625rem; }

.note { max-width: 70ch; color: var(--muted); font-size: 0.875rem; }

/* ---------- Segment-navigation (dage, perioder) ---------- */

.seg {
    display: inline-flex;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: var(--surface);
    margin-bottom: 1.75rem;
}

.seg a, .seg span {
    padding: 0.4rem 1rem;
    border-radius: 999px;
    text-decoration: none;
    font-size: 0.9375rem;
    color: var(--muted);
}
.seg a:hover { color: var(--ink); }
.seg [aria-current] { background: var(--ink); color: var(--surface); }

/* ---------- Grafer ---------- */

.panel {
    margin: 0 0 1.25rem;
    padding: 1rem 1rem 0.5rem;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 6px;
}

.panel figcaption {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.legend { display: flex; gap: 1rem; font-weight: 400; color: var(--muted); font-size: 0.875rem; }

.sw {
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    margin-right: 0.4rem;
    border-radius: 2px;
    vertical-align: -0.05rem;
}
.sw.charge { background: var(--charge); }
.sw.discharge { background: var(--discharge); }
.sw.idle { background: var(--idle); }

.scroll { overflow-x: auto; }

.chart { display: block; width: 100%; min-width: 640px; height: auto; }
.chart .charge { fill: var(--charge); }
.chart .discharge { fill: var(--discharge); }
.chart .idle { fill: var(--idle); }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .base { stroke: var(--muted); stroke-width: 1; }
.chart .soc { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.chart text { font: 12px Archivo, system-ui, sans-serif; fill: var(--muted); }
.chart .ay { text-anchor: end; }
.chart .dl { fill: var(--ink); font-weight: 600; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover { fill: rgba(23, 32, 43, 0.06); }

#tip {
    position: fixed;
    z-index: 10;
    max-width: 22rem;
    padding: 0.4rem 0.6rem;
    background: var(--ink);
    color: var(--surface);
    border-radius: 4px;
    font-size: 0.8125rem;
    pointer-events: none;
}

/* ---------- Nøgletal ---------- */

.facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 1px;
    margin: 0 0 1.25rem;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 6px;
    overflow: hidden;
}
.facts div { padding: 0.75rem 1rem; box-shadow: 0 0 0 1px var(--rule); }
.facts dt { color: var(--muted); font-size: 0.875rem; }
.facts dd { margin: 0.15rem 0 0; font-size: 1.375rem; font-weight: 600; font-stretch: 110%; }

/* ---------- Tabeller ---------- */

table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.875rem; }
th, td { padding: 0.55rem 0.75rem 0.55rem 0; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.n { text-align: right; }
tr.idle td { color: var(--muted); }

/* ---------- Formularer ---------- */

.settings { margin-top: 2.75rem; border-top: 1px solid var(--rule); padding-top: 1rem; }
.settings summary { cursor: pointer; font-weight: 600; font-size: 1.0625rem; }
.settings form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 1rem 1.25rem;
    margin-top: 1.25rem;
    align-items: end;
}
.settings fieldset { grid-column: 1 / -1; border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
.settings legend { padding: 0; margin-bottom: 0.4rem; color: var(--muted); font-size: 0.875rem; }

label { display: grid; gap: 0.3rem; color: var(--muted); font-size: 0.875rem; }
label.radio { display: flex; align-items: center; gap: 0.5rem; color: var(--ink); font-size: 0.9375rem; }

input:not([type=radio]), select {
    width: 100%;
    padding: 0.55rem 0.7rem;
    font: inherit;
    font-size: 1rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid #b9c0b6;
    border-radius: 4px;
}

button[type=submit] {
    justify-self: start;
    padding: 0.6rem 1.25rem;
    font: inherit;
    font-weight: 600;
    color: var(--surface);
    background: var(--ink);
    border: 0;
    border-radius: 4px;
    cursor: pointer;
}
button[type=submit]:hover { background: #2b3644; }

/* ---------- Login ---------- */

.login {
    display: grid;
    gap: 0.75rem;
    max-width: 22rem;
    margin: 12vh auto 0;
}
.login h1 { margin-bottom: 0; }
.login .lede { margin-bottom: 1rem; }
.error { margin: 0; color: var(--error); }

@media (max-width: 40rem) {
    main { padding-top: 1.75rem; }
    .top { gap: 1rem; padding-inline: 1rem; }
    .top nav { gap: 0.9rem; }
    .brand { font-stretch: 100%; }
    .pos { min-width: 12rem; }
    .track { flex-basis: 4.5rem; }
    .seg a, .seg span { padding: 0.4rem 0.75rem; }
}

/* ---------- Trading ---------- */

.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .ln.charge { stroke: var(--charge); }
.chart .ln.discharge { stroke: var(--discharge); }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .dot.charge { fill: var(--charge); }
.chart .dot.discharge { fill: var(--discharge); }

.sub { display: flex; gap: 1.25rem; margin-bottom: 1.5rem; font-size: 0.9375rem; }
.sub a { color: var(--muted); text-decoration: none; }
.sub a[aria-current] { color: var(--ink); font-weight: 600; }

.sym { color: var(--muted); font-size: 0.8125rem; margin-left: 0.25rem; }

.trend span { display: inline-block; min-width: 2.6rem; color: var(--muted); }
.trend .up, .trend .down { color: var(--ink); }
.trend .up::before { content: "↑ "; color: var(--charge); }
.trend .down::before { content: "↓ "; color: var(--discharge); }

.pos { display: flex; align-items: center; gap: 0.75rem; min-width: 15rem; }
.track {
    position: relative;
    flex: 0 0 7rem;
    height: 0.75rem;
    background: linear-gradient(var(--muted), var(--muted)) 50% / 1px 100% no-repeat;
}
.track i { position: absolute; top: 1px; bottom: 1px; border-radius: 2px; min-width: 0; }
.track .long { background: var(--charge); border-top-left-radius: 0; border-bottom-left-radius: 0; }
.track .short { background: var(--discharge); border-top-right-radius: 0; border-bottom-right-radius: 0; }

.empty { margin: 0.5rem 0 1rem; color: var(--muted); }

.prose { max-width: 66ch; }
.prose p { margin: 0 0 0.9rem; }

.scroll + .panel, .scroll + figure { margin-top: 1.75rem; }
