/* =====================================================================
   Secsys Rekvisition OCR — delt design-system
   ===================================================================== */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;

  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-weak: #eef2ff;
  --brand-ink: #3730a3;

  --ok-bg: #dcfce7;   --ok-fg: #15803d;
  --warn-bg: #fef9c3; --warn-fg: #a16207;
  --err-bg: #fee2e2;  --err-fg: #b91c1c;

  --maxw: 100%;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 6px 20px rgba(15,23,42,.06);
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);

  /* Typografi ala secsys.cloud: Space Grotesk til display/overskrifter, Inter til brødtekst */
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1 { font-family: var(--font-display); font-size: 1.55rem; font-weight: 600; letter-spacing: -.02em; margin: 0 0 28px; }
h2 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; letter-spacing: -.01em; margin: 0 0 12px; }
p.lead { color: var(--muted); margin: 0 0 24px; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
  height: 62px; display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; font-size: 1.1rem; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand) 0%, #7c3aed 100%); color: #fff; box-shadow: var(--shadow-sm); }
.brand .sub { color: var(--muted); font-weight: 500; font-size: .8rem; margin-left: 2px; }

.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a {
  padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 550; font-size: .9rem;
  transition: background .15s, color .15s; display: inline-flex; align-items: center; gap: 7px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--brand-weak); color: var(--brand-ink); }
.nav a svg { width: 16px; height: 16px; }

.user { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.user .who { text-align: right; line-height: 1.2; }
.user .who .email { font-weight: 600; font-size: .85rem; }
.user .who .org { color: var(--muted); font-size: .78rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-weak); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 700; font-size: .85rem; }

/* ---------- Layout ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 28px 32px 60px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } .topbar-inner { gap: 14px; } .nav a span { display: none; } }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; }
.card + .card { margin-top: 20px; }
/* Kort side om side i et grid adskilles af grid-gap — auto-margin må ikke
   skubbe det 2. kort ned, ellers "hopper" kortene ud af linje. */
.grid-2 > .card + .card,
.detail-grid > .card + .card,
.work-grid > .card + .card,
.req-layout > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-head h2 { margin: 0; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 10px 18px;
  font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; transition: background .15s, border-color .15s, opacity .15s; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--surface); color: var(--err-fg); border-color: #f0c0c0; }
.btn-danger:hover { background: var(--err-bg); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-sm { padding: 7px 12px; font-size: .82rem; }
.btn-linklike { background: none; border: none; color: var(--err-fg); font: inherit; font-size: .82rem;
  font-weight: 600; cursor: pointer; padding: 6px 0 0; }
.btn-linklike:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .8rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.input, select.input { width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; font-size: .92rem; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.input:focus, select.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }
.field .hint-text { font-size: .78rem; color: var(--muted); margin-top: 5px; }
.field-row { display: flex; align-items: center; gap: 10px; }

/* Toggle-switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .15s; }
.switch .slider::before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: var(--shadow-sm); }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* Sektions-header i kort */
.section-note { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 16px; }

/* Logo i topbar */
.logo.logo-img { background: none; box-shadow: none; overflow: hidden; }
.logo.logo-img img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- Faner ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab { padding: 10px 16px; border: none; background: none; font: inherit; font-weight: 600; font-size: .92rem;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 8px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.tab svg { width: 16px; height: 16px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Logo-upload ---------- */
.logo-uploader { display: flex; align-items: center; gap: 16px; }
.logo-preview { width: 132px; height: 66px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview .ph { color: var(--muted-2); font-size: .78rem; }

/* ---------- Integrationskort ---------- */
.integration { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.integration .head { display: flex; align-items: flex-start; gap: 14px; }
.integration .ico { width: 42px; height: 42px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--brand-weak); color: var(--brand); }
.integration .ico svg { width: 22px; height: 22px; }
.integration .title { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; }
.integration .desc { color: var(--muted); font-size: .84rem; }
.integration .badge-ok { margin-left: auto; background: var(--ok-bg); color: var(--ok-fg);
  font-size: .78rem; font-weight: 650; padding: 4px 12px; border-radius: 999px; white-space: nowrap; }
.integration .badge-off { margin-left: auto; background: #e2e8f0; color: #475569;
  font-size: .78rem; font-weight: 650; padding: 4px 12px; border-radius: 999px; white-space: nowrap; }
.integration .keyline { margin: 16px 0; font-size: .85rem; }
.integration .keyline code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 10px; font-family: ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: .04em; }
.integration .actions { display: flex; gap: 10px; margin-top: 4px; }

/* ---------- Generisk modal (fx opret-formularer på admin) ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 24px; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(560px, 96vw); max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-box.modal-sm { width: min(440px, 96vw); }

/* ---------- AI-fane ---------- */
.ai-keybox { display: flex; align-items: center; gap: 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 6px 0 22px; }
.ai-keybox .ico { width: 36px; height: 36px; border-radius: 9px; flex: none; display: grid;
  place-items: center; background: var(--brand-weak); color: var(--brand-ink); }
.ai-keybox .ico svg { width: 18px; height: 18px; }
.ai-keybox code { font-size: .9rem; letter-spacing: .02em; }
.ai-keybox .src { margin-left: auto; font-size: .72rem; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 11px; }
.ai-formlabel { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin: 2px 0 12px; }
.ai-stats { display: flex; gap: 14px; }
.ai-stat { flex: 1; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; }
.ai-stat .num { font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; color: var(--text); }
.ai-stat .lbl { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; }
.modal-close { background: none; border: none; font-size: 1.4rem; line-height: 1; color: var(--muted);
  cursor: pointer; padding: 2px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }

/* ---------- Handlings-ikonknapper i tabelrækker ---------- */
.tbl-actions { display: inline-flex; gap: 4px; justify-content: flex-end; width: 100%; }
.tbl-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border: 1px solid transparent; border-radius: 8px; background: none; color: var(--muted); cursor: pointer;
  transition: background .12s, color .12s, border-color .12s; }
.tbl-btn svg { width: 16px; height: 16px; }
.tbl-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.tbl-btn.danger:hover { background: var(--err-bg); color: var(--err-fg); border-color: #f0c0c0; }

/* ---------- Brugerliste ---------- */
.user-row { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px; }
.user-row .u-name { font-weight: 650; }
.user-row .u-email { color: var(--muted); font-size: .84rem; }
.user-row .spacer { flex: 1; }
.role-badge { background: var(--brand-weak); color: var(--brand-ink); font-size: .74rem; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; text-transform: capitalize; }
.badge-pending { background: var(--warn-bg); color: var(--warn-fg); font-size: .72rem; font-weight: 650;
  padding: 3px 9px; border-radius: 999px; }
.section-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 700; margin: 4px 0 12px; }
.invite-link { display: block; margin-top: 12px; padding: 12px; background: var(--surface-2);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); font-size: .82rem; word-break: break-all; }

/* ---------- Licens / plan ---------- */
.plan-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.plan-name { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; letter-spacing: -.02em; }
.plan-price { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; color: var(--brand-ink); margin-top: 12px; }
.plan-badge { font-size: .78rem; font-weight: 700; padding: 4px 13px; border-radius: 999px; white-space: nowrap; }
.plan-badge-none { background: var(--warn-bg); color: var(--warn-fg); }
.plan-badge-active { background: var(--ok-bg); color: var(--ok-fg); }
.plan-features { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; }
.plan-features li { display: flex; align-items: center; gap: 9px; font-size: .9rem; }
.plan-select { padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: 7px; font: inherit; font-size: .84rem; background: var(--surface); }

/* ---------- Dropzone ---------- */
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
  padding: 34px 24px; text-align: center; transition: border-color .15s, background .15s; }
.dropzone.drag { border-color: var(--brand); background: var(--brand-weak); }
.dropzone .icon { width: 46px; height: 46px; margin: 0 auto 12px; color: var(--brand); }
.dropzone .hint { color: var(--muted); font-size: .88rem; margin: 6px 0 16px; }
.dropzone .filename { font-weight: 600; color: var(--text); }

/* ---------- Status badges ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px;
  font-size: .76rem; font-weight: 650; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-approved { background: var(--ok-bg); color: var(--ok-fg); }
.status-review { background: var(--warn-bg); color: var(--warn-fg); }
.status-unknown_customer { background: var(--err-bg); color: var(--err-fg); }
.status-pending { background: #e2e8f0; color: #475569; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 650; padding: 0 12px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: .9rem; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-2); }
.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: .88rem; vertical-align: top; }
.kv td:first-child { color: var(--muted); font-weight: 550; width: 42%; }
.kv tr:last-child td { border-bottom: none; }

/* ---------- Misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 46px 20px; }
.empty .icon { width: 42px; height: 42px; margin: 0 auto 12px; color: var(--muted-2); }
.meta { color: var(--muted); font-size: .82rem; }
.pill-count { background: var(--brand-weak); color: var(--brand-ink); font-size: .74rem; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; }
.login-brand { font-family: var(--font-display); }
pre.raw { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border);
  padding: 12px; border-radius: var(--radius-sm); max-height: 320px; overflow: auto; font-size: .8rem; color: #334155; }
details summary { cursor: pointer; color: var(--brand-ink); font-weight: 600; font-size: .85rem; }
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: .88rem; margin-top: 14px; }
.alert-err { background: var(--err-bg); color: var(--err-fg); }
.alert-ok { background: var(--ok-bg); color: var(--ok-fg); }
.confidence-bar { height: 7px; background: var(--border); border-radius: 999px; overflow: hidden; width: 120px; }
.confidence-bar > span { display: block; height: 100%; background: var(--brand); }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.toolbar h1 { margin: 0; }  /* titel-rækken (rekvisitioner): afstanden styres af .toolbar */
.toolbar .spacer { flex: 1; }

/* ---------- PDF-preview ---------- */
.pdf-panel { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.pdf-panel .pdf-head { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border); }
.pdf-panel .pdf-head h2 { margin: 0; }
.pdf-frame { width: 100%; border: 0; background: #f1f5f9; display: block; }
.pdf-empty { flex: 1; display: grid; place-items: center; }

/* Arbejds-layout: PDF-preview til venstre, handling/resultat til højre */
.work-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .work-grid { grid-template-columns: 1fr; } }

/* Kompakt upload-linje (fylder lidt så resultatet får overblik) */
.upload-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dropzone.compact { flex: 1; min-width: 220px; margin: 0; padding: 12px 16px; text-align: left;
  display: flex; align-items: center; gap: 14px; }
.dropzone.compact .icon { width: 28px; height: 28px; margin: 0; flex: none; }
.dropzone.compact .filename { font-size: .9rem; }
.dropzone.compact .hint { margin: 0; font-size: .8rem; }

/* ---------- Detalje-grid (PDF | resultat) — delt af upload + rekvisitionsside ---------- */
.detail-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 1200px) { .detail-grid { grid-template-columns: 1fr; } }
.input.from-region { border-color: var(--ok-fg); box-shadow: 0 0 0 2px var(--ok-bg); }

/* ---------- Marker-felter modal (delt: marker.js) ---------- */
.marker-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 24px; }
.marker-overlay.open { display: flex; }
.marker-box { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(1180px, 96vw); max-height: 94vh; display: flex; flex-direction: column; overflow: hidden; }
.marker-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.marker-head h2 { margin: 0; }
.marker-head .spacer { flex: 1; }
.marker-body { display: grid; grid-template-columns: 1fr 350px; gap: 0; min-height: 0; flex: 1; }
.marker-stagewrap { overflow: auto; background: #f1f5f9; padding: 16px; display: flex; justify-content: center; }
.marker-stage { position: relative; align-self: flex-start; box-shadow: var(--shadow-sm); }
.marker-stage canvas { display: block; }
.marker-draw { position: absolute; inset: 0; cursor: crosshair; }
.marker-draw.disabled { cursor: default; }
.region-box { position: absolute; border: 2px solid var(--brand); background: rgba(79,70,229,.12); pointer-events: none; }
.region-box .tag { position: absolute; top: -18px; left: -2px; background: var(--brand); color: #fff;
  font-size: .68rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.region-box.live { border-style: dashed; }
.marker-side { border-left: 1px solid var(--border); padding: 16px; overflow-y: auto; overflow-x: hidden; }
.marker-hint { font-size: .82rem; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 14px; }
.mfield { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 12px; margin-bottom: 10px; }
.mfield.armed { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-weak); }
.mfield .row { display: flex; align-items: center; gap: 6px; }
.mfield .name { font-weight: 650; font-size: .86rem; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mfield .saved { flex: none; font-size: .62rem; font-weight: 700; color: var(--ok-fg); background: var(--ok-bg);
  padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.mfield .row .btn { flex: none; padding: 5px 11px; font-size: .78rem; }
.mfield .del { flex: none; background: none; border: none; color: var(--err-fg); font: inherit;
  font-size: .78rem; font-weight: 600; cursor: pointer; padding: 5px 4px; }
.mfield .del:hover { text-decoration: underline; }
.mfield .val { font-size: .82rem; color: var(--text); margin-top: 6px; word-break: break-word;
  min-height: 1em; line-height: 1.4; }
.mfield .val:empty::before { content: 'ingen markering'; color: var(--muted-2); }
