/* ── CSS Variables ──────────────────────────────────────────────────────────── */
:root {
  --teal:          #005b89;
  --teal-dark:     #004972;
  --teal-light:    #e8f4fb;

  --bg:            #F3F4F6;
  --surface:       #FFFFFF;
  --sidebar-bg:    #FFFFFF;

  --text-primary:  #111827;
  --text-body:     #374151;
  --text-muted:    #6B7280;
  --text-faint:    #9CA3AF;

  --border:        #E5E7EB;
  --border-focus:  #005b89;

  --danger:        #dc2626;
  --danger-bg:     #fef2f2;

  --shadow-sm:     0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.07);
  --shadow-lg:     0 10px 30px rgba(0,0,0,0.14), 0 4px 10px rgba(0,0,0,0.08);

  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     14px;

  --sidebar-w:     280px;
  --header-h:      56px;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo-mark {
  width: 28px;
  height: 28px;
  background: var(--teal);
  border-radius: 7px;
  position: relative;
  flex-shrink: 0;
}
.header-logo-mark::after {
  content: '';
  position: absolute;
  inset: 5px;
  border: 2px solid rgba(255,255,255,0.6);
  border-radius: 3px;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── App body ────────────────────────────────────────────────────────────────── */
.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}

.sidebar-section {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-body);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-label-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover {
  background: var(--teal-light);
  border-color: var(--teal);
}

.vg-textarea {
  font-family: 'Courier New', 'Menlo', monospace;
  font-size: 12.5px;
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  resize: vertical;
  min-height: 140px;
  background: #FAFAFA;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.vg-textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,91,137,0.10);
  background: var(--surface);
}

.progress-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--teal);
  width: 0%;
  transition: width 0.18s ease;
  border-radius: 2px;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 0 16px;
}

.sidebar-info {
  padding-top: 12px;
}
.sidebar-hint {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.5;
}
.project-name-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: #FAFAFA;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.project-name-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,91,137,0.10);
  background: var(--surface);
}
.project-name-input::placeholder { color: var(--text-faint); font-weight: 400; }

.sidebar-hint kbd {
  font-family: inherit;
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: #FAFAFA;
  color: var(--text-muted);
}

/* ── Main area ───────────────────────────────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  gap: 12px;
}

.toolbar-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sort-select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface);
  outline: none;
  cursor: pointer;
  transition: border-color 0.12s;
}
.sort-select:focus { border-color: var(--teal); }

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 9px;
  color: var(--text-faint);
  pointer-events: none;
}
.search-input {
  padding: 6px 10px 6px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
  width: 180px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,91,137,0.10);
}
.search-input::-webkit-search-cancel-button { cursor: pointer; }

/* ── Page viewport ───────────────────────────────────────────────────────────── */
.page-viewport {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
  min-height: 0;
}

.page-scaler {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px;
  gap: 40px;
  min-height: 100%;
}

/* Page wrapper: sized to scaled A4 dimensions by JS */
.page-wrapper {
  position: relative;
  flex-shrink: 0;
  /* width/height set by JS */
}

/* The actual A4 page - scaled via transform */
.a4-page {
  position: absolute;
  top: 0;
  left: 0;
  width: 210mm;
  height: 297mm;
  background: white;
  transform-origin: top left;
  box-shadow: 0 4px 40px rgba(0,0,0,0.18), 0 1px 4px rgba(0,0,0,0.1);
  /* transform: scale(N) set by JS */
}

/* Page number label below each page */
.page-num {
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Label slot */
.label-slot {
  position: absolute;
  width: 85mm;
  height: 54mm;
  box-sizing: border-box;
  cursor: pointer;
  --ss: 1;
  /* left/top set per slot */
}
.label-slot[data-step="1"] { --ss: 0.85; }
.label-slot[data-step="2"] { --ss: 0.70; }

/* Empty slot: dashed border, subtle */
.label-slot.empty {
  border: 1.5px dashed #D1D5DB;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #E5E7EB;
  font-size: 8mm;
  font-weight: 300;
}

/* Filled slot */
.label-slot.filled {
  border: 1px dashed #C8CDD4;
  border-radius: 2px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.label-slot.filled:hover {
  border-color: rgba(0,91,137,0.45);
  border-style: solid;
}
.label-slot.filled.selected {
  border: 2px solid var(--teal);
  box-shadow: 0 0 0 2px rgba(0,91,137,0.15);
}

/* Label content - exact sign layout */
.label-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 3.5mm 3.5mm 3.5mm 7.5mm;
  font-family: Helvetica, Arial, sans-serif;
  overflow: hidden;
}

.label-text-area {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.4mm;
}

.sign-creator {
  font-size: calc(4.94mm * var(--ss));
  font-weight: 400;
  color: #000;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sign-title {
  font-size: calc(4.94mm * var(--ss));
  font-weight: 700;
  color: #000;
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-top: 0.5mm;
}
.sign-creator + .sign-creator,
.sign-title + .sign-title,
.sign-artform + .sign-artform { margin-top: 0; }

.sign-artform {
  font-size: calc(4.23mm * var(--ss));
  font-weight: 400;
  color: #000;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.8mm;
}
.sign-year {
  font-size: calc(3.53mm * var(--ss));
  font-weight: 400;
  color: #000;
  margin-top: 0.4mm;
}

.sign-bottom {
  height: 14mm;
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 1.5mm;  /* baseline för VG-nummer */
}
.sign-id {
  font-size: 2.47mm;
  font-family: Helvetica, Arial, sans-serif;
  color: #000;
  line-height: 1;
}
.sign-logo {
  height: 11mm;
  width: auto;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
  /* Logotypbilden har tomt utrymme undertill.
     margin-bottom kompenserar så att logotypens textdel
     linjerar med VG-numrets baslinje i preview (ca 135/454 px). */
  margin-bottom: -3.3mm;
}

/* Slot position badge (top-left corner, tiny) */
.slot-badge {
  position: absolute;
  top: 1mm;
  left: 1mm;
  font-size: 2mm;
  color: #C0C8D0;
  font-family: Helvetica, sans-serif;
  pointer-events: none;
  line-height: 1;
}

/* Drag state */
.label-slot[draggable="true"] { cursor: grab; }

.label-slot.dragging {
  opacity: 0.35;
  outline: 2px dashed var(--teal);
  outline-offset: 2px;
}

/* Insert-before indicator: teal line on the left edge of the drop target */
.label-slot.drag-over {
  background: rgba(0,91,137,0.06);
  box-shadow: -3px 0 0 0 var(--teal), 0 0 0 1px rgba(0,91,137,0.20);
}

/* Brief glow after a successful drop */
@keyframes slot-land {
  0%   { box-shadow: 0 0 0 4px rgba(0,91,137,0.45); }
  100% { box-shadow: none; }
}
.label-slot.just-dropped {
  animation: slot-land 0.55s ease-out forwards;
}

/* Edit popover */
.edit-popover {
  position: fixed;
  z-index: 500;
  width: 264px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid var(--border);
  overflow: hidden;
}

.popover-header {
  background: var(--teal);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pop-vg-badge {
  font-size: 11px;
  font-weight: 600;
  color: white;
  font-family: 'Courier New', monospace;
}
.pop-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.pop-close:hover { color: white; }

.popover-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.popover-body label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.popover-body input,
.popover-body textarea {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.12s;
}
.popover-body textarea {
  resize: vertical;
  min-height: 28px;
  line-height: 1.35;
}
.popover-body input:focus,
.popover-body textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(0,91,137,0.12);
}

.pop-step-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

.pop-step-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pop-step-btns {
  display: flex;
  gap: 3px;
}

.pop-step-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  width: 32px;
  height: 26px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: Helvetica, Arial, sans-serif;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.pop-step-btn[data-step="2"] { font-size: 9px;  }
.pop-step-btn[data-step="1"] { font-size: 11px; }
.pop-step-btn[data-step="0"] { font-size: 14px; }
.pop-step-btn:hover { background: var(--teal-light); border-color: var(--teal); color: var(--teal); }
.pop-step-btn.active { background: var(--teal); border-color: var(--teal); color: white; }

/* Search dim */
.label-slot.search-dim { opacity: 0.18; pointer-events: none; filter: saturate(0.3); }
.label-slot.filled.search-match {
  border: 2px solid #E67E22;
  box-shadow: 0 0 0 3px rgba(230,126,34,0.22);
  animation: searchPulse 0.9s ease-out;
}
@keyframes searchPulse {
  0%   { box-shadow: 0 0 0 0 rgba(230,126,34,0.55); }
  100% { box-shadow: 0 0 0 3px rgba(230,126,34,0.22); }
}

/* ── Merge bar ───────────────────────────────────────────────────────────────── */
.merge-bar {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 600;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), opacity 0.18s ease;
  white-space: nowrap;
  color: var(--text-body);
  font-size: 13px;
  font-weight: 500;
}
.merge-bar.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.merge-bar svg { color: var(--teal); flex-shrink: 0; }

.merge-bar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.merge-step-btns {
  display: flex;
  gap: 2px;
}
.merge-step-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  width: 28px;
  height: 26px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: Helvetica, Arial, sans-serif;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.merge-step-btn[data-step="2"] { font-size: 8px; }
.merge-step-btn[data-step="1"] { font-size: 10px; }
.merge-step-btn[data-step="0"] { font-size: 13px; }
.merge-step-btn:hover { background: var(--teal-light); border-color: var(--teal); color: var(--teal); }

.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
}

/* Empty state (shown inside page-scaler when no artworks) */
.wysiwyg-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
}
.wysiwyg-empty svg { opacity: 0.4; }
.wysiwyg-empty h2 { font-size: 18px; font-weight: 600; color: var(--text-body); }
.wysiwyg-empty p  { font-size: 13px; line-height: 1.5; max-width: 300px; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: default; pointer-events: none; }

.btn-primary {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
}
.btn-primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-body);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); border-color: #ccc; }

.btn-ghost {
  background: transparent;
  color: var(--text-body);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg); }

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}
.btn-danger-ghost:hover { background: var(--danger-bg); border-color: transparent; }

.btn-block {
  width: 100%;
  justify-content: center;
}

/* ── Context menu ────────────────────────────────────────────────────────────── */
.ctx-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  min-width: 180px;
  padding: 4px;
  list-style: none;
  font-size: 13px;
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-body);
  transition: background 0.1s;
}
.ctx-item:hover:not(.disabled) { background: var(--bg); }
.ctx-item.disabled { color: var(--border); pointer-events: none; }
.ctx-item--danger { color: var(--danger); }
.ctx-item--danger:hover { background: var(--danger-bg); }

.ctx-divider {
  height: 1px;
  background: var(--border);
  margin: 3px 0;
  list-style: none;
}

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.open { display: flex; }

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 94vw;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-in 0.18s ease;
}

@keyframes modal-in {
  from { transform: scale(0.96) translateY(8px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);   opacity: 1; }
}

.modal-header {
  background: var(--teal);
  color: white;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 14px;
  font-weight: 600;
}

.modal-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}
.modal-close-btn:hover { color: white; background: rgba(255,255,255,0.15); }

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}

.modal-field input,
.modal-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: #FAFAFA;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.modal-field textarea {
  resize: vertical;
  min-height: 42px;
  line-height: 1.4;
}
.modal-field input:focus,
.modal-field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,91,137,0.10);
  background: var(--surface);
}

.modal-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: #FAFAFA;
}

/* ── Toast notifications ─────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 3000;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
  min-width: 240px;
  max-width: 360px;
  pointer-events: auto;
  animation: toast-in 0.25s ease;
  color: white;
}
@keyframes toast-in {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.toast.toast-out {
  animation: toast-out 0.25s ease forwards;
}
@keyframes toast-out {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(110%); opacity: 0; }
}

.toast--info    { background: #1e40af; }
.toast--success { background: #15803d; }
.toast--error   { background: #dc2626; }

.toast-icon { font-size: 16px; flex-shrink: 0; line-height: 1.2; }
.toast-msg  { flex: 1; line-height: 1.4; }

/* ── Header icon button (kugghjul m.fl.) ─────────────────────────────────────── */
.icon-btn--header {
  width: 34px;
  height: 34px;
  color: var(--text-muted);
}
.icon-btn--header:hover {
  color: var(--teal);
}

/* ── Settings modal ──────────────────────────────────────────────────────────── */
.settings-body {
  gap: 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child {
  border-bottom: none;
}

.settings-row-text {
  flex: 1;
  min-width: 0;
}

.settings-row-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.settings-row-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.settings-number {
  width: 72px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: #FAFAFA;
  outline: none;
  text-align: right;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.settings-number:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,91,137,0.10);
  background: var(--surface);
}

.settings-select {
  padding: 7px 28px 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: #FAFAFA url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") no-repeat right 8px center;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.settings-select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,91,137,0.10);
  background-color: var(--surface);
}

/* ── Toggle switch ───────────────────────────────────────────────────────────── */
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.18s;
}
.switch-slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.18s;
}
.switch input:checked + .switch-slider {
  background: var(--teal);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(16px);
}
.switch input:focus-visible + .switch-slider {
  box-shadow: 0 0 0 3px rgba(0,91,137,0.25);
}

/* ── Utskrift ────────────────────────────────────────────────────────────────── */
@media print {
  @page { size: A4; margin: 0; }

  body > *                        { display: none !important; }
  body > .app-body                { display: flex !important; }
  .app-body > .sidebar            { display: none !important; }
  .app-body > .main-area          { display: block !important; width: 100%; }
  .toolbar, .page-num             { display: none !important; }

  .page-viewport  { overflow: visible !important; padding: 0 !important; background: none !important; }
  .page-scaler    { display: block !important; transform: none !important; }

  .page-wrapper {
    width: 210mm !important;
    height: 297mm !important;
    break-after: page;
    overflow: hidden;
    box-shadow: none !important;
    margin: 0 !important;
  }

  .a4-page {
    transform: none !important;
    width: 210mm !important;
    height: 297mm !important;
    position: relative;
    background: white;
  }

  .slot-badge            { display: none !important; }
  .label-slot.empty      { display: none !important; }
  .label-slot.filled     { border: none !important; box-shadow: none !important; }
  .label-slot.search-dim { opacity: 1 !important; filter: none !important; pointer-events: auto !important; }
  .label-slot.search-match { border: none !important; box-shadow: none !important; animation: none !important; }

  #edit-popover, #ctx-menu, .merge-bar, #modal-overlay, #settings-overlay,
  .toast-container, #toast-container { display: none !important; }
}
