/* =========================
   SkallHunter — Prototype
   ========================= */

:root {
  --bg: #f6f8fb;
  --bg-elev: #ffffff;
  --bg-soft: #f1f5f9;
  --bg-deep: #0f172a;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;

  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --primary-deep: #1d4ed8;

  --warn: #ea580c;
  --warn-soft: #ffedd5;

  --overlap: #7c3aed;
  --overlap-soft: #ede9fe;

  --success: #16a34a;
  --success-soft: #dcfce7;

  --danger: #dc2626;

  /* Manually added krav need a colour of their own: blue is an identified
     krav, orange a conflict, purple an overlap. Teal is far enough from all
     three to read at a glance in a thumbnail. */
  --manual: #0d9488;
  --manual-soft: #ccfbf1;

  --hl-blue: rgba(37, 99, 235, 0.18);
  --hl-blue-strong: rgba(37, 99, 235, 0.32);
  --hl-orange: rgba(234, 88, 12, 0.20);
  --hl-purple: rgba(124, 58, 237, 0.20);
  --hl-manual: rgba(13, 148, 136, 0.18);
  --hl-green: rgba(22, 163, 74, 0.20);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.16);

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

* { box-sizing: border-box; }

/* The `hidden` attribute must win over any class that sets `display`.
   Both are specificity (0,1,0), so a later `.stream-bar { display: flex }`
   or `.filter-chip { display: inline-flex }` silently defeats it — which is
   why the streaming banner showed a pale strip under the header with no run
   in progress, and the provisional-krav filter chip appeared with a count of
   zero. Everything the app hides uses this attribute. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}

.hidden { display: none !important; }

.screen {
  display: none;
  height: 100vh;
  width: 100vw;
}
.screen.active { display: flex; }


/* =========================
   UPLOAD SCREEN
   ========================= */

#upload-screen {
  position: relative;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 50%, #ecfeff 100%);
  overflow: hidden;
}

.upload-bg {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(37, 99, 235, 0.10), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(124, 58, 237, 0.08), transparent 40%);
  pointer-events: none;
}

.upload-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 540px;
  padding: 40px;
  text-align: center;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 48px;
}
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: white;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}
.brand-mark.small { width: 32px; height: 32px; font-size: 13px; border-radius: 8px; }
.brand-text { text-align: left; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.brand-sub { font-size: 12px; color: var(--text-muted); }

.upload-card,
.analyzing-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  box-shadow: var(--shadow-md);
  animation: fadeUp 0.4s ease;
}

.folder-stack {
  position: relative;
  width: 96px;
  height: 88px;
  margin: 0 auto 24px;
}
.folder {
  position: absolute;
  border-radius: 6px;
}
.folder-1 {
  z-index: 3;
  inset: 0;
  background: linear-gradient(180deg, #fcd34d 0%, #f59e0b 100%);
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
  overflow: hidden;
}
.folder-tab {
  position: absolute;
  top: -8px;
  left: 6px;
  width: 38px;
  height: 12px;
  background: #f59e0b;
  border-radius: 4px 4px 0 0;
}
.folder-body {
  position: absolute;
  inset: 16px 12px 12px 12px;
  background: white;
  border-radius: 4px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.doc-line {
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
}
.doc-line.short { width: 60%; }
.folder-2 {
  inset: 6px -8px -6px -8px;
  background: #fbbf24;
  z-index: 2;
  opacity: 0.7;
}
.folder-3 {
  inset: 12px -16px -12px -16px;
  background: #fde68a;
  z-index: 1;
  opacity: 0.5;
}

.upload-card h1 {
  margin: 0 0 12px 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.upload-help {
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 28px 0;
}

.primary-btn {
  background: var(--primary);
  color: white;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}
.primary-btn:hover {
  background: var(--primary-deep);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.btn-icon { font-size: 16px; }

.supported-formats {
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-soft);
}

/* Analyzing card */
.analyzing-card { text-align: left; }
.analyzing-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.analyzing-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1.4s ease infinite;
}
.analyzing-status {
  margin: 0 0 24px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.progress-bar {
  height: 6px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.file-stream {
  background: #fafbfd;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  height: 168px;
  overflow-y: auto;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 11.5px;
}
.file-stream-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  animation: fadeIn 0.2s ease;
}
.file-stream-row .icon { font-size: 13px; }
.file-stream-row .name { flex: 1; color: var(--text); }
.file-stream-row .status { color: var(--success); }
.file-stream-row .status.processing { color: var(--primary); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}


/* =========================
   APP SCREEN
   ========================= */

#app-screen {
  flex-direction: column;
  background: var(--bg);
}

.app-header {
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 24px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 320px;
}
.header-project { line-height: 1.3; }
.project-title { font-size: 14px; font-weight: 600; }
.project-meta { font-size: 11.5px; color: var(--text-muted); }

.view-tabs {
  display: flex;
  background: var(--bg-soft);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  margin: 0 auto;
}
.view-tab {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.view-tab:hover { color: var(--text); }
.view-tab.active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.tab-icon { font-size: 13px; }

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ghost-btn {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  transition: all 0.15s;
}
.ghost-btn:hover { background: var(--bg-soft); color: var(--text); }

/* ---- Demo toggle + popover ---- */
.demo-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  transition: all 0.15s;
}
.demo-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.demo-toggle[aria-pressed="true"] {
  color: var(--primary-deep);
  border-color: var(--primary);
  background: var(--primary-soft);
}
.demo-toggle .demo-icon { font-size: 14px; }
.demo-toggle .demo-switch {
  width: 28px;
  height: 16px;
  background: #cbd5e1;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.demo-toggle[aria-pressed="true"] .demo-switch { background: var(--primary); }
.demo-toggle .demo-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.demo-toggle[aria-pressed="true"] .demo-knob { transform: translateX(12px); }

.demo-popover {
  position: fixed;
  top: 64px;
  right: 16px;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 1100;
  animation: popIn 0.2s ease;
  overflow: hidden;
}
.demo-popover-arrow {
  position: absolute;
  top: -7px;
  right: 162px;
  width: 14px;
  height: 14px;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}
.demo-popover-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 6px;
}
.demo-popover-pill {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 2px 8px;
  border-radius: 999px;
}
.demo-popover-head h3 {
  margin: 0;
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.demo-popover-close {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-muted);
}
.demo-popover-close:hover { background: var(--bg-soft); }
.demo-popover-body {
  padding: 4px 16px 14px;
}
.demo-popover-body p {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  margin: 0 0 12px 0;
}
.demo-popover-body p.muted {
  color: var(--text-muted);
  font-size: 12px;
}
.demo-popover-body h4 {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 14px 0 8px 0;
}
.demo-popover-body h4:first-child { margin-top: 0; }
.demo-tips {
  list-style: none;
  margin: 0;
  padding: 0;
}
.demo-tips li {
  display: flex;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  padding: 6px 0;
  border-top: 1px dashed var(--border);
}
.demo-tips li:first-child { border-top: none; padding-top: 0; }
.demo-tip-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.demo-callout {
  background: linear-gradient(135deg, #f5f3ff 0%, #eff6ff 100%);
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: #4c1d95;
  line-height: 1.5;
  margin-top: 4px;
}
.demo-callout strong { color: #1d4ed8; }
.demo-popover-foot {
  background: var(--bg-soft);
  padding: 8px 16px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: white;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
}

/* View containers */
.view {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.view.active { display: flex; }


/* =========================
   DOCUMENT VIEW
   ========================= */

.document-view {
  flex-direction: row;
}

/* ----- Doc pane (left) ----- */
.doc-pane {
  flex: 0 0 38%;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  position: relative;
  min-width: 0;
}

.doc-tabs {
  display: flex;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  height: 38px;
  gap: 2px;
  overflow-x: auto;
  flex-shrink: 0;
}
.doc-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 100%;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.15s;
}
.doc-tab:hover { color: var(--text); }
.doc-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--bg-elev);
}
.doc-tab .doc-icon { font-size: 12px; }

.doc-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  flex-shrink: 0;
}
.tool-btn {
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  transition: all 0.15s;
}
.tool-btn:hover { background: var(--bg-soft); color: var(--text); }
.tool-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-indicator, .zoom-indicator {
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
}
.toolbar-spacer { flex: 1; }

.doc-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: #f1f5f9;
  display: flex;
  justify-content: center;
  /* Without this the default `align-items: stretch` pins .doc-page to the
     scroller's own height, so a page with many paragraphs spills out below
     the white sheet instead of the sheet growing to hold it. flex-start lets
     the item take its content height; min-height keeps a short page looking
     like a page. */
  align-items: flex-start;
}

.doc-page {
  background: white;
  width: 100%;
  max-width: 640px;
  min-height: 800px;
  padding: 56px 64px;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 13px;
  line-height: 1.7;
  color: #1e293b;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  border-radius: 2px;
  position: relative;
  user-select: text;
  transition: transform 0.2s ease;
}

.doc-page h1 { font-size: 22px; margin: 0 0 12px 0; font-weight: 600; letter-spacing: -0.3px; }
.doc-page h2 { font-size: 17px; margin: 4px 0 18px 0; font-weight: 600; color: #334155; }
.doc-page h3 { font-size: 15px; margin: 28px 0 10px 0; font-weight: 600; color: #1e293b; }
.doc-page h4 { font-size: 13.5px; margin: 18px 0 8px 0; font-weight: 600; color: #334155; }
.doc-page .meta { font-size: 11.5px; color: var(--text-muted); margin: 2px 0; font-family: 'Inter', sans-serif; }
.doc-page p { margin: 0 0 12px 0; }
.doc-page p.indent { padding-left: 18px; }
.doc-page p strong { color: #0f172a; font-weight: 600; }
.doc-page hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* MR-relevant paragraphs */
.doc-page p.mr-paragraph {
  background: var(--hl-blue);
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  margin-left: -14px;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  transition: all 0.15s;
}
.doc-page p.mr-paragraph:hover {
  background: var(--hl-blue-strong);
}
.doc-page p.mr-paragraph.conflict {
  background: var(--hl-orange);
  border-left-color: var(--warn);
}
.doc-page p.mr-paragraph.overlap {
  background: var(--hl-purple);
  border-left-color: var(--overlap);
}
.doc-page p.mr-paragraph.active {
  background: var(--hl-blue-strong);
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.doc-page p.mr-paragraph.active.conflict {
  background: rgba(234, 88, 12, 0.32);
  outline-color: var(--warn);
}
.doc-page p.mr-paragraph.active.overlap {
  background: rgba(124, 58, 237, 0.32);
  outline-color: var(--overlap);
}

.mr-tag {
  display: inline-block;
  margin-left: 8px;
  background: var(--primary);
  color: white;
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  vertical-align: middle;
  letter-spacing: 0.3px;
}
.mr-tag.warn { background: var(--warn); }
.mr-tag.overlap { background: var(--overlap); }

.floating-add {
  position: fixed;
  /* Modal-backdrop uses z-index 1000, so the pill must be higher to be
     clickable on top of the Compare modal. */
  z-index: 1200;
  display: none;
}
.floating-add.show { display: block; }
.floating-add button {
  background: var(--bg-deep);
  color: white;
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
}
.floating-add button:hover { background: #1e293b; }


/* ----- MR pane (middle) ----- */
.mr-pane {
  flex: 0 0 30%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
}

.mr-pane-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mr-pane-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.mr-pane-title h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.mr-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-soft);
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 500;
}
.mr-search input {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  outline: none;
  transition: all 0.15s;
}
.mr-search input:focus {
  border-color: var(--primary);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.mr-filters {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  /* Five chips no longer fit on one line in a narrow middle pane. Wrapping
     replaces the horizontal scroll the row used to need. */
  flex-wrap: wrap;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-soft);
  border-radius: 999px;
  white-space: nowrap;
  transition: all 0.15s;
}
.filter-chip:hover { background: var(--border); }
.filter-chip.active {
  background: var(--bg-deep);
  color: white;
}
.chip-count {
  background: rgba(0,0,0,0.1);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.filter-chip.active .chip-count {
  background: rgba(255,255,255,0.2);
}

.mr-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.mr-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.mr-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.mr-card.active {
  border-color: var(--primary);
  background: #f8faff;
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.mr-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 10px;
}
.mr-code {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 7px;
  border-radius: 4px;
}
.mr-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.mr-badge {
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.mr-badge.cat {
  background: var(--bg-soft);
  color: var(--text-muted);
}
.mr-badge.conflict {
  background: var(--warn-soft);
  color: var(--warn);
}
.mr-badge.overlap {
  background: var(--overlap-soft);
  color: var(--overlap);
}
.mr-badge.manual {
  background: var(--success-soft);
  color: var(--success);
}

.mr-card-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.4;
  color: var(--text);
}
.mr-card-summary {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mr-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-soft);
}
.confidence {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.confidence-bar {
  width: 36px;
  height: 4px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}
.confidence-fill {
  height: 100%;
  background: var(--success);
  border-radius: 999px;
}
.confidence-fill.medium { background: #f59e0b; }
.confidence-fill.low { background: var(--warn); }


/* ----- Detail pane (right) ----- */
.detail-pane {
  flex: 1;
  min-width: 0;
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.detail-empty {
  margin: auto;
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  max-width: 320px;
}
.empty-icon {
  font-size: 36px;
  margin-bottom: 14px;
  opacity: 0.6;
}
.detail-empty h3 {
  margin: 0 0 8px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.detail-empty p { font-size: 13px; line-height: 1.55; }

.detail-content { padding: 24px 28px; }

.detail-head {
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.detail-head .top-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.detail-head h1 {
  margin: 0 0 6px 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.detail-head .summary {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

.detail-section {
  margin-bottom: 22px;
}
.detail-section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: 0 0 10px 0;
}

.quote-box {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 13.5px;
  line-height: 1.65;
  background: #fafbfd;
  border-left: 3px solid var(--primary);
  padding: 14px 18px;
  border-radius: 0 6px 6px 0;
  color: #1e293b;
}

.source-ref {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-elev);
}
.source-ref:hover {
  border-color: var(--primary);
  background: #f8faff;
}
.source-icon { font-size: 18px; }
.source-info { flex: 1; min-width: 0; }
.source-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}
.source-loc {
  font-size: 11.5px;
  color: var(--text-muted);
}
.source-arrow { color: var(--text-soft); }

.source-original-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  color: var(--primary);
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.source-original-btn:hover {
  background: #eef2ff;
  border-color: #818cf8;
  color: var(--primary-deep);
}
.source-original-btn .ms { vertical-align: -3px; }

.conflict-banner {
  background: var(--warn-soft);
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
}
.conflict-icon { font-size: 18px; flex-shrink: 0; }
.conflict-text {
  font-size: 12.5px;
  line-height: 1.5;
  color: #9a3412;
}
.conflict-text strong { color: #7c2d12; }

.overlap-banner {
  background: var(--overlap-soft);
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
}
.overlap-banner .conflict-icon { color: var(--overlap); }
.overlap-banner .conflict-text { color: #5b21b6; }
.overlap-banner .conflict-text strong { color: #4c1d95; }

.related-mr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.related-mr:hover { background: var(--bg-soft); }

.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}


/* =========================
   OVERVIEW VIEW
   ========================= */

.overview-view {
  flex-direction: column;
  background: var(--bg);
}
.overview-controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 24px 32px 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 24px;
}
.overview-controls-left h2 {
  margin: 0 0 4px 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.overview-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 600px;
}
.overview-controls-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
#overview-doc-select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elev);
  outline: none;
  cursor: pointer;
}
.overview-legend {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-muted);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.dot.blue { background: var(--primary); }
.dot.orange { background: var(--warn); }
.dot.purple { background: var(--overlap); }

.pages-grid {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.doc-group {
  margin-bottom: 36px;
}
.doc-group-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.doc-group-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.doc-group-title-text { white-space: nowrap; }
.doc-group-header .doc-group-icon {
  width: 24px;
  height: 24px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.doc-group-meta {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 4px;
}

.thumb-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.page-thumb {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
  position: relative;
}
.page-thumb:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  border-color: var(--primary);
}

.thumb-content {
  aspect-ratio: 1 / 1.414;
  padding: 14px 12px;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 4.5px;
  line-height: 1.45;
  color: #334155;
  overflow: hidden;
  position: relative;
  background: white;
}
.thumb-content h1 { font-size: 7px; margin: 0 0 4px; }
.thumb-content h2 { font-size: 6px; margin: 0 0 4px; color: #475569; }
.thumb-content h3 { font-size: 5.5px; margin: 4px 0 2px; }
.thumb-content h4 { font-size: 5px; margin: 3px 0 1px; }
.thumb-content .meta { font-size: 4px; color: var(--text-muted); }
.thumb-content p { margin: 0 0 3px; }
.thumb-content p.mr-paragraph {
  background: var(--hl-blue);
  border-left: 1.5px solid var(--primary);
  padding: 2px 4px;
  margin-left: -4px;
  border-radius: 0 2px 2px 0;
}
.thumb-content p.mr-paragraph.conflict {
  background: var(--hl-orange);
  border-left-color: var(--warn);
}
.thumb-content p.mr-paragraph.overlap {
  background: var(--hl-purple);
  border-left-color: var(--overlap);
}

.thumb-foot {
  background: var(--bg-soft);
  padding: 7px 10px;
  font-size: 10.5px;
  color: var(--text);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Inter', sans-serif;
}
.thumb-foot .mr-count-pill {
  background: var(--primary);
  color: white;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
}
.thumb-foot .mr-count-pill.has-conflict {
  background: var(--warn);
}


/* =========================
   CHECKLIST VIEW
   ========================= */

.checklist-view {
  flex-direction: column;
  background: #e2e8f0;
}

.checklist-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 20px 32px 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 24px;
}
.checklist-toolbar-left h2 {
  margin: 0 0 4px 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.checklist-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 600px;
}
.checklist-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.group-by-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-right: 4px;
}
.group-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 6px;
  transition: all 0.15s;
}
.group-btn:hover { color: var(--text); }
.group-btn.active {
  background: var(--bg-deep);
  color: white;
  border-color: var(--bg-deep);
}
.primary-btn.small {
  padding: 7px 14px;
  font-size: 12.5px;
}

.checklist-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 32px 16px;
}

.checklist-paper {
  background: white;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 56px 64px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.10);
  border-radius: 2px;
  font-family: 'Inter', sans-serif;
  color: #0f172a;
}

.cl-doc-head {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 16px;
  margin-bottom: 24px;
}
.cl-doc-head .cl-pretitle {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.cl-doc-head h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px 0;
  letter-spacing: -0.3px;
}
.cl-doc-head .cl-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.cl-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
  padding: 14px 18px;
  background: var(--bg-soft);
  border-radius: 8px;
}
.cl-meta-cell .cl-meta-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 2px;
  font-weight: 600;
}
.cl-meta-cell .cl-meta-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.cl-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.cl-progress-bar .cl-progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.cl-section {
  margin-bottom: 28px;
  page-break-inside: auto;
}
.cl-section-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 12px;
}
.cl-section-header h2 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text);
  margin: 0;
}
.cl-section-header .cl-section-count {
  font-size: 11.5px;
  color: var(--text-muted);
}

.cl-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
  page-break-inside: avoid;
}
.cl-item:last-child { border-bottom: none; }

.cl-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid #475569;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.15s;
}
.cl-checkbox:hover { border-color: var(--primary); }
.cl-checkbox.checked {
  background: var(--primary);
  border-color: var(--primary);
}
.cl-checkbox.checked::after {
  font-family: 'Material Symbols Outlined';
  font-feature-settings: 'liga';
  content: 'check';
  color: white;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
}

.cl-item-body {
  min-width: 0;
}
.cl-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.cl-code {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 1px 7px;
  border-radius: 4px;
}
.cl-item-title {
  font-size: 13.5px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
}
.cl-item.checked .cl-item-title {
  text-decoration: line-through;
  color: var(--text-muted);
}
.cl-flag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
}
.cl-flag.conflict { background: var(--warn-soft); color: var(--warn); }
.cl-flag.overlap { background: var(--overlap-soft); color: var(--overlap); }

.cl-item-summary {
  font-size: 12.5px;
  line-height: 1.55;
  color: #334155;
  margin: 4px 0 8px 0;
}

.cl-conflict-warning {
  background: var(--warn-soft);
  border-left: 3px solid var(--warn);
  padding: 8px 12px;
  border-radius: 0 4px 4px 0;
  font-size: 11.5px;
  color: #9a3412;
  margin: 4px 0 8px 0;
  line-height: 1.5;
}
.cl-conflict-warning strong { color: #7c2d12; }

.cl-source {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.cl-source-icon { font-size: 12px; }

.cl-notes-row {
  margin-top: 6px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.cl-notes-row label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}
.cl-notes-input {
  flex: 1;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 3px 0;
  font-size: 12.5px;
  background: transparent;
  outline: none;
  color: var(--text);
  font-family: 'Inter', sans-serif;
}
.cl-notes-input:focus { border-bottom-color: var(--primary); }
.cl-notes-input::placeholder { color: var(--text-soft); font-style: italic; }

.cl-signature-block {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 2px solid #0f172a;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}
.cl-signature-cell {
  display: flex;
  flex-direction: column;
}
.cl-signature-line {
  border-bottom: 1px solid #0f172a;
  height: 32px;
  margin-bottom: 4px;
}
.cl-signature-cell .cl-meta-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
}

.cl-foot-meta {
  margin-top: 24px;
  font-size: 10.5px;
  color: var(--text-soft);
  text-align: center;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}


/* ---------- PRINT STYLES ---------- */
@media print {
  @page {
    size: A4;
    margin: 16mm 14mm;
  }

  html, body {
    background: white !important;
    overflow: visible !important;
    height: auto !important;
  }

  .screen { display: none !important; }
  #app-screen { display: block !important; height: auto !important; }
  .app-header,
  .no-print,
  #document-view,
  #overview-view,
  .demo-popover,
  .floating-add,
  .modal-backdrop {
    display: none !important;
  }

  .checklist-view {
    display: block !important;
    background: white !important;
    overflow: visible !important;
    height: auto !important;
  }
  .checklist-scroll {
    overflow: visible !important;
    padding: 0 !important;
    display: block !important;
  }
  .checklist-paper {
    box-shadow: none !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  .cl-section { page-break-inside: auto; }
  .cl-section-header { page-break-after: avoid; }
  .cl-item { page-break-inside: avoid; }
  .cl-doc-head { page-break-after: avoid; }

  .cl-checkbox {
    border-color: #000 !important;
    background: white !important;
  }
  .cl-checkbox.checked { background: #000 !important; border-color: #000 !important; }

  /* Re-enable colors for highlight items in print */
  .cl-conflict-warning,
  .cl-flag {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Notes input: hide placeholder hint, keep a clean writing line */
  .cl-notes-input::placeholder,
  .cl-notes-input::-webkit-input-placeholder,
  .cl-notes-input::-moz-placeholder {
    color: transparent !important;
    opacity: 0 !important;
  }
  .cl-notes-input {
    border-bottom: 1px solid #94a3b8 !important;
    color: #000 !important;
  }
}


/* =========================
   MODAL
   ========================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

/* "Lägg till skall-krav manuellt" och konfliktlösnings­modalen kan
   triggas inifrån Jämför-modalen och måste därför ligga ovanpå den.
   Stacking-ordning:  compare (1000) < add-mr / conflict (1100) < floating-add (1200). */
#add-mr-modal,
#conflict-modal { z-index: 1100; }
.modal {
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  width: 540px;
  max-width: 92vw;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.25s ease;
}
.modal.modal-wide {
  width: 920px;
  max-width: 96vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-wide .modal-body { overflow-y: auto; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
}
.modal-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}
.modal-close {
  font-size: 22px;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--bg-soft); }
.modal-body {
  padding: 0 24px 18px;
}
.modal-body label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 14px;
}
.modal-body label:first-child { margin-top: 0; }
.required { color: var(--danger); }
.selected-text-preview {
  background: #fafbfd;
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 13px;
  line-height: 1.55;
  color: #1e293b;
  max-height: 80px;
  overflow-y: auto;
}
.modal-body input[type="text"],
.modal-body select,
.modal-body textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elev);
  outline: none;
  transition: all 0.15s;
  resize: vertical;
}
.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.modal-body input:disabled {
  background: var(--bg-soft);
  color: var(--text-muted);
}
.form-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
}
.form-group { min-width: 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 18px 24px 20px;
  border-top: 1px solid var(--border);
}
.btn-primary {
  background: var(--primary);
  color: white;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  transition: all 0.15s;
}
.btn-primary:hover { background: var(--primary-deep); }
.btn-secondary {
  color: var(--text-muted);
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  transition: all 0.15s;
}
.btn-secondary:hover { background: var(--bg-soft); }


/* ---- Conflict modal ---- */
.conflict-modal-pill {
  display: inline-block;
  background: var(--warn);
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 2px 9px;
  border-radius: 999px;
  margin-bottom: 4px;
}
.conflict-modal-body {
  padding: 12px 24px 24px;
}
.conflict-intro {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0 0 18px 0;
  background: var(--warn-soft);
  border-left: 3px solid var(--warn);
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
}
.conflict-intro strong { color: #7c2d12; }

.conflict-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.conflict-grid.three { grid-template-columns: 1fr 1fr 1fr; }

.conflict-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  transition: all 0.15s;
  position: relative;
}
.conflict-card.is-prioritized {
  border-color: var(--success);
  background: #f0fdf4;
}
.conflict-card.is-deprioritized {
  border-color: var(--border);
  background: #fafbfd;
  opacity: 0.55;
}
.conflict-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.conflict-card-head .mr-code { font-size: 11px; }
.conflict-card-source {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-left: auto;
}
.conflict-card h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin: 0 0 10px 0;
  line-height: 1.35;
}
.conflict-card .quote-box {
  font-size: 12.5px;
  line-height: 1.6;
  margin: 0 0 14px 0;
  flex: 1;
  border-left-color: var(--text-muted);
}
.conflict-card.is-prioritized .quote-box { border-left-color: var(--success); }

.conflict-card-meta {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.conflict-card-meta strong { color: var(--text); font-weight: 600; }

.priority-btn {
  width: 100%;
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-deep);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s;
}
.priority-btn:hover { background: #1e293b; transform: translateY(-1px); }
.priority-btn.active {
  background: var(--success);
}
.priority-btn.active:hover { background: #15803d; }

.priority-badge {
  position: absolute;
  top: -10px;
  right: 14px;
  background: var(--success);
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 3px 9px;
  border-radius: 999px;
  box-shadow: 0 2px 4px rgba(22, 163, 74, 0.3);
}
.deprio-badge {
  position: absolute;
  top: -10px;
  right: 14px;
  background: var(--text-muted);
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 3px 9px;
  border-radius: 999px;
}

/* Resolution status banner on detail pane */
.resolved-banner {
  background: var(--success-soft);
  border: 1px solid #86efac;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.resolved-banner .conflict-icon { color: var(--success); font-size: 18px; }
.resolved-banner .conflict-text { color: #166534; font-size: 12.5px; }
.resolved-banner .conflict-text strong { color: #14532d; }
.resolved-banner .reset-link {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
  flex-shrink: 0;
}
.resolved-banner .reset-link:hover { color: var(--text); }

/* MR list cards: deprioritized state */
.mr-card.deprioritized {
  opacity: 0.55;
}
.mr-card.deprioritized .mr-card-title {
  text-decoration: line-through;
}
.mr-card .priority-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--success);
  color: white;
}
.mr-card .deprio-pill {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-muted);
}

/* Resolve button in detail actions */
.btn-resolve {
  background: var(--warn);
  color: white;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.btn-resolve:hover { background: #c2410c; }


/* =========================
   SCROLLBAR
   ========================= */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
  background-clip: padding-box;
  border: 2px solid transparent;
}

/* =========================
   COMPARE FEATURE
   ========================= */

/* "Jämför med original" button on each doc group in Overview view.
   Placeras på egen rad under dokumenttiteln (se .doc-group-header). */
.compare-doc-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  background: #fff;
  color: #1d4ed8;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.compare-doc-btn:hover {
  background: #eef2ff;
  border-color: #818cf8;
  color: #4338ca;
}
.compare-doc-btn .icon {
  font-size: 14px;
  line-height: 1;
}
.compare-doc-btn[disabled] {
  color: #94a3b8;
  border-color: #e2e8f0;
  background: #f8fafc;
  cursor: not-allowed;
}

/* Compare modal */
.compare-modal {
  width: 96vw;
  max-width: 1700px;
  height: 92vh;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.compare-modal .modal-header {
  border-bottom: 1px solid #e2e8f0;
  padding: 14px 22px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}
.compare-modal .modal-header h2 {
  margin: 4px 0 2px 0;
  font-size: 18px;
}
.compare-modal-pill {
  display: inline-block;
  background: #eef2ff;
  color: #4338ca;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 4px;
}
.compare-subtitle {
  font-size: 12px;
  color: #64748b;
  font-weight: 400;
}

.compare-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  min-height: 0;
}
.compare-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #f8fafc;
}
.compare-side-head {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.compare-side-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
}
.compare-side-tag.synthetic { background: #dbeafe; color: #1d4ed8; }
.compare-side-tag.real      { background: #fef3c7; color: #92400e; }

.compare-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #475569;
  margin-left: auto;
}
.compare-zoom {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* Shared page navigation bar (one set of arrows for both panes) */
.compare-page-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 16px;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  font-size: 13px;
}
.compare-page-bar .tool-btn {
  font-size: 12.5px;
  padding: 6px 14px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.compare-page-bar .tool-btn:hover:not(:disabled) {
  background: #eef2ff;
  border-color: #818cf8;
  color: #4338ca;
}
.compare-page-bar .tool-btn:disabled {
  background: #f8fafc;
  color: #94a3b8;
  border-color: #e2e8f0;
  cursor: not-allowed;
}
.compare-page-indicator {
  font-weight: 600;
  color: #0f172a;
  min-width: 120px;
  text-align: center;
}

.compare-divider {
  background: #e2e8f0;
}

.compare-scroll {
  flex: 1;
  overflow: auto;
  padding: 24px;
  background: #f1f5f9;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.compare-scroll .doc-page {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  padding: 36px 48px;
  max-width: 720px;
  width: 100%;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 14px;
  line-height: 1.55;
}
#cmp-real-img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.18);
  background: #fff;
  display: block;
  transform-origin: top center;
}

.compare-footer {
  border-top: 1px solid #e2e8f0;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f8fafc;
}
.compare-foot-note {
  font-size: 12px;
  color: #64748b;
}

/* =========================
   PROJECT LIBRARY (upload screen redesign)
   ========================= */

.library-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1320px;
  padding: 32px 40px 48px 40px;
  margin: 0 auto;
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}
.library-header .brand {
  margin-bottom: 0;
  justify-content: flex-start;
}
.library-stats {
  font-size: 12px;
  color: var(--text-muted);
}

.library-grid {
  display: grid;
  grid-template-columns: minmax(380px, 460px) 1fr;
  gap: 28px;
  align-items: start;
}

/* --- Create panel (left) --- */
.create-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 24px 28px;
  box-shadow: var(--shadow-md);
  animation: fadeUp 0.4s ease;
}
.create-panel-head h2 {
  margin: 0 0 6px 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.create-panel-head p {
  margin: 0 0 18px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin: 4px 0 6px;
  text-align: left;
}
.form-label .required {
  color: var(--warn, #dc2626);
  font-weight: 500;
}
.project-name-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  margin-bottom: 18px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.project-name-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* The upload-card lives inside the create panel now: relax its padding */
.create-panel .upload-card {
  background: #f8fafc;
  border-style: dashed;
  padding: 28px 24px;
  text-align: center;
  box-shadow: none;
}
.create-panel .upload-card h1 {
  font-size: 17px;
  margin-bottom: 8px;
}
.create-panel .upload-card .upload-help {
  font-size: 12.5px;
  margin-bottom: 18px;
}
.create-panel .upload-card .folder-stack {
  width: 64px;
  height: 60px;
  margin-bottom: 14px;
}
.create-panel .upload-card .folder-tab { width: 26px; height: 8px; top: -6px; }
.create-panel .upload-card .doc-line { height: 3px; }
.create-panel .upload-card .folder-body { gap: 3px; padding: 7px 6px; }
.create-panel .upload-card .supported-formats { font-size: 11px; margin-top: 12px; }

.create-panel .analyzing-card {
  background: #f8fafc;
  border-style: solid;
  padding: 28px 24px;
  text-align: left;
  box-shadow: none;
}

/* --- Project library (right) --- */
.library-panel {
  background: transparent;
  padding: 8px 0 0 0;
}
.library-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.library-panel-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.library-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
}
.library-hint {
  margin: 6px 0 18px 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.project-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 18px;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  position: relative;
}
.project-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.10);
  border-color: #c7d2fe;
}
.project-card-icon {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: #eef2ff;
  border: 1px solid #e0e7ff;
}
.project-card-body {
  min-width: 0;
}
.project-card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 2px 0;
  color: var(--text);
  letter-spacing: -0.2px;
}
.project-card-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 6px 0;
}
.project-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.project-card-meta strong {
  color: var(--text);
  font-weight: 600;
}
.project-card-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}
.project-card-stats .docs-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eef2ff;
  color: #4338ca;
  font-weight: 600;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
}
.project-card-stats .arrow {
  font-size: 18px;
  color: #94a3b8;
  margin-top: 4px;
}
.project-card:hover .arrow { color: var(--primary); }

.library-empty-hint {
  margin-top: 24px;
  text-align: center;
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 32px 24px;
  color: var(--text-muted);
}
.library-empty-hint .empty-icon {
  font-size: 28px;
  margin-bottom: 8px;
}
.library-empty-hint p { margin: 0; font-size: 13px; }

/* Responsive: stack on narrow viewports */
@media (max-width: 980px) {
  .library-grid {
    grid-template-columns: 1fr;
  }
  .library-container {
    padding: 24px 20px 36px;
  }
}

/* =========================
   ICONS – Google Material Symbols Outlined
   ========================= */
.ms {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'liga';
  vertical-align: -3px;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  user-select: none;
  font-size: 18px;
}
.ms-sm    { font-size: 16px; vertical-align: -2px; }
.ms-lg    { font-size: 22px; vertical-align: -4px; }
.ms-xl    { font-size: 28px; vertical-align: -5px; }
.ms-fill  { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }

/* contextual colors (used inline rather than via class when convenient) */
.ms-warn    { color: var(--warn); }
.ms-success { color: var(--success); }
.ms-info    { color: var(--primary); }
.ms-muted   { color: var(--text-muted); }

/* When a Material Symbol sits inside another span/button label, fine-tune
   vertical alignment so the icon optical centre matches the adjacent text. */
button .ms, a .ms, .filter-chip .ms, .mr-badge .ms,
.tab-icon .ms, .btn-icon .ms, .demo-icon .ms,
.doc-icon .ms, .source-icon .ms, .conflict-icon .ms,
.demo-tip-icon .ms, .compare-doc-btn .icon .ms,
.cl-flag .ms {
  vertical-align: -4px;
}

/* "Back to library" affordance in app header */
.brand-back {
  cursor: pointer;
  border: none;
  outline: none;
  transition: transform 0.12s, box-shadow 0.12s;
}
.brand-back:hover { transform: scale(1.05); box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3); }

.library-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  margin-left: -2px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.library-back-btn:hover {
  background: #eef2ff;
  border-color: #818cf8;
  color: var(--primary-deep);
}
.library-back-btn .ms { vertical-align: -3px; }

/* =========================
   REAL UPLOAD, SETTINGS, STORED PROJECTS
   Added when the scripted demo animation was replaced by the real
   parse → analyse → persist pipeline.
   ========================= */

/* --- library header: stats + settings side by side --- */
.library-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.settings-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.settings-btn:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
  color: var(--text);
}

/* --- upload card additions --- */
.linkish-btn {
  display: block;
  margin: 10px auto 0;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.linkish-btn:hover { color: var(--primary-deep); }

.selected-files {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--primary-soft);
  color: var(--primary-deep);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  text-align: center;
}

/* Drop target feedback. A dashed outline rather than a coloured edge stripe. */
.upload-card.dragging {
  outline: 2px dashed var(--primary);
  outline-offset: -6px;
  background: var(--primary-soft);
}

/* --- analysis failure --- */
.analyze-error {
  margin-top: 16px;
  padding: 14px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
}
.analyze-error-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: #991b1b;
}
.analyze-error-head .ms { color: var(--danger); }
.analyze-error-detail {
  margin: 8px 0 12px;
  font-size: 12.5px;
  line-height: 1.55;
  color: #7f1d1d;
}

/* --- settings panel --- */
.settings-panel {
  margin-top: 22px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 22px 24px 24px;
}
.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.settings-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.settings-hint {
  margin: 6px 0 16px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-muted);
}
.settings-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.settings-row select {
  flex: 1;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}
.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 18px 0 16px;
}
.settings-storage {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-muted);
}
.settings-storage code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11.5px;
  background: var(--bg-soft);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text);
}

/* --- project cards: delete + demo marker --- */
.project-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.project-delete:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

.demo-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  background: var(--bg-soft);
  color: var(--text-soft);
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  vertical-align: 2px;
}

/* The card became a div to hold its own delete button, so the pointer and
   focus affordances a <button> gave for free are restored here. */
.project-card[role="button"] { cursor: pointer; }
.project-card[role="button"]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* --- processing statistics (Overview view) --- */
.proc-stats {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px 16px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}
.proc-stats-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.proc-stats-head h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.proc-stats-total {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Wide table on a narrow pane scrolls itself rather than the page. */
.proc-table-wrap { overflow-x: auto; }
.proc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.proc-table th {
  text-align: left;
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
  padding: 0 10px 7px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.proc-table th.num, .proc-table td.num { text-align: right; }
.proc-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--bg-soft);
  color: var(--text-muted);
  white-space: nowrap;
}
.proc-table tbody tr:last-child td { border-bottom: none; }
.proc-table tbody tr:hover td { background: var(--bg-soft); }
.proc-table td.doc {
  color: var(--text);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 7px;
}
.proc-table td.strong { color: var(--text); font-weight: 600; }
.proc-icon { color: var(--text-soft); display: inline-flex; }

.proc-stats-note {
  margin: 12px 0 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-soft);
}
.proc-stats-note strong { color: var(--text-muted); font-weight: 600; }

/* Failure diagnostics under the analysis error box. Preserves newlines so a
   per-file reason list stays readable. */
.analyze-error-detail { white-space: pre-wrap; }
.analyze-diagnostics {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-muted);
}
.analyze-diagnostics div + div { margin-top: 5px; }

/* =========================
   STREAMING ANALYSIS
   Provisional candidates from the rule engine, plus the background-run
   progress bar. Provisional items are distinguished by a dashed outline and
   a label, never by a coloured edge stripe.
   ========================= */

.stream-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  background: var(--primary-soft);
  border-bottom: 1px solid #bfdbfe;
  font-size: 12.5px;
  color: var(--primary-deep);
  flex: 0 0 auto;
}
.stream-bar.finished {
  background: var(--success-soft);
  border-bottom-color: #bbf7d0;
  color: #166534;
}
.stream-icon { display: inline-flex; }
.stream-icon.spinning .ms { animation: stream-spin 1.1s linear infinite; }
@keyframes stream-spin { to { transform: rotate(360deg); } }
.stream-text { flex: 1; min-width: 0; }
.stream-text strong { font-weight: 600; }

.stream-track {
  width: 160px;
  height: 4px;
  background: rgba(37, 99, 235, 0.18);
  border-radius: 999px;
  overflow: hidden;
  flex: 0 0 auto;
}
.stream-fill {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.35s ease;
}
.stream-dismiss {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}
.stream-dismiss:hover { border-color: var(--border-strong); color: var(--text); }

/* --- document tab status --- */
.doc-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: inline-block;
  margin-right: 2px;
}
.doc-dot.done      { background: var(--success); }
.doc-dot.queued    { background: transparent; border: 1px solid var(--border-strong); }
.doc-dot.failed    { background: var(--warn); }
.doc-dot.analysing { background: var(--primary); animation: dot-pulse 1.2s ease-in-out infinite; }
@keyframes dot-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

/* --- provisional candidate cards --- */
.mr-card.preview {
  border-style: dashed;
  background: #fcfcfd;
}
.mr-card.preview .mr-card-title { color: var(--text-muted); font-weight: 500; }
.mr-code.preview {
  background: var(--bg-soft);
  color: var(--text-soft);
  border: 1px dashed var(--border-strong);
}
.preview-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.preview-reason {
  font-size: 10.5px;
  color: var(--text-soft);
  font-style: italic;
  text-align: right;
  max-width: 55%;
}

.preview-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0 0 18px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
}
.preview-banner .conflict-icon .ms { color: var(--text-soft); }
.preview-banner strong { color: var(--text); }

.preview-rules { display: flex; flex-wrap: wrap; gap: 5px; }
.rule-chip {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* --- provisional krav: tag colour; paragraph fills live with the other
       paragraph states, which need the higher-specificity selector --- */
.mr-tag.preview {
  background: var(--bg-soft);
  color: var(--text-soft);
  border: 1px dashed var(--border-strong);
}

/* --- library card: unfinished analysis --- */
.pending-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-size: 10.5px;
  font-weight: 600;
}

/* --- destructive actions in Inställningar --- */
.settings-danger {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 8px 13px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-danger:hover { background: #fef2f2; border-color: var(--danger); }
.storage-rows {
  display: inline-block;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-soft);
}

/* =========================
   PARAGRAPH STATES — resolved conflicts, manual krav, provisional

   Selectors match the established `.doc-page p.mr-paragraph.<state>` pattern
   deliberately. That existing rule is specificity (0,3,1); a plainer
   `.paragraph.resolved` (0,2,0) loses to it no matter where it sits in the
   file, which is why an earlier attempt at this — and at the provisional
   styling — silently did nothing in the document view while appearing to
   work in the thumbnails, where no competing rule existed.
   ========================= */

/* A settled conflict: candy stripes in the conflict orange and the resolved
   green, so it reads as "was a conflict, now decided" rather than as either
   one. Solid green would look like a fresh finding; solid orange would keep
   pulling the eye toward work that is already done. */
.doc-page p.mr-paragraph.resolved {
  background: repeating-linear-gradient(
    45deg,
    var(--hl-orange) 0, var(--hl-orange) 6px,
    var(--hl-green) 6px, var(--hl-green) 12px
  );
  border-left-color: var(--success);
}
.doc-page p.mr-paragraph.resolved:hover {
  background: repeating-linear-gradient(
    45deg,
    rgba(234, 88, 12, 0.32) 0, rgba(234, 88, 12, 0.32) 6px,
    rgba(22, 163, 74, 0.32) 6px, rgba(22, 163, 74, 0.32) 12px
  );
}
.doc-page p.mr-paragraph.active.resolved {
  background: repeating-linear-gradient(
    45deg,
    rgba(234, 88, 12, 0.34) 0, rgba(234, 88, 12, 0.34) 6px,
    rgba(22, 163, 74, 0.34) 6px, rgba(22, 163, 74, 0.34) 12px
  );
  outline-color: var(--success);
}

/* Manually added krav. */
.doc-page p.mr-paragraph.manual {
  background: var(--hl-manual);
  border-left-color: var(--manual);
}
.doc-page p.mr-paragraph.manual:hover { background: rgba(13, 148, 136, 0.30); }
.doc-page p.mr-paragraph.active.manual {
  background: rgba(13, 148, 136, 0.32);
  outline-color: var(--manual);
}

/* Provisional rule-engine candidates: no fill, a dashed rail, so they read as
   "not yet confirmed" next to the solid fills of verified krav. */
.doc-page p.mr-paragraph.preview {
  background: transparent;
  border-left: 3px dashed var(--border-strong);
}
.doc-page p.mr-paragraph.preview:hover { background: var(--bg-soft); }
.doc-page p.mr-paragraph.active.preview {
  background: var(--bg-soft);
  outline-color: var(--border-strong);
}

/* Thumbnails render a whole page at roughly a fifth of size, so the stripe
   period is scaled down to stay legible rather than turning to mud. */
.thumb-content p.mr-paragraph.resolved {
  background: repeating-linear-gradient(
    45deg,
    var(--hl-orange) 0, var(--hl-orange) 3px,
    var(--hl-green) 3px, var(--hl-green) 6px
  );
  border-left-color: var(--success);
}
.thumb-content p.mr-paragraph.manual {
  background: var(--hl-manual);
  border-left-color: var(--manual);
}
.thumb-content p.mr-paragraph.preview {
  background: transparent;
  border-left: 1.5px dashed var(--border-strong);
}

.mr-tag.resolved { background: var(--success-soft); color: var(--success); }
.mr-tag.manual   { background: var(--manual-soft); color: #0f766e; }

/* Manual marker on an Overview thumbnail pill. */
.thumb-manual-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--manual);
  vertical-align: 1px;
}

/* --- Overview: which passes a document has been through --- */
.doc-group-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.scan-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.scan-badge .ms { font-size: 13px; vertical-align: -2px; }
.scan-badge.quick   { background: var(--bg-soft);      color: var(--text-muted); border-color: var(--border); }
.scan-badge.deep    { background: var(--success-soft);  color: #15803d; border-color: #bbf7d0; }
.scan-badge.running { background: var(--primary-soft);  color: var(--primary-deep); border-color: #bfdbfe; }
.scan-badge.pending { background: #fff;                 color: var(--text-soft); border-color: var(--border); }
.scan-badge.failed  { background: var(--warn-soft);     color: #9a3412; border-color: #fed7aa; }
.scan-badge.running .ms { animation: stream-spin 1.1s linear infinite; }

/* --- Overview legend additions --- */
.overview-legend .dot.teal { background: var(--manual); }
.overview-legend .dot.striped {
  background: repeating-linear-gradient(
    45deg, var(--warn) 0, var(--warn) 3px, var(--success) 3px, var(--success) 6px
  );
}
.overview-legend .dot.dashed {
  background: transparent;
  border: 1px dashed var(--border-strong);
}

/* Statistics cells with no number yet: a document mid-queue. Muted and
   non-numeric so the eye keeps reading the real figures in the column. */
.proc-table td .cell-pending {
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: normal;
  color: var(--text-soft);
  font-style: italic;
}
.proc-table td .cell-pending.working { color: var(--primary); font-style: normal; }
.proc-table td .cell-pending.failed  { color: var(--warn);    font-style: normal; }
