/* ==========================================================================
   Alpha Sikring Ordrestyring – stylesheet
   Design follows tools.alpha-sikring.dk: dark navy sidebar, light content.
   All colours are variables – change the theme here.
   No inline styles are allowed (CSP), so all styling lives in this file.
   ========================================================================== */

:root {
    /* Sidebar */
    --nav-bg: #1e1e3a;
    --nav-bg-hover: #2a2a4f;
    --nav-active: #313c74;
    --nav-text: #c3c6dc;
    --nav-text-strong: #ffffff;
    --nav-border: rgba(255, 255, 255, 0.08);

    /* Content */
    --bg: #f3f4f6;
    --surface: #ffffff;
    --surface-muted: #f9fafb;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text: #1f2433;
    --text-muted: #6b7280;
    --text-faint: #9ca3af;

    /* Accent (blue/indigo as on the tools site) */
    --accent: #5b7cf0;
    --accent-hover: #4766e0;
    --accent-soft: #eef1fe;
    --accent-text: #3049b8;

    /* Status */
    --success: #15803d;
    --success-soft: #ecfdf3;
    --warning: #b45309;
    --warning-soft: #fffbeb;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-soft: #fef2f2;
    --info: #1d4ed8;
    --info-soft: #eff6ff;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.18);

    --sidebar-collapsed: 60px;
    --sidebar-expanded: 248px;
    --content-max: 1180px;

    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .6em; color: var(--text); }
h1 { font-size: 1.6rem; font-weight: 600; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1.02rem; font-weight: 600; }
p { margin: 0 0 1em; }
a { color: var(--accent-text); }
a:hover { color: var(--accent-hover); }
code, .mono { font-family: var(--font-mono); font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: -3px; }
.icon-sm { width: 15px; height: 15px; flex-shrink: 0; vertical-align: -2px; }
.icon-lg { width: 24px; height: 24px; flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- App layout ---------- */
.app-body { min-height: 100vh; }
.main {
    margin-left: var(--sidebar-collapsed);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 28px 28px 40px;
    flex: 1;
}
.container-wide { max-width: none; }
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-header h1 { margin: 0; }
.page-header .subtitle { color: var(--text-muted); margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { font-size: .85rem; color: var(--text-muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent-text); }
.footer {
    padding: 14px 28px;
    font-size: .8rem;
    color: var(--text-faint);
    text-align: center;
}
.footer a { color: var(--text-muted); }

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: var(--sidebar-collapsed);
    background: var(--nav-bg);
    color: var(--nav-text);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width .18s ease, box-shadow .18s ease;
}
/* Expands on hover/keyboard focus (desktop) and when opened by tap (touch) */
@media (hover: hover) and (min-width: 768px) {
    .sidebar:hover, .sidebar:focus-within { width: var(--sidebar-expanded); box-shadow: var(--shadow-lg); }
}
.sidebar.is-open { width: var(--sidebar-expanded); box-shadow: var(--shadow-lg); }

.sidebar-brand {
    display: flex;
    align-items: center;
    height: 64px;
    padding: 0 12px;
    border-bottom: 1px solid var(--nav-border);
    flex-shrink: 0;
    text-decoration: none;
}
.sidebar-brand .brand-eagle { width: 36px; height: auto; flex-shrink: 0; }
.sidebar-brand .brand-full {
    margin-left: 12px;
    color: #fff;
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: .01em;
    white-space: nowrap;
    opacity: 0;
    transition: opacity .15s;
}
.sidebar-brand { gap: 0; }

.sidebar-tools { padding: 12px 10px 4px; display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.sidebar-search {
    display: flex;
    align-items: center;
    height: 38px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    color: var(--nav-text);
    padding: 0 10px;
    gap: 10px;
}
.sidebar-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--nav-text-strong);
    font: inherit;
    font-size: .9rem;
    outline: none;
    opacity: 0;
}
.sidebar-search input::placeholder { color: var(--nav-text); opacity: .7; }
.sidebar-search input:disabled { background: transparent; cursor: not-allowed; }
.sidebar-create {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 38px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    width: 100%;
    text-align: left;
}
.sidebar-create:hover { background: var(--accent-hover); }
.sidebar-create[disabled] { opacity: .55; cursor: not-allowed; }

.nav { list-style: none; margin: 0; padding: 8px 0; }
.nav-main { flex: 1; overflow-y: auto; overflow-x: hidden; }
.nav-bottom { border-top: 1px solid var(--nav-border); flex-shrink: 0; }
.nav-item a, .nav-item button {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    height: 42px;
    padding: 0 20px;
    color: var(--nav-text);
    text-decoration: none;
    font: inherit;
    font-size: .92rem;
    background: none;
    border: 0;
    cursor: pointer;
    white-space: nowrap;
    border-left: 3px solid transparent;
    text-align: left;
}
.nav-item a:hover, .nav-item button:hover { background: var(--nav-bg-hover); color: var(--nav-text-strong); }
.nav-item.active a { background: var(--nav-active); color: var(--nav-text-strong); border-left-color: var(--accent); }
.nav-item .icon { width: 19px; height: 19px; margin-left: -3px; }
.nav-label, .sidebar-create .label { opacity: 0; transition: opacity .12s; }
.nav-section {
    padding: 14px 20px 4px;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--nav-text);
    opacity: 0;
    white-space: nowrap;
}
.nav-item form { margin: 0; }

/* Show labels when expanded */
@media (hover: hover) and (min-width: 768px) {
    .sidebar:hover .nav-label, .sidebar:focus-within .nav-label,
    .sidebar:hover .brand-full, .sidebar:focus-within .brand-full,
    .sidebar:hover .sidebar-search input, .sidebar:focus-within .sidebar-search input,
    .sidebar:hover .sidebar-create .label, .sidebar:focus-within .sidebar-create .label,
    .sidebar:hover .nav-section, .sidebar:focus-within .nav-section { opacity: 1; }
}
.sidebar.is-open .nav-label, .sidebar.is-open .brand-full, .sidebar.is-open .sidebar-search input,
.sidebar.is-open .sidebar-create .label, .sidebar.is-open .nav-section { opacity: 1; }

/* Toggle button for touch devices (tablet): opens the rail without hover */
.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    height: 40px;
    margin: 0 10px 6px;
    border: 0;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    color: var(--nav-text);
    cursor: pointer;
}
@media (hover: none) and (min-width: 768px) {
    .sidebar-toggle { display: flex; }
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(15, 17, 35, 0.45);
    display: none;
}
.sidebar-backdrop.is-visible { display: block; }

/* Mobile top bar + off-canvas menu */
.mobile-topbar { display: none; }
@media (max-width: 767.98px) {
    .main { margin-left: 0; }
    .container { padding: 18px 16px 32px; }
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        position: sticky;
        top: 0;
        z-index: 30;
        height: 56px;
        padding: 0 12px;
        background: var(--nav-bg);
        color: #fff;
    }
    .mobile-topbar img { height: 34px; width: auto; }
    .mobile-topbar .burger {
        display: flex; align-items: center; justify-content: center;
        width: 40px; height: 40px; border: 0; border-radius: var(--radius-sm);
        background: transparent; color: #fff; cursor: pointer;
    }
    .sidebar {
        width: var(--sidebar-expanded);
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar .nav-label, .sidebar .brand-full, .sidebar .sidebar-search input,
    .sidebar .sidebar-create .label, .sidebar .nav-section { opacity: 1; }
    h1 { font-size: 1.35rem; }
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.card-header h2, .card-header h3 { margin: 0; }
.card-header-start { justify-content: flex-start; }
.card-muted { background: var(--surface-muted); box-shadow: none; border: 1px solid var(--border); }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-header { padding: 18px 24px 0; }
.card-danger { border: 1px solid #fecaca; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: .85rem; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 960px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }
.grid > * { min-width: 0; }

.stat { display: block; text-decoration: none; color: inherit; }
.stat .stat-value { font-size: 1.8rem; font-weight: 600; line-height: 1.1; }
.stat .stat-label { color: var(--text-muted); font-size: .88rem; }
.stat.warn .stat-value { color: var(--warning); }
.stat.bad .stat-value { color: var(--danger); }

.admin-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tile {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    text-decoration: none;
    color: var(--text);
    border: 1px solid transparent;
}
.tile:hover { border-color: var(--accent); color: var(--text); }
.tile .tile-icon {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 8px;
    background: var(--accent-soft); color: var(--accent-text); flex-shrink: 0;
}
.tile strong { display: block; margin-bottom: 2px; }
.tile span { color: var(--text-muted); font-size: .86rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: .92rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-muted); color: var(--text); border-color: var(--text-faint); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost { background: transparent; color: var(--accent-text); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent-text); }
.btn-sm { height: 32px; padding: 0 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.inline-form { display: inline; margin: 0; }
.button-row-center { justify-content: center; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
@media (max-width: 640px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }
label, .label { display: block; font-size: .87rem; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.label-hint { font-weight: 400; color: var(--text-muted); }
.input, input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], input[type=search], select, textarea {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .95rem;
}
textarea { height: auto; min-height: 120px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
textarea.tall { min-height: 420px; font-family: var(--font-mono); font-size: .88rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.has-error, select.has-error, textarea.has-error { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .84rem; margin: 5px 0 0; }
.field-hint { color: var(--text-muted); font-size: .82rem; margin: 5px 0 0; }
.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-weight: 400;
    font-size: .92rem;
    cursor: pointer;
    margin: 0;
}
.checkbox input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.checkbox.is-locked { color: var(--text-faint); cursor: not-allowed; }
.checkbox.is-locked input { accent-color: var(--text-faint); cursor: not-allowed; }
.code-input {
    font-family: var(--font-mono);
    font-size: 1.5rem !important;
    letter-spacing: .3em;
    text-align: center;
    height: 54px !important;
}
.password-field { position: relative; }
.password-field input { padding-right: 44px; }
.password-toggle {
    position: absolute; right: 4px; top: 4px; width: 34px; height: 32px;
    border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center; border-radius: 4px;
}
.password-toggle:hover { color: var(--text); }
fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
legend { font-weight: 600; font-size: .95rem; margin-bottom: 10px; padding: 0; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .form-group { margin: 0; min-width: 160px; }
.filters .grow { flex: 1; min-width: 200px; }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; background: var(--surface-muted); }
.table tbody tr:hover { background: var(--surface-muted); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .row-link { color: var(--text); text-decoration: none; font-weight: 600; }
.table .row-link:hover { color: var(--accent-text); }
.table-compact th, .table-compact td { padding: 7px 10px; }
.empty { padding: 28px; text-align: center; color: var(--text-muted); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 600;
    background: var(--surface-muted);
    color: var(--text-muted);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: #bbf7d0; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: #fde68a; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: #bfdbfe; }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); border-color: #c7d2fe; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Alerts / flash ---------- */
.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: .93rem;
    border: 1px solid;
}
.alert .icon { margin-top: 1px; }
.alert p:last-child { margin-bottom: 0; }
.alert-success { background: var(--success-soft); border-color: #bbf7d0; color: #14532d; }
.alert-error { background: var(--danger-soft); border-color: #fecaca; color: #7f1d1d; }
.alert-warning { background: var(--warning-soft); border-color: #fde68a; color: #78350f; }
.alert-info { background: var(--info-soft); border-color: #bfdbfe; color: #1e3a8a; }

/* Floating flash messages (app layout) */
.flash-stack {
    position: fixed; z-index: 60; top: 16px; right: 16px;
    width: min(440px, calc(100vw - 32px));
    display: flex; flex-direction: column; gap: 8px;
}
.alert.toast { margin: 0; box-shadow: var(--shadow-lg); padding-right: 40px; position: relative; animation: toast-in .2s ease; }
.alert.toast.is-leaving { opacity: 0; transform: translateY(-6px); transition: all .25s ease; }
.toast-close {
    position: absolute; top: 8px; right: 8px; width: 26px; height: 26px;
    border: 0; background: transparent; color: inherit; opacity: .6; cursor: pointer; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
}
.toast-close:hover { opacity: 1; background: rgba(0, 0, 0, .06); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@media (max-width: 767.98px) { .flash-stack { top: 64px; right: 12px; width: calc(100vw - 24px); } }

/* ---------- Auth pages (login etc.) ---------- */
.auth-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #1b1b33 0%, #23284a 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}
.auth-logo { width: 190px; height: auto; margin-bottom: 22px; }
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    padding: 30px 32px;
}
.auth-card.wide { max-width: 560px; }
.auth-card h1 { font-size: 1.3rem; margin-bottom: 6px; }
.auth-card .lead { color: var(--text-muted); font-size: .92rem; margin-bottom: 20px; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 16px; font-size: .88rem; }
.auth-footer { margin-top: 20px; font-size: .8rem; color: #a5a8c4; }
.auth-footer a { color: #c7c9e0; }
.qr-box { display: flex; justify-content: center; margin: 12px 0; }
.qr-box img { width: 210px; height: 210px; border: 1px solid var(--border); border-radius: 8px; padding: 6px; background: #fff; }
.secret {
    font-family: var(--font-mono);
    background: var(--surface-muted);
    border: 1px dashed var(--border-strong);
    padding: 8px 12px;
    border-radius: 6px;
    text-align: center;
    word-break: break-all;
    letter-spacing: .05em;
}
.steps { padding-left: 1.2em; margin: 0 0 16px; font-size: .92rem; }
.steps li { margin-bottom: 6px; }
.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 16px;
    font-family: var(--font-mono);
    font-size: 1.05rem;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    margin: 14px 0;
    text-align: center;
}
.toggle-link { background: none; border: 0; padding: 0; color: var(--accent-text); cursor: pointer; font: inherit; font-size: .88rem; text-decoration: underline; }
.is-hidden { display: none !important; }

/* ---------- Permission matrix & lists ---------- */
.matrix-wrap { overflow-x: auto; }
.matrix { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .88rem; }
.matrix th, .matrix td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.matrix thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--surface); text-align: center; font-size: .82rem; vertical-align: bottom;
}
.matrix thead th:first-child { text-align: left; }
.matrix td.check { text-align: center; width: 110px; }
.matrix td.check input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.matrix td.check input:disabled { accent-color: var(--text-faint); cursor: not-allowed; }
.matrix tr.module th {
    text-align: left; background: var(--surface-muted); font-size: .78rem;
    text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
}
.matrix .perm-key { display: block; font-family: var(--font-mono); font-size: .74rem; color: var(--text-faint); }
.matrix .col-toggle { display: block; margin-top: 4px; font-size: .72rem; font-weight: 400; }
.matrix tbody tr:hover td { background: var(--surface-muted); }

.perm-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px 24px; }
.perm-group h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 0 0 8px; }
.perm-group .checkbox { margin-bottom: 6px; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: .84rem; color: var(--text-muted); margin-bottom: 14px; }

.dept-list { display: grid; gap: 8px; }
.dept-row { display: grid; grid-template-columns: 1fr auto auto; gap: 18px; align-items: center; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.dept-row .checkbox { white-space: nowrap; }
@media (max-width: 640px) { .dept-row { grid-template-columns: 1fr; gap: 6px; } }

/* ---------- Key/value lists ---------- */
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin: 0; font-size: .92rem; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }
@media (max-width: 640px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; } }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 14px; font-size: .9rem; }
.pagination a, .pagination span { padding: 6px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border); text-decoration: none; color: var(--text); background: var(--surface); }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Audit log ---------- */
.details-json { font-family: var(--font-mono); font-size: .78rem; color: var(--text-muted); white-space: pre-wrap; word-break: break-word; max-width: 420px; margin: 0; }

/* ---------- Content pages (cookie policy) ---------- */
.prose { max-width: 760px; }
.prose h1 { margin-top: 0; }
.prose h2 { margin-top: 1.6em; }
.prose ul { padding-left: 1.3em; }
.prose li { margin-bottom: .4em; }

/* ---------- Placeholder (coming in later phase) ---------- */
.placeholder {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    color: var(--text-muted);
    background: var(--surface);
}
.placeholder .icon-lg { color: var(--accent); margin-bottom: 8px; }

/* ---------- Error page ---------- */
.error-page { text-align: center; padding: 40px 16px; }
.error-page .code { font-size: 3.4rem; font-weight: 700; color: var(--accent); line-height: 1; margin-bottom: 10px; }
.error-detail { text-align: left; font-family: var(--font-mono); font-size: .8rem; background: var(--danger-soft); padding: 12px; border-radius: 6px; white-space: pre-wrap; word-break: break-word; }

/* ---------- Install ---------- */
.check-list { list-style: none; padding: 0; margin: 0 0 16px; font-size: .9rem; }
.check-list li { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--border); }
.check-list .ok { color: var(--success); }
.check-list .bad { color: var(--danger); }
.check-list .detail { margin-left: auto; color: var(--text-muted); font-size: .82rem; text-align: right; word-break: break-all; }
pre.config-snippet { background: #111827; color: #e5e7eb; padding: 12px 14px; border-radius: 6px; font-size: .8rem; overflow-x: auto; }

/* ==========================================================================
   Phase 2: customers, products, orders, lines
   ========================================================================== */

.mt-1 { margin-top: 6px; }
.mb-1 { margin-bottom: 6px; }
.p-0 { padding: 0 !important; }
.pre-line { white-space: pre-line; }
.span-2 { grid-column: span 2; }
.form-narrow { max-width: 260px; }
.checkbox-row { display: flex; gap: 24px; flex-wrap: wrap; }
.filter-checkbox { height: 40px; align-items: center; }
.is-muted td { color: var(--text-faint); }
.row-link.plain { font-weight: 400; }
.button-row-tight { margin-top: 4px; }
.kv-compact { grid-template-columns: 110px 1fr; font-size: .9rem; }
.danger-zone { margin: 8px 0 24px; text-align: right; }
.text-danger.btn-ghost:hover { background: var(--danger-soft); color: var(--danger); }

/* "+ Opret ny" dropdown in sidebar */
.sidebar-create-menu { position: relative; }
.sidebar-create-menu > summary { list-style: none; }
.sidebar-create-menu > summary::-webkit-details-marker { display: none; }
.create-menu {
    margin-top: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    padding: 4px;
}
.create-menu a {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 4px;
    color: var(--nav-text-strong); text-decoration: none; font-size: .9rem; white-space: nowrap;
}
.create-menu a:hover { background: var(--nav-bg-hover); }
@media (hover: hover) and (min-width: 768px) {
    .sidebar:not(:hover):not(:focus-within):not(.is-open) .create-menu { display: none; }
}

/* Segmented radio (customer type) */
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segment { margin: 0; font-weight: 500; cursor: pointer; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment span { display: block; padding: 9px 18px; font-size: .92rem; }
.segment + .segment span { border-left: 1px solid var(--border-strong); }
.segment input:checked + span { background: var(--accent); color: #fff; }
.segment input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Order type cards */
.type-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 900px) { .type-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.type-card { margin: 0; cursor: pointer; font-weight: 400; }
.type-card input { position: absolute; opacity: 0; pointer-events: none; }
.type-card > span {
    display: block; height: 100%; padding: 12px 14px;
    border: 2px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.type-card strong { display: block; }
.type-card small { color: var(--text-muted); font-size: .8rem; }
.type-card input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.type-card input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Autocomplete */
.autocomplete { position: relative; }
.autocomplete-list {
    position: absolute; z-index: 30; left: 0; right: 0; top: 100%;
    margin-top: 2px; max-height: 320px; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
}
.form-group.autocomplete .autocomplete-list { top: auto; }
.autocomplete-item { padding: 8px 12px; cursor: pointer; font-size: .9rem; border-bottom: 1px solid var(--border); }
.autocomplete-item:last-child { border-bottom: 0; }
.autocomplete-item small { display: block; color: var(--text-muted); font-size: .8rem; }
.autocomplete-item.is-active, .autocomplete-item:hover { background: var(--accent-soft); }
.autocomplete-empty { padding: 10px 12px; color: var(--text-muted); font-size: .88rem; }

/* Lists with inline editing (customer locations/contacts) */
.stack { display: flex; flex-direction: column; }
.stack-item { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.stack-item:last-child { border-bottom: 0; }
.stack-main { flex: 1; min-width: 200px; }
.stack-main a { text-decoration: none; margin-right: 10px; }
.inline-edit > summary { list-style: none; }
.inline-edit > summary::-webkit-details-marker { display: none; }
.inline-edit[open] { flex-basis: 100%; }
.inline-edit.add { margin-top: 12px; }
.inline-form-box { margin-top: 10px; padding: 14px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* Admin row forms */
.row-form { display: grid; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.row-form .checkbox { white-space: nowrap; }
.row-form input, .row-form select { height: 34px; }
.row-form-terms { grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) 80px auto auto auto; padding: 8px 14px; }
.row-form-simple { grid-template-columns: minmax(0, 1fr) auto auto auto; }
.add-row { border-bottom: 0; margin-top: 6px; }
.row-buttons { display: inline-flex; gap: 4px; align-items: center; justify-content: flex-end; }
@media (max-width: 760px) { .row-form-terms, .row-form-simple { grid-template-columns: 1fr 1fr; } }

/* Import mapping */
.mapping-table th { min-width: 150px; vertical-align: bottom; text-transform: none; letter-spacing: 0; font-weight: 400; }
.mapping-table select { height: 34px; margin-top: 4px; font-size: .85rem; }

.price-old { color: var(--text-faint); text-decoration: line-through; }
.price-up { color: var(--danger); }
.price-down { color: var(--success); }

/* Search results */
.result-list { list-style: none; margin: 0; padding: 0 24px 10px; }
.result-list li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--border); }
.result-list li:last-child { border-bottom: 0; }
.result-list a { font-weight: 600; text-decoration: none; }

/* Order page */
.reference-bar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 10px 16px; margin-bottom: 20px;
    background: var(--accent-soft); border: 1px solid #c7d2fe; border-radius: var(--radius-sm);
}
.reference-bar .reference { font-size: 1.05rem; font-weight: 700; color: var(--accent-text); background: transparent; }
.status-form .form-group { margin-bottom: 10px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; flex-wrap: wrap; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.timeline li:last-child { border-bottom: 0; }

/* Line component */
.lines-table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 1280px; table-layout: fixed; }
.lines-table .col-desc { width: auto; }
.lines-table th {
    text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em;
    color: var(--text-muted); padding: 6px 4px; border-bottom: 1px solid var(--border-strong); white-space: nowrap;
}
.lines-table td { padding: 3px 4px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.lines-table input {
    width: 100%; height: 32px; padding: 0 7px; font-size: .88rem; border: 1px solid var(--border);
    border-radius: 4px; background: var(--surface); color: var(--text); font-family: inherit;
}
.lines-table input.mono { font-family: var(--font-mono); font-size: .82rem; }
.lines-table input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.lines-table input:hover { border-color: var(--border-strong); }
.lines-table .num { text-align: right; }
.lines-table .col-handle { width: 26px; color: var(--text-faint); cursor: grab; text-align: center; }
.lines-table .col-sku { width: 120px; }
.lines-table .col-supplier { width: 110px; }
.lines-table .col-num { width: 96px; text-align: right; }
.lines-table .col-small { width: 68px; }
.lines-table td.col-desc { position: relative; }
.lines-table .col-desc input { padding-right: 40px; }
.lines-table .col-desc .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: .75rem; pointer-events: none; }
.lines-table .col-actions { width: 92px; white-space: nowrap; text-align: right; }
.lines-table .line-total, .lines-table .subtotal { font-weight: 600; white-space: nowrap; padding-right: 8px; }
.lines-table .line-group td { background: var(--surface-muted); border-top: 2px solid var(--border-strong); }
.lines-table .group-input { font-weight: 700; font-size: .95rem; background: transparent; }
.lines-table .line-text input { font-style: italic; }
.lines-table tr.is-dragging { opacity: .4; }
.lines-table tr.drop-before td { box-shadow: inset 0 2px 0 var(--accent); }
.lines-table tr.drop-after td { box-shadow: inset 0 -2px 0 var(--accent); }
.lines-table .autocomplete-list { min-width: 380px; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border: 0; border-radius: 4px; background: transparent;
    color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-muted); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.lines-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.lines-empty { padding: 16px 0; }
.lines-footer { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; flex-wrap: wrap; margin-top: 8px; }
.lines-save { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.lines-dirty { color: var(--warning); font-weight: 600; }
.totals {
    display: grid; grid-template-columns: auto auto; gap: 4px 24px; margin: 0;
    font-size: .92rem; min-width: 300px; margin-left: auto;
}
.totals dt { color: var(--text-muted); }
.totals dd { margin: 0; text-align: right; white-space: nowrap; }
.totals .total-strong { font-weight: 700; color: var(--text); }
.totals dt.total-strong { padding-top: 6px; border-top: 1px solid var(--border); }
.totals dd.total-strong { padding-top: 6px; border-top: 1px solid var(--border); }
.lines-readonly .line-group td { background: var(--surface-muted); font-weight: 700; }
.lines-readonly .line-text td { font-style: italic; color: var(--text-muted); }

/* ==========================================================================
   Phase 3a: Min plan, field work, time
   ========================================================================== */

.btn-lg { height: 48px; padding: 0 22px; font-size: 1rem; }
.compact-list { margin: 4px 0 0; padding-left: 1.1em; }
.compact-list li { margin: 2px 0; }
.date-compact { height: 32px !important; width: auto !important; font-size: .85rem !important; }
.segmented-sm .segment span { padding: 6px 12px; font-size: .85rem; }
.segment-link { display: block; padding: 6px 14px; font-size: .85rem; text-decoration: none; color: var(--text); }
.segment-link + .segment-link { border-left: 1px solid var(--border-strong); }
.segment-link.active { background: var(--accent); color: #fff; }
.visually-hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
label.btn { position: relative; margin: 0; }
.sticky-actions {
    position: sticky; bottom: 0; z-index: 5; padding: 12px 0;
    background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* Global running-timer bar */
.timer-bar {
    position: sticky; top: 0; z-index: 25;
    display: flex; align-items: center; gap: 12px;
    padding: 8px 20px; background: #0f5132; color: #fff;
}
.timer-bar-link { display: flex; gap: 12px; align-items: baseline; color: #fff; text-decoration: none; flex: 1; min-width: 0; }
.timer-bar-link:hover { color: #fff; }
.timer-bar .timer-elapsed { font-family: var(--font-mono); font-weight: 700; font-size: 1.05rem; }
.timer-bar-order { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9rem; opacity: .9; }
.timer-dot { width: 10px; height: 10px; border-radius: 50%; background: #4ade80; flex-shrink: 0; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (max-width: 767.98px) { .timer-bar { top: 56px; padding: 8px 12px; } }

/* "Waiting for you" bar on every page */
.attention-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 20px; background: #fef3c7; color: #78350f; border-bottom: 1px solid #fde68a; font-size: .88rem;
}
.attention-bar.has-error { background: #fee2e2; color: #7f1d1d; border-bottom-color: #fecaca; }
.attention-bar ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.attention-bar a { color: inherit; text-decoration: none; }
.attention-bar a:hover { text-decoration: underline; }
@media (max-width: 767.98px) { .attention-bar { padding: 7px 12px; font-size: .82rem; } }

/* Count badge on menu icons */
.nav-icon { position: relative; display: inline-flex; flex-shrink: 0; }
.nav-badge {
    position: absolute; top: -7px; right: -9px; min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 9px; background: #f59e0b; color: #1f2433; font-size: .65rem; font-weight: 800;
    display: flex; align-items: center; justify-content: center; line-height: 1;
}

/* Quick actions on the order (mobile) */
.field-actions {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 20px;
}
.field-action {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 12px 6px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
    color: var(--text); text-decoration: none; font-size: .8rem; font-weight: 600; text-align: center;
}
.field-action .icon { width: 22px; height: 22px; color: var(--accent); }
.field-action:hover { color: var(--accent-text); }
@media (max-width: 480px) { .field-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Stopwatch on the order */
.timer-box { padding: 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); margin-bottom: 12px; }
.timer-box.is-running { border: 2px solid #22c55e; background: #f0fdf4; }
.timer-display { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.timer-display .timer-elapsed { font-family: var(--font-mono); font-size: 1.8rem; font-weight: 700; }
.timer-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.timer-form select, .timer-form input { flex: 1; min-width: 180px; }

/* Entry lists (time, expenses) */
.entry-list { display: flex; flex-direction: column; margin-top: 8px; }
.entry { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--border); }
.entry:last-child { border-bottom: 0; }
.entry-main { flex: 1; min-width: 220px; }
.entry-main > strong { margin-right: 8px; }
.entry-actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.material-form .form-group { margin-bottom: 10px; }

/* Photos and files */
.photo-upload { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.photo-upload .upload-status { flex-basis: 100%; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo-grid figure { margin: 0; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; background: var(--surface-muted); }
.photo-grid figcaption { margin-top: 3px; }
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--border); }
.file-list li:last-child { border-bottom: 0; }
.file-list a { font-weight: 600; text-decoration: none; }
.note-body { flex-basis: 100%; }

/* Planning card on the order */
.chip-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.inline-add { display: flex; gap: 6px; margin-top: 8px; }
.inline-add select { height: 34px; }

/* Min plan */
.plan-header { align-items: center; }
.plan-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.plan-period { padding: 0 6px; }
.plan-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
@media (max-width: 1100px) {
    .plan-layout { grid-template-columns: minmax(0, 1fr); }
    .plan-side { order: -1; }
}
.plan-calendar.is-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.plan-calendar.is-day { display: grid; grid-template-columns: minmax(0, 1fr); }
@media (max-width: 900px) { .plan-calendar.is-week { grid-template-columns: minmax(0, 1fr); } }
.plan-day { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); min-height: 160px; display: flex; flex-direction: column; }
.plan-day.is-weekend { background: repeating-linear-gradient(135deg, var(--surface-muted), var(--surface-muted) 8px, #eef0f3 8px, #eef0f3 16px); }
.plan-day.is-today { box-shadow: 0 0 0 2px var(--accent); }
.plan-day-head {
    display: flex; justify-content: space-between; align-items: baseline; gap: 6px; flex-wrap: wrap;
    padding: 8px 10px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text);
}
.plan-day-name { font-weight: 700; font-size: .9rem; }
.plan-day-hours { display: flex; gap: 8px; color: var(--text-muted); }
.plan-day-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.plan-absence { background: #e5e7eb; color: #4b5563; border-radius: 6px; padding: 6px 8px; font-size: .82rem; font-weight: 600; }
.plan-booking {
    display: flex; flex-direction: column; gap: 1px; padding: 7px 9px; border-radius: 6px;
    text-decoration: none; color: #fff; background: var(--accent); font-size: .85rem; line-height: 1.3;
}
.plan-booking:hover { color: #fff; filter: brightness(1.08); }
.plan-booking-time { font-weight: 700; font-size: .78rem; opacity: .95; }
.plan-booking-addr { opacity: .9; }
.plan-booking.type-consultancy { background: #7c8b2a; }
.plan-booking.type-quote-project { background: #3f5bd9; }
.plan-booking.type-service-agreement { background: #0e7c86; }
.plan-booking.type-service { background: #c2410c; }
.plan-empty { padding: 4px; }
.plan-side { padding: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab { flex: 1; padding: 12px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }
.tab-panel { padding: 14px 16px; }
.tab-panel h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 12px 0 6px; }
.tab-panel h3:first-child { margin-top: 0; }
.side-item { display: flex; flex-direction: column; gap: 1px; padding: 9px 0; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.side-item:last-child { border-bottom: 0; }
.side-item:hover strong { color: var(--accent-text); }
.pool-item { gap: 6px; }
.pool-item a { display: flex; flex-direction: column; text-decoration: none; color: var(--text); }

/* Schedule editor */
.schedule-grid { display: grid; grid-template-columns: 90px 120px 14px 120px auto; gap: 8px; align-items: center; margin-bottom: 6px; }
.schedule-grid label { margin: 0; font-weight: 500; }
.schedule-grid input { height: 36px; }
@media (max-width: 520px) { .schedule-grid { grid-template-columns: 70px 1fr 10px 1fr; } .schedule-grid > span.text-small { display: none; } }

/* ==========================================================================
   Phase 3b: planning board
   ========================================================================== */
.planning { display: flex; flex-direction: column; gap: 12px; }
.planning:fullscreen { background: var(--bg); padding: 12px; overflow: auto; }
.planning-toolbar {
    display: flex; gap: 10px 16px; align-items: center; flex-wrap: wrap;
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px;
}
.toolbar-group { display: flex; gap: 6px; align-items: center; }
.toolbar-right { margin-left: auto; }
.toolbar-week { padding: 0 4px; white-space: nowrap; }
.toolbar-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar-form > label { display: flex; gap: 6px; align-items: center; margin: 0; font-weight: 500; font-size: .85rem; color: var(--text-muted); }
.toolbar-input { height: 32px !important; width: auto !important; padding: 0 8px !important; font-size: .85rem !important; }
.toolbar-check { font-size: .85rem; align-items: center; }

.planning-body { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 12px; align-items: start; }
.planning.panel-collapsed .planning-body { grid-template-columns: 44px minmax(0, 1fr); }
.planning.panel-collapsed .orders-panel > :not(.orders-panel-head) { display: none; }
.planning.panel-collapsed .orders-panel-head strong { display: none; }
.planning.panel-collapsed [data-toggle-panel] { transform: rotate(180deg); }
.orders-panel {
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
    position: sticky; top: 12px; max-height: calc(100vh - 160px); display: flex; flex-direction: column; overflow: hidden;
}
.orders-panel-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.orders-panel-filters { display: grid; gap: 6px; padding: 10px 12px 0; }
.orders-panel-filters input { height: 34px; font-size: .85rem; }
.orders-panel-hint { padding: 6px 12px 0; margin: 0; }
.orders-list { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.orders-empty { padding: 8px; }
.order-item {
    position: relative; padding: 8px 10px 8px 12px; border-radius: 6px; border: 1px solid var(--border);
    background: var(--surface); font-size: .85rem; line-height: 1.35; border-left: 4px solid var(--accent);
    touch-action: none; user-select: none;
}
.order-item.is-draggable { cursor: grab; }
.order-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.order-item strong { display: block; }
.order-item-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: .78rem; }
.order-item-status { margin-left: auto; color: var(--text-muted); }
.order-item-open { position: absolute; right: 8px; bottom: 6px; text-decoration: none; font-size: .9rem; }
.order-item.type-consultancy { border-left-color: #7c8b2a; }
.order-item.type-quote-project { border-left-color: #3f5bd9; }
.order-item.type-service-agreement { border-left-color: #0e7c86; }
.order-item.type-service { border-left-color: #c2410c; }

.timeline-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 160px); }
.planning:fullscreen .timeline-wrap, .planning:fullscreen .orders-panel { max-height: calc(100vh - 90px); }
.timeline { position: relative; min-width: 100%; }
.tl-head { display: flex; position: sticky; top: 0; z-index: 6; background: var(--surface); border-bottom: 1px solid var(--border-strong); }
.tl-name {
    flex-shrink: 0; position: sticky; left: 0; z-index: 5; background: var(--surface);
    padding: 8px 10px; border-right: 1px solid var(--border-strong); display: flex; flex-direction: column; justify-content: center;
    font-size: .85rem; line-height: 1.3; overflow: hidden;
}
.tl-corner { z-index: 7; font-size: .78rem; color: var(--text-muted); font-weight: 600; }
.tl-days { display: flex; flex-shrink: 0; }
.tl-day-head { flex-shrink: 0; border-right: 1px solid var(--border); }
.tl-day-head.is-weekend { background: var(--surface-muted); }
.tl-day-head.is-today .tl-day-label { color: var(--accent-text); }
.tl-day-label { text-align: center; font-weight: 700; font-size: .82rem; padding: 6px 0 2px; text-transform: capitalize; }
.tl-ticks { position: relative; height: 18px; }
.tl-tick { position: absolute; top: 0; font-size: .68rem; color: var(--text-faint); padding-left: 2px; border-left: 1px solid var(--border); height: 100%; }
.tl-row { display: flex; border-bottom: 1px solid var(--border); }
.tl-lane { position: relative; flex-shrink: 0; touch-action: pan-y; }
.tl-lane.is-target { background: rgba(91, 124, 240, .07); }
.tl-cell { position: absolute; top: 0; bottom: 0; border-right: 1px solid var(--border); background: #f6f7f9; }
.tl-cell.is-weekend { background: repeating-linear-gradient(135deg, #eef0f3, #eef0f3 6px, #f6f7f9 6px, #f6f7f9 12px); }
.tl-work { position: absolute; top: 0; bottom: 0; background: var(--surface); }
.tl-cell.is-today { box-shadow: inset 0 0 0 1px rgba(91, 124, 240, .35); }
.tl-absence {
    position: absolute; top: 2px; bottom: 2px; background: repeating-linear-gradient(135deg, #d1d5db, #d1d5db 6px, #e5e7eb 6px, #e5e7eb 12px);
    border-radius: 4px; color: #374151; font-size: .72rem; font-weight: 700; overflow: hidden; z-index: 1;
}
.tl-absence span { position: sticky; left: 4px; padding: 2px 6px; display: inline-block; }
.tl-reg { position: absolute; bottom: 2px; transform: translateX(-100%); font-size: .68rem; font-weight: 700; color: var(--success); background: var(--success-soft); padding: 0 4px; border-radius: 3px; z-index: 3; white-space: nowrap; }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 4; pointer-events: none; }
.tl-empty { padding: 30px; color: var(--text-muted); text-align: center; }
.bk {
    position: absolute; z-index: 2; border-radius: 5px; padding: 3px 7px; overflow: hidden;
    color: #fff; background: var(--accent); font-size: .74rem; line-height: 1.25; cursor: grab;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .15); touch-action: none; user-select: none;
}
.bk:hover, .bk:focus { filter: brightness(1.08); outline: none; box-shadow: 0 0 0 2px rgba(0, 0, 0, .25); z-index: 3; }
.bk.is-moving { opacity: .35; }
.bk.is-clipped { border-right: 3px dashed rgba(255, 255, 255, .7); }
.bk-time { font-weight: 700; white-space: nowrap; }
.bk-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk-reg { background: rgba(255, 255, 255, .25); border-radius: 3px; padding: 0 3px; font-weight: 600; }
.bk-resize { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.bk-resize-l { left: 0; }
.bk-resize-r { right: 0; }
.bk.type-consultancy { background: #7c8b2a; }
.bk.type-quote-project { background: #3f5bd9; }
.bk.type-service-agreement { background: #0e7c86; }
.bk.type-service { background: #c2410c; }
.drag-ghost {
    position: fixed; z-index: 100; pointer-events: none; padding: 6px 10px; border-radius: 6px;
    background: var(--nav-bg); color: #fff; font-size: .8rem; font-weight: 600; box-shadow: var(--shadow-lg); white-space: nowrap;
}
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }
.booking-dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
.booking-dialog::backdrop { background: rgba(15, 17, 35, .45); }
.booking-dialog-form { padding: 18px 20px; }
.booking-dialog-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.copy-box { margin-top: 12px; }
.copy-box > summary { list-style: none; }
.copy-box > summary::-webkit-details-marker { display: none; }
.copy-days { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 10px; margin: 6px 0 10px 24px; font-size: .85rem; }
.copy-days .checkbox { font-size: .85rem; text-transform: capitalize; }
.copy-weeks { width: 64px !important; height: 30px !important; display: inline-block; margin: 0 4px; }
.booking-dialog-msg { margin-top: 10px; }
@media (max-width: 1000px) {
    .planning-body { grid-template-columns: minmax(0, 1fr); }
    .orders-panel { position: static; max-height: 300px; }
}

@media print {
    .sidebar, .mobile-topbar, .footer, .page-actions, .no-print { display: none !important; }
    .main { margin: 0; }
    body, .auth-body { background: #fff; }
    .card, .auth-card { box-shadow: none; }
}

/* Bulk actions on lists (products) */
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 10px; }
.bulk-bar select { width: auto; min-width: 0; max-width: 100%; }
.col-check { width: 34px; }
.ml-auto { margin-left: auto; }

/* ---------------------------------------------------------------- Tilbud (fase 4) */
.mb-0 { margin-bottom: 0; }
.h-small { font-size: .95rem; margin: 14px 0 6px; }
.rich-text p { margin: 0 0 8px; }
.rich-text ul { margin: 0 0 8px 18px; padding: 0; }
.upload-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.upload-row input[type=file] { width: auto; max-width: 100%; }
.confirm-form { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-top: 10px; }
.quote-text-edit { padding: 12px 0; border-bottom: 1px solid var(--border); }
.quote-text-edit:first-of-type { padding-top: 0; }
.quote-text-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.quote-text-head input[type=text] { flex: 1; min-width: 0; font-weight: 600; }
.quote-text-head .checkbox { white-space: nowrap; }
.mail-preview { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; background: var(--surface-muted); }

/* Budget mod forbrug */
.budget-table td, .budget-table th { white-space: nowrap; }
.budget-bar { position: relative; height: 8px; border-radius: 4px; background: var(--surface-muted); border: 1px solid var(--border); min-width: 120px; overflow: hidden; }
.budget-bar span { position: absolute; inset: 0 auto 0 0; border-radius: 4px; }
.budget-ok .budget-bar span { background: var(--success); }
.budget-warn .budget-bar span { background: var(--warning); }
.budget-over .budget-bar span { background: var(--danger); }
.budget-over .budget-pct { color: var(--danger); font-weight: 700; }
.budget-warn .budget-pct { color: var(--warning); font-weight: 700; }

/* Kundens offentlige tilbudsside */
.public-body { background: var(--bg); margin: 0; }
.public-band { background: var(--nav-bg); border-bottom: 4px solid #1aa3b5; }
.public-band-inner { max-width: 920px; margin: 0 auto; padding: 18px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #fff; }
.public-band img { height: 46px; width: auto; }
.public-band .doc-no { text-align: right; font-size: .9rem; color: #c9cde0; }
.public-band .doc-no strong { display: block; color: #fff; font-size: 1.15rem; letter-spacing: .5px; text-transform: uppercase; }
.public-main { max-width: 920px; margin: 0 auto; padding: 20px 16px 40px; }
.public-lines td, .public-lines th { vertical-align: top; }
.public-lines tr.group td { font-weight: 700; background: var(--surface-muted); }
.public-lines tr.text td { color: var(--text-muted); font-style: italic; }
.public-lines tr.child td { border-bottom: 0; padding-top: 4px; padding-bottom: 4px; }
.public-section h2 { border-left: 3px solid #1aa3b5; padding-left: 8px; font-size: 1rem; text-transform: uppercase; letter-spacing: .3px; }
.public-answer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 767.98px) { .public-answer { grid-template-columns: minmax(0, 1fr); } .public-band img { height: 38px; } }
.public-footer { text-align: center; color: var(--text-muted); font-size: .85rem; padding: 0 16px 30px; }

/* ---------------------------------------------------------------- Fakturering (fase 5) */
.mode-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 767.98px) { .mode-cards { grid-template-columns: minmax(0, 1fr); } }
.code-block { background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; font-size: .8rem; overflow: auto; max-height: 520px; white-space: pre-wrap; word-break: break-word; margin: 0; }
.mode-banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: .92rem; }
.mode-banner.mode-test { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; }
.mode-banner.mode-live { background: var(--success-soft); border: 1px solid #bbf7d0; color: #14532d; }
.mode-banner.mode-off { background: var(--surface-muted); border: 1px solid var(--border); color: var(--text-muted); }
.issue-box { border: 2px solid var(--accent); }
.issue-box dl { margin-bottom: 12px; }
.reg-table td, .reg-table th { vertical-align: top; }
.reg-table .reg-check { width: 90px; text-align: center; }
.reg-table tr.is-invoiced td { color: var(--text-faint); }
.invoice-create { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.invoice-create .form-group { margin-bottom: 0; }
