:root {
  --navy: #0e1526; --navy2: #19233a; --navy3: #2a3651;
  --on: #ffffff; --on-mut: #aeb9ce;
  --ink: #111827; --mut: #556072; --line: #e3e6ec; --bg: #f3f4f7; --card: #ffffff;
  --acc: #2456e6; --acc-dark: #1a3fb0; --over: #bf4609; --ok: #14693f;
  --ok-on: #6fdcab; --over-on: #ffa36b;
  --ok-bg: #e6f4ec; --over-bg: #fbede4; --neutral-bg: #eef0f4;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 28px rgba(16, 24, 40, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--acc); }
a:hover { color: var(--acc-dark); }
h1, h2, h3 { letter-spacing: -.01em; line-height: 1.2; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 32px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid #7aa2ff; outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- sidhuvud ---------- */
.band { background: var(--navy); color: var(--on); }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 16px 0; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--on); text-decoration: none; font-size: 19px; font-weight: 650; }
.brand:hover { color: var(--on); }
.logo-ring { fill: #fff; stroke: #e0452b; stroke-width: 4; }
.logo-text { font: 700 12px var(--font); fill: #111827; }
.place-form { display: flex; gap: 6px; align-items: center; }
.place-select {
  font: 500 14px var(--font); min-height: 44px; max-width: 340px; padding: 0 36px 0 14px; border-radius: 999px;
  border: 1px solid var(--navy3); background: var(--navy2); color: var(--on); appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23AEB9CE' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.place-select option, .place-select optgroup { color: var(--ink); background: #fff; }
.mainnav { display: flex; gap: 2px; flex: 1; justify-content: center; overflow-x: auto; scrollbar-width: none; }
.mainnav a, .usermenu a {
  color: var(--on-mut); text-decoration: none; font-weight: 500; padding: 11px 16px; border-radius: 999px; white-space: nowrap;
}
.mainnav a:hover, .usermenu a:hover { color: var(--on); }
.mainnav a[aria-current], .usermenu a[aria-current] { color: var(--on); background: var(--navy2); font-weight: 600; }
.usermenu { display: flex; align-items: center; gap: 6px; }
.usermenu form { margin: 0; }
.btn-ghost {
  font: 500 14px var(--font); min-height: 44px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--navy3); background: transparent; color: var(--on);
}
.btn-ghost:hover { background: var(--navy2); }

.pagehead { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 20px 0 36px; }
.pagehead > div:first-child { flex: 1; min-width: 240px; }
.pagehead h1 { margin: 0; font-size: 34px; font-weight: 650; }
.pagehead p { margin: 6px 0 0; color: var(--on-mut); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 16px; }
.toolbar .spacer { flex: 1; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 4px; border-radius: 999px; background: var(--navy2); }
.segmented a {
  color: var(--on-mut); text-decoration: none; font-weight: 500; font-size: 14px; padding: 10px 16px; border-radius: 999px;
  min-height: 44px; display: inline-flex; align-items: center;
}
.segmented a:hover { color: var(--on); }
.segmented a[aria-current] { background: #fff; color: var(--ink); font-weight: 600; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; background: var(--navy2); color: var(--on); border-radius: 999px; padding: 10px 16px; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok-on); }
.status.off .dot { background: var(--over-on); }

.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 32px; padding: 32px 0 44px; align-items: end; }
.hero-main { display: flex; flex-direction: column; gap: 8px; }
.hero-kicker { color: var(--on-mut); font-size: 14px; }
.hero-num { font-size: clamp(64px, 11vw, 104px); font-weight: 750; line-height: .95; letter-spacing: -.03em; }
.hero-num small { font-size: .42em; font-weight: 600; color: var(--on-mut); letter-spacing: 0; }
.hero-text { font-size: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 24px; padding: 22px 24px; border-radius: var(--radius); background: var(--navy2); }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi-label { font-size: 13px; color: var(--on-mut); }
.kpi-val { font-size: 32px; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-val small { font-size: 15px; font-weight: 500; color: var(--on-mut); }
.delta { font-size: 13px; }
.band .delta.good { color: var(--ok-on); }
.band .delta.bad { color: var(--over-on); }
.band .delta.flat { color: var(--on-mut); }

/* ---------- innehåll ---------- */
.content { padding-top: 28px; padding-bottom: 48px; display: flex; flex-direction: column; gap: 22px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 22px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 22px; }
.card { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); min-width: 0; }
.card > h2, .card-head h2 { margin: 0; font-size: 19px; font-weight: 650; }
.card .sub { margin: 4px 0 0; color: var(--mut); font-size: 14px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head > div { flex: 1; }
.card > h2 + .sub { margin-bottom: 14px; }
.tile .label { font-size: 13px; color: var(--mut); }
.tile .val { font-size: 30px; font-weight: 650; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile .val small { font-size: 15px; font-weight: 500; color: var(--mut); }
.tile .note { font-size: 13px; color: var(--mut); }
.tile .note.good { color: var(--ok); }
.tile .note.bad { color: var(--over); }
.empty { color: var(--mut); margin: 12px 0; }
.scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
th { text-align: left; padding: 8px 12px; font-size: 13px; font-weight: 500; color: var(--mut); }
td { padding: 13px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
td.num, th.num { text-align: right; }
td.strong { font-weight: 650; }
td.right, th.right { text-align: right; }
.speed { font-weight: 650; font-size: 17px; }
.speed small { font-weight: 400; font-size: 13px; color: var(--mut); }
.pill { display: inline-block; font-size: 13px; font-weight: 500; padding: 4px 10px; border-radius: 999px; background: var(--neutral-bg); color: var(--mut); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.over { background: var(--over-bg); color: var(--over); }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.kv span:first-child { color: var(--mut); }
.kv span:last-child { font-weight: 500; text-align: right; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--mut); margin-top: 12px; }
.legend i { width: 24px; height: 12px; border-radius: 4px; display: inline-block; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 16px; flex-wrap: wrap; }

/* formulär */
form.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 180px; }
.field label { font-size: 14px; font-weight: 500; }
.field .hint { font-size: 13px; color: var(--mut); }
input[type=text], input[type=email], input[type=number], input[type=datetime-local], input[type=date], select.input, textarea {
  font: 400 16px var(--font); min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid #8a93a1;
  background: #fff; color: var(--ink); width: 100%;
}
textarea { padding: 12px 14px; min-height: 90px; }
.btn {
  font: 600 15px var(--font); min-height: 48px; padding: 0 20px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--acc); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none;
}
.btn:hover { background: var(--acc-dark); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: #fff; color: var(--over); border: 1px solid #f0c9b3; font-weight: 500; }
.btn.small { min-height: 44px; font-size: 14px; padding: 0 14px; }
.btn.light { background: #fff; color: var(--ink); }
.inline { display: inline; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.msg { padding: 14px 18px; border-radius: 14px; font-weight: 500; }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.err { background: var(--over-bg); color: var(--over); }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; word-break: break-all; background: var(--bg); padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); width: 100%; }
.foot { color: var(--mut); font-size: 13px; padding-bottom: 32px; }

/* ---------- diagram ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart.heat { min-width: 640px; }
.chart.timeline { min-width: 640px; }
.chart text { font: 12px var(--font); fill: var(--mut); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.bar-ok { fill: var(--acc); }
.bar-over { fill: var(--over); }
.chart .limit { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 4 5; }
.chart .limit-tag { fill: var(--ink); }
.chart text.limit-text { fill: #fff; font-weight: 600; }
.line { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.area { opacity: .1; stroke: none; }
.dot { stroke: #fff; stroke-width: 2; }
.c-over.line { stroke: var(--over); } .c-over.area, .c-over.dot { fill: var(--over); }
.c-acc.line { stroke: var(--acc); } .c-acc.area, .c-acc.dot { fill: var(--acc); }
.c-teal.line { stroke: #0f7c8a; } .c-teal.area, .c-teal.dot { fill: #0f7c8a; }
.h-none { fill: #f6f7f9; } .h-few { fill: #e9ebef; }
.h0 { fill: #edf1fa; } .h1 { fill: #cdd9f7; } .h2 { fill: #9db5f0; } .h3 { fill: #628aea; } .h4 { fill: #2456e6; } .h5 { fill: #122f86; }
.av-ok { fill: #2fa36b; } .av-warn { fill: #e0a93b; } .av-bad { fill: var(--over); } .av-none { fill: #e3e6ec; }
.tl-past { fill: #c9d3e6; } .tl-active { fill: var(--acc); } .tl-sel { stroke: var(--ink); stroke-width: 2.5; }
.chart text.tl-text { fill: var(--ink); font-weight: 600; font-size: 14px; }
.chart text.tl-text-on { fill: #fff; font-weight: 600; font-size: 14px; }

/* ---------- inloggning ---------- */
body.auth { background: var(--navy); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 28px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--on); }
.auth-brand b { display: block; font-size: 24px; }
.auth-brand span { color: var(--on-mut); font-size: 14px; }
.auth-card { background: #fff; border-radius: 22px; padding: 32px; display: flex; flex-direction: column; gap: 20px; }
.auth-card h1 { margin: 0; font-size: 28px; }
.auth-card p { margin: 0; color: var(--mut); }
.auth-card .btn { min-height: 56px; font-size: 17px; border-radius: 14px; }
.auth-card .foot-note { border-top: 1px solid var(--line); padding-top: 16px; font-size: 14px; color: var(--mut); }

.chart.avail text { font-size: 7px; }
.scroll table { min-width: 560px; }
td:first-child { white-space: nowrap; }

@media (max-width: 720px) {
  .chart text { font-size: 15px; }
  .chart.heat text, .chart.timeline text { font-size: 12px; }
  .chart.avail text { font-size: 11px; }
  .chart.avail { min-width: 560px; }
  .wrap { padding: 0 16px; }
  .top { gap: 10px; }
  .place-form { order: 3; width: 100%; }
  .place-select { width: 100%; max-width: none; }
  .mainnav { order: 4; width: 100%; justify-content: flex-start; }
  .usermenu { margin-left: auto; }
  .usermenu a { display: none; }
  .card { padding: 18px; }
  .tiles { gap: 12px; }
  .tile .val { font-size: 24px; }
  .pagehead h1 { font-size: 28px; }
  .kpis { gap: 16px; padding: 18px; }
}
.legend i.lg0 { background: #edf1fa; } .legend i.lg1 { background: #cdd9f7; } .legend i.lg2 { background: #9db5f0; }
.legend i.lg3 { background: #628aea; } .legend i.lg4 { background: #2456e6; } .legend i.lg5 { background: #122f86; }
.legend i.lgfew { background: #e9ebef; }
.segmented.light-seg { background: var(--bg); }
.segmented.light-seg a { color: var(--mut); }
.segmented.light-seg a:hover { color: var(--ink); }
.segmented.light-seg a[aria-current] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }
.status.light { background: var(--neutral-bg); color: var(--ink); }
.status.light.on .dot { background: #2fa36b; }
.status.light.off .dot { background: var(--over); }
.sharebar { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }
.sharebar svg { width: 110px; height: 10px; }
.sb-bg { fill: var(--neutral-bg); } .sb-fg { fill: var(--over); }
small.muted, .muted { color: var(--mut); font-weight: 400; }
.signrow { align-items: center; }
.signrow small { color: var(--mut); font-weight: 400; }
.firstplace, .addsign { padding: 16px 0; border-top: 1px solid var(--line); }
.chart.heat text { font-size: 9px; }
