/* Kundhjälpen – gränssnitt. Designtokens (ljust + mörkt tema), appskal, komponenter och sidor. */
:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --surface-3: #eef2f5;
  --sidebar: #ffffff;
  --border: #e1e7ec;
  --border-strong: #ccd5de;
  --text: #0b1a33;
  --text-2: #43546b;
  --text-3: #66768c;
  --placeholder: #97a5b6;

  --brand: #0b1a33;
  --brand-2: #13294d;
  --accent: #14a3ad;
  --primary: #0b7c89;
  --primary-hover: #096875;
  --on-primary: #ffffff;
  --link: #0a7380;
  --primary-soft: #e7f6f7;
  --primary-ring: rgba(13, 140, 153, .26);

  --ok: #067647;   --ok-bg: #ecfdf3;   --ok-border: #abefc6;   --ok-text: #054f31;
  --warn: #b54708; --warn-bg: #fffaeb; --warn-border: #fedf89; --warn-text: #7a2e0e;
  --err: #b42318;  --err-bg: #fef3f2;  --err-border: #fecdca;  --err-text: #7a271a;
  --info: #0a7380; --info-bg: #e7f6f7; --info-border: #b5e2e5; --info-text: #0b4a52;

  --toast: #0b1a33;
  --overlay: rgba(16, 24, 40, .45);
  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 16px 32px -8px rgba(11, 26, 51, .2), 0 4px 8px -2px rgba(11, 26, 51, .06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bottomnav-h: 64px;

  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --sidebar-w: 276px;
  --mobilebar-h: 56px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #08121f;
  --surface: #0e1a2b;
  --surface-2: #122034;
  --surface-3: #18283f;
  --sidebar: #0a1524;
  --border: #1d2d45;
  --border-strong: #2b3f5c;
  --text: #e6edf3;
  --text-2: #a9b8ca;
  --text-3: #7d8ea5;
  --placeholder: #5d6f87;
  --brand: #e6edf3;
  --primary: #1fb3bd;
  --primary-hover: #3cc6cf;
  --on-primary: #04161c;
  --link: #4fd1d9;
  --primary-soft: rgba(31, 179, 189, .13);
  --primary-ring: rgba(31, 179, 189, .35);
  --ok: #4ad295;   --ok-bg: rgba(18, 183, 106, .12);  --ok-border: rgba(18, 183, 106, .32);  --ok-text: #a6f4c5;
  --warn: #fdb022; --warn-bg: rgba(247, 144, 9, .12); --warn-border: rgba(247, 144, 9, .34); --warn-text: #fedf89;
  --err: #f97066;  --err-bg: rgba(240, 68, 56, .12);  --err-border: rgba(240, 68, 56, .34);  --err-text: #fecdca;
  --info: #4fd1d9; --info-bg: rgba(31, 179, 189, .11); --info-border: rgba(31, 179, 189, .3); --info-text: #bdeef1;
  --toast: #1d3049;
  --overlay: rgba(0, 0, 0, .6);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ bas */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 90px; }
body { margin: 0; font: 15px/1.6 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; min-height: 100vh; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.015em; color: var(--text); }
h1 { font-size: 1.6rem; font-weight: 680; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .8rem; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
:root[data-theme="dark"] a:hover { color: #8ae3e8; }
small, .small { font-size: .85rem; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 2px; border-radius: 4px; }
svg.icon { width: 1.1em; height: 1.1em; flex: none; vertical-align: -.18em; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; font-family: var(--font);
  font-size: .72rem; font-weight: 600; color: var(--text-3); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px;
  background: var(--surface); line-height: 1; }
::selection { background: var(--primary-ring); }

/* ------------------------------------------------------------- appskal */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--sidebar);
  border-right: 1px solid var(--border); z-index: 60; }
.sb-top { padding: 16px 14px 10px; display: grid; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.05rem; padding: 0 4px; }
.brand:hover { color: var(--text); }
.brand-mark { width: 34px; height: 34px; flex: none; display: block; }
.brand-name { font-weight: 750; letter-spacing: -.02em; color: var(--brand); font-size: 1.12rem; }
.brand-tag { font-size: .64rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--info);
  background: var(--primary-soft); border: 1px solid var(--info-border); padding: 1px 6px; border-radius: 999px; }
.sidebar .sb-close { margin-left: auto; display: none; }
.sb-search { display: flex; align-items: center; gap: 8px; width: 100%; height: 36px; padding: 0 8px 0 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text-3); font: inherit; font-size: .9rem; cursor: pointer; box-shadow: var(--shadow-sm); }
.sb-search:hover { border-color: var(--border-strong); color: var(--text-2); }
.sb-search .grow { text-align: left; }
.sb-nav { display: grid; gap: 1px; padding: 4px 10px 8px; }
.sb-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text-2);
  text-decoration: none; font-weight: 550; font-size: .92rem; }
.sb-link:hover { background: var(--surface-3); color: var(--text); }
.sb-link[aria-current="page"] { background: var(--surface-3); color: var(--text); }
.sb-link .count { margin-left: auto; font-size: .75rem; color: var(--text-3); font-weight: 600; }
.sb-list { flex: 1; overflow-y: auto; padding: 0 10px 12px; scrollbar-width: thin; }
.sb-group { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); padding: 14px 10px 6px; }
.sb-case { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text-2);
  text-decoration: none; font-size: .9rem; min-width: 0; }
.sb-case:hover { background: var(--surface-3); color: var(--text); }
.sb-case[aria-current="page"] { background: var(--primary-soft); color: var(--text); font-weight: 600; }
.sb-case .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--border-strong); }
.dot.risk-hög { background: var(--risk-high); } .dot.risk-medel { background: var(--risk-mid); } .dot.risk-låg { background: var(--risk-low-dot); }
.dot.running, .dot.queued { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
.dot.error { background: var(--err); box-shadow: 0 0 0 2px var(--err-bg); }
.sb-empty { padding: 10px; font-size: .86rem; color: var(--text-3); }
.sb-foot { border-top: 1px solid var(--border); padding: 10px; display: flex; align-items: center; gap: 6px; }
.sb-user { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.sb-user:hover { background: var(--surface-3); }
.sb-user .who { min-width: 0; line-height: 1.25; }
.sb-user .who strong { display: block; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user .who span { display: block; font-size: .78rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #d5f0f2, #b3e1e5); color: #0b4a52;
  display: grid; place-items: center; font-weight: 700; font-size: .85rem; text-transform: uppercase; flex: none; }
:root[data-theme="dark"] .avatar { background: linear-gradient(135deg, #12606b, #0d3f4a); color: #e6edf3; }

.main { min-width: 0; display: flex; flex-direction: column; }
.mobilebar { display: none; }
.page { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 32px 48px; }
.page.narrow { max-width: 860px; }
.page-foot { padding: 16px 32px 22px; color: var(--text-3); font-size: .8rem; display: flex; gap: 8px; align-items: center; justify-content: center; }
.scrim { display: none; }

/* ---------------------------------------------------------------- menyer */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 80; animation: pop-in .12s ease-out; }
.menu-panel.up { top: auto; bottom: calc(100% + 6px); left: 0; right: auto; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none;
  color: var(--text); text-decoration: none; font: inherit; font-size: .92rem; border-radius: var(--radius-sm); cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--surface-3); color: var(--text); }
.menu-item .kbd { margin-left: auto; }
.menu-item.danger { color: var(--err); }
.menu-item.danger:hover { background: var(--err-bg); color: var(--err); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }
.menu-label { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 6px 10px 4px; }
.seg { display: flex; gap: 2px; padding: 3px; margin: 2px 6px 6px; background: var(--surface-3); border-radius: var(--radius-sm); }
.seg button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: none; color: var(--text-2);
  font: inherit; font-size: .82rem; font-weight: 600; padding: 5px 6px; border-radius: 5px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ----------------------------------------------------------------- kort */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-body { padding: 20px 22px; }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2 { margin: 0; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.section-title { font-size: .74rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); margin: 0 0 8px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .lead { color: var(--text-2); margin: 4px 0 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; }

/* -------------------------------------------------------------- knappar */
.btn { --b: var(--primary); display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--b); background: var(--b); color: var(--on-primary); font: inherit; font-weight: 600;
  font-size: .92rem; cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, box-shadow .15s, color .15s, transform .05s; }
.btn:hover { --b: var(--primary-hover); color: var(--on-primary); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }
.btn-danger { --b: var(--err); color: #fff; }
.btn-danger:hover { --b: #912018; color: #fff; }
.btn-sm { height: 32px; padding: 0 12px; font-size: .86rem; }
.btn-lg { height: 44px; padding: 0 22px; font-size: 1rem; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.btn .spinner { width: 16px; height: 16px; border-width: 2px; border-color: color-mix(in srgb, var(--on-primary) 40%, transparent); border-top-color: var(--on-primary); }
.btn-secondary .spinner, .btn-ghost .spinner { border-color: var(--border-strong); border-top-color: var(--primary); }

/* -------------------------------------------------------------- formulär */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field-label .opt { font-weight: 400; color: var(--text-3); }
.field-hint { font-size: .82rem; color: var(--text-3); margin-top: 6px; }
.input, .textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); font: inherit; color: var(--text); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.input:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.textarea { resize: vertical; min-height: 96px; line-height: 1.55; }
.input::placeholder, .textarea::placeholder { color: var(--placeholder); }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: .92rem; color: var(--text-2); }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }
.search { position: relative; display: block; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search .input { padding-left: 34px; height: 36px; }
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .2s; }

/* ------------------------------------------------------ badges och chips */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: .78rem;
  font-weight: 600; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge.analyzed, .badge.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.badge.queued, .badge.running, .badge.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.badge.running::before, .badge.queued::before { animation: pulse 1.2s ease-in-out infinite; }
.badge.error, .badge.bad { background: var(--err-bg); color: var(--err); border-color: var(--err-border); }
.badge.info { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 550;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; line-height: 1.5; }
.chip-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); font-size: .74rem; vertical-align: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
button.chip { cursor: pointer; font: inherit; font-size: .84rem; padding: 5px 12px; }
button.chip:hover { border-color: var(--primary); color: var(--link); background: var(--primary-soft); }
button.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.risk { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; padding: 4px 12px 4px 10px;
  border-radius: var(--radius-sm); border: 1px solid; }
.risk .bars { display: inline-flex; gap: 2px; align-items: flex-end; }
.risk .bars i { width: 4px; border-radius: 1px; background: currentColor; opacity: .25; }
.risk .bars i:nth-child(1) { height: 7px; } .risk .bars i:nth-child(2) { height: 11px; } .risk .bars i:nth-child(3) { height: 15px; }
.risk-låg { color: var(--risk-low); background: var(--risk-low-bg); border-color: var(--risk-low-border); }
.risk-låg .bars i:nth-child(1) { opacity: 1; }
.risk-medel { color: var(--risk-mid); background: var(--risk-mid-bg); border-color: var(--risk-mid-border); }
.risk-medel .bars i:nth-child(-n+2) { opacity: 1; }
.risk-hög { color: var(--risk-high); background: var(--risk-high-bg); border-color: var(--risk-high-border); }
.risk-hög .bars i { opacity: 1; }
.risk-sm { font-size: .8rem; padding: 1px 8px 1px 7px; font-weight: 650; }
.risk-sm .bars i:nth-child(1) { height: 5px; } .risk-sm .bars i:nth-child(2) { height: 8px; } .risk-sm .bars i:nth-child(3) { height: 11px; }
.risk-sm .bars i { width: 3px; }

/* --------------------------------------------------------------- notiser */
.alert { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid; font-size: .92rem; }
.alert .icon { margin-top: 2px; }
.alert p:last-child, .alert ul:last-child { margin-bottom: 0; }
.alert-info { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.alert-error { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }
.alert-ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: var(--toast); color: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-size: .92rem; animation: toast-in .22s cubic-bezier(.2, .9, .3, 1.2); }
.toast.error { background: #b42318; }
.toast.hide { animation: toast-out .2s ease-in forwards; }
.toast .t-action { margin-left: auto; background: rgba(255, 255, 255, .14); border: 0; color: #fff; font: inherit; font-weight: 600; font-size: .85rem;
  padding: 3px 10px; border-radius: 5px; cursor: pointer; }
.toast .t-close { background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; padding: 0 2px; margin-left: auto; }
.toast .t-action + .t-close { margin-left: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }
.spinner { display: inline-block; width: 20px; height: 20px; border: 2.5px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------------------------------------------------------------- dialog */
dialog.modal { border: 1px solid var(--border); padding: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: min(460px, calc(100vw - 32px)); color: var(--text); background: var(--surface); }
dialog.modal[open] { animation: pop-in .16s ease-out; }
dialog::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
.modal-body { padding: 22px 22px 8px; }
.modal-body h2 { font-size: 1.1rem; margin-bottom: 6px; }
.modal-body p { color: var(--text-2); font-size: .94rem; }
.modal-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 14px; }
.modal-icon.danger { background: var(--err-bg); color: var(--err); }
.modal-icon.info { background: var(--info-bg); color: var(--info); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 8px 0 0; font-size: .92rem; }
dl.kv dt { color: var(--text-3); }
dl.kv dd { margin: 0; font-family: var(--mono); font-size: .86rem; overflow-wrap: anywhere; }
.shortcut-list { display: grid; grid-template-columns: 1fr auto; gap: 8px 18px; font-size: .92rem; margin: 10px 0 0; }
.shortcut-list dt { color: var(--text-2); }
.shortcut-list dd { margin: 0; display: flex; gap: 4px; justify-content: flex-end; }
.shortcut-head { grid-column: 1 / -1; font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); margin-top: 8px; }

/* -------------------------------------------------------- kommandopalett */
dialog.palette { border: 1px solid var(--border); padding: 0; border-radius: 14px; box-shadow: var(--shadow-lg); background: var(--surface);
  color: var(--text); width: min(620px, calc(100vw - 24px)); margin-top: 12vh; max-height: 70vh; overflow: hidden; }
dialog.palette[open] { display: flex; flex-direction: column; animation: pop-in .14s ease-out; }
.pal-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.pal-input .icon { color: var(--text-3); width: 20px; height: 20px; }
.pal-input input { flex: 1; height: 54px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 1.02rem; }
.pal-input input:focus { outline: none; }
.pal-input input::placeholder { color: var(--placeholder); }
.pal-list { overflow-y: auto; padding: 6px; flex: 1; }
.pal-group { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); padding: 10px 10px 4px; }
.pal-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--text); font-size: .94rem; }
.pal-item .ic { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; color: var(--text-2); flex: none; }
.pal-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-item .sub { color: var(--text-3); font-size: .82rem; white-space: nowrap; }
.pal-item[aria-selected="true"] { background: var(--primary-soft); }
.pal-item[aria-selected="true"] .ic { background: var(--primary); color: var(--on-primary); }
.pal-item mark { background: none; color: var(--link); font-weight: 700; }
.pal-empty { padding: 28px; text-align: center; color: var(--text-3); }
.pal-foot { display: flex; gap: 16px; padding: 9px 14px; border-top: 1px solid var(--border); font-size: .78rem; color: var(--text-3); background: var(--surface-2); }
.pal-foot span { display: inline-flex; align-items: center; gap: 5px; }

/* --------------------------------------------------------------- inlogg */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 40px 16px; }
.auth-card { width: min(400px, 100%); }
.auth-card .brand { justify-content: center; margin-bottom: 22px; font-size: 1.2rem; }
.auth-card h1 { font-size: 1.35rem; text-align: center; }
.auth-card .lead { text-align: center; color: var(--text-2); margin-bottom: 22px; }
.auth-card .card-foot { padding: 12px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------------------------------------------------------- nytt ärende */
.home { max-width: 820px; margin: 4vh auto 0; }
.home-hero { text-align: center; margin-bottom: 26px; }
.home-hero h1 { font-size: 2rem; margin-bottom: 8px; }
.home-hero p { color: var(--text-2); font-size: 1.02rem; margin: 0; }
.composer-card { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s; position: relative; }
.composer-card:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring), var(--shadow); }
.composer-card .title-input { width: 100%; border: 0; background: transparent; font: inherit; font-size: 1.05rem; font-weight: 650; color: var(--text);
  padding: 18px 20px 0; }
.composer-card .title-input:focus { outline: none; }
.composer-card .title-input::placeholder { color: var(--placeholder); font-weight: 500; }
.composer-card textarea { display: block; width: 100%; border: 0; background: transparent; font: inherit; color: var(--text); line-height: 1.6;
  padding: 8px 20px 12px; min-height: 150px; max-height: 50vh; resize: none; }
.composer-card textarea:focus { outline: none; }
.composer-card textarea::placeholder { color: var(--placeholder); }
.composer-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 6px; }
.file-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 280px; padding: 6px 6px 6px 10px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2); font-size: .86rem; animation: pop-in .15s ease-out; }
.file-chip .ic { color: var(--text-2); }
.file-chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.file-chip .sz { color: var(--text-3); font-size: .78rem; white-space: nowrap; }
.file-chip.bad { border-color: var(--err-border); background: var(--err-bg); color: var(--err); }
.file-chip button { border: 0; background: none; color: var(--text-3); cursor: pointer; padding: 2px; border-radius: 4px; display: grid; }
.file-chip button:hover { background: var(--surface-3); color: var(--text); }
.composer-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px 12px 14px; border-top: 1px solid var(--border); }
.composer-bar .hint { font-size: .8rem; color: var(--text-3); display: inline-flex; align-items: center; gap: 4px; }
.templates { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.drop-overlay { position: fixed; inset: 0; z-index: 300; background: color-mix(in srgb, var(--primary) 12%, transparent); backdrop-filter: blur(2px);
  display: grid; place-items: center; pointer-events: none; opacity: 0; transition: opacity .12s; }
.drop-overlay.on { opacity: 1; }
.drop-overlay .box { border: 2px dashed var(--primary); border-radius: 20px; padding: 40px 56px; background: var(--surface); text-align: center;
  box-shadow: var(--shadow-lg); color: var(--text); }
.drop-overlay .box .icon { width: 36px; height: 36px; color: var(--link); margin-bottom: 8px; }
.recent { margin-top: 40px; }
.recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.case-card { display: block; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  text-decoration: none; color: var(--text); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, transform .15s; }
.case-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); color: var(--text); }
.case-card .t { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 4px; }
.case-card .m { font-size: .82rem; color: var(--text-3); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ------------------------------------------------------------ ärendelista */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.toolbar .search { width: min(320px, 100%); }
.list-group { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3);
  padding: 14px 20px 6px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.case-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto 130px; gap: 14px; align-items: center; padding: 12px 20px;
  border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); transition: background .1s; }
.case-row:hover, .case-row.kb { background: var(--surface-2); color: var(--text); }
.case-row.kb { box-shadow: inset 3px 0 0 var(--primary); }
.case-row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-row .s { font-size: .84rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-row .d { font-size: .84rem; color: var(--text-3); text-align: right; white-space: nowrap; }
.empty { text-align: center; padding: 48px 22px; color: var(--text-3); }
.empty .icon-wrap { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 50%; background: var(--surface-3);
  display: grid; place-items: center; color: var(--text-3); }
.empty .icon-wrap .icon { width: 24px; height: 24px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* ------------------------------------------------------------- ärendesida */
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); text-decoration: none; font-size: .88rem; }
.crumb:hover { color: var(--text); }
.case-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 8px 0 20px; flex-wrap: wrap; }
.case-head h1 { margin-bottom: 6px; overflow-wrap: anywhere; }
.case-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; color: var(--text-3); font-size: .9rem; }
.case-meta .sep { width: 3px; height: 3px; border-radius: 50%; background: currentColor; }
.case-actions { display: flex; gap: 8px; align-items: center; }
.stickybar { position: sticky; top: 0; z-index: 30; margin: -28px -32px 0; padding: 10px 32px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid transparent; display: flex; align-items: center; gap: 12px;
  transition: border-color .2s, box-shadow .2s; min-height: 56px; }
.stickybar.stuck { border-bottom-color: var(--border); box-shadow: 0 1px 0 rgba(0, 0, 0, .02); }
.stickybar .sb-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: 0; transform: translateY(4px);
  transition: opacity .2s, transform .2s; min-width: 0; flex: 1; display: flex; align-items: center; gap: 10px; }
.stickybar.stuck .sb-title { opacity: 1; transform: none; }
.stickybar.stuck .crumb { display: none; }

.progress-card { display: flex; gap: 16px; align-items: center; padding: 18px 22px; margin-bottom: 20px; }
.progress-card .spinner { width: 28px; height: 28px; border-width: 3px; }
.progress-card h2 { margin: 0 0 2px; font-size: 1rem; }
.progress-card p { margin: 0; color: var(--text-2); font-size: .92rem; }
.steps { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.steps span { font-size: .78rem; padding: 2px 9px; border-radius: 999px; background: var(--surface-3); color: var(--text-3); border: 1px solid var(--border); transition: all .3s; }
.steps span.on { background: var(--primary-soft); color: var(--link); border-color: var(--info-border); }
.steps span.done { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }

.overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.overview .cell { padding: 16px 20px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.overview .cell .section-title { margin-bottom: 6px; }
.overview .cell .val { font-weight: 600; }
.overview-foot { padding: 16px 20px; display: grid; gap: 14px; }
.deadlines { display: flex; flex-wrap: wrap; gap: 8px; }
.deadline { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); font-size: .88rem; }
.deadline .name { font-weight: 600; }
.deadline .basis { color: var(--text-3); font-size: .82rem; }
.recommend { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--primary-soft); border: 1px solid var(--info-border); }
.recommend .icon { color: var(--link); width: 20px; height: 20px; margin-top: 1px; }
.recommend .section-title { color: var(--link); margin-bottom: 4px; }
.recommend .md p:last-child { margin: 0; }

.case-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; margin-top: 20px; }
.aside { position: sticky; top: 72px; display: grid; gap: 16px; }

.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs [role=tab] { position: relative; background: none; border: 0; padding: 14px 10px; font: inherit; font-weight: 600; font-size: .92rem;
  color: var(--text-3); cursor: pointer; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs [role=tab]:hover { color: var(--text); }
.tabs [role=tab][aria-selected=true] { color: var(--link); }
.tabs [role=tab][aria-selected=true]::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: -1px; height: 2px; background: var(--link); border-radius: 2px; }
.tabs .count { font-size: .74rem; padding: 0 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-weight: 600; }
.tabs [aria-selected=true] .count { background: var(--primary-soft); color: var(--link); }
.tabs .kbd { display: none; }
[role=tabpanel] { padding: 22px; }
[role=tabpanel][hidden] { display: none; }
.panel-layout { display: grid; grid-template-columns: minmax(0, 1fr) 170px; gap: 28px; }
.toc { position: sticky; top: 140px; align-self: start; font-size: .84rem; border-left: 1px solid var(--border); }
.toc a { display: block; padding: 4px 12px; color: var(--text-3); text-decoration: none; margin-left: -1px; border-left: 2px solid transparent; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--link); border-left-color: var(--link); font-weight: 600; }

.prose-section + .prose-section { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--border); }
.prose-section > h2 { font-size: 1.05rem; display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.md { overflow-wrap: anywhere; }
.md > :last-child { margin-bottom: 0; }
.md ul, .md ol { padding-left: 1.3rem; margin: 0 0 .8rem; }
.md li + li { margin-top: .25rem; }
.md h2 { font-size: 1.02rem; margin-top: 1.2rem; }
.md h3 { font-size: .96rem; margin-top: 1rem; }
.md blockquote { margin: .6rem 0; padding: .4rem .9rem; border-left: 3px solid var(--border-strong); color: var(--text-2); background: var(--surface-2); border-radius: 0 6px 6px 0; }
.md pre { background: var(--surface-2); border: 1px solid var(--border); padding: 12px; border-radius: var(--radius-sm); white-space: pre-wrap; font-size: .88rem; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; margin: .6rem 0; font-size: .9rem; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
a.ref { display: inline-block; font-size: .74rem; font-weight: 700; line-height: 1; padding: 3px 5px; margin: 0 1px; border-radius: 4px;
  background: var(--primary-soft); color: var(--link); text-decoration: none; vertical-align: 1px; border: 1px solid var(--info-border); }
a.ref:hover { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.ref-pop { position: absolute; z-index: 90; width: min(380px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 12px 14px; font-size: .86rem; color: var(--text-2); pointer-events: none; animation: pop-in .12s ease-out; }
.ref-pop strong { display: block; color: var(--text); margin-bottom: 4px; font-size: .9rem; }

.arg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.arg-col { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--surface-2); }
.arg-col h3 { font-size: .9rem; display: flex; align-items: center; gap: 8px; }
.arg-col ul { margin: 0; padding-left: 1.1rem; font-size: .92rem; }
.arg-col li + li { margin-top: 6px; }
.arg-col .support { display: block; font-size: .8rem; color: var(--text-3); margin-top: 2px; }

.statute-list, .source-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.statute-list li { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .92rem; }
.statute-list .cit { font-weight: 650; }
.statute-list blockquote { margin: 8px 0 0; padding: 6px 10px; border-left: 3px solid var(--border-strong); background: var(--surface-2); color: var(--text-2); font-size: .88rem; white-space: pre-wrap; }
.src { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: box-shadow .2s, border-color .2s; }
.src.flash-target { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.src > summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; }
.src > summary::-webkit-details-marker { display: none; }
.src > summary .chev { margin-left: auto; color: var(--text-3); transition: transform .15s; margin-top: 3px; }
.src[open] > summary .chev { transform: rotate(90deg); }
.src .refno { flex: none; font-size: .74rem; font-weight: 700; padding: 3px 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); margin-top: 2px; min-width: 32px; text-align: center; }
.src .src-title { font-weight: 650; }
.src .src-meta { font-size: .84rem; color: var(--text-3); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
.src .src-body { padding: 0 14px 14px 58px; font-size: .9rem; color: var(--text-2); }
.src .statute-text { white-space: pre-wrap; background: var(--surface-2); border-left: 3px solid var(--border-strong); padding: 10px 12px; border-radius: 0 6px 6px 0; margin-bottom: 8px; color: var(--text); }
.src[open] .src-summary { display: none !important; }
.src.cited .refno { background: var(--primary-soft); color: var(--link); }
.outcome-bifall { color: var(--ok); } .outcome-avslag { color: var(--err); }

.reply-card .card-head { padding: 14px 18px; }
.reply-card .card-body { padding: 16px 18px; }
.reply-card .textarea { min-height: 300px; font-size: .92rem; }
.reply-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.reply-actions:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.save-state { font-size: .82rem; color: var(--text-3); }
.save-state.dirty { color: var(--warn); }

.att-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.att-list li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.att-list .ficon { flex: none; width: 34px; height: 34px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; color: var(--text-2); }
.att-list .fname { font-weight: 600; overflow-wrap: anywhere; }
.att-list .warn { color: var(--warn); font-size: .84rem; display: block; margin-top: 2px; }
.input-text { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; font-size: .92rem; color: var(--text-2); max-height: 320px; overflow: auto; }

.chat { display: grid; gap: 14px; margin-bottom: 16px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; font-size: .94rem; position: relative; animation: pop-in .15s ease-out; }
.msg.user { justify-self: end; background: var(--primary); color: var(--on-primary); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant { justify-self: start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.assistant .md p:last-child { margin-bottom: 0; }
.msg.failed { opacity: .75; }
.msg .msg-foot { font-size: .78rem; margin-top: 6px; display: flex; gap: 8px; align-items: center; }
.msg.user .msg-foot { color: var(--on-primary); opacity: .9; justify-content: flex-end; }
.msg.user .msg-foot button { color: var(--on-primary); background: rgba(255, 255, 255, .2); border: 0; border-radius: 4px; padding: 1px 8px; cursor: pointer; font: inherit; }
.updated-reply { margin-top: 10px; border: 1px solid var(--info-border); background: var(--surface); border-radius: var(--radius-sm); }
.updated-reply .ur-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--info-border);
  background: var(--primary-soft); font-size: .84rem; font-weight: 600; color: var(--link); border-radius: 6px 6px 0 0; }
.updated-reply pre { margin: 0; padding: 10px; white-space: pre-wrap; font: inherit; font-size: .88rem; max-height: 220px; overflow: auto; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite both; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.composer { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.composer textarea { width: 100%; border: 0; resize: none; padding: 12px 14px 4px; font: inherit; min-height: 64px; background: transparent; color: var(--text); }
.composer textarea:focus { outline: none; }
.composer textarea::placeholder { color: var(--placeholder); }
.composer .bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 8px 14px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.disclaimer { display: flex; gap: 8px; align-items: flex-start; font-size: .82rem; color: var(--text-3); margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--border); }

/* --------------------------------------------------------------- responsivt */
@media (max-width: 1599px) {
  .panel-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 1100px) {
  .case-grid { grid-template-columns: minmax(0, 1fr); }
  .aside { position: static; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .sidebar .sb-close { display: inline-flex; }
  .mobilebar { display: flex; position: sticky; top: 0; z-index: 40; height: var(--mobilebar-h); align-items: center; gap: 8px; padding: 0 10px;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
  .mobilebar .brand { font-size: 1rem; }
  .page { padding: 20px 16px 40px; }
  .stickybar { top: var(--mobilebar-h); margin: -20px -16px 0; padding: 8px 16px; }
  .aside { top: auto; }
  .page-foot { padding: 14px 16px 20px; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .home-hero h1 { font-size: 1.5rem; }
  .card-body, [role=tabpanel] { padding: 16px; }
  .arg-grid { grid-template-columns: 1fr; }
  .overview .cell { padding: 12px 16px; }
  .src .src-body { padding-left: 14px; }
  .msg { max-width: 100%; }
  .case-row { grid-template-columns: 10px minmax(0, 1fr) auto; }
  .case-row .d, .case-row .r { display: none; }
  .composer-bar .hint { display: none; }
  .stickybar .case-actions .btn-label { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ====================================================== v3: förlopp, mobilapp, röst */

/* Levande förlopp under analys */
.progress-card { display: block; padding: 22px 24px; margin-bottom: 20px; overflow: hidden; position: relative; }
.progress-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%; background-repeat: no-repeat;
  animation: sweep 1.6s ease-in-out infinite; }
.progress-card.done::before { animation: none; background: var(--ok); background-size: 100% 100%; }
@keyframes sweep { from { background-position: -50% 0; } to { background-position: 150% 0; } }
.pc-head { display: flex; align-items: center; gap: 16px; }
.pc-head h2 { margin: 0 0 2px; font-size: 1.05rem; }
.pc-head p { margin: 0; color: var(--text-2); font-size: .93rem; min-height: 1.5em; transition: opacity .25s; }
.pc-head p.fade { opacity: 0; }
.orb { width: 44px; height: 44px; flex: none; border-radius: 50%; position: relative;
  background: conic-gradient(from 0deg, transparent 0 25%, var(--accent) 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px)); animation: spin 1.1s linear infinite; }
.orb-wrap { position: relative; width: 44px; height: 44px; flex: none; }
.orb-wrap img { position: absolute; inset: 9px; width: 26px; height: 26px; }
.progress-card.done .orb { animation: none; background: var(--ok); }
.stepper { list-style: none; margin: 18px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.stepper li { display: flex; align-items: center; gap: 9px; font-size: .86rem; color: var(--text-3); padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); transition: all .3s; }
.stepper .si { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; }
.stepper li.active { color: var(--text); border-color: var(--info-border); background: var(--primary-soft); font-weight: 600; }
.stepper li.active .si { border-color: var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.stepper li.done { color: var(--text-2); }
.stepper li.done .si { border-color: var(--ok); background: var(--ok); }
.stepper li.done .si::after { content: ""; width: 7px; height: 4px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.chat-stage { font-size: .84rem; color: var(--text-3); display: inline-flex; align-items: center; gap: 8px; }

/* Röstinmatning och kamera */
.mic-btn[hidden] { display: none !important; }
.mic-btn.listening { color: #fff !important; background: var(--err) !important; border-color: var(--err) !important; }
.mic-btn.listening .icon { animation: pulse 1s ease-in-out infinite; }
.listening-hint { font-size: .8rem; color: var(--err); display: inline-flex; align-items: center; gap: 6px; }
.listening-hint::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--err); animation: pulse 1s infinite; }
.only-touch { display: none !important; }
@media (pointer: coarse) { .only-touch { display: inline-flex !important; } .only-fine { display: none !important; } }

/* Mobil flikrad (iPhone/Android), säkra marginaler för notch och hemindikator */
.bottomnav { display: none; }
@media (max-width: 900px) {
  .mobilebar { padding-top: var(--safe-top); height: calc(var(--mobilebar-h) + var(--safe-top)); }
  .mobilebar .brand-name { font-size: 1.02rem; }
  .stickybar { top: calc(var(--mobilebar-h) + var(--safe-top)); }
  .bottomnav { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    padding: 6px 8px calc(6px + var(--safe-bottom)); background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: saturate(180%) blur(14px); border-top: 1px solid var(--border); }
  .bottomnav a, .bottomnav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 52px;
    border: 0; background: none; color: var(--text-3); font: inherit; font-size: .7rem; font-weight: 600; text-decoration: none; border-radius: 12px; cursor: pointer; }
  .bottomnav .icon { width: 22px; height: 22px; }
  .bottomnav [aria-current="page"] { color: var(--link); }
  .bottomnav .bn-new .bubble { width: 44px; height: 32px; border-radius: 12px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; }
  .bottomnav .bn-new { color: var(--text-2); }
  .page { padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 28px); }
  .page-foot { display: none; }
  .toasts { bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 12px); }
  .mobilebar .mb-actions { display: none; }
  .sidebar { padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); }
}
/* Pekskärm: större träffytor, 16 px i fält (iOS zoomar annars in), inga tangentbordstips */
@media (pointer: coarse) {
  .input, .textarea, .composer textarea, .composer-card textarea, .composer-card .title-input, .pal-input input, #reply-subject { font-size: 16px; }
  .btn-sm { height: 40px; } .btn-icon.btn-sm { width: 40px; }
  .sb-case, .sb-link { padding-top: 10px; padding-bottom: 10px; }
  .kbd, .composer-bar .hint .kbd, .pal-foot { display: none !important; }
  .tabs [role=tab] { padding: 15px 12px; }
}
/* Installerad app (hemskärm) */
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
}
/* iPad liggande: sidomeny + innehåll; stående: flikrad */
@media (min-width: 901px) and (max-width: 1180px) {
  :root { --sidebar-w: 248px; }
  .page { padding: 24px 24px 40px; }
  .stickybar { margin: -24px -24px 0; padding: 10px 24px; }
}

/* Inga horisontella överflöden på smala skärmar: långa lagnamn och frister radbryts */
.main { overflow-x: clip; }
.chips .chip { white-space: normal; max-width: 100%; text-align: left; }
.deadline { min-width: 0; max-width: 100%; }
.deadline > div { min-width: 0; overflow-wrap: anywhere; }
.overview .cell { min-width: 0; overflow-wrap: anywhere; }

/* Risknivåer: gul = låg, orange = medel, röd = hög */
:root {
  --risk-low: #8a6100; --risk-low-dot: #eab308; --risk-low-bg: #fefbe8; --risk-low-border: #f5e08a;
  --risk-mid: #c2410c; --risk-mid-bg: #fff4ea; --risk-mid-border: #fdc89a;
  --risk-high: #b42318; --risk-high-bg: #fef3f2; --risk-high-border: #fecdca;
}
:root[data-theme="dark"] {
  --risk-low: #facc15; --risk-low-dot: #facc15; --risk-low-bg: rgba(250, 204, 21, .12); --risk-low-border: rgba(250, 204, 21, .34);
  --risk-mid: #fb923c; --risk-mid-bg: rgba(251, 146, 60, .12); --risk-mid-border: rgba(251, 146, 60, .36);
  --risk-high: #f97066; --risk-high-bg: rgba(240, 68, 56, .12); --risk-high-border: rgba(240, 68, 56, .34);
}

/* (i)-förklaringar till frister */
.info-btn { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-left: 2px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--text-3); cursor: pointer; vertical-align: -5px; }
.info-btn .icon { width: 16px; height: 16px; }
.info-btn:hover, .info-btn[aria-expanded="true"] { color: var(--link); background: var(--primary-soft); }
.info-pop { position: fixed; z-index: 95; width: min(360px, calc(100vw - 24px)); background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 14px 16px; font-size: .88rem;
  line-height: 1.55; animation: pop-in .12s ease-out; }
.info-pop strong { display: block; color: var(--text); font-size: .94rem; margin-bottom: 6px; }
.info-pop p { margin: 0 0 8px; }
.info-pop .ip-status { color: var(--text); font-weight: 550; }
.info-pop .ip-case span { font-weight: 650; color: var(--text); }
.info-pop a { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; }
@media (pointer: coarse) { .info-btn { width: 32px; height: 32px; vertical-align: -9px; } }
