:root {
  --paused: #64748b;
  --paused-bg: #edf0f4;
  --signed: #6d28d9;
  --signed-bg: #f1ebfd;
  --navy: #0f2a44;
  --navy-2: #173a5c;
  --red: #c8102e;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --border: #dde3ea;
  --text: #16202b;
  --muted: #5d6b7a;
  --primary: #1f5fa8;
  --primary-hover: #194f8c;
  --open: #1f5fa8;
  --open-bg: #e7f0fb;
  --progress: #b26a00;
  --progress-bg: #fff3df;
  --closed: #23804a;
  --closed-bg: #e3f4ea;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 42, 68, .06), 0 1px 8px rgba(15, 42, 68, .05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* ---------- layout ---------- */
.topbar {
  background: var(--navy); color: #fff; display: flex; align-items: center; gap: 1rem;
  padding: 0 1.25rem; height: 56px; position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: #fff; letter-spacing: .2px; flex-shrink: 0; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 400; opacity: .7; }
.brand-logo { display: flex; background: #fff; border-radius: 6px; padding: 3px 6px; }
.brand-logo img { height: 38px; width: auto; display: block; }
.nav { display: flex; gap: .25rem; margin-left: 1rem; flex-shrink: 0; white-space: nowrap; }
.nav a { color: #cfdbe8; padding: .45rem .75rem; border-radius: 6px; font-weight: 500; }
.nav a:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--navy-2); color: #fff; box-shadow: inset 0 -2px 0 var(--red); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: .5rem; min-width: 0; }
.userbox .who { text-align: right; line-height: 1.15; font-size: .85rem; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbox button { flex-shrink: 0; white-space: nowrap; }
.userbox .who span { display: block; opacity: .7; font-size: .75rem; }
.menu-btn { display: none; }

main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.page-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; }
.card + .card, .stack > * + * { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: 2fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

/* ---------- buttons & inputs ---------- */
button, .btn {
  font: inherit; font-weight: 600; font-size: .9rem; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .5rem .9rem; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; min-height: 38px;
}
button:hover, .btn:hover { background: #f5f7fa; text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-ghost { background: transparent; border-color: transparent; }
.topbar button { background: transparent; color: #fff; border-color: rgba(255,255,255,.25); }
.topbar button:hover { background: var(--navy-2); }
.btn-sm { padding: .3rem .6rem; min-height: 30px; font-size: .82rem; }

label.field { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { margin-top: .25rem; }
input, select, textarea {
  font: inherit; width: 100%; border: 1px solid #c8d1db; border-radius: 8px; padding: .5rem .65rem; background: #fff; color: var(--text); min-height: 38px;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid #8bb5e6; outline-offset: 1px; border-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .35rem; }
.chip-check { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--border); padding: .35rem .65rem; border-radius: 999px; cursor: pointer; font-weight: 500; color: var(--text); }
.chip-check input { width: auto; min-height: 0; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar select { max-width: 200px; }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.kpi { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); color: var(--text); border-top: 4px solid var(--c); }
.kpi:hover { text-decoration: none; border-color: var(--c); }
.kpi .label { font-weight: 600; color: var(--muted); font-size: .9rem; }
.kpi .value { font-size: 2.4rem; font-weight: 700; line-height: 1.1; margin-top: .25rem; color: var(--c); font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--muted); }
.kpi.registrerad { --c: #64748b; }
.kpi.oppen { --c: var(--open); }
.kpi.pagaende { --c: var(--progress); }
.kpi.avslutad { --c: var(--closed); }
.kpi.signerad { --c: var(--signed); }
.kpi.pausad { --c: var(--paused); }

/* ---------- förlopp & rapporter ---------- */
.progress { height: 8px; background: #e6ebf1; border-radius: 999px; overflow: hidden; margin: .4rem 0 .3rem; }
.progress span { display: block; height: 100%; background: var(--progress); border-radius: inherit; transition: width .25s; }
.progress.done span { background: var(--primary); }
.progress.signed span { background: var(--closed); }
.section-head { display: flex; align-items: baseline; gap: .75rem; margin-bottom: .75rem; }
.section-head h2 { margin: 0; }
.reports { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.report { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--progress); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; display: flex; flex-direction: column; }
.report header { display: flex; gap: .75rem; align-items: flex-start; }
.report .grow { flex: 1; min-width: 0; }
.report .title { font-weight: 700; font-size: 1.02rem; color: var(--text); }
.report .pct { font-size: 1.6rem; font-weight: 700; color: var(--progress); line-height: 1; font-variant-numeric: tabular-nums; }
.report .pct small { font-size: .8rem; }
.report-sum { margin-bottom: .5rem; }
.report.signerad { border-left-color: var(--signed); }
.report.signerad .pct { color: var(--signed); }
.proto-list { list-style: none; margin: 0 0 .75rem; padding: 0; border-top: 1px solid #eef1f5; }
.proto-list li { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid #eef1f5; font-size: .88rem; }
.proto-list .grow { flex: 1; min-width: 0; color: var(--text); }
.proto-list .mini { width: 70px; }
.proto-list .mini .progress { margin: 0; height: 6px; }
.report footer { margin-top: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.code-sm { font-size: .72rem; font-weight: 700; color: var(--muted); }
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid #eef1f5; }
.todo li:last-child { border-bottom: 0; }
.todo .grow { flex: 1; min-width: 0; }
.warn { color: var(--danger); font-weight: 600; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.badge.ready { background: var(--open-bg); color: var(--open); }

.proto-progress { position: sticky; top: 56px; z-index: 15; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-top: 1rem;
  background: rgba(255,255,255,.97); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: .6rem 1rem; }
.proto-progress .grow { flex: 1 1 220px; }
.proto-progress .progress { margin-bottom: 0; }
.sec-count { font-size: .78rem; font-weight: 700; background: var(--progress-bg); color: var(--progress); padding: .1rem .5rem; border-radius: 999px; }
.sec-count.done { background: var(--closed-bg); color: var(--closed); }
.check-item, .q-field { scroll-margin-top: 130px; border-radius: 6px; transition: background .4s; }
.check-item.done .pos { color: var(--closed); }
.check-item { padding-left: .6rem; }
.check-item.done { box-shadow: inset 3px 0 0 var(--closed); }
.only-open .check-item.done, .only-open .q-field.done { display: none; }
.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { background: #fff1c2; } 100% { background: transparent; } }

/* ---------- ny servicerapport ---------- */
.step-no { display: inline-flex; width: 1.6rem; height: 1.6rem; align-items: center; justify-content: center; border-radius: 50%; background: var(--navy); color: #fff; font-size: .85rem; margin-right: .35rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem; }
.tiles.tpl { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tile { flex-direction: column; align-items: flex-start; text-align: left; gap: .2rem; padding: .85rem 1rem; min-height: 90px; font-weight: 400; border-width: 2px; }
.tile strong { font-size: 1rem; }
.tile .ico { font-size: 1.6rem; line-height: 1; }
.tile.sel { border-color: var(--primary); background: var(--open-bg); box-shadow: 0 0 0 1px var(--primary); }
.tile.sel:hover { background: var(--open-bg); }
.segs { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 9px; padding: 3px; background: #f3f5f8; gap: 3px; margin-bottom: .75rem; }
.seg { border: 0; background: transparent; min-height: 32px; padding: .3rem .8rem; font-size: .85rem; color: var(--muted); }
.seg:hover { background: #e8edf3; }
.seg.on { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(15, 42, 68, .15); }
.fac-list { max-height: 360px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.fac { display: flex; align-items: center; gap: .75rem; padding: .6rem .8rem; border-bottom: 1px solid #eef1f5; cursor: pointer; }
.fac:last-child { border-bottom: 0; }
.fac:hover { background: #f7f9fc; }
.fac.sel { background: var(--open-bg); }
.fac input { width: auto; min-height: 0; }
.fac .grow { flex: 1; min-width: 0; }

/* ---------- tables & lists ---------- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; padding: .55rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.list td { padding: .65rem .6rem; border-bottom: 1px solid #eef1f5; vertical-align: top; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #f7f9fc; }
table.list.zebra tbody tr:nth-child(even) td { background: #eaf3fc; }
table.list.zebra tbody tr.click:hover td { background: #d6e7f8; }
table.list.zebra tbody tr:nth-child(even) .badge.sys, table.list.zebra tbody tr.click:hover .badge.sys { background: #fff; }
table.list tr:last-child td { border-bottom: 0; }
/* Anläggningar grupperade per systemtyp: hopfällbara rubrikrader. */
table.facility-groups tbody.group-head td { padding: 0; border-bottom: 1px solid var(--border); background: transparent; }
table.facility-groups tbody:not(.group-head) tr:last-child td { border-bottom: 1px solid var(--border); }
.group-toggle { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .85rem .6rem; background: none; border: 0; border-radius: 0; min-height: 0;
  text-align: left; font-size: .9rem; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; color: var(--text); cursor: pointer; }
.group-toggle:hover { background: #f7f9fc; }
.group-toggle .chevron { display: inline-block; width: 1rem; font-size: 1.25rem; line-height: 1; color: var(--muted); transition: transform .15s; }
.group-toggle[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.group-toggle .group-count { font-size: .75rem; font-weight: 600; color: var(--muted); background: var(--bg); border-radius: 999px; padding: .1rem .5rem; letter-spacing: 0; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.badge.registrerad { background: #eef1f5; color: #475569; }
.badge.oppen { background: var(--open-bg); color: var(--open); }
.badge.pagaende { background: var(--progress-bg); color: var(--progress); }
.badge.pausad { background: var(--paused-bg); color: var(--paused); }
.badge.signerad { background: var(--signed-bg); color: var(--signed); }
.badge.avslutad { background: var(--closed-bg); color: var(--closed); }
.badge.hog { background: var(--danger-bg); color: var(--danger); }
.badge.lag { background: #eef1f5; color: var(--muted); }
.badge.sys { background: #eef1f5; color: #34495e; font-weight: 600; }
.badge.signed { background: var(--signed-bg); color: var(--signed); }
.badge.draft { background: #eef1f5; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: .25rem; }

dl.info { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
dl.info dt { color: var(--muted); font-size: .85rem; }
dl.info dd { margin: 0; font-weight: 500; }

.item-row { display: flex; align-items: center; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid #eef1f5; }
.item-row:last-child { border-bottom: 0; }
.item-row .grow { flex: 1; min-width: 0; }
.log { list-style: none; padding: 0; margin: 0; font-size: .87rem; }
.log li { padding: .45rem 0; border-bottom: 1px solid #eef1f5; }
.log li:last-child { border-bottom: 0; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .6rem; }
.thumb { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #f5f7fa; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; text-align: center; font-size: .8rem; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .del { position: absolute; top: 4px; right: 4px; min-height: 0; padding: .1rem .4rem; background: rgba(255,255,255,.92); }
.question-photos { grid-column: 1 / -1; margin-top: .5rem; min-width: 0; }
.question-photo-list { display: flex; flex-wrap: wrap; gap: .6rem; }
.question-photo-list:empty { display: none; }
.question-photo { display: flex; flex-direction: column; gap: .3rem; width: 110px; max-width: 100%; break-inside: avoid; }
.question-photo a { display: flex; align-items: center; justify-content: center; width: 100%; height: 100px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #f5f7fa; }
.question-photo img { width: 100%; height: 100%; object-fit: contain; }
.question-photo span { font-size: .8rem; overflow-wrap: anywhere; }
.photo-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.photo-state:not(:empty) { margin-top: .4rem; }

.status-steps { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- protocol form ---------- */
.proto-head { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.proto-head .code { background: var(--navy); color: #fff; font-weight: 700; font-size: .8rem; padding: .2rem .5rem; border-radius: 5px; }
.proto-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem 1rem; margin-top: 1rem; font-size: .88rem; }
.proto-meta div span { display: block; color: var(--muted); font-size: .75rem; }
.section-title { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.section-title .bulk { margin-left: auto; display: flex; gap: .4rem; }

.check-item { display: grid; grid-template-columns: minmax(2.2rem, max-content) 1fr auto; gap: .35rem .75rem; padding: .75rem 0; border-bottom: 1px solid #eef1f5; align-items: start; }
.check-item:last-child { border-bottom: 0; }
.check-item .pos { font-weight: 700; color: var(--muted); padding-top: .35rem; }
.check-item .text { padding-top: .35rem; }
.check-item .hint { font-size: .8rem; color: var(--muted); }
.check-item .opts { display: flex; gap: .35rem; }
.check-item .extra { grid-column: 2 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .5rem; }
.check-item .extra label { font-size: .78rem; }
/* Svar på kontrollpunkt: klickbara rutor. Grön = OK, röd = Ej OK, grå = Ej tillämpligt. */
.status-boxes { display: flex; gap: .35rem; flex-wrap: wrap; }
.sbox { --c: var(--closed); --bg: var(--closed-bg); gap: .45rem; font-weight: 600; min-height: 40px; padding: .4rem .7rem; white-space: nowrap; }
.sbox.ejok { --c: var(--danger); --bg: var(--danger-bg); }
.sbox.na { --c: #4b5866; --bg: #e8ecf0; }
.sbox .box { width: 20px; height: 20px; border: 2px solid var(--c); border-radius: 4px; background: #fff; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.sbox[aria-checked=true] { border-color: var(--c); background: var(--bg); color: var(--c); }
.sbox[aria-checked=true] .box { background: var(--c); }
.sbox.ok[aria-checked=true] .box::after { content: ""; width: 5px; height: 10px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }
.sbox.ejok[aria-checked=true] .box::after { content: "✕"; color: #fff; font-size: 13px; line-height: 1; font-weight: 700; }
.sbox.na[aria-checked=true] .box::after { content: ""; width: 10px; height: 2.5px; background: #fff; border-radius: 2px; }
.sbox:disabled { opacity: 1; cursor: default; }
.sbox:disabled:not([aria-checked=true]) { color: #9aa5b1; }
.sbox:disabled:not([aria-checked=true]) .box { border-color: #c7cfd8; }
.check-item:has([data-status=ejok]) { box-shadow: inset 3px 0 0 var(--danger); }
.check-item:has([data-status=na]) { box-shadow: inset 3px 0 0 #8a96a3; }
.check-item:has([data-status=ejok]) .pos { color: var(--danger); }
.check-item:has([data-status=na]) .pos { color: #8a96a3; }
.status-tag { display: inline-flex; align-items: center; gap: .35rem; font-weight: 700; white-space: nowrap; }
.status-tag .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.status-tag[data-status=ok] { color: var(--closed); } .status-tag[data-status=ok] .dot { background: var(--closed); }
.status-tag[data-status=ejok] { color: var(--danger); } .status-tag[data-status=ejok] .dot { background: var(--danger); }
.status-tag[data-status=na] { color: #5d6b7a; } .status-tag[data-status=na] .dot { background: #8a96a3; }
.cb-chip input { width: 18px; height: 18px; accent-color: var(--closed); }
.cb-chip:has(input:checked) { border-color: var(--closed); background: var(--closed-bg); }
.note-toggle { font-size: .8rem; }

.remarks-row, .table-row { display: grid; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.remarks-row { grid-template-columns: 90px 1fr auto; }
.table-row { grid-template-columns: 80px 110px 1.4fr 1.4fr auto; }
.table-row.has-result { grid-template-columns: 80px 185px 110px 1.3fr 1.3fr auto; }
.result-choices { display: flex; gap: .25rem; }
.table-scroll { overflow-x: auto; }
@media screen and (min-width: 761px) {
  .table-row.section-columns { grid-template-columns: 80px 185px 90px 80px 240px 60px 140px 70px 140px 130px 130px 170px 170px 180px auto; min-width: 1905px; }
  .table-row.section-columns.with-artikelnr { grid-template-columns: 80px 185px 90px 80px 120px 240px 60px 140px 70px 140px 130px 130px 170px 170px 180px auto; min-width: 2025px; }
}
.table-row.head { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.table-row .center { display: flex; justify-content: center; }
.table-row input[type=checkbox] { width: 22px; height: 22px; min-height: 0; }

.sig-wrap { border: 1px dashed #9fb0c2; border-radius: 8px; background: #fbfcfd; position: relative; touch-action: none; }
.sig-wrap canvas { display: block; width: 100%; height: 160px; }
.sig-wrap .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #9fb0c2; pointer-events: none; }
.sig-sub { margin: 1.25rem 0 .6rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.kund-ej-note { margin-top: .75rem; padding: .6rem .85rem; border-radius: 8px; background: #eef1f4; color: #5d6b7a; font-size: .9rem; }
.sig-img { max-height: 110px; max-width: 100%; }

.savebar { position: sticky; bottom: 0; background: rgba(243,245,248,.95); backdrop-filter: blur(4px); border-top: 1px solid var(--border); padding: .75rem 0; margin-top: 1.25rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; z-index: 10; }
.savebar .state { font-size: .85rem; color: var(--muted); margin-right: auto; }
.locked-note { background: var(--closed-bg); color: var(--closed); border-radius: 8px; padding: .6rem .9rem; font-weight: 600; margin-bottom: 1rem; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 26, 38, .45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 1rem; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal header h2 { margin: 0; }
.modal header button { margin-left: auto; }
.modal .body { padding: 1.25rem; }
.modal footer { padding: .9rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; }
.error { background: var(--danger-bg); color: var(--danger); padding: .55rem .8rem; border-radius: 8px; font-size: .88rem; margin-bottom: .85rem; }
#toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%) translateY(150%); background: var(--navy); color: #fff; padding: .7rem 1.1rem; border-radius: 8px; transition: transform .2s, opacity .2s; z-index: 60; opacity: 0; pointer-events: none; max-width: calc(100% - 2rem); }
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.err { background: var(--danger); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(160deg, var(--navy) 0%, #1d4a75 100%); }
.login .card { width: 100%; max-width: 380px; padding: 2rem; }
.login .logo { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.5rem; }
.login .logo strong { font-size: 1.15rem; display: block; }
.login .login-logo { height: 72px; width: auto; }
/* Startsidan efter inloggning: Service appen och Jeeves UPD. */
.launcher .card { max-width: 820px; }
.launcher-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.launcher-tile { display: flex; flex-direction: column; align-items: center; gap: .45rem; text-align: center; padding: 1.4rem 1rem;
  border: 1px solid var(--border, #d6dde6); border-radius: 12px; color: inherit; text-decoration: none; background: var(--surface, #fff); }
.launcher-tile:hover, .launcher-tile:focus-visible { border-color: var(--primary); box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.launcher-tile strong { font-size: 1.1rem; }
.launcher-icon { display: inline-flex; width: 64px; height: 64px; border-radius: 16px; align-items: center; justify-content: center; background: var(--navy); color: #fff; }
.launcher-icon svg { width: 36px; height: 36px; }
.jeeves-topbar .brand small { font-weight: 700; }
.login form > * + * { margin-top: .9rem; }
.login button { width: 100%; justify-content: center; min-height: 44px; }

/* ---------- print document ---------- */
.print-doc { background: #fff; max-width: 820px; margin: 0 auto; padding: 2rem; color: #000; font-size: 12.5px; }
.print-doc header { display: flex; align-items: center; border-bottom: 3px solid var(--navy); padding-bottom: .75rem; margin-bottom: 1rem; }
.print-doc header .t { margin-left: auto; text-align: right; }
.print-doc header .t strong { font-size: 1.15rem; display: block; }
.print-doc table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.print-doc th, .print-doc td { border: 1px solid #9aa7b4; padding: .3rem .45rem; text-align: left; vertical-align: top; }
.print-doc th { background: #e9eef3; font-size: 11px; }
.print-doc .meta td:nth-child(odd) { background: #f4f6f8; font-weight: 600; width: 18%; }
.print-doc h3 { background: var(--navy); color: #fff; padding: .3rem .5rem; margin: 1rem 0 0; font-size: 12.5px; }
.print-doc .box { text-align: center; width: 52px; font-weight: 700; }
.print-doc .sign td { height: 60px; }
.print-actions { max-width: 820px; margin: 1rem auto; display: flex; gap: .5rem; padding: 0 1rem; }

/* ---------- kundrapport (efter BIAB:s blankett "Protokoll avtalsservice inbrott, kombilarm") ---------- */
.mail-hint { margin-top: -.5rem; display: block; }
.kund-doc { position: relative; background: #fff; max-width: 820px; margin: 0 auto 2rem; padding: 2rem 2.4rem; color: #000; font-family: Arial, Helvetica, sans-serif; font-size: 12.5px; box-shadow: var(--shadow); }
.kund-doc header { display: grid; grid-template-columns: 170px 1fr; align-items: center; margin-bottom: 1.6rem; }
.kund-doc .klogo { width: 150px; }
.kund-doc h1 { font-size: 19px; text-align: center; white-space: pre-line; line-height: 1.25; margin-right: 170px; }
.khead { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem 1.5rem; margin-bottom: .9rem; }
.kf { display: grid; grid-template-columns: max-content 1fr; gap: .4rem; align-items: baseline; }
.kf > span:first-child { min-width: 110px; text-align: right; }
.kbox { display: inline-flex; width: 13px; height: 13px; border: 1px solid #000; align-items: center; justify-content: center; font-size: 11px; line-height: 1; margin: 0 .2rem 0 .35rem; vertical-align: -2px; }
.ktab { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.ktab th { font-weight: 400; font-size: 9.5px; text-align: left; border: 1px solid #000; padding: 1px 4px; }
.ktab td { border: 1px solid #000; padding: 2px 5px; font-size: 13px; vertical-align: top; }
.ktab .pos { width: 52px; }
.ktab .kc { width: 78px; text-align: center; }
.ktab .kc .kbox { width: 14px; height: 14px; margin: 0; }
.ksign { margin-top: 2.2rem; font-size: 11px; }
.ksign p { margin: 0 0 1.6rem; }
.ksign .kf { grid-template-columns: 90px 1fr; margin-bottom: 1.2rem; }
.ksign .kf > span:first-child { text-align: left; min-width: 0; }
.ksign img { max-height: 55px; }
.kund-doc footer { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.2fr 1fr; gap: .6rem; border-top: 2px solid #000; padding-top: .4rem; margin-top: 2rem; font-size: 10.5px; white-space: pre-line; }
.kcert { width: 100%; margin-top: .9rem; }
.utkast { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-28deg); font-size: 96px; font-weight: 800; color: rgba(200, 16, 46, .1); pointer-events: none; letter-spacing: 8px; }

.dev-banner {
  position: fixed;
  right: max(.75rem, env(safe-area-inset-right));
  bottom: max(.75rem, env(safe-area-inset-bottom));
  z-index: 25;
  padding: .35rem .6rem;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 6px;
  background: var(--navy);
  color: #fff;
  font: 11px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
  box-shadow: 0 2px 8px rgba(15, 42, 68, .15);
  pointer-events: none;
}

@media print {
  .dev-banner { display: none !important; }
  .mail-hint { display: none !important; }
  .kund-doc { box-shadow: none; padding: 0; max-width: none; margin: 0; }
  .kbox, .utkast { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; }
  .topbar, .print-actions, #toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .print-doc { padding: 0; max-width: none; }
  .print-doc h3 { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-doc th, .print-doc .meta td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  tr { break-inside: avoid; }
}

/* ---------- responsive ---------- */
@media (max-width: 80rem) {
  .topbar { gap: .5rem; }
  .menu-btn { display: inline-flex; flex-shrink: 0; }
  .brand small { display: none; }
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--navy); flex-direction: column; padding: .5rem; margin: 0;
    max-height: calc(100vh - 56px); max-height: calc(100dvh - 56px); overflow-y: auto; overscroll-behavior: contain; }
  .nav.open { display: flex; }
  .nav > a, .nav-menu summary { min-height: 44px; display: flex; align-items: center; }
}
@media (max-width: 900px) {
  .userbox .who { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .proto-meta { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  main { padding: 1rem 1rem 4rem; }
  .topbar { padding: 0 .75rem; }
  .page-head .actions { width: 100%; margin-left: 0; }
  .kpis { gap: .5rem; grid-template-columns: repeat(2, 1fr); }
  .kpi { padding: .8rem; }
  .kpi .value { font-size: 1.9rem; }
  .kpi .label { font-size: .8rem; }
  .form-grid { grid-template-columns: 1fr; }
  .check-item { grid-template-columns: minmax(1.6rem, max-content) 1fr; }
  .check-item .opts { grid-column: 2; }
  .table-row, .table-row.has-result, .table-row.section-columns { grid-template-columns: 44px 1fr auto; }
  .table-row.head { display: none; }
  .table-row .benamning, .table-row .anm { grid-column: 1 / -1; }
  .hide-sm { display: none; }
  .reports { grid-template-columns: minmax(0, 1fr); }
  .proto-list li { flex-wrap: wrap; }
  .proto-list .grow { flex-basis: 100%; }
  .todo li { flex-wrap: wrap; }
  .todo .grow { flex-basis: 100%; }
  .kund-doc { padding: 1rem; overflow-x: auto; }
  .kund-doc header, .khead { grid-template-columns: 1fr; }
  .kund-doc h1 { margin: .5rem 0 0; }
  .kund-doc footer { grid-template-columns: 1fr 1fr; }
  .proto-progress { padding: .5rem .75rem; gap: .5rem; }
  .toolbar input[type=search], .toolbar select { max-width: none; flex: 1 1 140px; }
}

/* Avslutsdialog: val av åtgärd för rapporten */
.choices { display: grid; gap: .5rem; }
.choice { display: flex; gap: .75rem; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: .75rem .9rem; cursor: pointer; }
.choice input { width: 20px; height: 20px; min-height: 0; margin-top: .1rem; flex: none; accent-color: var(--primary); }
.choice > span { display: flex; flex-direction: column; gap: .15rem; }
.choice:has(input:checked) { border-color: var(--primary); background: #eef4fc; }
.action-note { background: #eef4fc; border: 1px solid #b9d0ee; border-radius: 8px; padding: .65rem .9rem; color: #173a5c; display: block; }
@media print { .action-note { display: none !important; } }

/* Mallkategorier: Interna mallar / Externa/Kundmallar */
.tpl-group { margin: 1rem 0 .5rem; padding-left: .6rem; border-left: 3px solid var(--c, var(--muted)); }
.tpl-group:first-child { margin-top: 0; }
.tpl-group h3 { margin: 0; font-size: .92rem; }
.tpl-group.cat-intern { --c: #64748b; }
.tpl-group.cat-extern { --c: var(--primary); }
.badge.cat-intern { background: #eef1f5; color: #475569; }
.badge.cat-extern { background: #e7f0fb; color: var(--primary); }

/* Admin-meny i navigeringen */
.nav-menu { position: relative; }
.nav-menu summary { list-style: none; cursor: pointer; color: #cfdbe8; padding: .45rem .75rem; border-radius: 6px; font-weight: 500; user-select: none; }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu summary::after { content: " ▾"; font-size: .75em; }
.nav-menu summary:hover, .nav-menu[open] summary { background: var(--navy-2); color: #fff; }
.nav-menu summary.active { background: var(--navy-2); color: #fff; box-shadow: inset 0 -2px 0 var(--red); }
.nav-menu .menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(15, 42, 68, .18); padding: .35rem; z-index: 30; display: flex; flex-direction: column; }
.nav-menu .menu a { color: var(--text); padding: .55rem .75rem; border-radius: 6px; font-weight: 500; }
.nav-menu .menu a:hover { background: #f1f4f8; text-decoration: none; }
.nav-menu .menu a.active { background: #eef4fc; color: var(--primary); box-shadow: none; }
@media (max-width: 80rem) {
  .nav-menu .menu { position: static; background: transparent; border: 0; box-shadow: none; padding: 0 0 0 .75rem; min-width: 0; }
  .nav-menu .menu a { color: #cfdbe8; }
  .nav-menu .menu a:hover, .nav-menu .menu a.active { background: var(--navy-2); color: #fff; }
}

/* Admin: mallar och kategorier */
.admin-cats { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.admin-cat { border-top: 4px solid var(--c); }
.admin-cats > .card + .card { margin-top: 0; }
.admin-cat.cat-intern { --c: #64748b; }
.admin-cat.cat-extern { --c: var(--primary); }
.admin-cat-count { margin: 1.1rem 0 .25rem; padding-top: .9rem; border-top: 1px solid var(--border); font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
@media (max-width: 900px) { .admin-cats { grid-template-columns: 1fr; } }

/* Admin: frågeregister */
.q-list-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.info-note { background: #eef4fc; border: 1px solid #b9d0ee; border-radius: 8px; padding: .7rem .95rem; color: #173a5c; font-size: .9rem; margin-bottom: 1rem; }
.q-sec .section-title { margin-bottom: .75rem; }
.q-row { display: grid; grid-template-columns: 2rem 1fr auto; gap: .75rem; padding: .7rem 0; border-top: 1px solid #eef1f5; align-items: start; }
.q-no { font-weight: 700; color: var(--muted); padding-top: .55rem; text-align: right; }
.q-main { display: grid; gap: .35rem; }
.q-main textarea { min-height: 0; resize: vertical; }
.q-main input { font-size: .85rem; min-height: 32px; padding: .3rem .6rem; }
.q-photo-option { display: flex; align-items: center; gap: .5rem; font-size: .85rem; cursor: pointer; }
.q-photo-option input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--primary); }
.q-tags { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.q-tags:empty { display: none; }
.q-actions { display: flex; gap: .3rem; padding-top: .2rem; }
.q-actions .btn-sm { min-width: 34px; justify-content: center; }
.q-row.is-hidden .q-main textarea, .q-row.is-hidden .q-main input { background: #f3f5f8; color: #8a96a3; text-decoration: line-through; }
.q-add { margin-top: .75rem; }
.state.warn { color: var(--progress); font-weight: 600; }
@media (max-width: 760px) {
  .q-row { grid-template-columns: 1.5rem 1fr; }
  .q-actions { grid-column: 2; }
}

.q-fields { display: grid; gap: 0; }
.q-field-row { display: flex; gap: .75rem; align-items: baseline; padding: .5rem 0; border-top: 1px solid #eef1f5; flex-wrap: wrap; }
.q-field-row strong { min-width: 160px; }

/* Kundrapport: extra fältblock under huvudet (t.ex. VMS-system för kamera) */
.kund-doc .kextra { margin-top: -.25rem; }
.kund-doc .kextra .ktitle { grid-column: 1 / -1; font-weight: 700; font-size: 12px; margin-bottom: .1rem; }

/* Sökbart fält mot anläggningsregistret (Objektnamn/nr) */
.fac-wrap { position: relative; margin-top: .25rem; }
.fac-suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(15, 42, 68, .18); max-height: 320px; overflow-y: auto; padding: .25rem; }
.fac-opt { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; width: 100%; border: 0; background: transparent; text-align: left; padding: .5rem .65rem; min-height: 0; border-radius: 6px; font-weight: 400; color: var(--text); }
.fac-opt:hover, .fac-opt.active { background: #eef4fc; }
.fac-hint { margin-top: .3rem; font-weight: 400; }
.contact-help { font-weight: 400; margin-bottom: .4rem; }
.journal-entry { display: grid; grid-template-columns: 9rem 1fr 1fr auto auto; gap: .6rem; align-items: end; margin-bottom: 1rem; }
.journal-fire { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .6rem; align-items: end; }
.journal-entry-error { grid-column: 1 / -1; scroll-margin-bottom: 6rem; }
.journal-sign { padding: .55rem 0; font-weight: 500; color: var(--text); white-space: nowrap; }
.journal-entry .field-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: .82rem; font-weight: 600; color: var(--muted); }
.journal-entry .field-head + input { margin-top: .25rem; }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--primary); font-size: .78rem; font-weight: 500; text-decoration: underline; cursor: pointer; }
.control-type-list { list-style: none; margin: .5rem 0 1rem; padding: 0; display: grid; gap: .25rem; }
.control-type-list li { display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid var(--border); }
.control-type-choice { flex: 1; min-width: 0; justify-content: flex-start; text-align: left; white-space: normal; overflow-wrap: anywhere; }
.journal-specific { margin: 0; padding-left: 1.2rem; display: grid; gap: .3rem; }
.journal-note { margin: 1rem 0 0; }
.tpl-inactive .grow { opacity: .55; }
.badge.tpl-off { background: #e8ecf0; color: #4b5866; }
.remark-presets { margin: .5rem 0 .25rem; }
.remark-presets .checks { margin-top: .35rem; }
.remark-add { margin: .5rem 0 0; }
.login-update { margin-top: .75rem; width: 100%; justify-content: center; }
.character-row { display: grid; grid-template-columns: 7rem 1fr 1fr auto; gap: .4rem; margin-bottom: .4rem; }
.character-row input { min-width: 0; }
@media (max-width: 640px) { .character-row { grid-template-columns: 1fr auto; } .character-row input { grid-column: 1; } .character-row button { grid-column: 2; grid-row: 1 / span 3; } }
table.collapsed tbody tr:nth-child(n+4) { display: none; }
.cases-toggle { margin-top: .5rem; width: 100%; justify-content: center; }
.section-status { margin-top: .75rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 8px; }
.section-status[hidden] { display: none; }
.section-head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.section-subhead { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: .25rem 0 .75rem; }
.section-scroll-nav { display: flex; gap: .25rem; }
.section-scroll-nav[hidden] { display: none; }
.section-scroll { max-height: 70vh; overflow: auto; }
.section-scroll thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); box-shadow: inset 0 -1px 0 var(--border); }
@media (min-width: 641px) {
  :where(.pin-5, .pin-6) tr > :nth-child(-n+5), :where(.pin-6) tr > :nth-child(6) { position: sticky; z-index: 1; background: var(--surface); }
  :where(.pin-5, .pin-6) tr > :nth-child(1) { left: var(--pin-0); }
  :where(.pin-5, .pin-6) tr > :nth-child(2) { left: var(--pin-1); }
  :where(.pin-5, .pin-6) tr > :nth-child(3) { left: var(--pin-2); }
  :where(.pin-5, .pin-6) tr > :nth-child(4) { left: var(--pin-3); }
  :where(.pin-5, .pin-6) tr > :nth-child(5) { left: var(--pin-4); }
  :where(.pin-6) tr > :nth-child(6) { left: var(--pin-5); box-shadow: 1px 0 0 var(--border); }
  :where(.pin-5) tr > :nth-child(5) { box-shadow: 1px 0 0 var(--border); }
  .section-scroll thead th:nth-child(-n+6) { z-index: 3; }
}
#save-section-cells[hidden], #delete-section-rows[hidden], #copy-section-rows[hidden] { display: none; }
.section-select { width: auto; min-height: 0; margin: .3rem 0 0; }
.section-sort { background: none; border: 0; padding: 0; min-height: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; white-space: nowrap; }
.section-sort:hover { background: none; color: var(--text, inherit); text-decoration: underline; }
.section-cell { width: 100%; min-width: 5.5rem; min-height: 0; padding: .25rem .35rem; border: 1px solid transparent; border-radius: 4px; background: transparent; font: inherit; }
.section-cell:hover { border-color: var(--border); }
.section-cell:focus { border-color: var(--border); background: #fff; }
.section-cell[data-k="omrade"], .section-cell[data-k="placering"] { min-width: 9rem; }
/* Artikelnamn får plats för långa produktnamn; Anl.nr och Antal är korta. */
.section-cell[data-k="artikel"] { min-width: 17rem; }
.section-cell[data-k="anl_nr"] { min-width: 4.5rem; }
.section-cell[data-k="antal"] { min-width: 3.5rem; }
#section-table th, #section-table td { padding-left: .3rem; padding-right: .3rem; }
.section-cell[data-k="installationsdatum"], .section-cell[data-k="ip"] { min-width: 7.5rem; }
.section-cell[data-k="kommentar"] { min-width: 14rem; }
.section-import { margin-top: .75rem; }
.section-import summary { cursor: pointer; font-weight: 600; }
.section-import textarea { width: 100%; margin-top: .5rem; }
.section-template { margin-top: .5rem; }
.section-row { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: .4rem; padding-bottom: .5rem; margin-bottom: .5rem; border-bottom: 1px solid var(--border); }
.section-row input { min-width: 0; }
.section-row input.wide { grid-column: span 2; }
.section-row button { grid-column: 5; grid-row: 1 / span 3; align-self: center; }
@media (max-width: 640px) { .section-row { grid-template-columns: 1fr auto; } .section-row input, .section-row input.wide { grid-column: 1; } .section-row button { grid-column: 2; grid-row: 1 / span 10; } }
.qr-box { display: flex; justify-content: center; }
.qr-box svg { width: 220px; height: 220px; }
.qr-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }
@media (max-width: 760px) { .journal-entry { grid-template-columns: 1fr; } }
.contact-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: .4rem; padding-bottom: .5rem; margin-bottom: .5rem; border-bottom: 1px solid var(--border); }
.contact-row button { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
.contact-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
@media (max-width: 640px) { .contact-row { grid-template-columns: 1fr auto; } .contact-row input { grid-column: 1; } .contact-row button { grid-column: 2; grid-row: 1 / span 4; } }
.field.fac-search { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); }
.fac-opt strong { color: var(--text); }

/* Ärendevyn: statusflöde Öppen → Pågående → 25 Slutförd av tekniker → Avslutad */
.flow { list-style: none; margin: 0 0 1rem; padding: 0; }
.flow li { --c: #b7c2cd; position: relative; display: flex; gap: .7rem; padding: 0 0 .85rem; color: var(--muted); }
.flow li:last-child { padding-bottom: 0; }
.flow li:not(:last-child)::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 2px; background: #dde3ea; }
.flow li.done:not(:last-child)::before { background: var(--c); }
.flow .dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--c); background: #fff; flex: none; margin-top: 2px; }
.flow li > div { display: flex; flex-direction: column; line-height: 1.3; }
.flow li strong { font-weight: 600; }
.flow li.done, .flow li.current { color: var(--text); }
.flow li.done .dot { background: var(--c); }
.flow li.current .dot { background: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent); }
.flow li.current strong { font-weight: 700; color: var(--c); }
.flow li.registrerad { --c: #64748b; }
.flow li.oppen { --c: var(--open); }
.flow li.pagaende { --c: var(--progress); }
.flow li.signerad { --c: var(--signed); }
.flow li.pausad { --c: var(--paused); }
.flow li.avslutad { --c: var(--closed); }
@media (max-width: 760px) {
  /* Protokollrader på ärendesidan: knapparna bryts under texten i stället för att göra sidan bredare än skärmen. */
  .item-row { flex-wrap: wrap; }
  .item-row > .grow { flex-basis: 100%; }
}

/* Hopp till en sektion (t.ex. underskriften via "25 Slutförd av tekniker") hamnar under den fasta förloppsraden. */
#proto-body > section { scroll-margin-top: 130px; }

.report.pausad { border-left-color: var(--paused); }
.report.pausad .pct { color: var(--paused); }
@media (max-width: 1100px) and (min-width: 761px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
/* Microsoft profile images and initials share the same compact layout. */
.avatar { position:relative; display:inline-flex; align-items:center; justify-content:center; flex:0 0 34px; width:34px; height:34px; border-radius:50%; overflow:hidden; background:#0078d4; color:#fff; font-weight:600; font-size:14px; line-height:1; vertical-align:middle; }
.avatar img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; opacity:0; }
.avatar img.loaded { opacity:1; }
.avatar-lg { flex-basis:72px; width:72px; height:72px; font-size:28px; }
.person { display:inline-flex; align-items:center; gap:10px; }
.person small { display:block; }
.profile-heading { display:flex; margin-bottom:20px; }
.microsoft-login { display:flex; align-items:center; justify-content:center; text-decoration:none; margin:18px 0; min-height:44px; }
.recovery-login { margin-top:20px; border-top:1px solid var(--border, #dce3ea); padding-top:16px; }
.recovery-login summary { cursor:pointer; font-size:14px; }
.recovery-login form { margin-top:14px; }
.connection-details { display:grid; grid-template-columns:max-content minmax(0,1fr); gap:8px 18px; font-size:13px; }
.connection-details dd { margin:0; overflow-wrap:anywhere; }
@media(max-width:600px) { .connection-details { grid-template-columns:1fr; gap:4px; } .connection-details dd { margin-bottom:10px; } }

/* Admin: auditlogg */
.audit-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem 1rem; margin: 1rem 0 1.4rem; }
.audit-filter-actions, .audit-paging, .audit-retention { display: flex; align-items: flex-end; flex-wrap: wrap; gap: .6rem; }
.audit-paging { align-items: center; justify-content: flex-end; margin-top: 1rem; }
.audit-paging > span { margin-right: auto; }
.audit-retention input { max-width: 12rem; }
.audit-table { table-layout: fixed; width: 100%; }
.audit-table td, .audit-table th { overflow-wrap: anywhere; vertical-align: top; }
.audit-table th:nth-child(1) { width: 14%; }
.audit-table th:nth-child(2) { width: 21%; }
.audit-table th:nth-child(3) { width: 22%; }
.audit-table th:nth-child(4) { width: 12%; }
.audit-table th:nth-child(5) { width: 13%; }
.audit-code { margin-top: .2rem; }
.audit-detail summary { cursor: pointer; color: var(--primary); }
.audit-detail[open] { min-width: 0; }
.audit-detail .connection-details { grid-template-columns: minmax(0, 1fr); gap: .3rem; margin-bottom: .7rem; }
.audit-detail dt { font-weight: 600; }
.audit-detail dd { margin-bottom: .4rem; }
.audit-detail pre { font-size: .75rem; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.audit-success { background: #e7f4ed; color: #24633d; }
.audit-failure { background: #fdebea; color: #a32d30; }
.audit-denied { background: #fff3d8; color: #78520c; }
.audit-empty { padding: 1rem 0; }
@media (max-width: 1000px) {
  .audit-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-table, .audit-table tbody, .audit-table tr, .audit-table td { display: block; }
  .audit-table thead { display: none; }
  .audit-table tr { border-top: 1px solid var(--border); padding: .6rem 0; }
  .audit-table td { display: grid; grid-template-columns: 6rem minmax(0, 1fr); gap: .5rem; border: 0; padding: .35rem 0; }
  .audit-table td::before { content: attr(data-label); font-weight: 600; color: var(--muted); }
  .audit-table td > .audit-code { grid-column: 2; }
  .audit-table td > .badge { justify-self: start; }
}
@media (max-width: 600px) {
  .audit-filters { grid-template-columns: minmax(0, 1fr); }
  .audit-retention { align-items: stretch; flex-direction: column; }
  .audit-retention input { max-width: none; }
}

/* Kontrolljournal öppnad från ett ärende för status 25 */
.journal-case-note { margin-bottom: 1rem; border-left: 4px solid var(--primary); display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline; }

/* Admin: hämtning från Jeeves */
.jeeves a.seg { display: inline-flex; align-items: center; color: var(--muted); text-decoration: none; border-radius: 7px; }
.jeeves a.seg.on { color: var(--primary); }
.jeeves input[type=checkbox], .jeeves input[type=radio] { width: auto; min-height: 0; margin: 0; }
.jeeves-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.jeeves-check { display: inline-flex; align-items: center; gap: .35rem; font-weight: 500; white-space: nowrap; cursor: pointer; }
.jeeves-group .section-head { flex-wrap: wrap; }
.jeeves-group .jeeves-all { margin-left: auto; font-size: .88rem; }
table.jeeves-items td.pick { width: 2.2rem; padding-top: .8rem; }
table.jeeves-items tr.jv-off { display: none; }
.jv-facilities .section-head { flex-wrap: wrap; gap: .5rem; }
.jv-fac-list { max-height: 18rem; overflow: auto; border: 1px solid var(--border, #ddd); border-radius: 6px; padding: .25rem .5rem; }
.jv-fac-list label { display: flex; gap: .5rem; align-items: center; padding: .25rem 0; cursor: pointer; }
.jv-fac-list [data-fac-row][hidden], .jv-fac-list [data-fac-row].jv-noavtal { display: none; }
.jv-fac-list input[type=checkbox] { width: auto; min-height: 0; margin: 0; flex: none; }
table.jeeves-items td { padding-top: .5rem; padding-bottom: .5rem; }
.jeeves-fields { font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.jeeves-fields del { color: var(--danger); }
.jeeves-fields ins { color: var(--closed); text-decoration: none; }
.jeeves-label { color: var(--text); font-weight: 600; }
.jeeves-conflict { display: flex; flex-wrap: wrap; gap: .3rem 1rem; align-items: center; margin: .2rem 0; }
.jeeves-conflict label { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; color: var(--text); }
.jeeves-colsel { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.jeeves-colsel select { width: auto; min-width: 11rem; max-width: 100%; }
table.jeeves-fieldmap tr.jeeves-off td { color: var(--muted); }
table.jeeves-fieldmap tr.jeeves-off select { opacity: .6; }
.jeeves-status { max-width: 28rem; }
.jeeves-result { border-left: 4px solid var(--closed); }
.jeeves-result.has-errors { border-left-color: var(--danger); }
.jeeves-list { margin: .25rem 0 .75rem; padding-left: 1.2rem; max-height: 18rem; overflow: auto; }

/* Kunddokument: behåll filnamnen läsbara även på telefon. */
.docs-list td:first-child { overflow-wrap: anywhere; }
.docs-list td:first-child a { display: inline-block; padding: .45rem 0; }
.docs-preview h2 { overflow-wrap: anywhere; }
.docs-image { display: block; max-width: 100%; height: auto; margin: auto; }
.docs-pdf-paper { overflow: auto; padding: .75rem; background: #e6e8ed; border-radius: .5rem; }
.docs-pdf-paper canvas { display: block; margin: auto; background: white; }
.docs-pdf-controls { flex-wrap: wrap; margin-bottom: .75rem; align-items: center; }
@media (max-width: 700px) {
  .docs-preview .section-head { align-items: stretch; flex-direction: column; }
  .docs-preview .actions { flex-wrap: wrap; }
}

@media print { .no-print, .jeeves-topbar { display: none !important; } .offer-material { box-shadow: none; border: 0; } }

/* Offert › Artikelregister: bred tabell med kalkylens kolumner. Sidan får hela bredden, tabellen rullar i sidled och
   höjdled inom rutan med fast rubrikrad och fast artikelnummer, så att rullningslisten alltid syns. */
main:has(.wide-register) { max-width: none; }
/* HSEQ: incidentlistan använder hela skärmbredden, så att alla kolumner syns. */
main:has(.hseq-list) { max-width: none; }
.hseq-list table.list thead th, .hseq-list .section-sort { white-space: normal; vertical-align: bottom; }
.hseq-list table.list td { vertical-align: top; }
.hseq-list table.list td:not(.nowrap) { white-space: normal; min-width: 5rem; }
/* HSEQ: rapport över öppna incidenter (skärm och utskrift). */
.hseq-report { max-width: 1000px; }
/* Artikelregistret: artikelbilden som i Jeeves, i grupper. */
.modal:has(.article-card) { max-width: 1100px; }
.modal:has(.enr-avvik) { max-width: 1200px; }
.enr-avvik { max-height: 60vh; overflow-y: auto; }
.enrlev-rad { white-space: nowrap; }
.enr-sum tr.enr-vald td { background: #eef3fb; font-weight: 600; }
/* Artikelkortet: bildplatsen. */
.article-bild { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem .75rem; margin: .75rem 0; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.article-bild legend { font-weight: 600; padding: 0 .3rem; }
.article-bild-box { width: 180px; height: 140px; border: 2px dashed var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center;
  background: #f7f9fc; overflow: hidden; }
.article-bild-box.drag { border-color: #2f6fd1; background: #eef3fb; }
.article-bild-box img { max-width: 100%; max-height: 136px; object-fit: contain; display: block; }
.article-bild-actions { display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; flex: 1; min-width: 200px; }
.enrlev-fel { color: #b42318; font-weight: 600; text-decoration: underline wavy; text-underline-offset: 3px; }
/* Samma E-nummer: varannan E-nummergrupp tonad så att grupperna syns. */
.enrd-udda td { background: var(--surface-2, #f4f6f8); }
.article-card { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .75rem; margin: 1rem 0; }
.ja-group { border: 1px solid var(--border); border-radius: 8px; padding: .4rem .75rem .6rem; margin: 0; min-width: 0; }
.ja-group legend { font-weight: 600; padding: 0 .3rem; }
.ja-row { display: grid; grid-template-columns: 9.5rem 1fr; gap: .5rem; padding: .2rem 0; align-items: baseline; }
.ja-row span { color: var(--muted, #5b6675); font-size: .9em; }
.ja-row output { min-height: 1.6em; padding: .1rem .4rem; background: #f4f6f9; border-radius: 4px; overflow-wrap: anywhere; }
.ja-all { margin-top: 1rem; }
/* Artikelregistret: inforuta med anläggningarna som har artikeln. */
.anl-hover { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; padding: .1rem .3rem; border-radius: 4px; }
.anl-hover:hover, .anl-hover:focus { background: #eef3fb; outline: none; }
.anl-tip { position: absolute; z-index: 50; max-width: min(420px, 92vw); max-height: 320px; overflow-y: auto; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: .6rem .75rem; font-size: .9rem; text-align: left; }
.anl-tip ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.anl-tip li { margin: .15rem 0; }
.anl-tip p { margin: .4rem 0 0; }
/* UPD Jeeves: fält som skickas, tiderna var för sig under sin grupp. */
.upd-grupp { display: flex; flex-direction: column; gap: .2rem; }
.upd-sub { display: flex; flex-wrap: wrap; gap: .25rem 1.2rem; padding-left: 1.6rem; }
/* Artikelregistret: val av flera produktklasser. */
.pk-pick { position: relative; }
.pk-pick > summary { list-style: none; cursor: pointer; white-space: nowrap; }
.pk-pick > summary::-webkit-details-marker { display: none; }
.pk-menu { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; width: min(380px, 90vw); background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: .6rem; display: flex; flex-direction: column; gap: .5rem; }
.pk-tools { display: flex; gap: .4rem; }
.pk-tools input { flex: 1; min-width: 0; }
.pk-list { max-height: 340px; overflow-y: auto; }
.pk-item { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem; align-items: center; padding: .25rem .2rem; cursor: pointer; }
.pk-item[hidden] { display: none; }
.pk-item:hover { background: #f4f6f9; }
/* UPD Jeeves. */
.upd-target { padding: .5rem .75rem; border-left: 4px solid #c27c0e; background: #fff7e6; border-radius: 4px; }
.upd-falt { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; display: flex; flex-direction: column; gap: .35rem; margin: 0; }
.upd-falt legend { font-weight: 600; padding: 0 .3rem; }
.upd-done { font-weight: 600; color: #1d6b35; }
.ja-src { grid-column: 1 / -1; margin: 0; }
.ja-all summary { cursor: pointer; }
.hseq-report h3 { margin: 1.25rem 0 .5rem; }
.hseq-sums { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.hseq-sums > div { min-width: 14rem; }
.hseq-sum td { padding: .25rem .5rem; }
.hseq-overview td { white-space: normal; }
.hseq-incident { border-top: 1px solid #d0d5dc; padding: .75rem 0; break-inside: avoid; }
.hseq-incident h4 { margin: 0 0 .35rem; }
.hseq-meta { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin-bottom: .5rem; }
.hseq-field { margin: .35rem 0; }
@media print { .hseq-report { max-width: none; } .hseq-overview a { color: inherit; text-decoration: none; } }
.wide-register .table-wrap { max-height: calc(100vh - 290px); min-height: 320px; overflow: auto; }
.wide-register table.list { font-size: .85rem; }
.wide-register table.list th, .wide-register table.list td { padding: .45rem .5rem; }
.wide-register table.list thead th { position: sticky; top: 0; z-index: 2; background: #fff; white-space: normal; min-width: 4.5rem; vertical-align: bottom; }
.wide-register table.list td:nth-child(5) { min-width: 14rem; }
.wide-register table.list th:nth-child(-n+3), .wide-register table.list td:nth-child(-n+3) { position: sticky; z-index: 1; background: inherit; }
.wide-register table.list th:nth-child(1), .wide-register table.list td:nth-child(1) { left: 0; }
.wide-register table.list th:nth-child(2), .wide-register table.list td:nth-child(2) { left: 2.2rem; }
.wide-register table.list th:nth-child(3), .wide-register table.list td:nth-child(3) { left: 5rem; }
.wide-register table.list thead th:nth-child(-n+3) { z-index: 3; }
.wide-register table.list tbody tr { background: #fff; }
.wide-register table.list th:nth-child(1), .wide-register table.list td:nth-child(1) { box-sizing: border-box; width: 2.2rem; min-width: 2.2rem; max-width: 2.2rem; }
.wide-register table.list th:nth-child(2), .wide-register table.list td:nth-child(2) { box-sizing: border-box; width: 2.8rem; min-width: 2.8rem; max-width: 2.8rem; }

/* Grupperad vy: produktklassen som rad som fälls ut och ihop, som grupperna i kalkylens flikar. */
.wide-register .offart-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }
.wide-register table.list tr.offart-group td { position: static; width: auto; min-width: 0; max-width: none; background: #dfe8f3; padding: 0; border-top: 1px solid var(--border); }
.wide-register .offart-toggle { position: sticky; left: 0; display: inline-flex; align-items: baseline; gap: .35rem; background: none; border: 0; padding: .5rem .6rem; cursor: pointer; font: inherit; color: inherit; text-align: left; }
.wide-register .offart-arrow { display: inline-block; width: 1em; }

/* Admin Jeeves › Struktur jämför */
.stat-row { display: flex; gap: .75rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.stat-row .stat { padding: .75rem 1rem; min-width: 9rem; display: flex; flex-direction: column; }
.stat-row .stat strong { font-size: 1.4rem; }
tr.struktur-group td { background: #dfe8f3; }
.actions label.check { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; }

/* Jeeves UPD › Artiklar: bred tabell med fast rubrikrad som rullar inom rutan. */
main:has(.wide-table) { max-width: none; }
.wide-table .table-wrap { max-height: calc(100vh - 300px); min-height: 320px; overflow: auto; }
.wide-table table.list { font-size: .85rem; }
.wide-table table.list thead th { position: sticky; top: 0; z-index: 1; background: #fff; }
.wide-table td.ja-suppliers { min-width: 16rem; white-space: nowrap; }
.ja-col { display: block; font-size: .68rem; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); }
.ja-fields code { font-size: .8rem; }
/* Larmcentraler: en tbody per larmcentral, randig per larmcentral så att utfällda anläggningar hör till raden ovanför. */
table.list.ac-table > tbody td { border-bottom: 0; }
table.list.ac-table > tbody:nth-of-type(even) td { background: #eaf3fc; }
.ac-count { font-size: inherit; }
.ac-detail td { padding-top: 0; }
.ac-facilities { margin: 0; padding: 0 0 .25rem; list-style: none; columns: 2 22rem; column-gap: 2rem; }
.ac-facilities li { break-inside: avoid; padding: .15rem 0; }
.jeeves label.check { display: inline-flex; align-items: center; gap: .35rem; font-weight: 400; }
/* Kvartalsprov Brand: kvartal, summering och tidigare avprovade kvartal per rad. */
.kvartal-box { background: #eef4fc; border: 1px solid #b9d0ee; border-radius: 8px; padding: .6rem .9rem; margin-bottom: .75rem; }
.kvartal-box label { margin-right: .75rem; }
.kvartal-box p { margin: .4rem 0 0; }
.ok-note { color: var(--ok, #1e7b34); font-weight: 600; }
.kv-badge { display: block; font-size: .7rem; color: #173a5c; font-weight: 600; white-space: nowrap; }
.table-row.tested-before > div:not(.center) { opacity: .5; }
.table-row.tested-before input:not([type=checkbox]) { background: #f1f3f5; color: #6b7280; }
