/* Layout: fast sidomeny till vänster, arbetsyta till höger; på mobil blir menyn en rad överst. */
:root {
  --bg: #F6F5F7; --surface: #FFFFFF; --surface-2: #EEECF0; --ink: #1F1C23; --ink-2: #625D69; --line: #DDD9E1;
  --accent: #1D6A9A; --accent-ink: #FFFFFF; --accent-soft: #E2F0F9; --renew: #2A7F73; --renew-ink: #FFFFFF; --bars: #C42F6E;
  --warn: #A2480E; --warn-soft: #FFEBDD; --bad: #B3261E; --bad-soft: #F8E0DC; --good: #1D7639; --good-soft: #DFF0E3;
  --grid: #E9E6EC; --demo: #2B2530; --demo-ink: #F1ECF3;
  --f-display: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #131115; --surface: #1B191E; --surface-2: #242128; --ink: #EDEAF0; --ink-2: #A6A0AD; --line: #332F38;
  --accent: #6CC0E8; --accent-ink: #06263A; --accent-soft: #16303F; --renew: #74CDBE; --renew-ink: #062A25; --bars: #FF6FA6;
  --warn: #FF9A55; --warn-soft: #3A2316; --bad: #F08B81; --bad-soft: #3B1A16; --good: #6CCB8A; --good-soft: #143020;
  --grid: #29262D; --demo: #2E2834; --demo-ink: #F1ECF3; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #131115; --surface: #1B191E; --surface-2: #242128; --ink: #EDEAF0; --ink-2: #A6A0AD; --line: #332F38;
  --accent: #6CC0E8; --accent-ink: #06263A; --accent-soft: #16303F; --renew: #74CDBE; --renew-ink: #062A25; --bars: #FF6FA6;
  --warn: #FF9A55; --warn-soft: #3A2316; --bad: #F08B81; --bad-soft: #3B1A16; --good: #6CCB8A; --good-soft: #143020;
  --grid: #29262D; --demo: #2E2834; --demo-ink: #F1ECF3; color-scheme: dark; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--f-body); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
.mono { font-family: var(--f-mono); font-size: 12.5px; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }


/* Skal */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100%; transition: grid-template-columns 0.28s ease; }
.side { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 20px; padding: 20px 12px; position: sticky; top: env(safe-area-inset-top, 0px); height: 100vh; overflow-y: auto; overflow-x: hidden; }
.brand { display: grid; padding: 0 8px; }
.brand > * { grid-area: 1 / 1; transition: opacity 0.2s ease; }
/* Infällt läge: hela loggan vriden på högkant, lågan nederst. */
.brand-flame { opacity: 0; position: relative; width: 34px; height: 80px; margin-left: -5px; }
.brand-flame .logo { position: absolute; left: 50%; top: 50%; height: 34px; width: auto; max-width: none; margin: 0; transform: translate(-50%, -50%) rotate(-90deg); }
.brand b { font-family: var(--f-display); font-size: 16px; }
.brand small { display: block; color: var(--ink-2); font-size: 11.5px; }
.brand-full { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.logo { display: block; width: auto; max-width: 100%; }
.logo-full { margin-left: -4px; }
.side { border-top: 3px solid transparent; border-image: linear-gradient(90deg, #66bce6, #d9b1e0, #ed5794, #fc7040, #ffd135) 1; border-image-slice: 1 0 0 0; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .grp { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); padding: 14px 11px 4px; white-space: nowrap; transition: opacity 0.2s ease; }
.nav a { display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: var(--r); cursor: pointer; color: var(--ink); position: relative; white-space: nowrap; padding-left: 11px; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav svg, .navtoggle svg, .me svg { flex: none; width: 18px; height: 18px; }
.t { transition: opacity 0.2s ease; }
.nav .count { margin-left: auto; transition: all 0.2s ease; font-size: 11.5px; background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 0 7px; font-weight: 600; }
.me { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 0 0; display: flex; flex-direction: column; gap: 4px; }
.me .id { display: flex; align-items: center; gap: 10px; padding: 4px 4px; white-space: nowrap; }
.me .who { font-weight: 600; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; text-align: left; font-weight: 500; }
.linkbtn:hover { text-decoration: underline; }

.main { min-width: 0; padding-block: 28px 56px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.wrap { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.head p { color: var(--ink-2); margin-top: 4px; }

.navtoggle, .logoutbtn { display: flex; align-items: center; gap: 10px; border: 0; background: none; color: var(--ink-2); padding: 7px 11px; white-space: nowrap; border-radius: var(--r); cursor: pointer; width: 100%; text-align: left; font-size: 13px; }
.navtoggle:hover, .logoutbtn:hover { background: var(--surface-2); color: var(--ink); }
.navtoggle svg { transition: transform 0.28s ease; }
.me .out { display: flex; align-items: center; gap: 8px; }
.avatar { display: flex; flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 12.5px; align-items: center; justify-content: center; }
/* Infälld meny: bara ikoner. Gäller automatiskt på mindre skärmar, eller när man fäller in den själv. */
.shell.collapsed { grid-template-columns: 64px minmax(0, 1fr); }
.collapsed .brand-full, .collapsed .t, .collapsed .nav .grp, .collapsed .me .txt { opacity: 0; pointer-events: none; }
.collapsed .brand-flame { opacity: 1; }
.collapsed .navtoggle svg { transform: rotate(180deg); }
.collapsed .nav .count { position: absolute; top: 2px; left: 26px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; line-height: 16px; text-align: center; }
/* Etikett som poppar ut till höger om ikonen i den infällda menyn. */
.tip { position: fixed; z-index: 70; pointer-events: none; display: flex; align-items: center; gap: 8px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 13px; padding: 7px 12px; border-radius: 8px; white-space: nowrap; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); opacity: 0; transform: translate(-8px, -50%) scale(0.92); transform-origin: left center; transition: opacity 0.14s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1); }
.tip::before { content: ""; position: absolute; left: -4px; top: 50%; width: 10px; height: 10px; background: inherit; border-radius: 2px; transform: translateY(-50%) rotate(45deg); }
.tip.on { opacity: 1; transform: translate(0, -50%) scale(1); }
.tip small { font-weight: 500; font-size: 12px; opacity: 0.7; }
@media (prefers-reduced-motion: reduce) { .tip { transition: opacity 0.1s; transform: translate(0, -50%); } }
@media (prefers-reduced-motion: reduce) { .shell, .shell * { transition: none !important; animation: none !important; } }
/* På mobil lägger sig den utfällda menyn ovanpå innehållet. */
@media (max-width: 640px) {
  .shell:not(.collapsed) { grid-template-columns: 64px minmax(0, 1fr); }
  .shell:not(.collapsed) .side { animation: slidein 0.28s ease; }
  @keyframes slidein { from { width: 64px; box-shadow: none; } }
  .shell:not(.collapsed) .side { position: fixed; left: 0; top: 0; bottom: 0; width: 248px; height: auto; z-index: 30; box-shadow: 0 0 32px rgba(0, 0, 0, 0.25); padding-top: calc(20px + env(safe-area-inset-top, 0px)); padding-left: max(12px, env(safe-area-inset-left, 0px)); }
}

/* Komponenter */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-b { padding: 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); padding: 7px 14px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn { transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background-position 0.45s ease, background-size 0.3s ease; }
.btn:hover:not(:disabled) { border-color: var(--ink-2); background-color: var(--surface-2); }
.btn.primary { background-color: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.renew { background-color: var(--renew); border-color: var(--renew); color: var(--renew-ink); }
.btn.primary, .btn.renew { position: relative; overflow: hidden; isolation: isolate; --base: var(--accent); --dark: color-mix(in srgb, var(--accent) 82%, var(--ink)); --to: #7652C4; }
.btn.renew { --base: var(--renew); --dark: color-mix(in srgb, var(--renew) 82%, var(--ink)); --to: #7652C4; }

:root[data-theme="dark"] .btn.primary { --to: #B9A2EC; }
:root[data-theme="dark"] .btn.renew { --to: #B9A2EC; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { --to: #B9A2EC; } :root:not([data-theme="light"]) .btn.renew { --to: #B9A2EC; } }
/* Hover: Beställ (blå) och Förnya (grön) glider över till loggans lila. Med 220 % bredd syns bara grundfärgen i vila och bara lila vid hover. Knappen lyfter inte. */
.btn.primary, .btn.renew { background-image: linear-gradient(100deg, var(--base) 0%, var(--base) 45%, var(--to) 55%, var(--to) 100%); background-size: 220% 100%; background-position: 0 0; }
.btn.primary:hover:not(:disabled), .btn.renew:hover:not(:disabled) { background-color: var(--to); background-position: 100% 0; border-color: var(--to); }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } .btn::after { display: none; } }
/* Rosaröd från loggans låga, för åtgärder som stänger av något. */
.btn.brand { background-color: var(--bars); border-color: var(--bars); color: #fff; position: relative; overflow: hidden; --base: var(--bars); --to: color-mix(in srgb, var(--bars) 70%, #5A1030); background-image: linear-gradient(100deg, var(--base) 0%, var(--base) 45%, var(--to) 55%, var(--to) 100%); background-size: 220% 100%; background-position: 0 0; }
.btn.brand:hover:not(:disabled) { background-color: var(--to); border-color: var(--to); background-position: 100% 0; }
:root[data-theme="dark"] .btn.brand { color: #2B0716; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.brand { color: #2B0716; } }
.warnicon { flex: none; width: 34px; height: 34px; border-radius: 50%; background: color-mix(in srgb, var(--bars) 16%, transparent); color: var(--bars); font-weight: 700; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.consequences { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.danger.solid { background: var(--bad); color: #fff; }
.btn.danger:hover:not(:disabled) { background: var(--bad-soft); border-color: var(--bad); }
.btn.danger.solid:hover:not(:disabled) { background: color-mix(in srgb, var(--bad) 85%, var(--ink)); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 1px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
/* Allt som har gått ut pulserar. */
.pill.expired { animation: expired-pulse 1.8s ease-in-out infinite; }
.pill.expired::before { animation: expired-dot 1.8s ease-in-out infinite; }
@keyframes expired-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 45%, transparent); } 60% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--bad) 0%, transparent); } }
@keyframes expired-dot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.7); } }
/* Går ut snart pulserar lugnare, i orange. */
.pill.soon { animation: soon-pulse 2.6s ease-in-out infinite; }
.pill.soon::before { animation: expired-dot 2.6s ease-in-out infinite; }
@keyframes soon-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--warn) 40%, transparent); } 60% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--warn) 0%, transparent); } }
@media (prefers-reduced-motion: reduce) { .pill.expired, .pill.expired::before, .pill.soon, .pill.soon::before { animation: none; } }
.pill.idle { background: var(--surface-2); color: var(--ink-2); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.tag { display: inline-block; font-size: 11.5px; border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; color: var(--ink-2); white-space: nowrap; }
.note { background: var(--surface-2); border-radius: var(--r); padding: 10px 12px; font-size: 13px; color: var(--ink-2); }
.note.warn { background: var(--warn-soft); color: var(--warn); }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
.sortbtn { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; text-transform: inherit; letter-spacing: inherit; }
.sortbtn .arr { font-size: 9px; opacity: 0; transition: opacity 0.15s; }
.sortbtn:hover .arr { opacity: 0.45; }
/* Hela rubrikcellen är klickbar och får en lätt ton vid hover. */
.sortbtn { box-sizing: border-box; margin: -10px -18px; padding: 10px 18px; width: calc(100% + 36px); transition: background-color 0.15s ease, color 0.15s ease; }
.sortbtn:hover { background: var(--surface-2); color: var(--ink); }
.sortbtn.on { color: var(--ink); }
.sortbtn.on .arr { opacity: 1; }
.sortbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
th.right .sortbtn { flex-direction: row-reverse; }
th { text-align: left; font-weight: 500; font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 18px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.sub { display: block; font-size: 12px; color: var(--ink-2); }
.right { text-align: right; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .lbl { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 7px 10px; width: 100%; min-width: 0; }
textarea { font-family: var(--f-mono); font-size: 12px; min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

/* Startsida */
.todo { display: flex; flex-direction: column; }
.todo-item { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--grid); flex-wrap: wrap; }
.todo-item:last-child { border-bottom: 0; }
.todo-item .txt { flex: 1; min-width: 200px; }
.todo-item .when { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 70px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.kpi .v { font-family: var(--f-display); font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.kpi .l { font-size: 12.5px; color: var(--ink-2); }
.kpi.warn .v { color: var(--warn); }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.charts .wide { grid-column: 1 / -1; }
@media (max-width: 760px) { .charts { grid-template-columns: minmax(0, 1fr); } }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { fill: var(--ink-2); font-size: 11px; font-family: var(--f-body); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend i.scale { width: 96px; height: 8px; border-radius: 4px; background: linear-gradient(90deg in oklch, #D7344F, #C4EBDA); }
.chart .val { fill: var(--ink); font-weight: 600; }
@media (max-width: 760px) { .chart.wide text { font-size: 19px; } }

/* Filter */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 20px; padding: 4px 12px; cursor: pointer; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.toolbar .search { flex: 1; min-width: 200px; max-width: 320px; }

/* Guide */
.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.steps span { font-size: 12.5px; padding: 4px 10px; border-radius: 20px; background: var(--surface-2); color: var(--ink-2); }
.steps span.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.steps span.done { background: var(--accent-soft); color: var(--accent); }
.prodgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .prodgrid { grid-template-columns: minmax(0, 1fr); } }
.prod { text-align: left; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.prod:hover { border-color: var(--ink-2); }
.prod[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.prod .price { font-family: var(--f-display); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.prod s { color: var(--ink-2); font-size: 12.5px; margin-left: 6px; }
.lvl { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; }
.checks { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.checks li { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.checks .ok { color: var(--good); font-weight: 700; }
.checks .no { color: var(--warn); font-weight: 700; }
.sum { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 8px 16px; }
.sum dt { color: var(--ink-2); }
.sum dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { .sum { grid-template-columns: minmax(0, 1fr); } .sum dd { margin-bottom: 6px; } }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }

/* Lådor och dialoger */
.scrim { position: fixed; inset: 0; background: rgba(10, 16, 14, 0.45); z-index: 40; display: flex; justify-content: flex-end; }
.drawer { width: min(520px, 100%); background: var(--surface); height: 100%; overflow-y: auto; padding: 22px; padding-top: calc(22px + env(safe-area-inset-top, 0px)); padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px)); padding-right: max(22px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 18px; border-left: 1px solid var(--line); }
.scrim.center { justify-content: center; align-items: center; padding: 16px; }
.dialog { width: min(560px, 100%); max-height: 100%; overflow-y: auto; background: var(--surface); border-radius: 10px; border: 1px solid var(--line); padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.scrim.leaving { pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .scrim.enter { animation: scrim-in 0.28s ease-out both; }
  .scrim.leaving { animation: scrim-out 0.22s ease-in both; }
  .scrim.center.enter .dialog { animation: dialog-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both; }
  .scrim.center.leaving .dialog { animation: dialog-out 0.22s cubic-bezier(0.4, 0, 1, 1) both; }
  .scrim.enter .drawer { animation: drawer-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both; }
  .scrim.leaving .drawer { animation: drawer-out 0.22s cubic-bezier(0.4, 0, 1, 1) both; }
  @keyframes scrim-in { from { background-color: rgba(10, 16, 14, 0); } }
  @keyframes scrim-out { to { background-color: rgba(10, 16, 14, 0); } }
  @keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.96); } }
  @keyframes dialog-out { to { opacity: 0; transform: translateY(6px) scale(0.97); } }
  @keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } }
  @keyframes drawer-out { to { transform: translateX(40px); opacity: 0; } }
}
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-2); padding: 2px 6px; }
.codebox { position: relative; background: var(--surface-2); border-radius: var(--r); padding: 10px 12px; font-family: var(--f-mono); font-size: 12px; overflow-x: auto; white-space: pre; }
.copyrow { display: flex; gap: 8px; align-items: center; }
.copyrow code { flex: 1; min-width: 0; background: var(--surface-2); border-radius: var(--r); padding: 7px 10px; font-family: var(--f-mono); font-size: 12px; overflow-x: auto; white-space: nowrap; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 60; max-width: calc(100% - 32px); font-weight: 500; box-shadow: 0 6px 24px rgba(0,0,0,0.2); }
.matrix td, .matrix th { text-align: center; padding: 8px 10px; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.yes { color: var(--good); font-weight: 700; }
.nope { color: var(--ink-2); }

/* Inloggning */
.login { min-height: 100%; display: grid; place-items: center; padding-block: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.login .card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 32px 28px 24px; display: flex; flex-direction: column; gap: 16px; position: relative; overflow: hidden; box-shadow: 0 12px 40px -18px rgba(30, 20, 50, 0.28); }
.login .card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, #66bce6, #d9b1e0, #ed5794, #fc7040, #ffd135); }
.login .card .btn.primary { width: 100%; --base: #6dbde2; --to: #fd695a; --dark: #fd695a; background-color: #6dbde2; border-color: #6dbde2; color: #0A1A30; transition: background-color 0.25s ease, background-position 0.45s ease, border-color 0.25s ease, box-shadow 0.25s ease; }
.login .card .btn.primary:hover { border-color: #fd695a; }
.wavebg { position: fixed; inset: 0; z-index: 0; background: #0A1A30; opacity: 0; visibility: hidden; transition: opacity 0.5s ease, visibility 0s linear 0.5s; }
.wavebg.on { opacity: 1; visibility: visible; transition: opacity 0.5s ease; }
.wavebg canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; -webkit-mask-image: linear-gradient(90deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.5) 32%, #000 62%); mask-image: linear-gradient(90deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.5) 32%, #000 62%); }
.login .card { box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.55); }
.login-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.login-head .logo { margin: 0; height: 56px; width: auto; transform: translateX(-4.6px); } /* m-ets mitt ligger 21,5 enheter höger om viewBox-mitten (×56/262 px) */
.login-head h1 { font-family: var(--f-display); font-size: 20px; margin: 0; }
.login-head p { margin: 4px 0 10px; color: var(--ink-2); font-size: 13px; }
.login .linkbtn { align-self: center; }
.otp { font-family: var(--f-mono); font-size: 24px; letter-spacing: 0.4em; text-align: center; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise 0.2s ease-out; } @keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } } }

/* Tillägg för den riktiga portalen */
a { color: var(--accent); }
.nav a { text-decoration: none; }
a.btn { text-decoration: none; color: inherit; }
a.btn.primary { color: var(--accent-ink); } a.btn.renew { color: var(--renew-ink); }
.flash { border-radius: var(--r); padding: 10px 14px; font-weight: 500; background: var(--good-soft); color: var(--good); }
.flash.error { background: var(--bad-soft); color: var(--bad); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.login .flash { font-size: 13px; }
.errors { color: var(--bad); font-size: 12.5px; }
.qr { flex: none; width: 132px; height: 132px; background: #fff; border-radius: 6px; padding: 6px; border: 1px solid var(--line); }
.qr svg { display: block; width: 100%; height: 100%; }
.inline { display: inline; margin: 0; }
td form.inline + form.inline { margin-left: 4px; }
.prod { color: inherit; text-decoration: none; }
.back { font-size: 13px; text-decoration: none; }
.back:hover { text-decoration: underline; }
.page-detail { max-width: 720px; }
.orgswitch { padding: 0 8px; }
.orgswitch select { font-size: 13px; padding: 5px 8px; }
.collapsed .orgswitch { opacity: 0; pointer-events: none; }
/* Dialoger med <dialog>. De öppnas mjukt och stängs mjukt (klassen closing sätts av portal.js). */
dialog.dialog { position: fixed; inset: 0; margin: auto; color: var(--ink); max-height: calc(100% - 32px); }
dialog.dialog::backdrop { background: rgba(10, 16, 14, 0.45); }
dialog.dialog:not([open]) { display: none; }
@media (prefers-reduced-motion: no-preference) {
  dialog.dialog[open] { animation: dialog-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both; }
  dialog.dialog[open]::backdrop { animation: scrim-in 0.28s ease-out both; }
  dialog.dialog.closing { animation: dialog-out 0.22s cubic-bezier(0.4, 0, 1, 1) both; }
  dialog.dialog.closing::backdrop { animation: scrim-out 0.22s ease-in both; }
}
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.96); } }
@keyframes dialog-out { to { opacity: 0; transform: translateY(6px) scale(0.97); } }
@keyframes scrim-in { from { background-color: rgba(10, 16, 14, 0); } }
@keyframes scrim-out { to { background-color: rgba(10, 16, 14, 0); } }
body { margin: 0; }
a.chip, a.pill, a.logoutbtn { text-decoration: none; color: inherit; }
a.pill.warn { color: var(--warn); }
a.chip[aria-pressed="true"] { color: var(--bg); }
