/*
 * Jarvis-appen – "command center"-designen (mörkblått glas, en tydlig accentfärg, rubriker i tung grotesk).
 * Designen kommer från Antons Next.js-utkast (jarvis.zip) och förebilden i TikTok-videon.
 * Typsnitten ligger i /fonts (SIL Open Font License, se OFL-*.txt).
 */
@font-face {
  font-family: "Plus Jakarta Sans Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("/fonts/plus-jakarta-sans-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Plus Jakarta Sans Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("/fonts/plus-jakarta-sans-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url("/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Jarvis command center – mörkblått glas, en tydlig accentfärg, rubriker i tung grotesk. */
:root {
  --bg-0: #060a14;
  --bg-1: #0a1122;
  --glass: rgba(150, 175, 230, 0.055);
  --glass-2: rgba(150, 175, 230, 0.09);
  --glass-3: rgba(150, 175, 230, 0.13);
  --line: rgba(165, 190, 240, 0.13);
  --line-2: rgba(165, 190, 240, 0.22);
  --ink: #eef2fa;
  --ink-2: #c6d0e3;
  --muted: #8592ad;
  --head: #f4eee4;
  --accent: #4c8dff;
  --accent-2: #2a66f5;
  --accent-soft: rgba(76, 141, 255, 0.16);
  --accent-glow: rgba(76, 141, 255, 0.45);
  --teal: #2dd4bf;
  --good: #4ade80;
  --good-ink: #062012;
  --good-soft: rgba(74, 222, 128, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.14);
  --radius: 16px;
  --sidebar: 248px;
  --font-sans: "Plus Jakarta Sans Variable", "Plus Jakarta Sans";
  --font-mono: "JetBrains Mono Variable", "JetBrains Mono";
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--font-sans), ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
/* Ljuset i bakgrunden: blått uppe till höger, turkos nere till vänster. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60vw 50vh at 85% -10%, rgba(59, 110, 246, 0.22), transparent 70%),
    radial-gradient(45vw 45vh at 18% 105%, rgba(45, 212, 191, 0.13), transparent 70%),
    radial-gradient(70vw 60vh at 55% 120%, rgba(88, 80, 236, 0.16), transparent 70%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
}
a { color: inherit; text-decoration: none; }
a.link { color: var(--accent); }
a.link:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.mono { font-family: var(--font-mono), ui-monospace, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.pre { white-space: pre-wrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.good-t { color: var(--good); } .warn-t { color: var(--warn); } .bad-t { color: var(--bad); }

/* ---------- Skal ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px 14px 18px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14, 22, 44, 0.75), rgba(8, 13, 26, 0.6));
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #5b9cff, #2457e6);
  box-shadow: 0 0 22px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.35);
  color: white; font-weight: 800; font-size: 19px; letter-spacing: -0.02em;
}
.brand-name { font-weight: 800; letter-spacing: 0.14em; font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 11px;
  color: var(--ink-2); font-weight: 600; font-size: 14px;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--glass); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); border-color: rgba(76, 141, 255, 0.35); box-shadow: inset 0 0 18px rgba(76,141,255,0.12); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: 0.9; }
.nav .badge { margin-left: auto; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px;
  display: inline-grid; place-items: center;
  background: var(--accent); color: white; font-size: 11.5px; font-weight: 700;
  font-family: var(--font-mono), monospace;
}
.nav-sep { height: 1px; background: var(--line); margin: 8px 6px; }

.syscard { margin-top: auto; padding: 12px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.syscard .row1 { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 10px var(--good); }
.dot.off { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
.dot.run { background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 14px clamp(16px, 3.4vw, 40px);
  background: linear-gradient(180deg, rgba(6, 10, 20, 0.86), rgba(6, 10, 20, 0.55));
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { display: none; padding: 0; }
.topbar-date { font-size: 11.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.clock { font-family: var(--font-mono), monospace; font-weight: 700; font-size: 26px; letter-spacing: 0.02em; color: var(--head); line-height: 1; font-variant-numeric: tabular-nums; }
.clock small { display: block; font-size: 10px; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; margin-top: 4px; text-align: right; font-weight: 600; }

.page { width: 100%; max-width: 1280px; padding: 28px clamp(16px, 3.4vw, 40px) 64px; display: flex; flex-direction: column; gap: 26px; }

.mobile-menu { display: none; position: relative; }
.mobile-menu summary { list-style: none; cursor: pointer; }
.mobile-menu summary::-webkit-details-marker { display: none; }
.mobile-menu .menu-panel {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 40;
  width: min(280px, 86vw); padding: 10px; border-radius: 14px;
  background: #0d1528; border: 1px solid var(--line-2); box-shadow: 0 18px 50px rgba(0,0,0,0.5);
}
.bottomnav { display: none; }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { padding-top: max(12px, calc(env(safe-area-inset-top) + 22px)); /* fritt från klockan och iPhones suddiga kant upptill */ padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .topbar .brand { display: flex; }
  .topbar .brand-sub { display: none; }
  .topbar-date { display: none; }
  .hide-sm { display: none !important; }
  .g3.keep { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .g3.keep .stat { padding: 10px; }
  .clock { font-size: 18px; }
  .clock small { display: none; }
  .mobile-menu { display: block; }
  .page { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .bottomnav {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
    background: rgba(8, 13, 26, 0.92); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .bottomnav a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; font-size: 11px; font-weight: 600; color: var(--muted); border-radius: 10px; }
  .bottomnav a[aria-current="page"] { color: var(--accent); }
  .bottomnav svg { width: 22px; height: 22px; }
  .bottomnav .badge { position: absolute; top: 0; left: calc(50% + 4px); height: 18px; min-width: 18px; font-size: 10.5px; }
}

/* ---------- Sidhuvud ---------- */
.pagehead { display: flex; flex-direction: column; gap: 6px; }
.pagehead .title { font-size: clamp(22px, 2.4vw, 28px); font-weight: 800; letter-spacing: -0.02em; color: var(--head); margin: 0; }
.pagehead .sub { color: var(--muted); font-size: 14px; margin: 0; }
.hero { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
.hero h1, .hero h2 {
  margin: 0; color: var(--head); font-weight: 800; letter-spacing: -0.035em; line-height: 1.02;
  font-size: clamp(32px, 5vw, 54px); text-wrap: balance;
  text-shadow: 0 0 40px rgba(244, 238, 228, 0.12);
}
.hero p { margin: 0; color: var(--ink-2); max-width: 62ch; font-size: 15.5px; }

/* ---------- Glaskort ---------- */
.card {
  position: relative; min-width: 0;
  background: linear-gradient(180deg, rgba(150, 175, 230, 0.075), rgba(150, 175, 230, 0.035));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.05) inset, 0 20px 50px rgba(0,0,0,0.25);
  display: flex; flex-direction: column; gap: 14px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-title { font-size: 13px; font-weight: 700; color: var(--ink-2); letter-spacing: 0.01em; margin: 0; }
h2.section { font-size: 18px; font-weight: 800; letter-spacing: -0.015em; color: var(--head); margin: 0; }
h3 { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--ink); text-wrap: balance; }
p { margin: 0; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } .span2 { grid-column: auto; } }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.between { justify-content: space-between; }

.stat { padding: 14px; border-radius: 12px; background: rgba(150, 175, 230, 0.06); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat .v { font-family: var(--font-mono), monospace; font-variant-numeric: tabular-nums; font-size: clamp(20px, 2.4vw, 28px); font-weight: 700; color: var(--head); line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .d { font-size: 12px; font-weight: 700; }
.stat.big .v { font-size: clamp(28px, 3.6vw, 40px); }

.focus-title { display: flex; gap: 12px; align-items: stretch; }
.focus-title::before { content: ""; width: 3px; border-radius: 3px; background: linear-gradient(180deg, var(--accent), var(--teal)); box-shadow: 0 0 12px var(--accent-glow); flex: none; }
.focus-title h3 { font-size: clamp(18px, 2vw, 22px); font-weight: 800; letter-spacing: -0.015em; color: var(--head); }

/* ---------- Chips och knappar ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; background: var(--glass-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.chip.acc { background: var(--accent-soft); color: #9cc0ff; border-color: rgba(76,141,255,0.35); }
.chip.good { background: var(--good-soft); color: var(--good); border-color: rgba(74,222,128,0.35); }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(251,191,36,0.35); }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: rgba(248,113,113,0.35); }
.chip .dot { width: 6px; height: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 8px 16px; border-radius: 11px;
  border: 1px solid var(--line-2); background: var(--glass-2);
  font-weight: 700; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:hover { background: var(--glass-3); border-color: rgba(165,190,240,0.32); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #5a98ff, #2d68f2); border-color: rgba(120,170,255,0.6); color: white; box-shadow: 0 0 20px rgba(76,141,255,0.35); }
.btn.approve { background: linear-gradient(180deg, #5ee894, #31c26e); border-color: rgba(120,240,170,0.6); color: var(--good-ink); box-shadow: 0 0 18px rgba(74,222,128,0.28); }
.btn.reject { background: transparent; color: var(--ink-2); }
.btn.reject:hover { color: var(--bad); border-color: rgba(248,113,113,0.5); background: var(--bad-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--glass); }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 12.5px; border-radius: 10px; }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn svg { width: 16px; height: 16px; }
form.inline { display: contents; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.filters { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filters::-webkit-scrollbar { display: none; }
.filters a { flex: none; padding: 7px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--glass); font-weight: 700; font-size: 13px; color: var(--ink-2); display: inline-flex; gap: 7px; }
.filters a[aria-current="true"] { background: var(--accent-soft); border-color: rgba(76,141,255,0.45); color: var(--ink); }

/* ---------- Listor ---------- */
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: rgba(150,175,230,0.035); }
.item { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border-top: 1px solid var(--line); min-width: 0; }
.item:first-child { border-top: none; }
.item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.item .t { font-weight: 700; font-size: 14px; color: var(--ink); }
.item .s { font-size: 12.5px; color: var(--muted); }
.tile {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 12.5px; letter-spacing: 0.02em;
  background: linear-gradient(145deg, rgba(91,156,255,0.35), rgba(36,87,230,0.25)); color: #cfe0ff; border: 1px solid rgba(120,170,255,0.35);
}
.tile.good { background: var(--good-soft); color: var(--good); border-color: rgba(74,222,128,0.35); }
.tile.warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(251,191,36,0.35); }
.ring { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(120,170,255,0.55); flex: none; margin-top: 1px; display: grid; place-items: center; box-shadow: 0 0 10px rgba(76,141,255,0.25); }
.check { width: 26px; height: 26px; border-radius: 8px; border: 1.8px solid var(--line-2); background: transparent; display: grid; place-items: center; cursor: pointer; flex: none; padding: 0; color: var(--good-ink); }
.check[aria-checked="true"] { background: var(--good); border-color: var(--good); box-shadow: 0 0 12px rgba(74,222,128,0.35); }
.check svg { width: 15px; height: 15px; }
.item.done .t { text-decoration: line-through; color: var(--muted); }

.empty { border: 1.5px dashed var(--line-2); border-radius: 14px; padding: 20px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.empty strong { color: var(--ink); font-size: 15px; }

/* ---------- Produktkort ---------- */
.econ { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 0; }
.econ div { background: #0d1529; padding: 9px 11px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.econ dt { font-size: 10.5px; color: var(--muted); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.econ dd { margin: 0; font-family: var(--font-mono), monospace; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 520px) { .econ { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.score { flex: none; width: 50px; height: 50px; border-radius: 13px; display: grid; place-items: center; font-family: var(--font-mono), monospace; font-weight: 700; font-size: 17px; background: var(--glass-2); border: 1px solid var(--line-2); }
.score.hi { background: var(--good-soft); color: var(--good); border-color: rgba(74,222,128,0.4); box-shadow: 0 0 16px rgba(74,222,128,0.18); }
details.more > summary { cursor: pointer; list-style: none; color: var(--accent); font-weight: 700; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary .open-hide { display: none; }
details.more:not([open]) > summary .open-show { display: none; }
.details { display: flex; flex-direction: column; gap: 14px; padding-top: 14px; margin-top: 12px; border-top: 1px dashed var(--line-2); }
.details ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.calc { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.calc td { padding: 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.calc td:last-child { text-align: right; font-family: var(--font-mono), monospace; white-space: nowrap; padding-left: 12px; }
.calc tr.tot td { font-weight: 800; }
.calc tr:last-child td { border-bottom: none; }

/* ---------- Agenter ---------- */
.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.agent {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border-radius: 14px; min-width: 0;
  background: linear-gradient(180deg, rgba(76, 141, 255, 0.17), rgba(76, 141, 255, 0.05));
  border: 1px solid rgba(120, 170, 255, 0.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.agent.planned { background: rgba(150,175,230,0.03); border-style: dashed; border-color: var(--line-2); opacity: 0.62; }
.agent.err { border-color: rgba(248,113,113,0.5); }
.agent-top { display: flex; gap: 10px; align-items: center; min-width: 0; }
.agent-top .grow { min-width: 0; flex: 1; }
.agent-name { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-role { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-task { font-size: 12.5px; color: var(--ink-2); line-height: 1.4; min-height: 2.8em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bar { height: 5px; border-radius: 99px; background: rgba(150,175,230,0.12); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #2a66f5, #6fb0ff); box-shadow: 0 0 10px var(--accent-glow); }
.bar.run i { width: 40% !important; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
.agent-foot { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--muted); }
.mini-stats { display: flex; gap: 18px; }
.mini-stats div { display: flex; flex-direction: column; align-items: flex-end; }
.mini-stats b { font-family: var(--font-mono), monospace; font-size: 17px; color: var(--head); line-height: 1.1; }
.mini-stats span { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

.feed { display: flex; flex-direction: column; gap: 2px; font-size: 13px; max-height: 460px; overflow: auto; }
.feed .ln { display: grid; grid-template-columns: 52px 108px minmax(0, 1fr); gap: 10px; padding: 6px 4px; border-bottom: 1px solid rgba(165,190,240,0.06); }
.feed .ln:last-child { border-bottom: none; }
.feed .tm { font-family: var(--font-mono), monospace; color: var(--muted); font-size: 12px; }
.feed .ag { font-weight: 700; color: #9cc0ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed .msg { overflow-wrap: anywhere; color: var(--ink-2); }
.feed .ln.ok .msg { color: var(--ink); }
.feed .ln.warn .msg { color: var(--warn); }
.feed .ln.error .msg { color: var(--bad); }
@media (max-width: 560px) { .feed .ln { grid-template-columns: 44px minmax(0, 1fr); } .feed .ag { grid-column: 2; } .feed .msg { grid-column: 2; } }

/* ---------- Radar ---------- */
.radar-wrap { position: relative; width: min(100%, 380px); aspect-ratio: 1; margin: 6px auto; }
.radar-wrap svg { width: 100%; height: 100%; display: block; overflow: visible; }
.sweep {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(76,141,255,0.55), rgba(76,141,255,0.12) 40deg, transparent 75deg);
  animation: spin 5s linear infinite;
  mask: radial-gradient(circle, black 69%, transparent 70%);
  -webkit-mask: radial-gradient(circle, black 69%, transparent 70%);
  pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.radar-center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; text-align: center; }
.radar-center b { font-family: var(--font-mono), monospace; font-size: 26px; color: var(--head); display: block; line-height: 1; }
.radar-center span { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.signal .metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.signal .metrics div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.signal .metrics span { font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.signal .metrics b { font-family: var(--font-mono), monospace; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) { .signal .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.signal:target { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 30px rgba(76,141,255,0.25); }

/* ---------- Diagram ---------- */
.chart { display: flex; align-items: flex-end; gap: clamp(10px, 3vw, 28px); height: 220px; padding: 12px 6px 0; border-bottom: 1px solid var(--line-2); }
.chart .col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.chart .col i { display: block; width: min(100%, 64px); border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, #6aa8ff, #2a5fe0); box-shadow: 0 0 22px rgba(76,141,255,0.35), inset 0 1px 0 rgba(255,255,255,0.35); min-height: 4px; }
.chart .col b { font-family: var(--font-mono), monospace; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.chart-labels { display: flex; gap: clamp(10px, 3vw, 28px); padding: 8px 6px 0; }
.chart-labels span { flex: 1; min-width: 0; text-align: center; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Formulär ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; }
.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 11px;
  border: 1px solid var(--line-2); background: rgba(6, 10, 20, 0.55); font-size: 15px; color: var(--ink);
}
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(76,141,255,0.2); }
textarea.input { min-height: 90px; resize: vertical; line-height: 1.45; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
select.input { color-scheme: dark; }
select.input option, select.input optgroup { background: #0d1424; color: #e8eefc; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 11px; overflow: hidden; align-self: flex-start; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 9px 16px; font-weight: 700; font-size: 13px; color: var(--muted); }
.seg input:checked + span { background: var(--accent-soft); color: var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- Chatt ---------- */
.chat { display: flex; flex-direction: column; gap: 14px; min-height: 260px; }
.bubble { max-width: min(80%, 640px); padding: 11px 14px; border-radius: 16px; font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.bubble.me { align-self: flex-end; background: linear-gradient(180deg, #4a8bff, #2c66ee); color: white; border-bottom-right-radius: 5px; box-shadow: 0 0 20px rgba(76,141,255,0.25); }
.bubble.j { align-self: flex-start; background: var(--glass-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble.typing { color: var(--muted); }
.bmeta { font-size: 11px; color: var(--muted); margin-top: -8px; }
.bmeta.me { align-self: flex-end; }
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 8px; border-radius: 16px; border: 1px solid var(--line-2); background: rgba(6,10,20,0.6); }
.composer textarea { flex: 1; min-height: 44px; max-height: 180px; border: none; background: transparent; padding: 10px; resize: none; font-size: 15px; outline: none; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest button { padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--glass); font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.suggest button:hover { border-color: var(--accent); color: var(--ink); }

/* ---------- Kör nu ---------- */
.run-pop { position: relative; }
.run-pop .panel { position: absolute; right: 0; top: calc(100% + 10px); width: min(360px, 88vw); z-index: 50; padding: 14px; border-radius: 14px; background: #0d1528; border: 1px solid var(--line-2); box-shadow: 0 18px 50px rgba(0,0,0,0.55); display: flex; flex-direction: column; gap: 10px; }

@media (max-width: 960px) {
  .agents { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .agent { padding: 11px; gap: 8px; }
  .agent .tile { width: 30px; height: 30px; font-size: 11px; }
  .agent-name { font-size: 13px; }
  .agent-task { font-size: 12px; }
  .agent-foot > span:last-child { display: none; }
  .mini-stats { gap: 14px; flex-wrap: wrap; }
}

.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 60;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 16px; border-radius: 12px; max-width: min(420px, calc(100vw - 32px));
  background: linear-gradient(180deg, #5ee894, #31c26e); color: var(--good-ink);
  font-weight: 700; font-size: 13.5px; box-shadow: 0 0 24px rgba(74,222,128,0.35), 0 12px 30px rgba(0,0,0,0.4);
  opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast svg { width: 16px; height: 16px; flex: none; }
@media (max-width: 480px) {
  .topbar { gap: 8px; }
  .topbar-right { gap: 8px; }
  .run-txt { display: none; }
  .clock { font-size: 16px; }
}
@media (max-width: 960px) { .toast { right: 16px; left: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); } }
.hero-icon { display: flex; align-items: center; gap: 14px; }
.hero-icon .brand-mark { width: 46px; height: 46px; font-size: 22px; border-radius: 13px; }

@media (prefers-reduced-motion: reduce) {
  .sweep, .dot.run, .bar.run i { animation: none; }
  * { transition: none !important; }
}

/* ---------- Tillägg för den här appen ---------- */
[hidden] { display: none !important; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.login { max-width: 400px; margin: 14vh auto 0; padding: 0 16px; display: flex; flex-direction: column; gap: 16px; text-align: center; }
.login .brand-mark { width: 64px; height: 64px; font-size: 30px; border-radius: 18px; margin: 0 auto; }
.login h1 { margin: 0; color: var(--head); font-weight: 800; letter-spacing: -0.03em; font-size: 34px; }
.login .code { font-family: var(--font-mono), monospace; font-size: 30px; letter-spacing: 0.4em; text-align: center; }
.login .err { color: var(--bad); font-weight: 700; }
.gallery { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.gallery img { width: 150px; height: 150px; flex: none; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); background: var(--glass); }
.gallery img.chosen { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 18px rgba(76,141,255,0.25); }
.pimg { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); background: var(--glass); }
.thumb { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; flex: none; border: 1px solid var(--line); background: var(--glass); }
.svgchart svg { width: 100%; height: auto; display: block; overflow: visible; }
.svgchart .gl { stroke: var(--line); }
.svgchart .lb { fill: var(--muted); font-size: 11px; font-family: var(--font-mono), monospace; }
.svgchart .pos { fill: url(#gpos); }
.svgchart .neg { fill: var(--bad); opacity: 0.85; }
.svgchart .rev { fill: url(#grev); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.table td.r, .table th.r { text-align: right; }
.table td.mono, .table td.r { font-family: var(--font-mono), monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 700; }
.switch input { width: 44px; height: 26px; appearance: none; background: var(--glass-3); border: 1px solid var(--line-2); border-radius: 13px; position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); transition: left .15s; }
.switch input:checked { background: var(--good); border-color: var(--good); }
.switch input:checked::after { left: 20px; background: var(--good-ink); }
.typing::after { content: "…"; animation: pulse 1.2s ease-in-out infinite; }

/* ---------- Mobil: ingen automatisk zoom, mjuk scroll ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* Inga dubbeltryck-zoomar på knappar och länkar (nypzoom fungerar fortfarande) */
a, button, summary, label, input, textarea, select, .item, .check { touch-action: manipulation; }
html, body { overscroll-behavior-y: none; }
/* Bakgrundsljuset ritas en gång i ett eget lager i stället för vid varje scroll */
body::before { transform: translateZ(0); will-change: transform; }
.sweep { will-change: transform; }
@media (max-width: 960px) {
  /* iPhone zoomar in i textfält med text under 16 px – därför 16 px på mobil */
  .input, input, textarea, select, .composer textarea { font-size: 16px; }
  /* Suddig genomskinlighet är tung att rita om när man scrollar – helt täckande på mobil */
  .topbar, .sidebar, .bottomnav, .mobile-menu .menu-panel, .run-pop .panel { backdrop-filter: none; -webkit-backdrop-filter: none; }
  .topbar { background: #070c18; }
  .bottomnav { background: #080d1a; }
  .card { box-shadow: 0 1px 0 rgba(255,255,255,0.05) inset; }
  .chat { max-height: 60dvh !important; }
}
/* Tunn laddningslinje överst när färska siffror hämtas */
.loadbar { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 60; pointer-events: none; opacity: 0; transition: opacity .2s; overflow: hidden; }
.loadbar.on { opacity: 1; }
.loadbar::after { content: ""; position: absolute; top: 0; bottom: 0; width: 35%; background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: loadslide 1s ease-in-out infinite; }
@keyframes loadslide { from { left: -35%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .loadbar::after { animation: none; left: 0; width: 100%; } }
/* Etiketter får aldrig bli bredare än skärmen (annars zoomar mobilen ut) */
.chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.chip.wrap { white-space: normal; overflow-wrap: anywhere; }
#view { min-width: 0; overflow-wrap: break-word; }
/* Sex knappar längst ner: lite mindre text på smala telefoner så allt får plats */
@media (max-width: 380px) {
  .bottomnav { padding-left: max(4px, env(safe-area-inset-left)); padding-right: max(4px, env(safe-area-inset-right)); }
  .bottomnav a { font-size: 10px; padding: 6px 0; letter-spacing: -0.1px; }
  .bottomnav svg { width: 20px; height: 20px; }
}
.bottomnav a span:not(.badge) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Radarns svep snurrar: håll det inom radarn. Annars blir sidan bredare i varje varv och mobilen zoomar ut och in. */
.radar-wrap { overflow: hidden; border-radius: 50%; }
/* Skyddsnät i mobilen: inget på en sida får göra sidan bredare än skärmen */
@media (max-width: 960px) { .page { overflow-x: clip; } }
/* Datumfält i iPhone: Safari ger det en egen minsta bredd, centrerad text och större höjd, så det sticker ut.
   Gör det likadant som de andra fälten. */
input[type="date"].input { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; height: 44px; line-height: 22px; text-align: left; color-scheme: dark; }
input[type="date"].input::-webkit-date-and-time-value { text-align: left; margin: 0; }
@media (max-width: 960px) { input[type="date"].input { height: 46px; } }
/* ---------- Jarvis liv (kassan) ---------- */
.life-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.life-cash { font-size: clamp(28px, 6vw, 38px); line-height: 1.1; }
.lifebar { height: 12px; border-radius: 99px; background: rgba(150,175,230,0.12); overflow: hidden; }
.lifebar i { display: block; height: 100%; border-radius: 99px; transition: width .6s ease; }
.lifebar.good i { background: linear-gradient(90deg, #22a35a, var(--good)); box-shadow: 0 0 12px rgba(74,222,128,0.45); }
.lifebar.warn i { background: linear-gradient(90deg, #d08a0c, var(--warn)); box-shadow: 0 0 12px rgba(251,191,36,0.45); }
.lifebar.bad i { background: linear-gradient(90deg, #c23b3b, var(--bad)); box-shadow: 0 0 12px rgba(248,113,113,0.5); }
.card.dead { border-color: rgba(248,113,113,0.45); background: linear-gradient(180deg, rgba(248,113,113,0.10), rgba(248,113,113,0.03)); }
.dead-head { display: flex; gap: 14px; align-items: center; }
.dead-head h2 { font-size: 22px; color: var(--head); }
.dead-mark { font-size: 40px; line-height: 1; filter: grayscale(0.2); }
.dead-list { margin: 0; padding-left: 18px; color: var(--ink-2); display: grid; gap: 4px; }
.deathbar { padding: 10px clamp(16px, 3.4vw, 40px); background: rgba(248,113,113,0.14); border-bottom: 1px solid rgba(248,113,113,0.4); color: #fecaca; font-size: 13.5px; font-weight: 600; }
.deathbar a { color: #fff; text-decoration: underline; white-space: nowrap; }
