/* Frontness app — login + shell. Vanilla, ingen byggkedja.
   Designspråk anpassat efter frontness.se: DM Sans, ink + mint/teal,
   varm off-white, pill-knappar, mjuka hairline-kanter. */
:root {
  --font: 'DM Sans', system-ui, -apple-system, "Segoe UI", sans-serif;

  --ink:        #1a1a1a;
  --ink-2:      rgba(26,26,26,.70);
  --muted:      rgba(26,26,26,.46);
  --ink-4:      rgba(26,26,26,.28);

  --bg:         #f7f7f5;
  --card:       #ffffff;
  --surface-2:  #fbfbf9;
  --line:       rgba(0,0,0,.08);
  --line-2:     rgba(0,0,0,.05);

  --accent:     #a6f4c5;   /* ljus mint */
  --brand:      #00bb7f;   /* teal — interaktivt */
  --brand-ink:  #007956;   /* smaragd — text/länkar */
  --dark:       #111111;
  --danger:     #dc2626;

  --radius:     18px;
  --r-md:       12px;
  --r-full:     9999px;

  --shadow:      0 28px 64px -22px rgba(0,0,0,.32);
  --shadow-sm:   0 1px 3px rgba(0,0,0,.06);
  --shadow-card: 0 16px 40px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--dark);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* ── Inloggnings-splash: mint-glöd + korn (som FAQ/AI på frontness.se) ── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(75% 70% at 86% -8%, rgba(0,187,127,.26), transparent 60%),
    radial-gradient(60% 60% at 6% 110%, rgba(166,244,197,.10), transparent 62%);
}
body::after {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.shell {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 92px 18px calc(32px + env(safe-area-inset-bottom));
}

/* ── Kort ── */
.card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px 28px;
  animation: rise .55s cubic-bezier(.16, 1, .3, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }

/* ── Fast toppbar: logotyp vänster, användare höger ── */
.appbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px;
  padding-top: calc(22px + env(safe-area-inset-top));
  pointer-events: none;
}
.appbar > * { pointer-events: auto; }
.appbar-logo { height: 17px; width: auto; display: block; }
.appbar-project { display: flex; align-items: center; }
.appbar-back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  cursor: pointer; transition: background .14s, border-color .14s, transform .12s;
}
.appbar-back:hover { background: var(--bg); border-color: rgba(0,0,0,.16); }
.appbar-back:active { transform: translateY(1px); }
.js-appbar-domain {
  margin-left: 13px; padding-left: 13px;
  border-left: 1px solid var(--line);
  font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; color: var(--ink);
}
.appbar-user { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.appbar-user .js-user-email { color: rgba(255,255,255,.55); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar-user .js-logout { color: rgba(255,255,255,.85); font-weight: 600; }
.appbar-user .js-logout:hover { color: #fff; }

.title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.03em;
  margin: 0 0 6px;
  color: var(--ink);
}
.lead {
  margin: 0 0 22px;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.6;
}
.lead b { color: var(--ink); font-weight: 700; }

/* ── Fält ── */
.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 7px;
}
.field input {
  width: 100%;
  font-size: 16px;
  padding: 13px 15px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input::placeholder { color: var(--ink-4); }
.field input:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0,187,127,.14);
}
.code-input {
  text-align: center;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 14px;
  text-indent: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ── Knapp ── */
.btn {
  position: relative;
  width: 100%;
  border: 0;
  border-radius: var(--r-full);
  padding: 14px 22px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .15s ease, background .18s, box-shadow .2s, color .15s;
}
.btn-primary {
  color: #fff;
  background: var(--ink);
}
.btn-primary:hover { background: #333; transform: translateY(-2px); box-shadow: 0 12px 26px -12px rgba(0,0,0,.55); }
.btn-primary:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: default; pointer-events: none; }
.btn[data-busy] .btn-label { visibility: hidden; }
.btn[data-busy] .spinner { display: block; }

/* ── Steg-fot (länkar) ── */
.step-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}
.link {
  border: 0;
  background: none;
  color: var(--brand-ink);
  font-size: 13.5px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  padding: 4px 2px;
  border-radius: 6px;
  text-underline-offset: 2px;
}
.link:hover { text-decoration: underline; }
.link:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.link-muted { color: var(--muted); }

/* ── Meddelande ── */
.msg {
  margin: 18px 0 0;
  padding: 11px 14px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  line-height: 1.5;
  background: #fdf2f2;
  color: var(--danger);
  border: 1px solid #f4c4c4;
}
.msg[data-tone="ok"] {
  background: rgba(0,187,127,.08);
  color: var(--brand-ink);
  border-color: rgba(0,187,127,.25);
}

/* ── Spinner ── */
.spinner {
  display: none;
  position: absolute;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner-lg {
  position: static;
  display: block;
  width: 26px; height: 26px;
  border-color: rgba(255,255,255,.22);
  border-top-color: var(--accent);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Inloggad vy ── */
.avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  color: #064e3b;
  background: linear-gradient(140deg, #a6f4c5, #34d399);
  margin: 4px 0 16px;
}
.placeholder {
  margin-top: 20px;
  padding: 18px;
  border: 1.5px dashed var(--line);
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: 13.5px;
}
.placeholder p { margin: 0; }

/* ── Boot-overlay tills sessionen är kontrollerad ── */
.boot { position: fixed; inset: 0; z-index: 1; display: grid; place-items: center; }
.boot[hidden] { display: none; }

/* ════════════════════════════════════════════════════════════════════
   APP — topbar, projektlista, dashboard
   ════════════════════════════════════════════════════════════════════ */
.app { max-width: 360px; padding-top: 24px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.screen { animation: fade .3s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.screen-loading, .boot { display: grid; place-items: center; padding: 40px 0; }

.screen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.screen-head .title { margin: 0; }

/* ── Tomt läge ── */
.empty { text-align: center; padding: 8px 0 4px; }
.empty .title { margin-bottom: 6px; }
.empty .lead { margin-bottom: 22px; }
.empty .create-form { text-align: left; }

/* ── Projektlista ── */
.proj-search { margin-bottom: 12px; }
.proj-search-input {
  width: 100%;
  font-size: 15px;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.proj-search-input::placeholder { color: var(--ink-4); }
.proj-search-input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(0,187,127,.14); }

.proj-list {
  display: flex;
  flex-direction: column;
  max-height: 450px;
  overflow-y: auto;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}
.proj-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1.5px solid var(--line);
  border-radius: 0;
  padding: 13px 15px;
  cursor: pointer;
  transition: background .15s;
}
.proj-card:last-of-type { border-bottom: 0; }
.proj-card:hover { background: #fff; }
.proj-card:active { background: var(--line-2); }
.proj-nomatch { padding: 18px 15px; margin: 0; text-align: center; font-size: 13.5px; color: var(--muted); }

.proj-favicon {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 11px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 17px; color: #064e3b;
  background: linear-gradient(140deg, #a6f4c5, #34d399);
}
.proj-favicon.lg { width: 50px; height: 50px; font-size: 21px; border-radius: 14px; }
.proj-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.proj-domain { font-weight: 700; font-size: 15px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-meta { font-size: 12.5px; color: var(--muted); }
.proj-arrow { flex: none; color: var(--ink-4); font-size: 22px; line-height: 1; }

.new-wrap { margin-top: 14px; }

/* ── Knapp-varianter ── */
.btn-sm { width: auto; padding: 9px 16px; font-size: 13.5px; border-radius: var(--r-full); }
.btn-ghost {
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); box-shadow: none;
}
.btn-ghost:hover { background: #fff; border-color: rgba(0,0,0,.16); color: var(--ink); }

/* ── Dashboard ── */
.back { display: inline-block; margin: 0 0 14px -2px; padding: 4px 4px 4px 0; }
.dash-head { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.dash-head .title { margin: 0; overflow-wrap: anywhere; }
.dash-head .small { margin: 3px 0 0; }

.block { margin-bottom: 24px; }
.section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); margin: 0 0 12px;
}

/* ── Medlemmar ── */
.member-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.member {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2);
}
.member-av {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff;
  background: linear-gradient(140deg, #3a3a3a, #1a1a1a);
}
.member-email { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag {
  font-size: 10.5px; font-weight: 700; color: var(--brand-ink);
  background: rgba(0,187,127,.12); padding: 1px 6px; border-radius: 6px; vertical-align: middle;
}
.badge { flex: none; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.badge-owner  { color: #92600a; background: #fdecc8; }
.badge-member { color: var(--ink-2); background: #efefea; }
.link-danger { color: var(--danger); flex: none; }

/* ── Inbjudningsformulär ── */
.invite-form { display: flex; flex-direction: column; gap: 10px; }
.invite-row { display: flex; gap: 8px; }
.invite-row input[type="email"] {
  flex: 1; min-width: 0; font-size: 14.5px; padding: 11px 13px; font-family: var(--font);
  border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.invite-row input[type="email"]:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(0,187,127,.14); }
.invite-row .btn { flex: none; }
.invite-opt { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.invite-opt input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }

/* ── Domänstatus i listan ── */
.warn-dot { color: #b45309; font-weight: 700; }
.ok-dot   { color: var(--brand-ink); font-weight: 700; }

/* ── Verifiering ── */
.verify-lead { margin: 0 0 12px; line-height: 1.6; }
.verify-lead code, .placeholder code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em; background: #efefea; padding: 1px 5px; border-radius: 5px; color: var(--ink); border: 1px solid var(--line-2);
}
.code-box {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--dark); border-radius: var(--r-md); padding: 13px 13px 13px 15px;
}
.code-box code {
  flex: 1; min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; color: #e8e8e3; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
}
.btn-copy {
  flex: none; border: 0; cursor: pointer;
  background: rgba(255,255,255,.12); color: #fff; font-family: var(--font);
  font-size: 12.5px; font-weight: 700; padding: 7px 13px; border-radius: 8px;
  transition: background .15s, color .15s;
}
.btn-copy:hover { background: var(--accent); color: #064e3b; }
.verify-btn { margin-top: 14px; }

.verified-card {
  display: flex; align-items: center; gap: 13px;
  background: rgba(0,187,127,.08); border: 1px solid rgba(0,187,127,.25); border-radius: 13px; padding: 15px 17px;
}
.verified-check {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: #fff; display: grid; place-items: center;
  font-size: 16px; font-weight: 800;
}
.verified-title { font-weight: 700; font-size: 14.5px; color: var(--brand-ink); }

/* ── Moduler (statistik / formulär) ── */
.mod-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.mod-head .section-title { margin: 0; }
.mod-status {
  flex: none; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px;
  display: inline-flex; align-items: center; gap: 5px;
}
.mod-status::before { content: '●'; font-size: 8px; }
.mod-status.on  { color: var(--brand-ink); background: rgba(0,187,127,.1); }
.mod-status.off { color: #b45309; background: #fff7ed; }
.mod-desc { margin: 0 0 12px; line-height: 1.6; color: var(--ink-2); }

/* ════════════════════════════════════════════════════════════════════
   DASHBOARD med vänstermeny
   ════════════════════════════════════════════════════════════════════ */
.app.wide { max-width: 900px; }

.dash { display: grid; grid-template-columns: 190px 1fr; gap: 30px; align-items: start; }

.dash-nav { display: flex; flex-direction: column; gap: 14px; }
.dash-proj { display: flex; align-items: center; gap: 9px; padding: 2px 0 6px; }
.dash-proj-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-proj .proj-favicon { width: 32px; height: 32px; font-size: 14px; border-radius: 9px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  text-align: left; border: 0; background: none; cursor: pointer; font-family: var(--font);
  font-size: 14px; font-weight: 600; color: var(--ink-2);
  padding: 9px 12px; border-radius: 10px; transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(0,0,0,.04); color: var(--ink); }
.nav-item.active { background: rgba(0,187,127,.1); color: var(--brand-ink); font-weight: 700; }
.nav-ico { flex: none; color: var(--ink-4); transition: color .12s; }
.nav-item:hover .nav-ico { color: var(--muted); }
.nav-item.active .nav-ico { color: var(--brand); }

.dash-main { min-width: 0; }
.view-title { font-size: 21px; font-weight: 800; letter-spacing: -.03em; margin: 0 0 18px; }
.view-title .small { font-weight: 500; color: var(--muted); }

/* ── Nyckeltal (kort med hårfina separatorer — samma stil som KPI-kortet) ── */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line);
  border: 1.5px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 22px; }
.stat-cards.stat-cards-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card { background: #fff; min-width: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 20px 16px; }
.stat-num { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1; color: var(--ink); }
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.status-row { font-size: 13px; color: var(--muted); }
.status-row .ok-dot { color: var(--brand); font-size: 9px; vertical-align: middle; margin-right: 4px; }

/* ── Installations-widget (pulserande, klickbar) ── */
/* Sidofotens widget + Växla projekt, fästa i botten */
.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.nav-foot .switch-proj { margin-top: 0; }
.install-widget {
  display: flex; align-items: center; gap: 10px; width: 100%; cursor: pointer; text-align: left;
  font-family: var(--font); font-size: 13px; font-weight: 600; color: var(--ink-2);
  background: var(--surface-2); border: 1.5px solid var(--line); border-radius: var(--r-md);
  padding: 10px 13px; transition: border-color .14s, background .14s, color .14s;
}
.install-widget:hover { border-color: rgba(0,0,0,.16); color: var(--ink); }
.iw-dot { position: relative; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--ink-4); }
.iw-dot::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; background: inherit;
  opacity: .65; animation: iwPulse 1.8s ease-out infinite;
}
.install-widget[data-state="active"] .iw-dot { background: var(--brand); }
.install-widget[data-state="active"] { color: var(--brand-ink); border-color: rgba(0,187,127,.30); background: rgba(0,187,127,.07); }
.install-widget[data-state="inactive"] .iw-dot { background: #e0a800; }
.install-widget[data-state="inactive"] { color: #8a6d00; border-color: rgba(224,168,0,.34); background: rgba(224,168,0,.08); }
.install-widget[data-state="checking"] .iw-dot { background: var(--ink-4); }
@keyframes iwPulse { 0% { transform: scale(1); opacity: .6; } 70% { transform: scale(2.6); opacity: 0; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .iw-dot::after { animation: none; } }

/* ── Statistik: datumväljare, deltas, mini-rad ── */
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.view-head .view-title { margin: 0; }
.view-head-l { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.kicker {
  font-size: 12px; font-weight: 700; letter-spacing: .01em; white-space: nowrap;
  color: var(--brand-ink); background: rgba(0,187,127,.10);
  border-radius: 999px; padding: 4px 11px;
}
.range-bar { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.range-sel { display: inline-flex; gap: 2px; background: rgba(0,0,0,.05); border-radius: 10px; padding: 3px; }
.range-btn { border: 0; background: none; cursor: pointer; font-family: var(--font); font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 6px 11px; border-radius: 8px; transition: color .12s, background .12s; }
.range-btn:hover { color: var(--ink); }
.range-btn.active { background: rgba(0,187,127,.12); color: var(--brand-ink); font-weight: 700; }
.range-cal { display: inline-flex; align-items: center; justify-content: center; padding: 6px 10px; }
.range-cal svg { display: block; }

/* ── Modal (eget datumintervall) ── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(0,0,0,.38); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: modalFade .12s ease;
}
.modal { width: 100%; max-width: 380px; max-height: 90vh; overflow-y: auto; background: #fff; border-radius: 18px; padding: 22px; box-shadow: var(--shadow); animation: modalPop .14s ease; }
.modal.modal-lg { max-width: 620px; }
.modal-title { margin: 0 0 16px; font-size: 17px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal-head .modal-title { margin: 0; }
.modal-sub { margin: 3px 0 0; }
.modal-x { flex: none; width: 32px; height: 32px; border: 0; background: none; cursor: pointer; font-size: 24px; line-height: 1; color: var(--muted); border-radius: 8px; transition: color .12s, background .12s; }
.modal-x:hover { background: var(--line-2); color: var(--ink); }
/* Sidstatistik-modal */
.pm-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin-bottom: 18px; }
.pm-tiles .mini-tile { padding: 2px 18px; border-left: 1.5px solid var(--line); }
.pm-tiles .mini-tile:first-child { border-left: 0; padding-left: 0; }
.pm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pm-grid .panel { background: var(--surface-2); }
@media (max-width: 560px) { .pm-grid { grid-template-columns: 1fr; } }
.modal-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-dates .field { margin: 0; }
.modal-body { color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.modal-lead { margin: 0; }
.modal-lead strong { color: var(--ink); font-weight: 700; }
.modal-msg { margin: 12px 0 0; color: var(--danger); font-size: 13px; }
.modal-msg[data-tone="info"] { color: var(--ink-2); }
.modal textarea, .modal select {
  width: 100%; font-size: 16px; padding: 13px 15px; border: 1.5px solid var(--line);
  border-radius: var(--r-md); background: var(--surface-2); color: var(--ink);
  font-family: var(--font); outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
.modal textarea { resize: vertical; min-height: 92px; line-height: 1.5; }
.modal textarea::placeholder { color: var(--ink-4); }
.modal textarea:focus, .modal select:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(0,187,127,.14); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.delta { font-size: 12px; font-weight: 700; vertical-align: middle; white-space: nowrap; }
.delta.up { color: var(--brand-ink); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--muted); }
.stat-mini { margin: -8px 0 22px; }
.stat-mini .ok-dot { color: var(--brand); font-weight: 700; }

/* ── Små nyckeltal (utan kort-design) ── */
.mini-tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; margin-bottom: 24px; }
.mini-tile { min-width: 0; padding: 2px 20px; border-left: 1.5px solid var(--line); }
.mini-tiles .mini-tile:nth-child(6n+1) { border-left: 0; padding-left: 0; }
.mt-num { font-size: 19px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.mt-num.hot { color: var(--brand); }
.mt-label { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* ── KPI-kort: ett kort, en grid, hårfina separatorer via gap ── */
.kpi-card { padding: 0; margin-bottom: 22px; overflow: hidden; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); grid-auto-rows: 1fr; gap: 1px; background: var(--line); }
.kpi-cell { background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px 16px; }
.kpi-ico { color: var(--brand); margin-bottom: 9px; line-height: 0; }
.kpi-num { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1; color: var(--ink); }
.kpi-unit { font-size: .6em; font-weight: 700; color: inherit; margin-left: 3px; letter-spacing: 0; }
.kpi-label { font-size: 12px; color: var(--muted); margin-top: 6px; }
@media (max-width: 640px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

/* ── Mer statistik (rader) ── */
.stat-rows-card { margin-bottom: 16px; }
.stat-rows-card .panel-title { margin-bottom: 4px; }
.stat-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line-2); }
.stat-row:first-of-type { border-top: 0; }
.stat-row-ico { flex: none; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: var(--surface-2); color: var(--muted); }
.stat-row-label { flex: 1; min-width: 0; font-size: 14px; color: var(--ink); }
.stat-row-val { flex: none; font-size: 18px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-row-unit { font-size: .62em; font-weight: 700; color: var(--muted); margin-left: 3px; }

/* ── Paneler ── */
.panel { background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.panel-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px; }
.panel-empty { margin: 0; color: var(--muted); }
/* Masonry via CSS-kolumner: korten packas vertikalt utan tomt mellanrum. */
.panel-grid { columns: 2; column-gap: 16px; margin-top: 16px; }
.panel-grid > .panel { break-inside: avoid; margin: 0 0 16px; }

/* ── Topplistor (ring + namn + värde, ingen bakgrund) ── */
.lst-row2 { display: flex; align-items: center; gap: 11px; padding: 8px 0; }
.lst-row2 + .lst-row2 { border-top: 1px solid var(--line-2); }
.lst-ring { flex: none; display: block; }
.lst-ring .lr-bg { fill: none; stroke: var(--line); stroke-width: 3; }
.lst-ring .lr-fg { fill: none; stroke: var(--brand); stroke-width: 3; stroke-linecap: round; }
.lst-rank { flex: none; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); font-size: 11.5px; font-weight: 800; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lst-nm { flex: 1; min-width: 0; font-size: 13.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.lst-ct { flex: none; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.lst-pc { color: var(--muted); font-weight: 500; font-size: 11.5px; margin-left: 7px; }
/* ── Synlighet (SEO) ── */
.seo-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.kw-pos {
  flex: none; min-width: 34px; text-align: center; font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--brand-ink);
  background: rgba(0,187,127,.10); border-radius: 6px; padding: 3px 7px;
}

.seo-sub { margin: 0 0 10px; }
/* Konkurrens-ring (svårt att ranka) */
.seo-ring { flex: none; display: inline-flex; line-height: 0; }
.seo-ring .sr-bg { fill: none; stroke: var(--line); stroke-width: 3; }
.seo-ring .sr-fg { fill: none; stroke-width: 3; stroke-linecap: round; }
.seo-ring .sr-txt { font-family: var(--font); font-size: 9px; font-weight: 800; }
.seo-ring-easy .sr-fg { stroke: var(--brand); } .seo-ring-easy .sr-txt { fill: var(--brand-ink); }
.seo-ring-mid  .sr-fg { stroke: #e0a800; }     .seo-ring-mid  .sr-txt { fill: #8a6d00; }
.seo-ring-hard .sr-fg { stroke: var(--danger); } .seo-ring-hard .sr-txt { fill: var(--danger); }
.seo-kw-legend { display: flex; align-items: center; gap: 5px; margin: 10px 0 0; flex-wrap: wrap; }
.seo-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.seo-dot-easy { background: var(--brand); } .seo-dot-mid { background: #e0a800; } .seo-dot-hard { background: var(--danger); }
.seo-watch-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.seo-watch-head .panel-title { margin: 0; }
.dk-tag { flex: none; font-size: 12px; font-weight: 700; }
.dk-tag.dk-added { color: var(--brand-ink); }
/* Drawer */
.drawer-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.38); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: modalFade .12s ease; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(460px, 100%); background: #fff; box-shadow: var(--shadow); display: flex; flex-direction: column; animation: drawerIn .18s ease; }
@keyframes drawerIn { from { transform: translateX(100%); } to { transform: none; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); flex: none; }
.drawer-title { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.dk-results { margin-top: 6px; }

/* ── Varumärke ── */
.brand-status { color: var(--muted); }
.brand-status.is-error { color: var(--danger); }
.brandview .panel { margin-bottom: 16px; }
.brandview .fields { display: grid; grid-template-columns: 1fr; gap: 18px; }
.brandview .fields--even { grid-template-columns: 1fr 1fr; }
.brandview .field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.brandview .field--full { grid-column: 1 / -1; }
.brandview .field__label { font-size: 13px; font-weight: 700; color: var(--ink); }
.brandview .field__hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
.brandview input[type=text], .brandview input[type=url], .brandview select, .brandview textarea {
  width: 100%; font-family: var(--font); font-size: 14px; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #fff; }
.brandview textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
.brandview input:focus, .brandview select:focus, .brandview textarea:focus { outline: none; border-color: var(--brand); }
.brandview .palette { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.brandview .palette__row { display: flex; align-items: center; gap: 8px; }
/* .brandview prefix krävs för att slå Frontness globala `.field input { width:100% }`. */
.brandview .palette__hex { width: 44px; height: 38px; flex: none; min-width: 0; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; padding: 3px; cursor: pointer; }
.brandview .palette__hex::-webkit-color-swatch-wrapper { padding: 0; }
.brandview .palette__hex::-webkit-color-swatch { border: none; border-radius: 5px; }
.brandview .palette__hex::-moz-color-swatch { border: none; border-radius: 5px; }
.brandview .palette__name { flex: 1 1 auto; min-width: 0; }
.brandview .palette__del { flex: none; width: 38px; height: 38px; padding: 0; border: 1.5px solid var(--line); background: #fff; border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
.brandview .palette__del:hover { color: var(--danger); border-color: rgba(220,38,38,.4); }
.brandview .field > .btn { align-self: flex-start; }
.brandview .brand-fetch-row { display: flex; gap: 8px; align-items: stretch; }
.brandview .brand-fetch-row input { flex: 1 1 auto; min-width: 0; }
.brandview .brand-fetch-row .btn { flex: none; white-space: nowrap; }
.logo-up { display: flex; align-items: center; gap: 14px; border: 1.5px solid var(--line); border-radius: 11px; padding: 10px; }
.logo-up__preview { flex: none; width: 72px; height: 72px; border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.logo-up--light .logo-up__preview { background: #fff; border: 1px solid var(--line); }
.logo-up--dark .logo-up__preview { background: #0f1620; }
.logo-up__preview img { max-width: 88%; max-height: 88%; object-fit: contain; }
.logo-up__ctrl { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.font-pick { position: relative; }
.font-pick__list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; background: #fff; border: 1.5px solid var(--line); border-radius: 11px; box-shadow: var(--shadow-card); max-height: 280px; overflow-y: auto; padding: 5px; }
.font-pick__opt { display: block; width: 100%; text-align: left; padding: 9px 11px; border: none; background: none; cursor: pointer; border-radius: 7px; font-size: 16px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-pick__opt:hover { background: var(--surface-2); }
.font-weight { margin-top: 8px; }
.font-weight:disabled { opacity: .5; }
.font-preview { border: 1.5px solid var(--line); border-radius: 11px; padding: 22px 20px; background: #fff; }
.font-preview__head { font-size: 27px; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; margin-bottom: 10px; color: var(--ink); }
.font-preview__body { font-size: 15px; line-height: 1.6; color: var(--ink); margin: 0; }
@media (max-width: 760px) { .brandview .fields--even { grid-template-columns: 1fr; } }

/* ── Recensioner ── */
.rv-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.rv-agg { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 240px; }
.rv-agg-empty { flex: 1; min-width: 240px; }
.rv-agg-empty p { margin: 0; }
.rv-aggnum { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1; color: var(--ink); }
.rv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .rv-grid { grid-template-columns: 1fr; } }
.rv-stars { position: relative; display: inline-block; font-size: 18px; line-height: 1; letter-spacing: 2px; white-space: nowrap; }
.rv-stars .rv-bg { color: #d9d9de; }
.rv-stars .rv-fg { position: absolute; left: 0; top: 0; overflow: hidden; color: var(--brand); white-space: nowrap; }
.rv-preview .rv-stars .rv-fg { color: #FFD700; }
.rv-srcrow { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.rv-srcrow:last-of-type { border-bottom: 0; }
.rv-srctop { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink); }
.rv-srcvalwrap { display: inline-flex; align-items: center; gap: 8px; justify-self: end; }
.rv-srcval { font-weight: 800; color: var(--ink); }
.rv-srcextra { grid-column: 1 / -1; }
.rv-warn { font-size: 12px; color: #8a6d00; }
.rv-input { width: 100%; font-family: var(--font); font-size: 13.5px; color: var(--ink); background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 11px; }
.rv-input:focus { outline: none; border-color: var(--brand); }
.rv-input:disabled { background: var(--line-2); color: var(--ink-2); cursor: not-allowed; }
select.rv-input { cursor: pointer; }
.rv-hint { margin: 12px 0 0; }
.rv-wrow { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.rv-wlabel { font-size: 12.5px; font-weight: 600; color: var(--muted); min-width: 48px; }
.rv-wrow .rv-input { width: auto; flex: 1; }
.rv-wrow > .rv-wlabel:first-child { min-width: 104px; }
.rv-snip-label { display: block; margin: 14px 0 6px; }
.rv-preview { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; padding: 18px; border-radius: 12px; margin-top: 6px; background: var(--surface-2); border: 1px dashed var(--line); }
.rv-preview.rv-theme-dark { background: #16161a; border-color: rgba(255,255,255,.12); }
.rv-badges { display: flex; flex-wrap: wrap; gap: 10px; }
.rv-meta { display: inline-flex; align-items: center; gap: 8px; padding: 0 2px; }
.rv-srcicons { display: inline-flex; align-items: center; gap: 6px; }
.rv-srcicon { display: inline-flex; width: 16px; height: 16px; flex: 0 0 16px; }
.rv-srcicon svg { width: 16px; height: 16px; display: block; }
.rv-total { font-size: 12px; font-weight: 600; color: #666; }
.rv-theme-dark .rv-total { color: rgba(255,255,255,.6); }
/* Ny widget: stjärnor+betyg på rad, antal under, klickbar käll-lista */
.rv-w { position: relative; display: inline-block; }
.rv-wmain { display: inline-flex; flex-direction: column; gap: 3px; align-items: flex-start; border: 1px solid rgba(0,0,0,.10); border-radius: 12px; padding: 9px 13px; background: #fff; cursor: pointer; line-height: 1.2; font: inherit; text-align: left; color: inherit; }
.rv-wmain:hover { border-color: rgba(0,0,0,.18); }
.rv-theme-dark .rv-wmain { background: #1f1f25; border-color: rgba(255,255,255,.12); }
.rv-wtop { display: inline-flex; align-items: center; gap: 8px; }
.rv-wsub { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: #666; }
.rv-wsubicons { display: inline-flex; align-items: center; gap: 4px; }
.rv-theme-dark .rv-wsub { color: rgba(255,255,255,.6); }
.rv-wpop { position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%); background: #fff; border: 1px solid rgba(0,0,0,.12); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.16); padding: 6px; display: none; z-index: 50; white-space: nowrap; }
.rv-w.is-open .rv-wpop { display: block; }
.rv-wpop::after { content: ""; position: absolute; top: 100%; left: 50%; width: 11px; height: 11px; margin: -6px 0 0 -5.5px; background: #fff; border-right: 1px solid rgba(0,0,0,.12); border-bottom: 1px solid rgba(0,0,0,.12); transform: rotate(45deg); }
.rv-theme-dark .rv-wpop { background: #16161a; border-color: rgba(255,255,255,.14); }
.rv-theme-dark .rv-wpop::after { background: #16161a; border-color: rgba(255,255,255,.14); }
.rv-srcrow { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: inherit; }
.rv-srcrow:hover { background: #f4f4f6; }
.rv-theme-dark .rv-srcrow:hover { background: #222; }
.rv-srcname { font-size: 13px; font-weight: 600; color: var(--ink); margin-right: auto; }
.rv-srcval { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; font-weight: 700; color: var(--ink); }
.rv-rs { color: #FFD700; }
.rv-theme-dark .rv-srcname, .rv-theme-dark .rv-srcval { color: #fff; }
.rv-srccnt { font-size: 12px; color: #888; }
/* Recensioner-widget (betyg-kort) */
.rl-list { display: flex; flex-wrap: wrap; gap: 12px; width: 100%; }
.rl-card { flex: 1 1 220px; max-width: 320px; box-sizing: border-box; border: 1px solid rgba(0,0,0,.1); border-radius: 14px; padding: 14px 15px; background: #fff; display: flex; flex-direction: column; gap: 8px; }
.rv-theme-dark .rl-card { background: #1f1f25; border-color: rgba(255,255,255,.12); }
.rl-head { display: flex; align-items: center; gap: 8px; }
.rl-author { font-size: 13px; font-weight: 700; color: var(--ink); margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-theme-dark .rl-author { color: #fff; }
.rl-text { font-size: 13px; line-height: 1.55; color: #333; margin: 0; }
.rv-theme-dark .rl-text { color: rgba(255,255,255,.78); }
.rl-date { font-size: 11px; color: #999; }
.rv-badge { display: inline-flex; align-items: center; gap: 9px; border: 1px solid rgba(0,0,0,.10); border-radius: 12px; padding: 9px 13px; background: #fff; }
.rv-theme-dark .rv-badge { background: #1f1f25; border-color: rgba(255,255,255,.12); }
.rv-bsrc { font-size: 12px; font-weight: 700; color: #555; }
.rv-theme-dark .rv-bsrc { color: #aaa; }
.rv-bval { font-size: 15px; font-weight: 800; color: var(--ink); }
.rv-theme-dark .rv-bval, .rv-theme-dark .muted { color: rgba(255,255,255,.7); }
/* Google: sök + kandidater + kopplad */
.rv-search { display: flex; gap: 8px; align-items: center; }
.rv-search .rv-gq { flex: 1; }
.rv-gresults { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.rv-cand { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 6px 12px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; }
.rv-cand-main { min-width: 0; }
.rv-cand-title { font-weight: 700; font-size: 14px; color: var(--ink); }
.rv-cand-rt { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.rv-match { grid-column: 1 / -1; font-size: 11.5px; font-weight: 700; }
.rv-match.ok { color: var(--brand-ink); }
.rv-match.warn { color: #8a6d00; }
.rv-connected { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rv-connstatus { display: inline-flex; align-items: center; gap: 8px; margin-top: 5px; }
/* Recensionslista */
.rv-revlist { display: flex; flex-direction: column; }
.rv-rev { padding: 12px 0; border-top: 1px solid var(--line-2); }
.rv-rev:first-child { border-top: 0; }
.rv-rev-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.rv-rev-author { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.rv-rev-meta { }
.rv-rev-text { margin: 7px 0 0; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }
.rv-rev-reply { margin: 8px 0 0 14px; padding-left: 11px; border-left: 2px solid var(--line); }
.rv-rev-reply p { margin: 2px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink-2); }
/* Tabbar + kanalstatus */
.rv-agg, .rv-agg-empty { margin-bottom: 16px; }
.rv-tabcount { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 5px; border-radius: 999px; background: rgba(0,0,0,.07); font-size: 11px; font-weight: 700; vertical-align: middle; }
.subtab.active .rv-tabcount { background: rgba(0,187,127,.16); color: var(--brand-ink); }
.rv-srcmeta { grid-column: 1 / -1; }
#rvTabBody > .panel { margin-bottom: 14px; }
.rv-chan { display: block; margin-top: 4px; }
.rv-boost { display: block; margin-top: 4px; }
.rv-srclink { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--brand-ink); text-decoration: none; }
.rv-srclink:hover { text-decoration: underline; }
.rv-actions { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.rv-revsub { margin: 0 0 12px; }

/* ── Mediabibliotek ── */
.media-drop { border: 1.5px dashed var(--line); border-radius: 14px; padding: 22px; text-align: center; margin-bottom: 18px; transition: border-color .14s, background .14s; }
.media-drop.drag { border-color: var(--brand); background: rgba(0,187,127,.05); }
.media-drop.uploading { opacity: .75; }
.media-drop-txt { margin: 0; color: var(--ink-2); font-size: 14px; }
.media-drop .link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand-ink); font-weight: 700; cursor: pointer; text-decoration: underline; }
.media-msg { margin: 12px 0 0; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.media-tile { border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.media-thumb { display: block; aspect-ratio: 4 / 3; background: var(--surface-2); overflow: hidden; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-meta { padding: 9px 11px 4px; min-width: 0; }
.media-name { display: block; font-size: 13px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-row { display: flex; align-items: center; gap: 6px; padding: 6px 9px 9px; margin-top: auto; }
.media-copy {
  flex: 1; min-width: 0; cursor: pointer; font-family: var(--font); font-size: 12.5px; font-weight: 700;
  color: var(--brand-ink); background: rgba(0,187,127,.10); border: 1.5px solid rgba(0,187,127,.30);
  border-radius: 8px; padding: 7px 10px; transition: background .12s, border-color .12s;
}
.media-copy:hover { background: rgba(0,187,127,.18); border-color: var(--brand); }
.media-copy.ok { background: var(--brand); border-color: var(--brand); color: #fff; }
.media-icon { flex: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid var(--line); background: #fff; color: var(--muted); border-radius: 8px; cursor: pointer; transition: color .12s, background .12s, border-color .12s; }
.media-icon:hover { color: var(--ink); border-color: rgba(0,0,0,.16); }
.media-del:hover { color: var(--danger); border-color: rgba(220,38,38,.3); background: rgba(220,38,38,.08); }
.media-tile { cursor: grab; }
.media-tile:active { cursor: grabbing; }
.media-ghost { opacity: .35; }
.media-ghost * { visibility: hidden; }
/* Medan Sortable drar: stäng av kortens egna transitions (de hackar annars mot
   Sortables transform-animation) och lyft till eget lager för mjuk rörelse. */
.media-grid.sorting .media-tile, .media-grid.sorting .media-tile * { transition: none !important; }
.media-grid.sorting .media-tile { will-change: transform; }
.media-fallback { opacity: .95; box-shadow: var(--shadow-card); transform: rotate(2deg); cursor: grabbing; }
/* Mappar + brödsmulor */
.media-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.media-bar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.media-crumbs { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.media-crumb { border: 0; background: none; padding: 4px 8px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 700; color: var(--brand-ink); }
.media-crumb:hover { background: rgba(0,187,127,.08); }
.media-crumb.drop-hover { background: rgba(0,187,127,.18); outline: 2px dashed var(--brand); }
.media-crumb-cur { font-weight: 700; color: var(--ink); }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.folder-tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface-2); cursor: pointer; transition: border-color .12s, background .12s; }
.folder-tile:hover { border-color: rgba(0,0,0,.16); }
.folder-tile.drop-hover { border-color: var(--brand); background: rgba(0,187,127,.08); outline: 2px dashed var(--brand); outline-offset: -2px; }
.folder-ico { color: var(--brand); }
.folder-name { font-size: 14px; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.folder-del { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; opacity: 0; }
.folder-tile:hover .folder-del { opacity: 1; }
.modal-warn { margin: 0 0 14px; padding: 9px 12px; border-radius: 9px; font-size: 13px; line-height: 1.5; color: #8a6d00; background: rgba(224,168,0,.12); border: 1px solid rgba(224,168,0,.30); }

/* Klickbar sida-rad (öppnar sidstatistik) */
.lst-click { width: 100%; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; border-radius: 8px; transition: background .12s; }
.lst-click:hover { background: rgba(0,187,127,.06); }
.lst-click:hover .lst-nm { color: var(--brand-ink); }

/* ── Heatmap (besök per dag × tid på dygnet) ── */
.hm-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.hm-top .panel-title { margin: 0; }
.hm-legend { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); }
.hm-grad { width: 56px; height: 8px; border-radius: 5px; background: linear-gradient(90deg, rgba(0,187,127,.12), var(--brand)); }
.hm-grid { display: grid; grid-template-columns: 56px repeat(5, 1fr); gap: 5px; align-items: center; }
.hm-corner { height: 1px; }
.hm-hr { font-size: 10.5px; color: var(--muted); text-align: center; line-height: 1.2; }
.hm-day { font-size: 12px; color: var(--muted); white-space: nowrap; }
.hm-day b { color: var(--ink); font-weight: 700; margin-right: 4px; }
.hm-c {
  aspect-ratio: 1 / 1; min-height: 30px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--line-2); color: transparent;
}
.hm-c.on {
  background: rgba(0,187,127,calc(.12 + var(--lvl, 0) * .82));
  color: #fff;
}
.hm-c.on.lo { color: var(--brand-ink); }

/* ── Visualiserings-rad (linjediagram jämte heatmap) ── */
.viz-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; align-items: stretch; }
.viz-grid .panel { margin: 0; }

/* ── Linjediagram ── */
.lc-panel { display: flex; flex-direction: column; }
.lc-top { margin-bottom: 6px; flex: none; }
.lc-sel { position: relative; display: inline-block; }
.lc-sel::after {
  content: ''; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-65%) rotate(45deg); pointer-events: none;
}
.lc-metric {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  font-family: var(--font); font-size: 12.5px; font-weight: 700; letter-spacing: .02em;
  color: var(--ink); background: var(--surface-2);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 32px 8px 13px;
}
.lc-metric:focus { outline: none; border-color: var(--brand); }
.lc-plot { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.lc-canvas { position: relative; flex: 1; min-height: 200px; }
.lc-svgbox { position: absolute; inset: 0; }
.lc-svg { display: block; width: 100%; height: 100%; }
.lc-empty { position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%); text-align: center; }
.lc-line { fill: none; stroke: var(--brand); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.lc-g0 { stop-color: var(--brand); stop-opacity: .28; }
.lc-g1 { stop-color: var(--brand); stop-opacity: 0; }
.lc-xaxis { flex: none; display: flex; justify-content: space-between; margin-top: 8px; }
.lc-xaxis span { font-size: 11px; color: var(--muted); }

.lc-cross, .lc-dot, .lc-tip { position: absolute; opacity: 0; pointer-events: none; transition: opacity .1s; }
.lc-canvas.lc-on .lc-cross, .lc-canvas.lc-on .lc-dot, .lc-canvas.lc-on .lc-tip { opacity: 1; }
.lc-cross { top: 6%; bottom: 6%; width: 1.5px; background: rgba(0,187,127,.45); transform: translateX(-50%); }
.lc-dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--brand); transform: translate(-50%, -50%); box-shadow: var(--shadow-sm); }
.lc-tip {
  transform: translate(-50%, calc(-100% - 14px)); white-space: nowrap;
  background: var(--ink); color: #fff; border-radius: 9px; padding: 7px 11px; box-shadow: var(--shadow-card);
}
.lc-tip b { display: block; font-size: 16px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.lc-tip span { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,.62); margin-top: 2px; }

@media (max-width: 1000px) {
  .viz-grid { grid-template-columns: 1fr; }
  .mini-tiles { grid-template-columns: repeat(3, 1fr); row-gap: 18px; }
  .mini-tiles .mini-tile:nth-child(3n+1) { border-left: 0; padding-left: 0; }
}

@media (max-width: 640px) {
  .stat-cards, .stat-cards.stat-cards-3 { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: 18px 12px; }
  .mini-tiles { grid-template-columns: repeat(2, 1fr); row-gap: 20px; }
  .mini-tile { padding: 2px 18px; }
  /* nth-child(even): återställ vänsterkant som läcker från bredare brytpunkters resets */
  .mini-tiles .mini-tile:nth-child(even) { border-left: 1.5px solid var(--line); }
  .mini-tiles .mini-tile:nth-child(odd) { border-left: 0; padding-left: 0; }
  .panel-grid { columns: 1; }
  .viz-grid { grid-template-columns: 1fr; }
  .hm-grid { grid-template-columns: 38px repeat(5, 1fr); gap: 3px; }
  .hm-c { min-height: 22px; font-size: 10px; border-radius: 5px; }
  .hm-hr { font-size: 8.5px; }
  .hm-day { font-size: 10.5px; }
  .hm-day b { margin-right: 2px; }
}

/* ── Trend (rad) ── */
.tr-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.tr-day { flex: none; width: 44px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tr-bar { flex: 1; height: 9px; background: rgba(0,0,0,.05); border-radius: 5px; overflow: hidden; }
.tr-bar i { display: block; height: 100%; background: linear-gradient(90deg, #34d399, var(--brand)); border-radius: 5px; }
.tr-val { flex: none; width: 26px; text-align: right; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Listor (toppsidor, regioner …) ── */
.lst-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.lst-row:last-child { border-bottom: 0; }
.lst-name { color: var(--ink); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lst-count { flex: none; color: var(--muted); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sub-val { flex: none; max-width: 60%; color: var(--ink); font-size: 13.5px; font-weight: 700; text-align: right; overflow-wrap: anywhere; }

/* ── Formulärsvar ── */
.sub-card { border: 1.5px solid var(--line); border-radius: 13px; padding: 14px 16px; margin-bottom: 12px; background: var(--surface-2); }
.sub-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.sub-head-r { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.sub-del {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px;
  background: none; color: var(--muted); cursor: pointer; transition: color .12s, background .12s;
}
.sub-del:hover { color: var(--danger); background: rgba(220,38,38,.10); }
.sub-meta { margin: 0 0 8px; color: var(--muted); }
.sub-name { font-weight: 700; font-size: 15px; }
.sub-msg { margin-top: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; }

/* ── Subtabbar (Formulär: Inskickade / Notiser / Integration) ── */
.subtabs { display: flex; gap: 2px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.subtab {
  border: 0; background: none; cursor: pointer; font-family: var(--font);
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  padding: 9px 13px; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .12s, border-color .12s;
}
.subtab:hover { color: var(--ink); }
.subtab.active { color: var(--brand-ink); border-bottom-color: var(--brand); font-weight: 700; }

/* ── Notiser ── */
.notify-row {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2); margin-bottom: 8px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.notify-row:hover { border-color: rgba(0,0,0,.14); background: #fff; }
.notify-row input { width: 17px; height: 17px; accent-color: var(--brand); flex: none; cursor: pointer; }
.notify-row .member-email { flex: 1; }

/* ── Integration: exempelformulär + kod ── */
.doc-form { display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.doc-form input, .doc-form textarea {
  width: 100%; font-size: 14.5px; padding: 11px 13px; font-family: var(--font);
  border: 1.5px solid var(--line); border-radius: var(--r-md); background: #fff; color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.doc-form input:focus, .doc-form textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,187,127,.12); }
.doc-form textarea { resize: vertical; }
.doc-form .btn { width: auto; align-self: flex-start; }

.doc-code { position: relative; background: var(--dark); border-radius: var(--r-md); padding: 42px 16px 14px; }
.doc-code pre {
  margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; line-height: 1.65; color: #e8e8e3;
  white-space: pre; overflow-x: auto;
}
.doc-code .btn-copy { position: absolute; top: 10px; right: 12px; }

/* ── Inställningar / farlig zon ── */
.btn-danger { color: #fff; background: var(--danger); box-shadow: 0 10px 22px -10px rgba(220,38,38,.5); }
.btn-danger:hover { background: #c81e1e; transform: translateY(-2px); }
.danger-zone { border: 1.5px solid #f4c4c4; border-radius: 14px; padding: 16px 18px; background: #fdf6f6; }
.danger-zone .section-title { color: #b91c1c; }
.danger-zone .muted { margin: 0 0 12px; }
.del-confirm { margin-top: 12px; }
.del-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ── Dashboard-läge: full sida, ljus arbetsyta ── */
body.dash-mode { background: var(--bg); }
body.dash-mode::before, body.dash-mode::after { display: none; }
body.dash-mode .appbar {
  background: rgba(255,255,255,.85);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--line);
  padding: 13px 24px;
  padding-top: calc(13px + env(safe-area-inset-top));
}
body.dash-mode .appbar-logo { filter: brightness(0); }       /* vit logga → mörk på ljus bar */
body.dash-mode .appbar-user .js-user-email { color: var(--muted); }
body.dash-mode .appbar-user .js-logout { color: var(--brand-ink); }
body.dash-mode .shell { display: block; padding: 0; padding-top: 44px; }
body.dash-mode #app.card {
  max-width: none; width: 100%;
  background: transparent; box-shadow: none; border-radius: 0;
  padding: 0; animation: none;
}
body.dash-mode .dash {
  grid-template-columns: 224px minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 44px);
  align-items: start;
}
body.dash-mode .dash-nav {
  position: sticky;
  top: 44px;
  height: calc(100vh - 44px);
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  gap: 16px;
}
body.dash-mode .dash-main { padding: 32px 36px; }
body.dash-mode .dash-main > * { max-width: 880px; }

/* Sticky "Växla projekt" nere i vänstra hörnet */
.switch-proj {
  margin-top: auto;
  display: flex; align-items: center; gap: 8px;
  width: 100%; border: 1px solid var(--line); background: #fff;
  border-radius: var(--r-md); padding: 10px 12px; cursor: pointer; font-family: var(--font);
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  transition: background .12s, border-color .12s;
}
.switch-proj:hover { background: var(--bg); border-color: rgba(0,0,0,.16); }
.switch-proj svg { flex: none; color: var(--muted); }

/* ── API-flik: dokumentation + nycklar ── */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.sub-val.mono { font-weight: 600; }
.api-lead { line-height: 1.65; margin: 0 0 18px; }

/* Nyckellista */
.api-keys-lead { margin: 0 0 14px; line-height: 1.55; }
.api-keys-empty { padding: 4px 0 12px; }
.api-keyrow {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-2); margin-bottom: 8px;
}
.api-keyico {
  flex: none; width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; color: var(--brand-ink); background: rgba(0,187,127,.12);
}
.api-keymeta { flex: 1; min-width: 0; }
.api-keyname { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.api-keyname .mono { font-weight: 500; font-size: 12px; }
.apikey-form { margin-top: 12px; }
.apikey-form .invite-row input[type="text"] {
  flex: 1; min-width: 0; font-size: 14.5px; padding: 11px 13px; font-family: var(--font);
  border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.apikey-form .invite-row input[type="text"]:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(0,187,127,.14); }

/* Nyss skapad nyckel (visas en gång) */
.apikey-new { margin: 4px 0 14px; padding: 14px; border: 1px solid rgba(0,187,127,.4); border-radius: var(--r-md); background: rgba(0,187,127,.06); }
.apikey-new-head { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.5; color: var(--ink); margin-bottom: 10px; }
.apikey-new-head svg { flex: none; margin-top: 1px; color: var(--brand-ink); }

/* Endpoints */
.api-docs-title { margin-top: 28px; }
.api-ep { margin-bottom: 26px; }
.api-ep-head { display: flex; align-items: center; gap: 9px; margin: 0 0 6px; }
.api-method {
  flex: none; font-size: 10.5px; font-weight: 800; letter-spacing: .05em;
  padding: 3px 8px; border-radius: 6px; background: #1c2536; color: #cfe2ff;
}
.api-method.get { background: rgba(0,187,127,.14); color: var(--brand-ink); }
.api-path { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; font-weight: 600; color: var(--ink); }
.api-desc { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 12px; }
.api-desc .mono { color: var(--ink); }
.api-params { margin: 0 0 12px; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: #fff; }
.api-param { display: flex; gap: 14px; padding: 8px 12px; font-size: 13px; line-height: 1.45; }
.api-param + .api-param { border-top: 1px solid var(--line-2); }
.api-param .mono { flex: none; min-width: 96px; color: var(--ink); font-weight: 600; }
.api-param span:last-child { color: var(--muted); }
.api-resp-lbl { margin: 10px 0 6px; font-weight: 600; }
.api-ep .doc-code { margin-bottom: 0; }

@media (max-width: 640px) {
  .dash { grid-template-columns: 1fr; gap: 16px; }
  .dash-nav { gap: 10px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav-item { white-space: nowrap; }
  body.dash-mode .dash { grid-template-columns: 1fr; min-height: 0; }
  body.dash-mode .dash-nav { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 14px; }
  body.dash-mode .dash-main { padding: 20px 16px; }
  .switch-proj { margin-top: 4px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .screen { animation: none; }
  .btn-primary:hover, .btn-danger:hover, .proj-card:hover { transform: none; }
  .spinner { animation-duration: 1.4s; }
}
