:root {
    --ink: #16232a;
    --ink-raised: #1e323b;
    --ink-line: #2c414a;
    --ink-text: #e7edee;
    --ink-text-soft: #9db0b6;

    --paper: #f5f3ee;
    --surface: #ffffff;
    --border: #e2ded2;
    --text: #1c2420;
    --text-muted: #6b7268;

    --accent: #1f6f64;
    --accent-hover: #17554c;
    --accent-soft: #e2ede9;

    --gold: #a9782f;
    --gold-soft: #f4e9d3;

    --success-bg: #e7f2e5;
    --success-text: #2f6b3c;
    --error-bg: #f8e8e3;
    --error-text: #a23b2e;

    --radius: 8px;
    --sidebar-w: 230px;

    --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
    --sans: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #12181a;
        --surface: #1a2225;
        --border: #2a3336;
        --text: #e6e9e6;
        --text-muted: #92a19a;
        --accent-soft: #17332d;
        --success-bg: #163223;
        --success-text: #7cc396;
        --error-bg: #351f1c;
        --error-text: #e2988a;
        --gold-soft: #2e2415;
    }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--sans);
    background: var(--paper);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--serif); font-weight: 400; text-wrap: balance; }
h1 { font-size: 1.7rem; margin: 0 0 1rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; margin: 1.6rem 0 0.75rem; }
h3 { font-size: 1.05rem; margin: 1.3rem 0 0.6rem; }

/* --- App-shell: fast venstre-sidebar + indhold --- */

.app-shell { display: flex; min-height: 100vh; }

aside.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--ink);
    color: var(--ink-text);
    display: flex;
    flex-direction: column;
    padding: 1.1rem 0 1rem;
}

.sidebar .brand {
    display: block;
    text-decoration: none;
    font-family: var(--serif);
    font-size: 1.25rem;
    color: #fff;
    padding: 0 1.2rem 1.1rem;
    border-bottom: 1px solid var(--ink-line);
    margin-bottom: 0.9rem;
}

.sidebar nav { flex: 1; overflow-y: auto; }

.nav-group { margin-bottom: 1.1rem; }
.nav-group .group-label {
    font-family: var(--mono);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-text-soft);
    padding: 0 1.2rem;
    margin-bottom: 0.35rem;
}
.nav-group a {
    display: block;
    color: var(--ink-text);
    padding: 0.45rem 1.2rem;
    font-size: 0.92rem;
    border-left: 3px solid transparent;
}
.nav-group a:hover {
    background: var(--ink-raised);
    text-decoration: none;
}
.nav-group a.active {
    background: var(--ink-raised);
    border-left-color: var(--gold);
    color: #fff;
}

.sidebar .session-block {
    border-top: 1px solid var(--ink-line);
    padding: 0.9rem 1.2rem 0;
    font-size: 0.85rem;
}
.sidebar .session-name { color: #fff; font-weight: 600; }
.sidebar .session-role { color: var(--ink-text-soft); font-size: 0.8rem; margin-bottom: 0.6rem; }
.sidebar form { margin: 0; }
.sidebar button.secondary {
    width: 100%;
    background: transparent;
    border: 1px solid var(--ink-line);
    color: var(--ink-text);
}
.sidebar button.secondary:hover { background: var(--ink-raised); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

header.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.9rem;
}

.credit-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    background: var(--gold-soft);
    color: var(--gold);
    border-radius: 999px;
    padding: 0.3rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
}
.credit-chip .n { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 0.95rem; }

main {
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
    padding: 1.75rem 1.75rem 3.5rem;
    flex: 1;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

ul.flash-messages { list-style: none; margin: 0 0 1.25rem; padding: 0; }
ul.flash-messages li {
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.92rem;
}
ul.flash-messages li.success { background: var(--success-bg); color: var(--success-text); }
ul.flash-messages li.error { background: var(--error-bg); color: var(--error-text); }

form label {
    display: inline-block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0.9rem 0.75rem 0;
}
form label input, form label select, form label textarea {
    display: block;
    margin-top: 0.25rem;
}

input[type=text], input[type=number], input[type=email], input[type=password],
input[type=date], select, textarea {
    font-family: inherit;
    font-size: 0.92rem;
    padding: 0.4rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
}
textarea { min-width: 100%; max-width: 100%; }

.range-group {
    display: inline-flex;
    flex-direction: column;
    margin: 0 0.9rem 0.75rem 0;
    vertical-align: top;
}
.range-group-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.range-group-inputs {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.range-group-inputs input[type=number] {
    width: 5.5rem;
}
.range-group-sep {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.filter-chips-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--border);
}
.filter-chip-active {
    display: inline-block;
    font-size: 0.82rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    text-decoration: none;
}
.filter-chip-active:hover { background: var(--accent); color: #fff; }
.filter-chip-clear {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-decoration: underline;
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.filter-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--text-muted);
    padding: 0.5rem 0.75rem;
    font-size: 0.88rem;
    cursor: pointer;
}
.filter-tab:hover { color: var(--text); }
.filter-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}
.filter-tab .tab-count {
    display: inline-block;
    min-width: 1.1rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: var(--gold-soft);
    color: var(--text);
    font-size: 0.72rem;
    font-weight: 600;
}
.filter-tab-panel { padding: 0.25rem 0 0.5rem; }

button, input[type=submit] {
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.45rem 1rem;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
}
button:hover, input[type=submit]:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}
button.secondary, .button-secondary {
    background: var(--surface);
    color: var(--accent);
    border: 1px solid var(--border);
}
button.secondary:hover, .button-secondary:hover { background: var(--paper); }
/* Link-knap ved siden af .btn-unlock: samme form og størrelse, men hvid med grøn kant */
a.button-secondary {
    display: inline-block;
    border-color: var(--accent);
    padding: calc(0.4rem - 1px) calc(0.95rem - 1px);
    border-radius: 6px;
    font-size: 0.86rem;
    font-weight: 600;
    text-decoration: none !important;
}
button.danger { background: var(--error-text); border-color: var(--error-text); }

/* Fremtrædende "lås op"-knap (afsnit 8: hele forretningen kører på dette klik) */
.btn-unlock {
    display: inline-block;
    background: var(--accent);
    color: #fff !important;
    padding: 0.4rem 0.95rem;
    border-radius: 6px;
    font-size: 0.86rem;
    font-weight: 600;
    text-decoration: none !important;
}
.btn-unlock:hover { background: var(--accent-hover); }

table {
    border-collapse: collapse;
    width: 100%;
    background: var(--surface);
    font-size: 0.9rem;
}
table th, table td {
    padding: 0.6rem 0.7rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}
table th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
table tr:hover td { background: var(--paper); }
table td.num, table th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }

/* Klikbare kolonneoverskrifter (26-07-2026): sortering/til-fra-toggle direkte fra
   tabellen -- arver th'ens egen farve/stil i stedet for at ligne et almindeligt link. */
.sortable-header { color: inherit; text-decoration: none; cursor: pointer; }
.sortable-header:hover { text-decoration: underline; }
.sortable-header-active { color: var(--accent); }

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    background: var(--paper);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.badge.active { background: var(--success-bg); color: var(--success-text); border-color: transparent; }
.badge.inactive { background: var(--error-bg); color: var(--error-text); border-color: transparent; }

/* --- Dashboard: nøgletal, søjlediagrammer (trin 9, afsnit 13) --- */

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.stat-card { background: var(--surface); padding: 1rem 1.2rem; }
.stat-card .stat-value {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    font-size: 1.6rem;
    color: var(--text);
    display: block;
}
.stat-card .stat-label {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.balance-bar-track {
    height: 0.6rem;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 999px;
    overflow: hidden;
    margin: 0.4rem 0 0.3rem;
}
.balance-bar-fill { height: 100%; background: var(--gold); }
.balance-bar-caption { font-size: 0.82rem; color: var(--text-muted); }

.hbar-chart { display: flex; flex-direction: column; gap: 0.55rem; }
.hbar-row { display: grid; grid-template-columns: 9rem 1fr 2.4rem; align-items: center; gap: 0.7rem; }
.hbar-label { font-size: 0.85rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 0.65rem; background: var(--paper); border-radius: 999px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.hbar-count { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 0.82rem; color: var(--text-muted); text-align: right; }

.trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.35rem;
    height: 7rem;
    padding-top: 0.5rem;
}
.trend-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    gap: 0.3rem;
}
.trend-bar {
    width: 100%;
    max-width: 1.4rem;
    background: var(--accent-soft);
    border-radius: 3px 3px 0 0;
    min-height: 2px;
    position: relative;
}
.trend-col.has-count .trend-bar { background: var(--accent); }
.trend-date {
    font-family: var(--mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    height: 2.6rem;
}

/* --- Rettigheds-chips (org_users.html) --- */
.perm-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; max-width: 28rem; }
.perm-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--sans);
    font-size: 0.82rem;
    padding: 0.3rem 0.75rem 0.3rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.perm-chip::before {
    content: "";
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
}
.perm-chip:hover { background: var(--paper); border-color: var(--text-muted); }
.perm-chip.granted {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: transparent;
    font-weight: 600;
}
.perm-chip.granted::before { background: var(--accent); }

/* --- Kompakt, kort-indrammet formular (fx "Opret ny bruger") --- */
.form-card {
    max-width: 26rem;
}
.form-card label { display: block; margin: 0 0 0.9rem; }
.form-card label input:not([type=checkbox]):not([type=radio]), .form-card label select {
    width: 100%;
    margin-top: 0.3rem;
}
.form-card label input[type=checkbox], .form-card label input[type=radio] {
    width: auto;
    margin-right: 0.4rem;
    vertical-align: middle;
}

/* --- Rig-tekst-editorens værktøjslinje (_richtext_editor.html) --- */
.richtext-toolbar {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 6px 6px 0 0;
    border-bottom: none;
    background: var(--paper);
    width: fit-content;
}
.richtext-toolbar button, .richtext-toolbar label {
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.4rem 0.7rem;
    border: none;
    border-right: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
}
.richtext-toolbar button:last-child, .richtext-toolbar label:last-child { border-right: none; }
.richtext-toolbar button:hover, .richtext-toolbar label:hover { background: var(--accent-soft); color: var(--accent); }
.richtext-editable {
    border: 1px solid var(--border);
    border-radius: 0 0 6px 6px;
    min-height: 100px;
    padding: 0.6rem 0.8rem;
    background: var(--surface);
    margin: 0 0 0.6rem;
}
.richtext-editable:focus-visible { outline: 2px solid var(--gold); outline-offset: -1px; }

/* Initial-badge: firkant med 1-2 bogstaver, farve afledt af teksten (branche
   før køb, rigtigt navn efter). Samme visuelle mønster som konkurrenters
   virksomhedslister, men uden at afsløre identitet før betaling. */
.avatar-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.avatar-1 { background: #1f6f64; }
.avatar-2 { background: #4a5568; }
.avatar-3 { background: #a9782f; }
.avatar-4 { background: #3d5a80; }
.avatar-5 { background: #6b4c5e; }
.avatar-6 { background: #5c6b3f; }

.row-with-avatar { display: flex; align-items: center; gap: 0.65rem; }

nav.main-menu ul { list-style: none; padding: 0; margin: 0; }
nav.main-menu li { margin-bottom: 0.5rem; }

.admin-viewing-banner {
    background: var(--gold-soft);
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.admin-viewing-banner button.secondary { border-color: var(--gold); color: var(--gold); }

/* --- Bekræft-dialog (2026-08-23): erstatter browserens native confirm(). --- */
.confirm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(22, 35, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.confirm-modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 24rem;
    width: calc(100% - 2.5rem);
    box-shadow: 0 12px 32px rgba(0,0,0,0.22);
}
.confirm-modal-box p { margin: 0 0 1.25rem; font-size: 0.95rem; }
.confirm-modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }

.text-muted { color: var(--text-muted); }
.pagination { margin-top: 1rem; display: flex; gap: 1rem; align-items: center; }

@media (max-width: 780px) {
    .app-shell { flex-direction: column; }
    aside.sidebar { width: 100%; }
    .sidebar nav { overflow-y: visible; }
}

/* --- Login/opret (2026-08-22 designgennemgang): før dette var login bare et
   fritsvævende kort midt på en tom side -- ingen farve, intet der signalerede
   hvad produktet faktisk er, før man var logget ind. Split-skærm med samme
   ink/gold-palet som sidebaren, så det føles som ét brand, ikke en anden stil. --- */
.auth-shell { display: flex; min-height: 100vh; }

.auth-panel {
    flex: 1 1 42%;
    max-width: 30rem;
    background: linear-gradient(155deg, var(--ink) 0%, var(--ink-raised) 100%);
    color: var(--ink-text);
    padding: 3rem 3rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.auth-panel::before {
    /* Subtilt gyldent lys i hjørnet -- personlighed uden at det bliver larmende. */
    content: "";
    position: absolute;
    top: -6rem; right: -6rem;
    width: 18rem; height: 18rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(169,120,47,0.28) 0%, transparent 70%);
}
.auth-brand {
    font-family: var(--serif);
    font-size: 1.5rem;
    color: #fff;
    text-decoration: none;
    margin-bottom: 2.5rem;
}
.auth-tagline {
    font-family: var(--serif);
    font-weight: 400;
    font-size: 1.7rem;
    line-height: 1.35;
    color: #fff;
    margin: 0 0 2rem;
    text-wrap: balance;
    position: relative;
}
.auth-points { list-style: none; padding: 0; margin: 0; position: relative; }
.auth-points li {
    font-size: 0.92rem;
    color: var(--ink-text-soft);
    padding: 0.5rem 0 0.5rem 1.4rem;
    border-top: 1px solid var(--ink-line);
    position: relative;
}
.auth-points li:first-child { border-top: none; }
.auth-points li::before {
    content: "";
    position: absolute;
    left: 0; top: 1.05rem;
    width: 0.4rem; height: 0.4rem;
    border-radius: 50%;
    background: var(--gold);
}

.auth-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--paper);
    padding: 2rem;
}
.auth-form-card { width: 100%; max-width: 22rem; }
.auth-form-card h1 { margin-top: 0; }
.auth-form-card form.card { padding: 0; border: none; background: none; margin-bottom: 1rem; }
.auth-form-card label { display: block; margin: 0 0 1rem; }
.auth-form-card label input { width: 100%; margin-top: 0.3rem; }
.auth-form-card button[type=submit] { width: 100%; margin-top: 0.4rem; }

@media (max-width: 780px) {
    .auth-shell { flex-direction: column; }
    .auth-panel { max-width: none; padding: 2rem 1.75rem; }
    .auth-tagline { font-size: 1.35rem; }
}
