/* Fiora klientgränssnitt – klickbar prototyp.
   Lugnare kontorsvariant av fiora.app-tokens. */

:root {
  --canvas: #E8E3E6;
  --paper: #FBF9FA;
  --white: #FFFFFF;
  --ink: #1A1419;
  --ink-2: #5E5560;
  --line: rgba(26, 20, 25, .13);
  --line-2: rgba(26, 20, 25, .07);
  --magenta: #B3309A;
  --soft: #F6D9EE;
  --marker: #F6E05E;
  --ok: #23824E;
  --ok-soft: #E3F1E8;

  --f-display: "Funnel Display", "Funnel Sans", system-ui, sans-serif;
  --f-ui: "Funnel Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "DM Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --shadow: 0 1px 0 rgba(26,20,25,.04), 0 8px 24px -12px rgba(26,20,25,.18);

  --rail-w: 220px;
  --top-h: 64px;
  --bottom-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--f-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* Mycket diskret prickraster, bara i kanterna – aldrig bakom arbetet. */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(26,20,25,.10) 1px, transparent 1.2px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(90deg, #000 0, transparent 60px, transparent calc(100% - 60px), #000 100%);
          mask-image: linear-gradient(90deg, #000 0, transparent 60px, transparent calc(100% - 60px), #000 100%);
  z-index: 0;
}

h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 600; letter-spacing: -.015em; margin: 0; line-height: 1.15; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { display: block; }

:focus { outline: none; }
:focus-visible { outline: 3px solid var(--magenta); outline-offset: 2px; border-radius: 8px; }

.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 999px; }
.skip:focus { left: 8px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Layout ---------- */
.app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  grid-template-rows: var(--top-h) 1fr;
  grid-template-areas: "top top" "rail view";
  height: 100vh; height: 100dvh;
}
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--canvas) 85%, transparent);
  backdrop-filter: blur(8px);
}
.rail { grid-area: rail; padding: 20px 14px; border-right: 1px solid var(--line); }
.view { grid-area: view; overflow: auto; min-width: 0; }
.view:focus, .view:focus-visible { outline: none; }
.bottombar { display: none; }

/* Wordmark pill */
.wordmark {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 14px 4px 4px;
  border-radius: 999px;
  background: var(--white);
  border: 1px solid var(--line);
  text-decoration: none;
  font-family: var(--f-display); font-weight: 700; font-size: 19px; letter-spacing: -.02em;
}
.wordmark img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }

/* Tenant switcher */
.tenant { position: relative; }
.tenant-btn {
  display: inline-flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 14px 0 12px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper);
  max-width: 320px;
}
.tenant-btn:hover { background: var(--white); }
.tenant-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.tenant-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.tenant-list {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 40;
  list-style: none; margin: 0; padding: 6px;
  min-width: 300px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow);
}
.tenant-list li button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border: 0; border-radius: var(--r-sm); background: none; text-align: left;
}
.tenant-list li button:hover, .tenant-list li button[aria-selected="true"] { background: var(--paper); }
.tenant-list small { display: block; color: var(--ink-2); font-size: 12.5px; }
.tenant-list .check { margin-left: auto; color: var(--magenta); }

.proto-badge {
  margin-left: auto;
  font-family: var(--f-mono); font-size: 11.5px; letter-spacing: .02em;
  padding: 6px 10px; border-radius: 999px;
  background: var(--paper); border: 1px dashed var(--line); color: var(--ink-2);
  white-space: nowrap;
}

/* Nav */
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  text-decoration: none; color: var(--ink-2); font-weight: 500;
}
.nav-link svg { flex: none; }
.nav-link:hover { background: color-mix(in srgb, var(--paper) 70%, transparent); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--white); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.nav-link[aria-current="page"] svg { color: var(--magenta); }
.nav-count {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-grid; place-items: center;
  font-family: var(--f-mono); font-size: 11px; border-radius: 999px;
  background: var(--soft); color: var(--ink);
}

/* ---------- Page ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 40px 40px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 32px; flex-wrap: wrap; }
.page-head h1 { font-size: 34px; }
.page-head p { color: var(--ink-2); margin-top: 6px; }
.eyebrow { font-family: var(--f-mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }

.section { margin-top: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { font-size: 19px; }
.section-head .muted { font-size: 13.5px; }
.muted { color: var(--ink-2); }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.card-pad { padding: 20px 22px; }

/* Tags & status */
.tag, .status {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--f-mono); font-size: 10.5px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 6px; white-space: nowrap;
  border: 1px solid var(--line); color: var(--ink-2); background: var(--white);
}
.status-arbetar { color: var(--ink); background: var(--soft); border-color: transparent; }
.status-arbetar::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--magenta); animation: pulse 1.4s ease-in-out infinite; }
.status-ko { color: var(--ink-2); }
.status-utkast { color: var(--ink); background: var(--white); }
.status-godkant { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.status-schemalagt { color: var(--ink); }
.status-publicerat { color: #fff; background: var(--ok); border-color: transparent; }
.tag-exempel { background: var(--marker); color: var(--ink); border-color: transparent; }
@keyframes pulse { 50% { opacity: .35; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--white); color: var(--ink);
  font-weight: 500; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { background: var(--paper); border-color: rgba(26,20,25,.25); }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: #000; border-color: #000; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn-undo { border-color: var(--magenta); color: var(--magenta); background: var(--white); }
.btn-undo:hover { background: var(--soft); border-color: var(--magenta); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13.5px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--white);
}
.icon-btn:hover { background: var(--paper); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--white); font-size: 14px; font-weight: 500;
}
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Composer */
.composer {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 14px 12px 18px;
  box-shadow: var(--shadow);
}
.composer:focus-within { border-color: rgba(26,20,25,.35); }
.composer textarea {
  width: 100%; border: 0; resize: none; background: transparent;
  min-height: 52px; max-height: 180px; font-size: 16px; line-height: 1.5;
}
.composer textarea:focus-visible { outline: none; }
.composer-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.composer-foot .chips { flex: 1; }
.composer-actions { display: flex; gap: 8px; margin-left: auto; }

/* ---------- Hem ---------- */
.hem-greeting { font-size: 34px; }
.desk-list { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
}
.row:last-child { border-bottom: 0; }
.row-btn {
  width: 100%; text-align: left; background: none; border: 0; border-radius: var(--r-sm);
}
.row-btn:hover { background: var(--white); }
.row-title { font-weight: 500; }
.row-meta { color: var(--ink-2); font-size: 13.5px; margin-top: 2px; }
.row-end { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.empty { padding: 22px; color: var(--ink-2); text-align: center; font-size: 14px; }

.approve-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.approve-card { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; }
.approve-card h3 { font-size: 17px; font-family: var(--f-ui); font-weight: 600; letter-spacing: 0; }
.approve-card p { color: var(--ink-2); font-size: 14px; }
.approve-card .btn-row { margin-top: auto; }

.countdown { font-family: var(--f-mono); font-size: 12px; color: var(--magenta); }

/* ---------- Chatten ---------- */
.chat {
  display: grid; grid-template-columns: minmax(380px, 1fr) minmax(420px, 1.1fr);
  height: 100%; min-height: 0;
}
.chat-left { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.chat-right { display: flex; flex-direction: column; min-height: 0; background: color-mix(in srgb, var(--canvas) 60%, var(--paper)); }

.chat, .chat-left, .chat-right { min-width: 0; }
.jobbar-row {
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--canvas);
  padding-right: 12px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}
.jobbar {
  display: flex; gap: 8px; overflow-x: auto; padding: 14px 20px;
  flex: 1; min-width: 0; scrollbar-width: thin;
}
.jobbar-draft { flex: none; }
.jobpill {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper); font-size: 13.5px; max-width: 260px;
}
.jobpill span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jobpill[aria-current="true"] { background: var(--white); border-color: var(--ink); }
.jobpill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-2); flex: none; }
.jobpill .dot.arbetar { background: var(--magenta); animation: pulse 1.4s infinite; }
.jobpill .dot.utkast { background: var(--marker); box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.jobpill .dot.godkant, .jobpill .dot.publicerat { background: var(--ok); }

.thread { flex: 1; overflow-y: auto; padding: 24px 24px 12px; display: flex; flex-direction: column; gap: 16px; }
.thread-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.thread-head h1 { font-size: 22px; }

.msg { max-width: 88%; display: flex; flex-direction: column; gap: 6px; }
.msg-meta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); flex-wrap: wrap; }
.msg-meta strong { color: var(--ink); font-weight: 600; }
.msg-body { padding: 12px 16px; border-radius: 16px; background: var(--paper); border: 1px solid var(--line); white-space: pre-wrap; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.user .msg-body { background: var(--white); border-color: rgba(26,20,25,.22); }
.msg.fiora .msg-body { border-top-left-radius: 6px; }
.msg.user .msg-body { border-top-right-radius: 6px; }
.via { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; padding: 2px 6px; border-radius: 5px; background: var(--white); border: 1px solid var(--line); }
.via.mejl { background: var(--canvas); }
.avatar-f { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }

.progress { list-style: none; margin: 0; padding: 0 0 0 4px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--ink-2); }
.progress li { display: flex; align-items: center; gap: 8px; }
.progress li::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--ok); background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M4 7.2 6 9.2 10 5' fill='none' stroke='white' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat; flex: none; }
.progress li.pending::before { background: none; border-color: var(--magenta); border-right-color: transparent; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.draft-card {
  align-self: stretch; max-width: 100%;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 14px; border: 1px dashed rgba(26,20,25,.25); background: var(--white);
}
.draft-card .t { font-weight: 500; flex: 1; min-width: 140px; }

.chat-composer { padding: 12px 20px 18px; border-top: 1px solid var(--line); background: var(--canvas); }
.chat-composer .composer { box-shadow: none; }

.preview-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--paper);
}
.preview-bar .grow { flex: 1; min-width: 0; }
.preview-bar .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-stage { flex: 1; overflow: auto; padding: 24px; display: flex; justify-content: center; align-items: flex-start; }
.decision {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px; border-top: 1px solid var(--line); background: var(--paper);
}
.decision .note { font-size: 13.5px; color: var(--ink-2); flex: 1; min-width: 160px; }
.show-draft { display: none; }

/* Preview frames (fiktiva varumärken) */
.frame {
  width: 100%; max-width: 640px; background: var(--white);
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
}
.frame-chrome { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border-bottom: 1px solid var(--line-2); background: #F4F1F3; }
.frame-chrome i { width: 9px; height: 9px; border-radius: 50%; background: rgba(26,20,25,.15); }
.frame-chrome .url { margin-left: 10px; font-family: var(--f-mono); font-size: 11px; color: var(--ink-2); background: #fff; padding: 3px 10px; border-radius: 6px; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.frame-note { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; text-align: center; padding: 6px; }
.changed { outline: 2px dashed var(--magenta); outline-offset: 4px; border-radius: 4px; }
.change-note { margin: 0 0 10px; font-size: 12.5px; color: var(--ink-2); font-family: var(--f-mono); }

.b-site { font-family: var(--b-body); color: var(--b-ink); background: var(--b-bg); }
.b-site header { display: flex; justify-content: space-between; align-items: center; padding: 14px 22px; border-bottom: 1px solid color-mix(in srgb, var(--b-p) 12%, transparent); }
.b-site .bw { font-family: var(--b-display); font-size: 17px; color: var(--b-p); display: flex; align-items: center; gap: 8px; }
.b-site .bw b { width: 26px; height: 26px; border-radius: 7px; background: var(--b-p); color: var(--b-bg); display: grid; place-items: center; font-size: 14px; }
.b-site nav { display: flex; gap: 14px; font-size: 12.5px; color: var(--b-p); }
.b-site .hero { padding: 40px 26px 30px; }
.b-site .kick { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--b-s); font-weight: 600; margin-bottom: 10px; }
.b-site h3 { font-family: var(--b-display); font-weight: 500; font-size: 32px; line-height: 1.08; color: var(--b-p); letter-spacing: -.02em; }
.b-site .lead { margin-top: 12px; font-size: 14.5px; line-height: 1.6; max-width: 32em; }
.b-site .cta { display: inline-block; margin-top: 18px; padding: 10px 18px; border-radius: 999px; background: var(--b-p); color: var(--b-bg); font-size: 13px; font-weight: 600; }
.b-site .cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 0 22px 26px; }
.b-site .cards div { background: #fff; border: 1px solid color-mix(in srgb, var(--b-p) 12%, transparent); border-radius: 12px; padding: 14px; font-size: 12.5px; line-height: 1.5; }
.b-site .cards strong { display: block; font-family: var(--b-display); font-weight: 500; font-size: 16px; color: var(--b-p); margin-bottom: 4px; }
.b-site .form { margin: 0 22px 26px; padding: 18px; border-radius: 12px; background: #fff; border: 1px solid color-mix(in srgb, var(--b-p) 14%, transparent); display: grid; gap: 8px; }
.b-site .form span { display: block; height: 34px; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--b-p) 20%, transparent); padding: 8px 10px; font-size: 12px; color: var(--b-s); }
.b-site .form em { font-style: normal; font-weight: 600; font-size: 13px; color: var(--b-p); }

.b-mail { background: #EFEDEA; padding: 20px; font-family: var(--b-body); color: var(--b-ink); }
.b-mail .meta { font-size: 12px; color: #6b6b6b; margin-bottom: 12px; line-height: 1.6; background: #fff; border-radius: 8px; padding: 10px 12px; }
.b-mail .meta b { color: #222; }
.b-mail .paper { background: var(--b-bg); max-width: 520px; margin: 0 auto; border-radius: 6px; overflow: hidden; }
.b-mail .mh { background: var(--b-p); color: var(--b-bg); padding: 18px 24px; font-family: var(--b-display); font-size: 18px; }
.b-mail .mb { padding: 24px; font-size: 14px; line-height: 1.65; }
.b-mail h3 { font-family: var(--b-display); font-weight: 500; color: var(--b-p); font-size: 24px; line-height: 1.15; margin-bottom: 10px; }
.b-mail .img { height: 120px; border-radius: 6px; margin: 14px 0; background: linear-gradient(135deg, var(--b-s), var(--b-p)); opacity: .85; }
.b-mail .cta { display: inline-block; padding: 10px 18px; border-radius: 999px; background: var(--b-a); color: var(--b-ink); font-weight: 600; font-size: 13px; margin-top: 8px; }
.b-mail .mf { padding: 14px 24px 20px; font-size: 11px; color: var(--b-s); border-top: 1px solid color-mix(in srgb, var(--b-p) 10%, transparent); }

.b-social { max-width: 400px; margin: 0 auto; background: #fff; font-family: system-ui, sans-serif; color: #111; }
.b-social .sh { display: flex; align-items: center; gap: 10px; padding: 12px 14px; font-size: 13px; }
.b-social .sh b { width: 32px; height: 32px; border-radius: 50%; background: var(--b-p); color: var(--b-bg); display: grid; place-items: center; font-family: var(--b-display); font-size: 14px; }
.b-social .sh small { display: block; color: #777; font-size: 11.5px; }
.b-social .img { aspect-ratio: 1 / 1; background: linear-gradient(160deg, var(--b-bg) 0, var(--b-s) 55%, var(--b-p) 100%); display: flex; align-items: flex-end; padding: 22px; }
.b-social .img span { font-family: var(--b-display); font-size: 26px; line-height: 1.1; color: var(--b-bg); text-shadow: 0 1px 12px rgba(0,0,0,.2); }
.b-social .cap { padding: 12px 14px 16px; font-size: 13.5px; line-height: 1.5; }
.b-social .acts { padding: 10px 14px 0; display: flex; gap: 14px; color: #333; }
.b-social .cta-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: #F2F2F2; font-size: 13px; }
.b-social .cta-bar em { font-style: normal; padding: 6px 12px; border-radius: 6px; background: #E4E6EB; font-weight: 600; }

/* ---------- Siffror ---------- */
.banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--r);
  background: var(--marker); color: var(--ink); font-weight: 600;
  margin-bottom: 24px;
}
.banner svg { flex: none; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--white); border: 1px solid var(--line); }
.seg button { height: 32px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; font-weight: 500; font-size: 14px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { padding: 18px 20px; }
.kpi .label { font-size: 13.5px; color: var(--ink-2); }
.kpi .value { font-family: var(--f-display); font-size: 32px; font-weight: 600; letter-spacing: -.02em; margin-top: 6px; }
.kpi .delta { font-size: 13px; margin-top: 2px; color: var(--ink-2); }
.kpi .delta b { color: var(--ink); font-weight: 600; }
.kpi .ex { margin-top: 10px; }

.charts { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-top: 14px; }
.chart-card { padding: 18px 20px 14px; min-width: 0; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.chart-head h3 { font-family: var(--f-ui); font-size: 15.5px; font-weight: 600; letter-spacing: 0; }
.chart-head p { font-size: 13px; color: var(--ink-2); }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line-2); }
.chart .axis text { fill: var(--ink-2); font-family: var(--f-mono); font-size: 10px; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .bar { transition: opacity .15s; }
.chart .bar.dim { opacity: .45; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--ink); color: #fff; font-size: 12.5px; line-height: 1.4;
  padding: 7px 10px; border-radius: 8px; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}
.tooltip small { display: block; color: rgba(255,255,255,.7); font-family: var(--f-mono); font-size: 10.5px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.link-btn { background: none; border: 0; padding: 4px 2px; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; font-size: 13px; }
.link-btn:hover { color: var(--ink); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line-2); }
table.data th { font-weight: 600; color: var(--ink-2); font-size: 12.5px; }
table.data td.n { font-family: var(--f-mono); text-align: right; }
table.data th.n { text-align: right; }

/* ---------- Kontakter ---------- */
.contacts-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.search {
  flex: 1; min-width: 220px; display: flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--white);
}
.search input { flex: 1; border: 0; background: transparent; min-width: 0; }
.search input:focus-visible { outline: none; }
.search:focus-within { outline: 3px solid var(--magenta); outline-offset: 2px; }
.contact-list { list-style: none; margin: 0; padding: 0; }
.contact-row {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 14px; align-items: center;
  width: 100%; padding: 12px 18px; border: 0; background: none; text-align: left;
  border-bottom: 1px solid var(--line-2);
}
.contact-list li:last-child .contact-row { border-bottom: 0; }
.contact-row:hover { background: var(--white); }
.initials {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--canvas); font-weight: 600; font-size: 14px;
}
.contact-row .tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.count-note { font-size: 13px; color: var(--ink-2); margin: 10px 4px 0; }

.detail dl { display: grid; grid-template-columns: 110px 1fr; gap: 10px 14px; margin: 18px 0; font-size: 14.5px; }
.detail dt { color: var(--ink-2); }
.detail dd { margin: 0; word-break: break-word; }
.notes { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 10px; }
.notes li { padding: 12px 14px; border-radius: 12px; background: var(--white); border: 1px solid var(--line); font-size: 14px; }
.notes small { display: block; color: var(--ink-2); font-family: var(--f-mono); font-size: 11px; margin-bottom: 4px; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13.5px; font-weight: 600; }
.field input, .field select, .field textarea {
  height: 42px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--white);
}
.field textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: 3px solid var(--magenta); outline-offset: 1px; }
.field .hint { font-size: 12.5px; color: var(--ink-2); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 14px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); }
.form-error { color: #A3261F; font-size: 13.5px; }

/* ---------- Inställningar ---------- */
.settings-tabs { margin-bottom: 24px; }
.settings-grid { display: grid; gap: 14px; }
.team-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 14px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.team-row:last-child { border-bottom: 0; }
.swatches { display: flex; gap: 12px; flex-wrap: wrap; }
.swatch { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.swatch i { width: 76px; height: 56px; border-radius: 12px; border: 1px solid var(--line); }
.swatch code { font-family: var(--f-mono); font-size: 11.5px; color: var(--ink-2); }
.logo-ph { width: 120px; height: 72px; border-radius: 12px; border: 1.5px dashed var(--line); display: grid; place-items: center; color: var(--ink-2); font-size: 12px; text-align: center; padding: 6px; }
.claims { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.claims li { padding: 10px 14px; border-radius: 12px; background: var(--white); border: 1px solid var(--line); font-size: 14.5px; display: flex; gap: 10px; align-items: center; }
.claims li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.brand-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.type-sample .d { font-size: 28px; line-height: 1.1; }
.type-sample .b { margin-top: 6px; font-size: 14.5px; color: var(--ink-2); }
.integ { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line-2); }
.integ:last-child { border-bottom: 0; }
.integ-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--white); border: 1px solid var(--line); display: grid; place-items: center; font-family: var(--f-display); font-weight: 700; }

/* ---------- Sheet / drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(26,20,25,.45); z-index: 70; animation: fade .18s ease; }
.sheet {
  position: fixed; z-index: 80; top: 12px; right: 12px; bottom: 12px;
  width: min(480px, calc(100vw - 24px));
  background: #FBF9FA; border-radius: var(--r-lg); border: 1px solid var(--line);
  box-shadow: 0 30px 80px -20px rgba(26,20,25,.4);
  display: flex; flex-direction: column;
  animation: slide-in .22s ease;
}
.sheet.wide { width: min(720px, calc(100vw - 24px)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 12px 22px; border-bottom: 1px solid var(--line-2); }
.sheet-title { font-size: 19px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 18px 22px 24px; }
.sheet-body .preview-stage { padding: 0; }
.sheet-foot { position: sticky; bottom: -24px; margin: 18px -22px -24px; padding: 14px 22px; background: var(--paper); border-top: 1px solid var(--line-2); display: flex; gap: 8px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
@keyframes slide-up { from { transform: translateY(40px); opacity: 0; } }

/* Toasts */
.toasts { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { pointer-events: auto; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); animation: slide-up .2s ease; text-align: center; }

/* ---------- Responsivt ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .chat { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  :root { --top-h: 56px; }
  body::before { display: none; }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--top-h) 1fr calc(var(--bottom-h) + env(safe-area-inset-bottom, 0px));
    grid-template-areas: "top" "view" "bottom";
  }
  .rail { display: none; }
  .bottombar {
    display: block; grid-area: bottom;
    border-top: 1px solid var(--line); background: var(--paper);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottombar .nav-list { flex-direction: row; justify-content: space-around; height: 100%; gap: 0; }
  .bottombar .nav-list li { flex: 1; }
  .bottombar .nav-link {
    flex-direction: column; gap: 3px; padding: 8px 2px; height: 100%;
    font-size: 11px; justify-content: center; border-radius: 0; position: relative;
  }
  .bottombar .nav-link[aria-current="page"] { box-shadow: none; background: none; }
  .bottombar .nav-link[aria-current="page"]::after { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; border-radius: 2px; background: var(--magenta); }
  .bottombar .nav-count { position: absolute; top: 4px; right: calc(50% - 22px); min-width: 16px; height: 16px; font-size: 9.5px; padding: 0 4px; }

  .topbar { padding: 0 12px; gap: 8px; }
  .wordmark { font-size: 0; gap: 0; padding: 4px; }
  .wordmark span { display: none; }
  .tenant { flex: 1; min-width: 0; }
  .tenant-btn { width: 100%; max-width: none; height: 38px; }
  .tenant-list { min-width: 0; width: calc(100vw - 24px); left: -44px; }
  .proto-badge { font-size: 10.5px; padding: 5px 10px; white-space: nowrap; max-width: none; }
  .badge-rest { display: none; }

  .page { padding: 22px 16px 40px; }
  .page-head { margin-bottom: 20px; }
  .page-head h1, .hem-greeting { font-size: 26px; }
  .section { margin-top: 28px; }
  .row { grid-template-columns: 1fr; gap: 8px; padding: 14px 16px; }
  .row > .status, .row > .tag { justify-self: start; }
  .row-end { justify-content: flex-start; }
  .approve-grid { grid-template-columns: 1fr; }
  .composer-foot { flex-wrap: wrap; }
  .composer-actions { width: 100%; justify-content: flex-end; }

  .chat { grid-template-columns: 1fr; }
  .chat-right { display: none; }
  .chat-left { border-right: 0; }
  .thread { padding: 18px 16px 10px; }
  .msg { max-width: 94%; }
  .chat-composer { padding: 10px 12px 12px; }
  .chat-composer .composer-foot { flex-wrap: nowrap; }
  .chat-composer .composer-actions { width: auto; }
  .chat-composer .btn-label { display: none; }
  .chat-composer .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; min-width: 0; }
  .chat-composer .chip { flex: none; }
  .show-draft { display: inline-flex; }

  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 24px; }
  .charts { grid-template-columns: 1fr; }
  .brand-grid { grid-template-columns: 1fr; }
  .contact-row { grid-template-columns: 40px 1fr; }
  .contact-row .tags { grid-column: 2; justify-content: flex-start; }
  .integ { grid-template-columns: 44px 1fr; }
  .integ .btn { grid-column: 1 / -1; justify-self: start; }
  .team-row { grid-template-columns: 40px 1fr; }
  .team-row > :last-child { grid-column: 2; justify-self: start; }

  .sheet {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%;
    max-height: 92dvh; border-radius: var(--r-lg) var(--r-lg) 0 0;
    animation: slide-up .22s ease;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #FBF9FA;
  }
  .jobbar-row { padding-right: 10px; }
  .jobbar { padding: 10px 12px 10px 16px; }
  .jobbar-draft { white-space: nowrap; }
  .sheet.wide { width: 100%; }
  .sheet-body { padding: 16px 16px 20px; }
  .sheet-foot { margin: 16px -16px -20px; padding: 12px 16px; bottom: -20px; }
  .b-site .cards { grid-template-columns: 1fr; }
  .b-site nav { display: none; }
  .b-site h3 { font-size: 26px; }
  .toasts { bottom: calc(var(--bottom-h) + 16px); }
  .toast { border-radius: 16px; }
}

/* Händelserader och aktivt jobb i tråden */
.event {
  align-self: center; text-align: center;
  font-family: var(--f-mono); font-size: 11.5px; color: var(--ink-2);
  padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--white);
}
.msg.on .msg-body { border-color: rgba(179, 48, 154, .38); }
.draft-card.on { border-color: var(--magenta); }
.tag-btn { cursor: pointer; }
.tag-btn:hover { border-color: var(--ink); color: var(--ink); }
.reply-to { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; min-width: 0; }
.reply-to b { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-to button { border: 0; background: none; color: var(--ink-2); padding: 2px 6px; border-radius: 6px; }
.reply-to button:hover { background: var(--canvas); color: var(--ink); }
.placeholder-box { width: 100%; max-width: 640px; padding: 48px 24px; text-align: center; color: var(--ink-2); border: 1.5px dashed var(--line); border-radius: 14px; background: var(--paper); }
.placeholder-box strong { display: block; color: var(--ink); font-family: var(--f-display); font-size: 18px; margin-bottom: 6px; }
.skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--canvas), var(--paper), var(--canvas)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; margin: 10px auto; max-width: 360px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.big-initials { width: 56px; height: 56px; font-size: 18px; }
.detail-head { display: flex; align-items: center; gap: 14px; }
.foot-note { margin-top: 28px; font-size: 13px; color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
