:root {
  /* FlexCare-branding: slate-teal (#8EB2BB) + koksgrå (#424242) */
  --bg: #18272b;
  --bg-soft: #1d3034;
  --panel: #ffffff;
  --ink: #3a3a3a;
  --ink-soft: #74808a;
  --line: #e4eaec;
  --logo-teal: #8eb2bb;
  --brand: #4e7681;
  --brand-deep: #38565e;
  --brand-bright: #5b8893;
  --accent: #6fa1ad;
  --accent-warm: #d99a4e;
  --teal-row: #eef5f6;
  --pink-row: #f6eef0;
  --ok: #3f8f7a;
  --shadow: 0 10px 40px rgba(20, 38, 42, 0.16);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1200px 500px at 80% -10%, #2c4a52 0%, transparent 60%),
    linear-gradient(180deg, #18272b 0%, #1c2f33 100%);
  color: var(--ink);
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px;
  background: linear-gradient(120deg, var(--brand-deep), var(--brand) 60%, #5c8893);
  color: #fff;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 16px; }
.brand-logo { height: 42px; width: auto; display: block; }
.brand-divider { width: 1px; height: 34px; background: rgba(255,255,255,.28); }
.brand-text h1 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 21px; font-weight: 700; margin: 0; letter-spacing: .3px;
}
.brand-text p { margin: 0; font-size: 12px; opacity: .72; letter-spacing: 1.5px; text-transform: uppercase; }
.topbar-meta { display: flex; align-items: center; gap: 12px; }
.meta-customer { font-size: 13px; opacity: .85; }

.badge {
  font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px;
}
.badge-demo { background: rgba(244,165,49,.18); color: #ffd089; border: 1px solid rgba(244,165,49,.5); }
.badge-live { background: rgba(24,194,156,.18); color: #7af0d0; border: 1px solid rgba(24,194,156,.55); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 14px;
  border: none; border-radius: 10px; padding: 9px 15px; cursor: pointer;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-bright); color: #fff; box-shadow: 0 4px 14px rgba(56,86,94,.4); }
.btn-primary:hover { background: #6a98a3; }
.btn-ghost { background: rgba(255,255,255,.1); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.2); }
.btn.small { padding: 6px 11px; font-size: 13px; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 4px; padding: 0 26px;
  background: var(--bg-soft);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.tab {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.55); font: inherit; font-weight: 600; font-size: 14.5px;
  padding: 14px 18px; position: relative;
  transition: color .15s;
}
.tab:hover { color: rgba(255,255,255,.85); }
.tab.active { color: #fff; }
.tab.active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 3px;
  background: linear-gradient(90deg, var(--brand-bright), var(--accent));
  border-radius: 3px 3px 0 0;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 26px;
  background: var(--bg);
}
.search {
  display: flex; align-items: center; gap: 9px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px; padding: 9px 13px; color: rgba(255,255,255,.6);
  min-width: 320px;
}
.search input {
  background: none; border: none; outline: none; color: #fff; font: inherit; font-size: 14px; width: 100%;
}
.search input::placeholder { color: rgba(255,255,255,.4); }
.select {
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  color: #fff; font: inherit; font-size: 14px; border-radius: 10px; padding: 9px 13px; cursor: pointer;
}
.select option { color: #0e1726; }
.spacer { flex: 1; }
.count-label { color: rgba(255,255,255,.6); font-size: 13px; font-weight: 500; }

/* ---------- Content ---------- */
main {
  padding: 0 26px 60px;
}
.panel {
  background: var(--panel); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}

/* ---------- Oversigt: kunde-blokke ---------- */
.cust-block {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; margin-bottom: 22px;
}
.cust-head {
  display: flex; align-items: baseline; gap: 12px;
  background: linear-gradient(110deg, var(--brand-deep), var(--brand));
  color: #fff; padding: 14px 20px;
}
.cust-name { font-family: "Space Grotesk", sans-serif; font-size: 17px; font-weight: 700; letter-spacing: .3px; }
.cust-count {
  font-size: 12.5px; font-weight: 600; opacity: .85;
  background: rgba(255,255,255,.15); padding: 3px 10px; border-radius: 999px;
}

/* ---------- Oversigt table ---------- */
/* Oversigten har sin egen scroll-boks (lodret + vandret), så kolonne-headeren
   og kunde-overskrifterne kan klæbe fast øverst når man ruller. */
.table-wrap { overflow: auto; max-height: calc(100vh - 200px); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid thead th {
  position: sticky; top: 0; z-index: 4;
  background: linear-gradient(180deg, var(--brand), var(--brand-deep));
  color: #fff; font-weight: 600; text-align: center;
  padding: 13px 12px; white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,.1);
}
table.grid thead th:first-child { text-align: left; }
/* Fast bredde på Boks/Rum-kolonnen, så den er ens på tværs af alle kunde-tabeller.
   Lange navne ombrydes i stedet for at udvide kolonnen. */
table.grid th.col-name, table.grid td.cell-name {
  width: 320px; min-width: 320px; max-width: 320px;
  white-space: normal; overflow-wrap: anywhere; word-break: break-word;
}
table.grid thead th.col-name { text-align: left; }
/* Ensartet bredde på pakke-kolonnerne, så de flugter lodret hele vejen ned.
   Lange pakkenavne i headeren ombrydes i stedet for at gøre kolonnen bredere. */
table.grid th.pkgcol, table.grid td.pkgcol {
  width: 94px; min-width: 94px; max-width: 94px;
}
table.grid thead th.pkgcol {
  white-space: normal; vertical-align: bottom; font-size: 12px; line-height: 1.25;
}
table.grid th.col-section, table.grid td.cell-left { min-width: 90px; }
table.grid th.col-id, table.grid td.col-id { min-width: 132px; white-space: nowrap; }
table.grid tbody td {
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  border-right: 1px solid #eef2f8; text-align: center; color: var(--ink);
}
table.grid tbody td.cell-name { text-align: left; font-weight: 600; }
table.grid tbody td.cell-left { text-align: left; }
/* Kunde-overskriftsrække: klæber fast lige under kolonne-headeren, hvid tekst.
   Selektoren er specifik nok til at slå `table.grid tbody td`-tekstfarven. */
table.grid tbody tr.section-row td {
  position: sticky; top: 56px; z-index: 3;
  background: linear-gradient(90deg, var(--brand-deep), var(--brand));
  color: #fff !important; font-family: "Space Grotesk", sans-serif; font-weight: 700;
  text-align: left !important; letter-spacing: .3px; padding: 11px 14px; font-size: 15px;
}
.section-row .sec-count { opacity: .8; font-weight: 500; font-size: 12.5px; margin-left: 8px; color: #fff; }
tr.grp-0 td:not(.section-row td) { }
.tone-teal td { background: var(--teal-row); }
.tone-pink td { background: var(--pink-row); }
.tone-teal:hover td { background: #d9f0eb; }
.tone-pink:hover td { background: #f6dde9; }

.check { color: var(--ok); font-weight: 800; font-size: 15px; }
.dash { color: #b8c2d4; }
.mac { font-family: "Space Grotesk", ui-monospace, monospace; font-size: 12.5px; color: var(--ink-soft); letter-spacing: .5px; }
.addons { text-align: left !important; }
.chip {
  display: inline-block; background: #eaf2f3; color: var(--brand-deep);
  border: 1px solid #d3e2e5; border-radius: 999px; padding: 2px 9px; margin: 2px 3px 2px 0;
  font-size: 12px; font-weight: 600;
}
.pill-count {
  display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 7px;
  border-radius: 999px; font-weight: 700; font-size: 12.5px;
  background: #eef2f8; color: var(--ink-soft);
}
.pill-count.has { background: var(--accent-warm); color: #5a3c00; }

/* ---------- Matrix ---------- */
.matrix-wrap { overflow: auto; max-height: 75vh; }
table.matrix { border-collapse: collapse; font-size: 12.5px; }
table.matrix th, table.matrix td { border: 1px solid var(--line); padding: 7px 9px; text-align: center; }
table.matrix thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--brand); color: #fff; white-space: nowrap;
}
table.matrix thead th.rot {
  height: 190px; min-width: 30px; padding: 8px 0 10px; vertical-align: bottom; cursor: default;
}
table.matrix thead th.rot > div {
  writing-mode: vertical-rl; transform: rotate(180deg); margin: 0 auto;
  white-space: nowrap; max-height: 172px; overflow: hidden; text-overflow: ellipsis;
  font-size: 12px; font-weight: 600; letter-spacing: .2px;
}
table.matrix th.row-head, table.matrix td.row-head {
  position: sticky; left: 0; z-index: 2; background: #f7f9fc; text-align: left;
  font-weight: 600; min-width: 220px; color: var(--ink);
}
table.matrix thead th.corner { position: sticky; left: 0; z-index: 4; background: var(--brand-deep); text-align: left; }
table.matrix td.on { background: var(--accent); }
table.matrix td.on::after { content: "✓"; color: #04382c; font-weight: 800; }

/* ---------- Statistik ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card {
  background: var(--panel); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow);
  border-left: 4px solid var(--brand-bright);
}
.stat-card .num { font-family: "Space Grotesk", sans-serif; font-size: 34px; font-weight: 700; color: var(--brand-deep); line-height: 1; }
.stat-card .lbl { font-size: 13px; color: var(--ink-soft); margin-top: 6px; font-weight: 500; }
.stat-card.accent { border-left-color: var(--accent); }
.stat-card.warm { border-left-color: var(--accent-warm); }
.stat-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .stat-panels { grid-template-columns: 1fr; } }
.stat-block { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.stat-block h3 { margin: 0 0 14px; font-family: "Space Grotesk", sans-serif; font-size: 16px; color: var(--ink); }
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar-row .name { width: 150px; font-size: 13px; font-weight: 600; color: var(--ink); flex-shrink: 0; }
.bar-track { flex: 1; height: 22px; background: #eef2f8; border-radius: 7px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 7px; background: linear-gradient(90deg, var(--brand-bright), var(--accent)); }
.bar-row .val { width: 38px; text-align: right; font-weight: 700; font-size: 13px; color: var(--ink-soft); }

/* ---------- Kunder (vis/skjul) ---------- */
.kunder-panel { padding: 0; }
.kunder-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 22px 24px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.kunder-head h2 { margin: 0 0 4px; font-family: "Space Grotesk", sans-serif; font-size: 19px; color: var(--ink); }
.kunder-head .hint { max-width: 560px; }
.kunder-actions { display: flex; align-items: center; gap: 10px; }
.kunder-actions .btn-ghost { background: #eef4f5; color: var(--brand-deep); }
.kunder-actions .btn-ghost:hover { background: #e1edef; }
.kunder-summary { font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-right: 4px; }
.kunder-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px;
  padding: 18px 24px 24px;
}
.kunder-row {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  background: #f7fafb; border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px;
  transition: background .12s, border-color .12s, opacity .12s;
}
.kunder-row:hover { border-color: var(--logo-teal); background: #eef5f6; }
.kunder-row.off { opacity: .55; }
.kunder-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); flex-shrink: 0; cursor: pointer; }
.kunder-row .k-name { font-weight: 600; color: var(--ink); flex: 1; }
.kunder-row .k-count {
  font-size: 12px; font-weight: 600; color: var(--ink-soft);
  background: #e8eef0; border-radius: 999px; padding: 3px 10px; flex-shrink: 0;
}

/* ---------- States ---------- */
.empty {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 60px 30px; text-align: center; color: var(--ink-soft);
}
.empty h3 { color: var(--ink); font-family: "Space Grotesk", sans-serif; margin: 14px 0 6px; }
.spinner {
  width: 38px; height: 38px; border: 4px solid #dde7e9; border-top-color: var(--brand-bright);
  border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-box {
  background: #fff4f4; border: 1px solid #ffd0d0; color: #a02020; border-radius: var(--radius);
  padding: 18px 20px; margin-top: 6px;
}
.error-box code { background: rgba(0,0,0,.06); padding: 2px 6px; border-radius: 5px; font-size: 12px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8,16,32,.6); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; background: #fff; border-radius: 18px; width: min(620px, 92vw);
  max-height: 88vh; overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px 6px; }
.modal-head h2 { margin: 0; font-family: "Space Grotesk", sans-serif; font-size: 20px; }
.icon-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--ink-soft); }
.modal-body { padding: 12px 26px; }
.field-group { padding: 16px 0; border-bottom: 1px solid var(--line); }
.field-group:last-child { border-bottom: none; }
.field-group h3 { margin: 0 0 4px; font-size: 15px; font-family: "Space Grotesk", sans-serif; }
.field-group label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-top: 14px; }
.field-group input, .field-group select {
  width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 9px; background: #fafbfe; color: var(--ink);
}
.field-group input:focus, .field-group select:focus { outline: none; border-color: var(--brand-bright); background: #fff; }
.field-group .row { display: flex; gap: 12px; }
.field-group .row > label { flex: 1; }
.token-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.link-btn {
  background: none; border: none; padding: 0; cursor: pointer; flex-shrink: 0;
  color: var(--brand); font: inherit; font-size: 12.5px; font-weight: 600; text-decoration: underline;
}
.link-btn:hover { color: var(--brand-deep); }
.link-btn.hidden { display: none; }
.opt { color: var(--ink-soft); font-weight: 400; }
.hint { color: var(--ink-soft); font-size: 12.5px; font-weight: 400; }
.columns-editor { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.pkg-edit {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center;
  background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
}
.pkg-edit.is-hidden { opacity: .5; }
.pkg-move { display: flex; flex-direction: column; gap: 2px; }
.pkg-move .mv {
  background: #e7edf6; border: none; border-radius: 5px; width: 26px; height: 17px; line-height: 1;
  font-size: 9px; cursor: pointer; color: var(--brand-deep);
}
.pkg-move .mv:disabled { opacity: .3; cursor: default; }
.pkg-name { font-weight: 700; color: var(--ink); }
.pkg-count { font-size: 12px; color: var(--ink-soft); }
.pkg-show { display: flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin: 0 !important; }
.pkg-show input { width: auto !important; margin: 0 !important; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 16px 26px 22px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #0e1726; color: #fff; padding: 12px 20px; border-radius: 11px;
  box-shadow: 0 12px 30px rgba(0,0,0,.4); font-size: 14px; font-weight: 500; z-index: 200;
  transition: opacity .25s, transform .25s;
}
.toast.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(10px); }
.toast.err { background: #7a1f1f; }
.toast.ok { background: #145c40; }

/* ---------- Udskriv-menu (skærm) ---------- */
.print-wrap { position: relative; }
.print-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 50;
  background: #fff; border-radius: 12px; box-shadow: 0 16px 44px rgba(0,0,0,.32);
  min-width: 300px; max-height: 64vh; overflow-y: auto; padding: 8px;
}
.print-menu.hidden { display: none; }
.pm-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  padding: 9px 12px; border-radius: 8px; font: inherit; font-size: 14px; color: var(--ink);
}
.pm-item:hover { background: #eef5f6; }
.pm-all { font-weight: 700; border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; }
.pm-count { color: var(--ink-soft); font-size: 12.5px; font-weight: 600; flex-shrink: 0; }
.pm-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--ink-soft); padding: 10px 12px 4px; }

/* ---------- Udskrifts-rapport ---------- */
#printRoot { display: none; }
.print-report { color: #222; font-family: "Inter", sans-serif; }
.print-top {
  display: flex; align-items: flex-end; justify-content: space-between;
  border-bottom: 3px solid var(--brand); padding-bottom: 10px; margin-bottom: 18px;
}
.pt-logo { height: 44px; width: auto; }
.pt-meta { text-align: right; }
.pt-title { font-family: "Space Grotesk", sans-serif; font-size: 16px; font-weight: 700; color: #1f1f1f; }
.pt-sub { font-size: 12.5px; color: var(--brand-deep); font-weight: 600; margin-top: 3px; }
.pt-date { font-size: 11px; color: #777; margin-top: 2px; }

/* Lad store kunder bryde over flere sider (undgår tom side 1), men hold
   header + statistik samlet og bryd ikke midt i en boks-række. */
.print-cust { break-inside: auto; margin-bottom: 22px; }
.print-cust-head {
  display: flex; align-items: baseline; justify-content: space-between;
  background: var(--brand); color: #fff; padding: 8px 13px; border-radius: 7px 7px 0 0;
  font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 15px;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
  break-inside: avoid; break-after: avoid;
}
.print-stats { break-inside: auto; }
.pch-count { font-weight: 500; font-size: 12px; opacity: .92; }
.print-cust h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--brand-deep); margin: 12px 0 6px; break-after: avoid;
}

.ps-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.ps-table tr { break-inside: avoid; }
.ps-table td { padding: 3px 6px; vertical-align: middle; }
.ps-name { font-weight: 600; color: #333; width: 42%; }
.ps-n { width: 38px; text-align: right; font-weight: 700; }
.ps-bar { width: 38%; }
.ps-bar span {
  display: inline-block; height: 9px; background: var(--logo-teal); border-radius: 3px; min-width: 2px;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.ps-pct { width: 46px; text-align: right; color: #666; }

.pm-table { width: 100%; border-collapse: collapse; font-size: 10.5px; margin-top: 2px; }
.pm-table th, .pm-table td { border: 1px solid #cdd6d8; padding: 4px 5px; text-align: center; }
.pm-table thead { display: table-header-group; } /* gentag overskrift på hver side */
.pm-table tr { break-inside: avoid; } /* bryd ikke midt i en boks-række */
.pm-table thead th {
  background: var(--brand-deep); color: #fff; font-weight: 600;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.pm-table th.pm-box, .pm-table td.pm-box { text-align: left; width: 28%; font-weight: 600; }
.pm-table .pm-c .yes { color: #2e7d5b; font-weight: 800; }
.pm-table .pm-c .no { color: #b6c0c2; }
.pm-table td.pm-id { font-family: ui-monospace, monospace; font-size: 9.5px; color: #555; white-space: nowrap; }

/* ---------- Print-tilstand ---------- */
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  .topbar, .tabs, .toolbar, main, .modal, #toast, .print-wrap { display: none !important; }
  body { background: #fff !important; }
  #printRoot { display: block !important; }
}
