/*
 * Verktygets utseende följer nogomedia.se: ljust, typsnittet Inter, svarta rundade knappar,
 * grå text och tunna grå linjer. Bara chattrutan har botens egen färg.
 */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --line: #e5e7eb;
  --line-soft: #f3f4f6;
  --text: #111111;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #111111;
  --accent-text: #ffffff;
  --link: #111111;
  --ok: #16a34a;
  --warn: #b45309;
  --err: #dc2626;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --font-head: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-underline-offset: 3px; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar { position: sticky; top: 0; z-index: 20; gap: 12px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; height: 64px; background: rgba(255, 255, 255, .85); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--line-soft); }
.logo { display: flex; align-items: center; text-decoration: none; color: var(--text); }
.logo img { height: 28px; width: auto; display: block; }
.tag { font-size: 13px; color: var(--muted); }

/* Märke som på nogomedia.se (grön punkt i en rundad ruta) */
.badge { display: inline-flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 16px; font-size: 14px; color: #4b5563; margin-bottom: 28px; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }

/* Startsida */
.gridbg { background-image: linear-gradient(rgba(0,0,0,.03) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,.03) 1px, transparent 1px); background-size: 60px 60px; }
.hero { max-width: 820px; margin: 0 auto; padding: 96px 20px 72px; text-align: center; }
.hero h1 { font-family: var(--font-head); font-weight: 500; letter-spacing: -0.025em; font-size: clamp(36px, 6vw, 64px); line-height: 1.1; margin: 0 0 22px; }
.hero h1 em { font-style: normal; color: var(--faint); }
.hero p.lead { color: var(--muted); font-size: 19px; line-height: 1.6; margin: 0 auto 40px; max-width: 600px; }
.urlform { display: flex; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px; max-width: 620px; margin: 0 auto; box-shadow: var(--shadow); text-align: left; }
.urlform input { flex: 1; min-width: 0; background: transparent; border: 0; padding: 12px 18px; font-size: 17px; }
.urlform input:focus { outline: none; }
.urlform:focus-within { border-color: #9ca3af; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent); border-radius: 999px; padding: 12px 24px; font-size: 15px; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background-color .15s; }
.btn:hover { background: #374151; border-color: #374151; }
.btn:disabled { opacity: .5; cursor: progress; }
a.btn { text-decoration: none; }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--surface); color: var(--err); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.formerror { color: var(--err); min-height: 24px; margin-top: 10px; font-size: 15px; }
.hero .formerror { text-align: center; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 56px; text-align: left; }
.fact { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--surface); }
.fact b { display: block; font-weight: 600; margin-bottom: 6px; }
.fact span { color: var(--muted); font-size: 14px; }
@media (max-width: 640px) {
  .urlform { flex-direction: column; border-radius: 20px; }
  .urlform .btn { width: 100%; }
  .facts { grid-template-columns: 1fr; }
  .hero { padding-top: 56px; }
}

/* Förhandsvisning och kundens bot */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 28px; max-width: 1180px; margin: 0 auto; padding: 32px 20px 64px; }
.layout.single { grid-template-columns: minmax(0, 1fr); max-width: 760px; }
@media (max-width: 960px) { .layout { grid-template-columns: minmax(0, 1fr); } .chat { position: static; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card h2 { font-family: var(--font-head); font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 16px; }
.site { font-family: var(--font-mono); font-size: 13px; color: var(--muted); word-break: break-all; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.steps li { flex-wrap: wrap; display: flex; gap: 12px; align-items: center; color: var(--muted); }
.steps li .ic { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; }
.steps li.active { color: var(--text); }
.steps li.active .ic { border-color: var(--accent); border-top-color: transparent; animation: spin 1s linear infinite; }
.steps li.done { color: var(--text); }
.steps li.done .ic { border-color: var(--ok); background: var(--ok); }
.steps li.done .ic::after { content: ""; width: 8px; height: 4px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px, -1px); }
.steps li.failed .ic { border-color: var(--err); background: var(--err); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .steps li.active .ic { animation: none; } }
.counter { font-family: var(--font-mono); font-size: 13px; color: var(--muted); margin-left: auto; }
.notice { border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-top: 14px; }
.notice.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.notice.err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.notice.info { background: var(--surface-2); border: 1px solid var(--line); color: #374151; }
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.pagelist { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; max-height: 300px; overflow: auto; }
.pagelist li { font-size: 14px; display: flex; gap: 10px; justify-content: space-between; border-bottom: 1px solid var(--line-soft); padding-bottom: 6px; }
.pagelist li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.pagelist li a { min-width: 0; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pagelist li a:hover { text-decoration: underline; }
.pagelist .why { color: var(--muted); font-size: 13px; text-align: right; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 500; color: #374151; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=url], .field textarea, .field select { background: var(--surface); border: 1px solid #d1d5db; border-radius: 10px; padding: 10px 12px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: #111; box-shadow: 0 0 0 3px rgba(17, 17, 17, .08); }
.field textarea { resize: vertical; min-height: 64px; }
.row { display: flex; gap: 10px; align-items: center; }
.field input[type=color] { width: 44px; height: 40px; padding: 0; border: 1px solid #d1d5db; border-radius: 10px; background: none; }
.saved { color: var(--ok); font-size: 13px; }

/* Chattförhandsvisning (samma utseende som widgeten) */
.chat { position: sticky; top: 84px; background: #fff; color: #111; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; height: min(680px, calc(100vh - 104px)); box-shadow: 0 20px 50px rgba(0,0,0,.10); }
.chat header { background: var(--bot, #111); color: var(--bot-text, #fff); padding: 14px 16px; display: flex; gap: 10px; align-items: center; }
.chat header img { width: 32px; height: 32px; border-radius: 8px; background: #fff; object-fit: contain; }
.chat header b { display: block; font-weight: 600; }
.chat header small { opacity: .85; font-size: 12px; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #f9fafb; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 14px; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; }
.msg.bot { background: #fff; border: 1px solid #e5e7eb; align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user { background: var(--bot, #111); color: var(--bot-text, #fff); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.err { background: #fef2f2; border: 1px solid #fecaca; color: #7f1d1d; }
.msg.note { align-self: center; max-width: 92%; background: transparent; color: #4b5563; font-size: 13px; text-align: center; padding: 2px 8px; }
.msg sup a { color: inherit; font-size: 11px; text-decoration: none; background: #f3f4f6; border-radius: 4px; padding: 0 4px; margin-left: 2px; }
.msg .srcs { margin-top: 8px; padding-top: 8px; border-top: 1px solid #f3f4f6; font-size: 12px; display: grid; gap: 3px; white-space: normal; }
.msg .srcs a { color: #1f2937; }
.msg.typing { color: #6b7280; font-style: italic; }
.chat form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #e5e7eb; background: #fff; }
.chat form input { flex: 1; border: 1px solid #d1d5db; border-radius: 999px; padding: 10px 14px; color: #111; background: #fff; }
.chat form button { background: var(--bot, #111); color: var(--bot-text, #fff); border: 0; border-radius: 999px; padding: 0 18px; font-weight: 600; cursor: pointer; }
.chat form button:disabled { opacity: .5; cursor: default; }
.chat .foot { font-size: 11px; color: #6b7280; padding: 0 12px 10px; background: #fff; display: flex; justify-content: space-between; }
.chat.locked .msgs { filter: grayscale(.4); }

/* Konto */
.topnav { display: flex; gap: 16px; align-items: center; font-size: 14px; }
.topnav a { color: #4b5563; text-decoration: none; }
.topnav a:hover { color: var(--text); }
.linkbtn { background: none; border: 0; color: #4b5563; cursor: pointer; padding: 0; font-size: 14px; }
.linkbtn:hover { color: var(--text); }
.narrow { max-width: 460px; margin: 0 auto; padding: 64px 20px 72px; }
.narrow.wide { max-width: 760px; }
.narrow h1 { font-family: var(--font-head); font-weight: 500; letter-spacing: -0.02em; font-size: 32px; line-height: 1.15; margin: 0 0 10px; }
.narrow h2 { font-size: 18px; font-weight: 600; margin: 28px 0 8px; }
.narrow p.lead { color: var(--muted); margin: 0 0 28px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 20px; }
.tabs button { flex: 1; background: none; border: 0; border-radius: 999px; padding: 9px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tabs button[aria-selected=true] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.field .hint { font-size: 12px; color: var(--muted); }
.btn.block { width: 100%; }
.botlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.botlist a { display: flex; gap: 14px; align-items: center; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); transition: border-color .15s; }
.botlist a:hover { border-color: #9ca3af; }
.botlist .sw { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.botlist .meta { min-width: 0; flex: 1; }
.botlist .meta b { display: block; font-weight: 600; }
.botlist .meta span { color: var(--muted); font-size: 13px; font-family: var(--font-mono); overflow-wrap: anywhere; }
.botlist .st { font-size: 12px; color: var(--muted); }
.savebox p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.savebox .row { flex-wrap: wrap; }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 12px 16px; }
  .topbar > .topnav { flex: 1 1 100%; flex-wrap: wrap; justify-content: space-between; row-gap: 6px; }
  .topnav #nav .tag { display: none; }
  .topbar > .topnav.compact { flex: 0 0 auto; }
}
#billingCard .hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
#billingCard .row { margin-top: 10px; }

/* Installation (kundens sparade bot) */
#installCard h3 { font-size: 15px; font-weight: 600; margin: 20px 0 10px; }
#installCard .card.domain { background: var(--surface-2); box-shadow: none; margin: 12px 0 0; padding: 16px; }
#installCard .field textarea { font-family: var(--font-mono); font-size: 12.5px; min-height: 0; background: var(--surface); }
#installCard details { margin: 10px 0; }
#installCard summary { cursor: pointer; color: var(--muted); }
#installCard #domainForm input { flex: 1; min-width: 0; background: var(--surface); border: 1px solid #d1d5db; border-radius: 999px; padding: 10px 16px; color: inherit; font: inherit; }
#installCard .row { flex-wrap: wrap; }

/* Kundportalen: sidomeny och vyer */
.portal { display: block; }
.portal.with-side { display: grid; grid-template-columns: 240px minmax(0, 1fr); max-width: 1480px; margin: 0 auto; }
.side { padding: 28px 16px 40px 24px; position: sticky; top: 64px; align-self: start; max-height: calc(100vh - 64px); overflow: auto; }
.side ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side a { display: block; padding: 8px 12px; border-radius: 10px; color: #4b5563; text-decoration: none; font-size: 14px; }
.side a:hover { background: var(--surface-2); color: var(--text); }
.side a[aria-current=page] { background: var(--line-soft); color: var(--text); font-weight: 600; }
.side .sub { margin: 2px 0 6px 12px; border-left: 1px solid var(--line); padding-left: 6px; }
.side .sub a { padding: 5px 10px; font-size: 13px; }
.side-back { margin-bottom: 14px; font-size: 13px !important; }
.side-bot { display: flex; gap: 10px; align-items: center; padding: 0 12px 14px; }
.side-bot .sw { width: 14px; height: 14px; border-radius: 4px; background: var(--line); flex: none; }
.side-bot b { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.view { padding: 32px 24px 64px; max-width: 980px; }
.view h1 { font-weight: 500; letter-spacing: -0.02em; font-size: 28px; margin: 0 0 6px; }
.view .lead { color: var(--muted); margin: 0 0 24px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { background: none; border: 0; border-radius: 999px; padding: 6px 14px; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 500; }
.pill { display: inline-block; font-size: 12px; border-radius: 999px; padding: 2px 10px; border: 1px solid var(--line); color: #374151; background: var(--surface-2); white-space: nowrap; }
.pill.ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.pill.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.pill.err { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; background: var(--surface); box-shadow: var(--shadow); }
.tile .k { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tile .v { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; }
.tile .s { font-size: 13px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding: 8px 0 0; border-bottom: 1px solid var(--line); }
.bars .b { flex: 1; display: flex; flex-direction: column-reverse; min-width: 2px; }
.bars .b span { display: block; }
.bars .b .a { background: #111; }
.bars .b .f { background: #f59e0b; }
.bars .b .o { background: #d1d5db; }
.bars-x { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: #4b5563; margin-top: 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line-soft); padding: 12px 0; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.list > li:last-child { border-bottom: 0; }
.list .main { min-width: 0; flex: 1; }
.list .main b { font-weight: 500; display: block; overflow-wrap: anywhere; }
.list .main small { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.list .acts { display: flex; gap: 8px; flex: none; align-items: center; }
.btn.small { padding: 6px 14px; font-size: 13px; }
.convo { display: grid; gap: 10px; }
.convo .m { max-width: 80%; padding: 10px 13px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.convo .m.user { justify-self: end; background: #111; color: #fff; border-bottom-right-radius: 4px; }
.convo .m.assistant { justify-self: start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.convo .m .srcs { margin-top: 8px; font-size: 12px; display: grid; gap: 2px; }
.convo .meta { font-size: 12px; color: var(--muted); }
.defs { font-size: 14px; color: #374151; }
.defs dt { font-weight: 600; margin-top: 10px; }
.defs dd { margin: 2px 0 0; color: var(--muted); }
table.hist { width: 100%; border-collapse: collapse; font-size: 14px; }
table.hist th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); }
table.hist td { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.filter { flex: 1; min-width: 180px; border: 1px solid #d1d5db; border-radius: 999px; padding: 8px 14px; background: var(--surface); }
.empty { color: var(--muted); padding: 8px 0; }
@media (max-width: 900px) {
  .portal.with-side { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; padding: 12px 16px 0; border-bottom: 1px solid var(--line-soft); }
  .side > ul { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 10px; }
  .side > ul > li > a { white-space: nowrap; }
  .side .sub, .side-bot { display: none; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view { padding: 20px 16px 48px; }
}
.hint { font-size: 13px; color: var(--muted); }
p.hint { margin: 6px 0 0; }
.list .main .kbody { display: block; white-space: pre-wrap; color: #374151; margin: 2px 0; max-height: 7.5em; overflow: hidden; }
.list .main .kform { margin: 4px 0; }
.convo .meta .fix { color: var(--muted); }
/* Beteende: förinställningar som valbara kort, kryssrutor och överlämnade ärenden. */
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.choice { display: grid; gap: 4px; align-content: start; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; font: inherit; color: var(--text); }
.choice:hover { background: var(--surface-2); }
.choice[aria-pressed=true] { border-color: #111; box-shadow: 0 0 0 2px rgba(17, 17, 17, .12); }
.choice b { font-weight: 600; font-size: 14px; }
.choice span { font-size: 13px; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: #374151; margin-bottom: 10px; cursor: pointer; }
.check input { margin-top: 2px; width: 16px; height: 16px; accent-color: #111; flex: none; }
.group-label { font-size: 13px; font-weight: 500; color: #374151; margin: 0 0 8px; padding: 0; }
.list .main .note { display: block; white-space: pre-wrap; color: #374151; margin: 4px 0; }
.list .main a.mail { color: inherit; }
@media (max-width: 900px) { .choices { grid-template-columns: minmax(0, 1fr); } }

/* Dokument (steg 3): texten som boten fick ut ur filen */
.doctext { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto; margin: 8px 0 0; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; font-family: var(--font-body); font-size: 13px; color: #374151; }
