/* BlixtDesk – designsystem
   Färg: kall ljusgrå arbetsyta, bläckblå text, indigo för handling, saffransgul för ärendenummer. */
:root {
  --bg: #F3F4F7;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --hover: #EEF0F4;
  --active: #E7E8F0;
  --line: #E4E6EC;
  --line-strong: #D5D8E0;
  --ink: #1B2130;
  --ink-2: #3A4254;
  --muted: #6A7283;
  --faint: #9AA1AF;
  --accent: #5A55F2;
  --accent-ink: #FFFFFF;
  --accent-soft: #EEEDFE;
  --accent-line: #C9C7FB;
  --saffron: #B9820A;
  --saffron-soft: #FDF4DC;
  --green: #1C8C68;
  --green-soft: #E3F5EE;
  --red: #C83E5E;
  --red-soft: #FCE9EE;
  --blue: #2F6FD6;
  --note: #FFF8E1;
  --note-line: #F1DB9B;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 4px 14px rgba(20, 24, 40, .05);
  --shadow-pop: 0 10px 38px rgba(20, 24, 40, .16), 0 2px 6px rgba(20, 24, 40, .08);
  --r-sm: 6px; --r: 9px; --r-lg: 14px;
  --font: "Inter", ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1219; --surface: #171B24; --surface-2: #1C212C; --hover: #232835; --active: #2A3040;
    --line: #262C39; --line-strong: #333A4A; --ink: #E8EAF0; --ink-2: #C5CAD6; --muted: #949BAA; --faint: #6E7687;
    --accent: #7D78FF; --accent-soft: #25244A; --accent-line: #3E3C7A; --saffron: #E6B642; --saffron-soft: #3A2F12;
    --green: #4CC59A; --green-soft: #16342A; --red: #F0708E; --red-soft: #3D1C26; --note: #2E2914; --note-line: #574B1E;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-pop: 0 12px 40px rgba(0,0,0,.5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1219; --surface: #171B24; --surface-2: #1C212C; --hover: #232835; --active: #2A3040;
  --line: #262C39; --line-strong: #333A4A; --ink: #E8EAF0; --ink-2: #C5CAD6; --muted: #949BAA; --faint: #6E7687;
  --accent: #7D78FF; --accent-soft: #25244A; --accent-line: #3E3C7A; --saffron: #E6B642; --saffron-soft: #3A2F12;
  --green: #4CC59A; --green-soft: #16342A; --red: #F0708E; --red-soft: #3D1C26; --note: #2E2914; --note-line: #574B1E;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-pop: 0 12px 40px rgba(0,0,0,.5); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 13.5px/1.5 var(--font); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.i { flex: none; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.hidden { display: none !important; }

/* ─── Skal ─────────────────────────────────────────── */
.shell { display: flex; height: 100vh; height: 100dvh; padding: 8px 8px 8px 0; gap: 0; }
.rail { width: 56px; flex: none; display: flex; flex-direction: column; align-items: center; padding: 6px 0; gap: 4px; }
.rail a, .rail button { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--r); color: var(--muted); border: 0; background: none; cursor: pointer; position: relative; }
.rail a:hover, .rail button:hover { background: var(--hover); color: var(--ink); }
.rail a.on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.rail .sep { width: 22px; height: 1px; background: var(--line-strong); margin: 6px 0; }
.rail .spacer { flex: 1; }
.rail .ws-dot { width: 28px; height: 28px; border-radius: 8px; color: #fff; font-weight: 650; font-size: 12px; display: grid; place-items: center; }
.rail .tip { position: absolute; left: 44px; background: var(--ink); color: var(--surface); font-size: 12px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none; transform: translateX(-4px); transition: .12s; z-index: 50; }
.rail a:hover .tip { opacity: 1; transform: none; }
.frame { flex: 1; min-width: 0; display: flex; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--line); }

.avatar { width: var(--s, 28px); height: var(--s, 28px); border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 650; font-size: calc(var(--s, 28px) * .38); flex: none; letter-spacing: .01em; }
.avatar.sq { border-radius: 8px; }

/* ─── Sidopanel (mappar) ───────────────────────────── */
.side { width: 236px; flex: none; background: var(--surface-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.side-head { height: 54px; padding: 0 10px 0 16px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid transparent; }
.side-head h1 { font-size: 15px; font-weight: 650; margin: 0; flex: 1; letter-spacing: -.01em; }
.side-scroll { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.side-label { font-size: 11.5px; color: var(--faint); font-weight: 550; padding: 14px 8px 4px; display: flex; align-items: center; justify-content: space-between; }
.nav-item { display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 8px; border-radius: var(--r-sm); color: var(--ink-2); font-size: 13.5px; }
.nav-item:hover { background: var(--hover); }
.nav-item.on { background: var(--active); color: var(--ink); font-weight: 560; }
.nav-item .i { color: var(--muted); }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-item.unread .label { font-weight: 620; color: var(--ink); }
.nav-item .dot-err { width: 7px; height: 7px; border-radius: 50%; background: var(--red); margin-left: auto; }
.side-foot { padding: 10px; border-top: 1px solid var(--line); }

/* ─── Knappar och fält ────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 530; font-size: 13px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: var(--red-soft); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12.5px; }
.btn.icon { width: 32px; padding: 0; }
.btn.sm.icon { width: 26px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-split { display: inline-flex; }
.btn-split .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-split .btn:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 1px solid rgba(255,255,255,.25); padding: 0 6px; }

label.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; font-weight: 560; color: var(--ink-2); }
.field small, .help { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s; }
textarea.input { height: auto; min-height: 96px; padding: 9px 11px; resize: vertical; line-height: 1.55; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.sm { height: 30px; font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 720px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.switch { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 20px; background: var(--line-strong); position: relative; flex: none; cursor: pointer; transition: background .15s; margin: 1px 0 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(14px); }
.switch b { display: block; font-weight: 560; }
.switch em { display: block; font-style: normal; color: var(--muted); font-size: 12.5px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11.5px; font-weight: 560; background: var(--hover); color: var(--ink-2); white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.saffron { background: var(--saffron-soft); color: var(--saffron); }
.ticket { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px 0 5px; border-radius: 5px; font-size: 11.5px; font-weight: 620; letter-spacing: .01em; background: var(--saffron-soft); color: var(--saffron); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ticket .i { width: 12px; height: 12px; }
.tagpill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 20px; font-size: 12px; background: var(--hover); color: var(--ink-2); }
.tagpill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--muted)); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; flex: none; }
.dot.ok { background: var(--green); } .dot.err { background: var(--red); } .dot.warn { background: var(--saffron); }

.flash { margin: 0 0 14px; padding: 10px 12px; border-radius: var(--r); font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.flash.success { background: var(--green-soft); color: var(--green); }
.flash.error { background: var(--red-soft); color: var(--red); }
.toast-wrap { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: var(--surface); padding: 9px 14px; border-radius: 10px; box-shadow: var(--shadow-pop); font-size: 13px; animation: toastIn .2s ease-out; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ─── Konversationslista ───────────────────────────── */
.list { width: 340px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.list-head { height: 54px; padding: 0 10px 0 16px; display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.list-head h2 { font-size: 15px; font-weight: 650; margin: 0; flex: 1; letter-spacing: -.01em; }
.list-search { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.list-search .input { height: 32px; background: var(--surface-2); }
.list-scroll { flex: 1; overflow-y: auto; padding: 6px; }
.conv { display: block; padding: 10px 10px 10px 12px; border-radius: var(--r); border: 1px solid transparent; position: relative; margin-bottom: 2px; }
.conv:hover { background: var(--surface-2); }
.conv.on { background: var(--accent-soft); border-color: var(--accent-line); }
.conv .top { display: flex; align-items: center; gap: 7px; }
.conv .who { font-weight: 560; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .who { font-weight: 680; }
.conv.unread::before { content: ""; position: absolute; left: 3px; top: 16px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.conv time { font-size: 11.5px; color: var(--faint); flex: none; font-variant-numeric: tabular-nums; }
.conv .subj { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.conv.unread .subj { color: var(--ink); font-weight: 560; }
.conv .prev { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.conv .meta { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.chan-ico { width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; background: var(--hover); color: var(--muted); flex: none; }
.chan-ico .i { width: 11px; height: 11px; }
.prio-urgent { color: var(--red); } .prio-high { color: var(--saffron); }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty .i { margin: 0 auto 12px; color: var(--faint); }
.empty h3 { color: var(--ink); font-size: 15px; margin: 0 0 4px; font-weight: 620; }

/* ─── Konversation ─────────────────────────────────── */
.thread { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.thread-head { min-height: 54px; padding: 8px 12px 8px 20px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.thread-head h2 { font-size: 15px; font-weight: 650; margin: 0; letter-spacing: -.01em; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thread-head .grow { min-width: 120px; }
.thread-scroll { flex: 1; overflow-y: auto; padding: 18px 24px 24px; background: var(--surface); }
.msg { display: flex; gap: 12px; margin-bottom: 18px; max-width: 880px; }
.msg .body { flex: 1; min-width: 0; }
.msg .head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.msg .head b { font-weight: 620; }
.msg .head .addr { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .head time { margin-left: auto; color: var(--faint); font-size: 12px; white-space: nowrap; }
.bubble { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; background: var(--surface); white-space: pre-wrap; word-wrap: break-word; line-height: 1.6; }
.msg.out .bubble { background: var(--surface-2); }
.msg.note .bubble { background: var(--note); border-color: var(--note-line); }
.msg.system { justify-content: center; }
.msg.system .sys { font-size: 12px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; padding: 3px 12px; }
.bubble iframe { width: 100%; border: 0; min-height: 80px; display: block; background: #fff; border-radius: 6px; }
.bubble.html { padding: 6px; white-space: normal; }
.delivery { font-size: 11.5px; color: var(--muted); margin-top: 4px; display: flex; gap: 5px; align-items: center; }
.delivery.failed { color: var(--red); }
.atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.att { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); font-size: 12.5px; max-width: 260px; }
.att:hover { border-color: var(--line-strong); background: var(--surface-2); }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att small { color: var(--faint); }

.composer { border-top: 1px solid var(--line); padding: 12px 20px 14px; background: var(--surface); }
.composer-box { border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); transition: border-color .12s, box-shadow .12s; }
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer.note-mode .composer-box { background: var(--note); border-color: var(--note-line); }
.composer-tabs { display: flex; gap: 2px; padding: 6px 6px 0; }
.composer-tabs button { border: 0; background: none; padding: 5px 10px; border-radius: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; font-weight: 540; }
.composer-tabs button.on { background: var(--hover); color: var(--ink); }
.composer textarea { width: 100%; border: 0; outline: 0; background: transparent; resize: none; min-height: 84px; max-height: 320px; padding: 8px 12px; line-height: 1.55; }
.composer-bar { display: flex; align-items: center; gap: 4px; padding: 4px 6px 6px 8px; }
.composer-files { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 10px; }

/* ─── Detaljpanel ─────────────────────────────────── */
.details { width: 300px; flex: none; border-left: 1px solid var(--line); background: var(--surface-2); overflow-y: auto; }
.details section { padding: 16px; border-bottom: 1px solid var(--line); }
.details h4 { margin: 0 0 10px; font-size: 12px; color: var(--faint); font-weight: 560; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 8px 10px; font-size: 13px; align-items: center; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.contact-card { display: flex; gap: 12px; align-items: center; }
.contact-card b { display: block; font-size: 14px; }
.hist a { display: block; padding: 7px 8px; border-radius: 6px; margin: 0 -8px; }
.hist a:hover { background: var(--hover); }

/* ─── Sidor (inställningar m.m.) ──────────────────── */
.page { flex: 1; overflow-y: auto; }
.page-inner { max-width: 1040px; margin: 0 auto; padding: 28px 32px 64px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 22px; letter-spacing: -.02em; margin: 0; font-weight: 680; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 64ch; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }
.crumb { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.crumb a:hover { color: var(--ink); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card + .card { margin-top: 16px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 640; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.card-body { padding: 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 9px 12px; font-weight: 540; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-color: var(--accent); }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 560; color: var(--muted); font-size: 12px; padding: 9px 20px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.table td { padding: 11px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 10px; transition: border-color .12s, box-shadow .12s; }
a.tile:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.tile-top { display: flex; gap: 12px; align-items: flex-start; }
.tile-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.tile h3 { margin: 0; font-size: 14.5px; font-weight: 640; }
.tile p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.tile-foot { display: flex; gap: 8px; align-items: center; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }

.type-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.type-opt { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); align-items: flex-start; }
.type-opt:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.type-opt b { display: block; font-weight: 600; }
.type-opt small { color: var(--muted); display: block; line-height: 1.45; margin-top: 2px; }

.code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; overflow-x: auto; white-space: pre; display: block; }
.copyline { display: flex; gap: 6px; align-items: center; }
.copyline .code { flex: 1; padding: 7px 10px; white-space: nowrap; }

.check-list { display: flex; flex-direction: column; }
.check-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.check-row:last-child { border-bottom: 0; }
.check-mark { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.check-mark.ok { background: var(--green-soft); color: var(--green); }
.check-mark.bad { background: var(--red-soft); color: var(--red); }
.check-mark.warn { background: var(--saffron-soft); color: var(--saffron); }
.check-row b { font-weight: 560; }
.check-row small { margin-left: auto; color: var(--muted); text-align: right; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat b { display: block; font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.meter { height: 6px; background: var(--hover); border-radius: 6px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }

/* Popover-meny */
.pop { position: relative; }
.pop-menu { position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-pop); padding: 5px; min-width: 210px; z-index: 60; display: none; max-height: 360px; overflow-y: auto; }
.pop.open .pop-menu { display: block; }
.pop-menu button, .pop-menu a, .pop-menu label { display: flex; width: 100%; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 6px; border: 0; background: none; text-align: left; cursor: pointer; font-size: 13px; }
.pop-menu button:hover, .pop-menu a:hover, .pop-menu label:hover { background: var(--hover); }
.pop-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* Modal */
dialog.modal { border: 0; padding: 0; border-radius: var(--r-lg); box-shadow: var(--shadow-pop); background: var(--surface); color: var(--ink); width: min(560px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(15, 18, 28, .38); backdrop-filter: blur(2px); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 15px; flex: 1; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }

/* ─── Chatbot-designer ────────────────────────────── */
.designer { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
.stage { position: sticky; top: 0; background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 10px, var(--bg) 10px, var(--bg) 20px); border: 1px solid var(--line); border-radius: var(--r-lg); height: 640px; overflow: hidden; }
.stage-bar { height: 34px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 6px; padding: 0 12px; }
.stage-bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.stage-bar span { margin-left: 10px; font-size: 12px; color: var(--faint); background: var(--surface-2); padding: 2px 10px; border-radius: 6px; }
.wprev { position: absolute; bottom: 20px; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.wprev.left { align-items: flex-start; }
.wpanel { width: 340px; height: 500px; background: #fff; color: #1b2130; border-radius: var(--wr, 18px); box-shadow: 0 16px 48px rgba(20,24,40,.22); overflow: hidden; display: flex; flex-direction: column; }
.wpanel.dark { background: #171b24; color: #e8eaf0; }
.whead { padding: 18px 18px 16px; background: var(--wc); color: var(--wt); }
.whead .wrow { display: flex; gap: 10px; align-items: center; }
.whead .wav { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.22); display: grid; place-items: center; font-weight: 700; }
.whead b { display: block; font-size: 15px; }
.whead small { opacity: .85; font-size: 12px; }
.wbody { flex: 1; padding: 14px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; font-size: 13.5px; }
.wmsg { max-width: 82%; padding: 8px 12px; border-radius: 14px; line-height: 1.45; }
.wmsg.bot { background: #f1f2f6; align-self: flex-start; border-bottom-left-radius: 4px; }
.wpanel.dark .wmsg.bot { background: #232835; }
.wmsg.me { background: var(--wc); color: var(--wt); align-self: flex-end; border-bottom-right-radius: 4px; }
.wsugg { display: flex; flex-wrap: wrap; gap: 6px; }
.wsugg span { border: 1px solid var(--wc); color: var(--wc); border-radius: 20px; padding: 4px 10px; font-size: 12px; }
.winput { border-top: 1px solid #eceef3; padding: 10px 12px; display: flex; gap: 8px; align-items: center; color: #9aa1af; font-size: 13px; }
.wpanel.dark .winput { border-color: #262c39; }
.winput .wsend { margin-left: auto; width: 30px; height: 30px; border-radius: 50%; background: var(--wc); color: var(--wt); display: grid; place-items: center; }
.wbrand { text-align: center; font-size: 10.5px; color: #9aa1af; padding: 0 0 8px; }
.wlauncher { height: 52px; padding: 0 18px 0 14px; border-radius: 26px; background: var(--wc); color: var(--wt); display: flex; align-items: center; gap: 8px; font-weight: 600; box-shadow: 0 8px 24px rgba(20,24,40,.22); }
.color-in { display: flex; gap: 8px; align-items: center; }
.color-in input[type=color] { width: 36px; height: 36px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 2px; background: var(--surface); cursor: pointer; }
.swatches { display: flex; gap: 6px; }
.swatches button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; }

/* ─── Auth och installation ───────────────────────── */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.auth-side { background: #14172B; color: #E8E9F5; padding: 44px 52px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.auth-side .brand { display: flex; align-items: center; gap: 10px; font-weight: 680; font-size: 16px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: #fff; }
.auth-side h2 { font-size: 34px; line-height: 1.12; letter-spacing: -.025em; font-weight: 650; margin: auto 0 18px; max-width: 14ch; }
.auth-side p { color: #A6A9C6; max-width: 42ch; margin: 0 0 32px; font-size: 14.5px; }
.auth-side .ticket-demo { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; max-width: 360px; }
.auth-side .tdemo { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); border-radius: 10px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; font-size: 13px; }
.auth-side .tdemo .ticket { background: rgba(230,182,66,.14); color: #E6B642; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 24px; letter-spacing: -.02em; margin: 0 0 6px; font-weight: 680; }
.auth-card > p { color: var(--muted); margin: 0 0 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .btn.primary { height: 40px; font-size: 14px; }
.auth-links { display: flex; justify-content: space-between; font-size: 13px; margin-top: 4px; }
.auth-links a { color: var(--accent); }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-side { display: none; } }

.install { min-height: 100vh; display: flex; justify-content: center; padding: 48px 20px; }
.install-wrap { width: 100%; max-width: 720px; }
.steps { display: flex; gap: 0; margin: 24px 0 20px; counter-reset: s; }
.steps li { list-style: none; flex: 1; display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; color: var(--faint); }
.steps li::before { content: ""; height: 3px; border-radius: 3px; background: var(--line); margin-right: 6px; }
.steps li.done::before, .steps li.on::before { background: var(--accent); }
.steps li.on { color: var(--ink); font-weight: 600; }
.steps li.done { color: var(--muted); }

/* ─── Mobil ───────────────────────────────────────── */
.mob-only { display: none !important; }
.mob-bar { display: none; }
@media (max-width: 1280px) { .details { display: none; } .details.force { display: block; position: fixed; right: 8px; top: 8px; bottom: 8px; z-index: 70; border-radius: var(--r-lg); box-shadow: var(--shadow-pop); } }
@media (max-width: 1060px) { .side { position: fixed; left: 56px; top: 8px; bottom: 8px; z-index: 65; border-radius: var(--r-lg); box-shadow: var(--shadow-pop); transform: translateX(-120%); transition: transform .18s; border: 1px solid var(--line); } .side.open { transform: none; } .designer { grid-template-columns: 1fr; } .stage { position: relative; } }
@media (max-width: 760px) {
  .shell { padding: 0 0 58px; }
  .frame { border-radius: 0; border: 0; }
  .rail { position: fixed; bottom: 0; left: 0; right: 0; height: 58px; width: auto; flex-direction: row; justify-content: space-around; background: var(--surface); border-top: 1px solid var(--line); z-index: 80; padding: 0 6px; }
  .rail .sep, .rail .spacer, .rail .hide-m { display: none; }
  .rail .tip { display: none; }
  .side { left: 0; top: 0; bottom: 58px; border-radius: 0; width: 84vw; }
  .list { width: 100%; border-right: 0; }
  .has-active .list { display: none; }
  .thread { display: none; }
  .has-active .thread { display: flex; }
  .thread-scroll { padding: 14px; }
  .composer { padding: 8px 10px 10px; }
  .page-inner { padding: 18px 16px 48px; }
  .page-head { flex-wrap: wrap; }
  .page-head .actions { margin-left: 0; }
  .mob-only { display: inline-flex !important; }
  .hide-m { display: none !important; }
  .msg .avatar { display: none; }
  .table th, .table td { padding: 9px 12px; }
}
