/* ============================================================
   MR INFO-palett: svart bas, röd accent, hög kontrast
   Byggd mobil först - iPhone i ena handen är normalfallet.
   ============================================================ */
:root {
  --bg: #050505;
  --surface: #121212;
  --surface2: #1A1A1A;
  --primary: #F01824;
  --orange: #FF7A00;
  --blue: #1E7BFF;
  --green: #36C653;
  --text: #FFFFFF;
  --muted: #A0A0A0;
  --border: #2A2A2A;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --bar-h: 78px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--primary); min-height: 20px; }
a { color: inherit; }

.view.centered {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.brand {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 10px rgba(240,24,36,.8);
  flex-shrink: 0;
}
.demo-tag {
  background: var(--orange);
  color: #000;
  border-radius: 4px;
  padding: 1px 6px;
  letter-spacing: 1px;
}

/* ---------- Kort ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  width: 100%;
  max-width: 430px;
}
.card h1 { font-size: 25px; margin: 14px 0 12px; line-height: 1.25; }
.card p { color: var(--muted); margin: 0 0 20px; font-size: 15px; }
code {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 13px;
  color: var(--text);
}

/* ---------- Knappar ---------- */
.btn {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  padding: 11px 16px;
  min-height: 44px;
  cursor: pointer;
  transition: background .12s, opacity .12s;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:active { opacity: .65; }
.btn:disabled { opacity: .4; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-ghost { background: transparent; }
.btn-lg { width: 100%; padding: 15px; font-size: 17px; min-height: 52px; }
.btn-sm { padding: 8px 12px; font-size: 14px; min-height: 40px; }
.btn-block { width: 100%; margin-top: 10px; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.topbar-actions::-webkit-scrollbar { display: none; }
#account { display: none; }

main {
  padding: 16px;
  padding-bottom: calc(var(--bar-h) + var(--safe-b) + 24px);
  max-width: 900px;
  margin: 0 auto;
}

/* ---------- Framsteg ---------- */
.progress-wrap { margin-bottom: 18px; }
.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 15px;
}
.progress {
  height: 8px;
  background: var(--surface2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--green);
  width: 0;
  transition: width .3s;
}
.legend {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}
.legend span { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ---------- Verktygsrad ---------- */
.toolbar { margin-bottom: 12px; }
.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.filters::-webkit-scrollbar { display: none; }
.toolbar-right { display: flex; gap: 8px; margin-top: 4px; }

.pill {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 40px;
}
.pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 16px hindrar iOS från att zooma in vid fokus */
.search, .select {
  font: inherit;
  font-size: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  padding: 11px 12px;
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
}
.search { flex: 1; min-width: 0; }
.select { flex-shrink: 0; max-width: 48%; }
.search:focus, .select:focus { outline: none; border-color: var(--primary); }

/* ---------- Markera alla ---------- */
.selectbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  margin-bottom: 10px;
  gap: 10px;
  flex-wrap: wrap;
}
.check-all {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  min-height: 32px;
}
input[type=checkbox] {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

/* ---------- Lista ---------- */
.list { display: flex; flex-direction: column; gap: 6px; }

.domain-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 2px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.domain-head .line { flex: 1; height: 1px; background: var(--border); }
.domain-head button {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--blue);
  cursor: pointer;
  text-transform: none;
  padding: 7px 11px;
  min-height: 36px;
  white-space: nowrap;
  flex-shrink: 0;
}
.domain-head button:active { opacity: .6; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 14px;
  min-height: 60px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.row:active { background: var(--surface2); }
.row.selected { border-color: var(--primary); background: rgba(240,24,36,.09); }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
}
.row-main { flex: 1; min-width: 0; }
.row-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-name.nameless { color: var(--muted); font-style: italic; font-weight: 400; }
.row-sub {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-tags { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

.tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}
.tag.guess { opacity: .7; border-style: dashed; }

.more-wrap { text-align: center; padding: 20px 0; }
.more-wrap .btn { width: 100%; }
.empty { text-align: center; color: var(--muted); padding: 44px 20px; }

/* ---------- Åtgärdsrad: alltid inom tummens räckvidd ---------- */
.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(18,18,18,.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--primary);
  padding: 8px 12px calc(8px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}
.ab-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.actionbar .count { font-weight: 700; font-size: 14px; white-space: nowrap; }
.actionbar-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.actionbar-btns .btn {
  flex: 1 1 0;
  min-width: 74px;
  padding: 11px 2px;
  font-size: 13px;
  min-height: 48px;
}
.actionbar #btn-clearsel { padding: 4px 10px; min-height: 32px; font-size: 13px; }
.kbd { display: none; }

/* ---------- Laddning & toast ---------- */
.loading { padding: 70px 20px; text-align: center; color: var(--muted); }
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 18px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 12px;
  right: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: 11px;
  padding: 12px 16px;
  z-index: 200;
  box-shadow: 0 8px 28px rgba(0,0,0,.7);
  font-size: 14px;
}
.toast.error { border-left-color: var(--primary); }

/* ---------- Vyväxling ---------- */
.vynav {
  display: flex;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 5px;
  margin-bottom: 18px;
}
.vyknapp {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  padding: 10px 6px;
  min-height: 42px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  position: relative;
}
.vyknapp.active { background: var(--surface2); color: var(--text); }
.prick {
  display: inline-block;
  min-width: 19px;
  padding: 1px 5px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.panel h2 { margin: 0 0 8px; font-size: 17px; }
.panel p { margin: 0; }

/* ---------- Länkrad under en kontakt ---------- */
.lankrad {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 11px 11px;
  padding: 10px 14px;
  margin-top: -8px;
  flex-wrap: wrap;
}
.lank {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lankknappar { display: flex; gap: 6px; }

/* ---------- Svarskort ---------- */
.svarkort {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.svarhuvud { margin-bottom: 14px; }
.diffar { border-top: 1px solid var(--border); padding-top: 12px; }
.diff {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  font-size: 14px;
  flex-wrap: wrap;
}
.diff-namn {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 105px;
}
.diff-fran { color: var(--muted); text-decoration: line-through; }
.diff-pil { color: var(--muted); }
.diff-till { color: var(--green); font-weight: 600; }
.diff.andrat { background: rgba(54,198,83,.06); border-radius: 6px; padding-inline: 8px; }
.meddelande {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface2);
  border-left: 3px solid var(--blue);
  border-radius: 8px;
  font-size: 14px;
  font-style: italic;
  color: #d5d8de;
}
.svarknappar {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ============================================================
   Större skärmar
   ============================================================ */
@media (min-width: 720px) {
  .topbar { padding: 16px 28px; }
  #account { display: inline; }
  main { padding: 24px 28px; padding-bottom: 120px; max-width: 1000px; }

  .toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .filters { padding-bottom: 0; flex-wrap: wrap; overflow: visible; }
  .toolbar-right { margin-top: 0; }
  .search { min-width: 240px; flex: none; }
  .select { max-width: none; }

  .actionbar {
    left: 50%;
    right: auto;
    bottom: 20px;
    transform: translateX(-50%);
    border: 1px solid var(--primary);
    border-radius: 14px;
    padding: 12px 18px;
    box-shadow: 0 10px 40px rgba(0,0,0,.75);
    max-width: calc(100vw - 40px);
    flex-direction: row;
    align-items: center;
    gap: 14px;
  }
  .ab-top { flex-direction: row-reverse; gap: 14px; }
  .actionbar-btns { flex: none; }
  .actionbar-btns .btn { flex: none; padding: 9px 14px; }
  .kbd {
    display: inline;
    font-size: 10px;
    opacity: .6;
    margin-left: 6px;
    border: 1px solid currentColor;
    border-radius: 3px;
    padding: 0 3px;
  }
  .toast { left: 50%; right: auto; transform: translateX(-50%); max-width: 560px; }
  .more-wrap .btn { width: auto; }
}

/* Skicka-knappen på varje rad i Utskick */
.btn.skicka {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  padding: 8px 14px;
  min-height: 38px;
  font-size: 13px;
}
.btn.skicka:active { opacity: .7; }

/* Utskicksraden: namnet får hela bredden, märkningarna ligger på rad två */
#u-list .row-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
#u-list .row-sub .txt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.minitag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
  flex-shrink: 0;
}
#u-list .btn.skicka { flex-shrink: 0; min-width: 78px; }

/* Kategorin som färg i stället för text */
#u-list .row.kant { border-left-width: 4px; }
.prick-farg {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: 1px;
}

/* Kopiera länken - liten knapp direkt på raden */
.kopiera-knapp {
  padding: 8px 11px;
  min-height: 38px;
  font-size: 13px;
  flex-shrink: 0;
  color: var(--muted);
}

/* Kanalval: mail eller dela */
.kanalval {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border-radius: 9px;
  padding: 3px;
}
.kanalknapp {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 7px 13px;
  min-height: 34px;
  border-radius: 7px;
  cursor: pointer;
}
.kanalknapp.active { background: var(--surface); color: var(--text); }

/* Erbjudande om notiser, överst i appen */
.notisbanner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: linear-gradient(90deg, rgba(240,24,36,.14), transparent);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.nb-text { display: flex; flex-direction: column; gap: 3px; min-width: 200px; flex: 1; }
.nb-knappar { display: flex; gap: 8px; }

/* Städvyn */
.stada-in {
  font: inherit;
  font-size: 15px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  padding: 12px 14px;
  resize: vertical;
  margin-bottom: 10px;
}
.stada-in:focus { outline: none; border-color: var(--primary); }
.stada-knappar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stadarad { display: flex; align-items: center; gap: 12px; }
.stadarad .adress { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.stadarad.behall { opacity: .55; }
.stadarad .agare { font-size: 10px; font-weight: 700; letter-spacing: .4px; color: var(--green); text-transform: uppercase; }

.stadarad .etikett { font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 4px; white-space: nowrap; }

.foretagrad { display: flex; align-items: center; gap: 12px; }
.foretagrad .fran { font-size: 13px; color: var(--muted); text-decoration: line-through; }
.foretagrad .till { font-size: 13px; color: var(--text); }
.foretagrad .pil { color: var(--muted); margin: 0 4px; }
.foretagrad.av { opacity: .45; }
.foretagrad .nytt { font-size: 10px; font-weight: 700; letter-spacing: .4px; color: var(--green); text-transform: uppercase; }

.mer { margin: -4px 0 20px; }
.mer summary { font-size: 13px; color: var(--muted); cursor: pointer; list-style: none; padding: 4px 0; }
.mer summary::-webkit-details-marker { display: none; }
.mer summary::before { content: "+ "; font-weight: 700; }
.mer[open] summary::before { content: "- "; }
.mer summary:hover { color: var(--text); }
.mer p { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

/* Inloggningskortets ingress i samma storlek som utfallningen under */
#view-login .card p { font-size: 13px; margin-bottom: 14px; }
