:root {
    --bg: #f7f5f0;
    --surface: #ffffff;
    --surface-soft: #fbfaf7;
    --panel: #ece8df;
    --ink: #22303c;
    --muted: #5d6b76;
    --line: #e3e0d8;
    --line-strong: #cfcac0;
    --primary: #1f7a6c;
    --primary-hover: #19685c;
    --link: #17665a;
    --primary-soft: #e4f1ee;
    --danger: #a3262a;
    --danger-soft: #fbeaea;
    --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
}

h1, h2 { margin: 0; }
a { color: var(--link); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Knapper og felter */
.btn {
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    height: 48px;
    padding: 0 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); height: 40px; font-size: 14px; }
.btn-secondary:hover { background: var(--surface-soft); }

.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 8px; font-size: 13.5px; font-weight: 600; }
.input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    font: inherit;
    font-size: 15px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
}
.input:focus, .btn:focus-visible, a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.check { display: flex; gap: 12px; align-items: center; margin: 4px 0 22px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

.alert {
    margin-bottom: 18px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--danger);
    background: var(--danger-soft);
    border: 1px solid #f0c9ca;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 22px;
    margin: 24px 0 18px;
}

/* Brand */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}
.brand-name { font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--muted); }

/* Login */
.auth-page { display: flex; min-height: 100vh; }
.auth-form-side { flex: 1 1 60%; display: flex; justify-content: center; padding: 40px 24px; }
.auth-form { width: 100%; max-width: 420px; padding-top: 24px; }
.auth-title { font-size: 28px; font-weight: 600; margin: 40px 0 8px; }
.auth-side {
    flex: 1 1 40%;
    display: flex;
    align-items: center;
    padding: 48px;
    background: var(--panel);
    border-left: 1px solid var(--line);
}
.auth-side-inner { max-width: 360px; }
.auth-side h2 { font-size: 24px; font-weight: 600; margin: 12px 0; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; color: var(--muted); }

@media (max-width: 800px) {
    .auth-side { display: none; }
}

/* Skal med sidemenu */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 225px;
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 22px 14px;
    background: var(--surface-soft);
    border-right: 1px solid var(--line);
}
.sidebar .brand { padding: 0 8px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
}
.nav-link:hover { background: var(--panel); }
.nav-link.active { background: var(--primary-soft); color: var(--link); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 0 4px; }
.user { margin-bottom: 12px; padding: 0 4px; }
.user-name { font-weight: 600; }
.user-sub { font-size: 12px; color: var(--muted); }

.content { flex: 1; min-width: 0; padding: 32px; max-width: 1100px; }
.page-eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.page-title { font-size: 28px; font-weight: 600; margin: 4px 0 12px; }

/* Sidehoved og værktøjer */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-head .page-title { margin-bottom: 4px; }
.page-head p { margin: 0; }
.btn-inline { width: auto; }
.btn-small { height: 34px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.actions { display: flex; gap: 10px; }

.card-flat { margin: 0 0 16px; padding: 18px; }
.filter { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.filter .field { flex: 1; max-width: 420px; margin-bottom: 0; }
.input-small { height: 38px; font-size: 14px; }
.field-error { margin-top: 6px; font-size: 13px; color: var(--danger); }

.notice {
    margin-bottom: 16px;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--link);
    border: 1px solid #c5e0da;
}

.empty { text-align: center; padding: 36px 18px; }
.empty p { margin: 6px 0 0; }

/* Tabel */
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-family: var(--mono); }
.table .actions-col { text-align: right; white-space: nowrap; }
.table .actions-col .btn + .btn { margin-left: 8px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: var(--primary-soft); color: var(--link); }
.badge-off { background: #eceae4; color: var(--muted); }

/* Formularer og små elementer til brugerstyring */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.field-wide { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.inline-row { display: flex; gap: 10px; }
.inline-row .input { flex: 1; font-family: var(--mono); }
.hint { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
select.input { appearance: auto; }
.kode { font-family: var(--mono); font-size: 14px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; padding: 2px 8px; user-select: all; }
.kode-linje { margin-top: 10px; }
.badge-wait { background: #f8efd9; color: #8a5a00; }
.link-button { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; color: var(--link); text-decoration: underline; cursor: pointer; }
.filter { flex-wrap: wrap; }
.filter .field { margin-bottom: 0; }

/* Blazor flytter fokus til sidens h1 ved navigation (tabindex="-1"). Ingen fokusramme om overskriften. */
h1[tabindex="-1"]:focus { outline: none; }

.section-title {
    font-size: 1.15rem;
    margin: 1.5rem 0 0.75rem;
}

/* Lokationsoversigt: filtre og kort */
.filterbar { display: flex; flex-direction: column; gap: 12px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter-row .field { margin-bottom: 0; flex: 0 1 200px; }
.filter-row .field-grow { flex: 1 1 260px; }
.filter-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.segmented { display: flex; padding: 3px; gap: 2px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); }
.seg { font: inherit; font-size: 13px; font-weight: 600; height: 32px; padding: 0 14px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); cursor: pointer; }
.seg-on { background: var(--primary-soft); color: var(--link); }
.seg:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.loc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.loc-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.loc-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 14px 16px; background: #ece8e0; min-height: 76px; }
.loc-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--surface); color: var(--muted); }
.loc-body { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; flex: 1; }
.loc-name { font-size: 16px; font-weight: 600; margin: 0; }
.loc-name a { color: var(--ink); text-decoration: none; }
.loc-name a:hover { text-decoration: underline; }
.loc-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 0; padding-top: 10px; border-top: 1px solid var(--line); }
.loc-facts dt { font-size: 12px; color: var(--muted); }
.loc-facts dd { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.loc-fact-wide { grid-column: 1 / -1; }
.mono { font-family: var(--mono); }
.loc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }
.loc-actions .btn { flex: 1 1 0; min-height: 40px; }
.btn-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

.btn-add { display: inline-flex; align-items: center; gap: 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; }
.chip { flex: 0 0 auto; font: inherit; font-size: 14px; font-weight: 500; height: 38px; padding: 0 14px; border-radius: 19px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; }
.chip-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.loc-chev { display: none; }

/* Mobil: bundmenu */
.tabbar, .more-panel { display: none; }

@media (max-width: 800px) {
    .shell { display: block; }
    .sidebar { display: none; }
    .content { padding: 16px 16px 96px; max-width: none; }
    .page-title { font-size: 22px; }

    .tabbar {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
        display: flex; height: 76px; padding: 6px 8px 18px;
        background: var(--surface-soft); border-top: 1px solid var(--line);
    }
    .tab {
        flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
        text-decoration: none; color: #3d4852; font-size: 11.5px; font-weight: 500; list-style: none; cursor: pointer;
        background: none; border: 0;
    }
    .tab::-webkit-details-marker { display: none; }
    .tab-ic { display: flex; padding: 2px 16px; border-radius: 14px; }
    .tab.active { color: var(--link); font-weight: 700; }
    .tab.active .tab-ic { background: var(--primary-soft); }
    .tab:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 8px; }

    .more { flex: 1 1 0; display: flex; }
    .more > summary { flex: 1; }
    .more[open] > summary { color: var(--link); font-weight: 700; }
    .more[open] .more-panel {
        display: flex; flex-direction: column; gap: 4px;
        position: absolute; right: 8px; bottom: 84px; width: min(280px, calc(100vw - 16px));
        padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
        box-shadow: 0 8px 24px rgba(34, 48, 60, .18);
    }
    .more-link { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; }
    .more-link.active { background: var(--primary-soft); color: var(--link); font-weight: 600; }
    .more-user { padding: 10px 12px 8px; border-top: 1px solid var(--line); margin-top: 4px; }

    .btn-add { width: 44px; height: 44px; padding: 0; justify-content: center; flex: none; }
    .btn-add .lbl { display: none; }
    .page-head p.muted { font-size: 13px; }

    .segmented { display: none; }
    .filter-row .field, .filter-row .field-grow { flex: 1 1 100%; }

    /* Lokationskort bliver til kompakte rækker */
    .loc-grid { grid-template-columns: 1fr; gap: 8px; }
    .loc-card { display: grid; grid-template-columns: 64px 1fr; gap: 0 12px; padding: 10px; border-radius: 10px; }
    .loc-head { display: contents; }
    .loc-icon { grid-row: 1 / 4; width: 64px; height: 64px; background: #ece8e0; border-radius: 8px; }
    .loc-head .badge { grid-column: 2; grid-row: 3; justify-self: start; align-self: start; margin-top: 4px; }
    .loc-body { display: contents; }
    .loc-name { grid-column: 2; grid-row: 1; align-self: start; font-size: 15px; }
    .loc-body > .muted { grid-column: 2; grid-row: 2; font-size: 13px; }
    .loc-facts, .loc-actions { grid-column: 1 / -1; }
    .loc-facts { margin-top: 10px; }
    .loc-actions { margin-top: 8px; padding-top: 0; }
    .loc-chev { display: none; }
}

.btn-inline { white-space: nowrap; }
.sms-tekst { max-width: 28ch; overflow-wrap: anywhere; }
.table td { vertical-align: top; }

/* Sammenklappelige filtre */
.filter-details > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 24px; }
.filter-details > summary::-webkit-details-marker { display: none; }
.filter-details > summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-right: 4px; transition: transform .15s; }
.filter-details[open] > summary::after { transform: rotate(-135deg); }
.filter-details[open] > summary { margin-bottom: 14px; }
.filter-details > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: 4px; }

@media (max-width: 800px) {
    .page-head { flex-wrap: nowrap; }
    .page-head > div { min-width: 0; }
    .filter { flex-direction: column; align-items: stretch; }
    .filter .field { max-width: none; }

    /* Tabeller som kort */
    .table-card { overflow: visible; background: transparent; border: 0; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .table tbody tr { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 6px 14px; }
    .table td { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); text-align: right; overflow-wrap: anywhere; }
    .table td:last-child, .table tbody tr:last-child td { border-bottom: 0; }
    .table td[data-label]::before { content: attr(data-label); flex: 0 0 38%; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; }
    .table td > * { min-width: 0; }
    .table .num { text-align: right; }
    .table td.actions-col { justify-content: flex-start; flex-wrap: wrap; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); border-bottom: 0; text-align: left; white-space: normal; }
    .table .actions-col .btn + .btn { margin-left: 0; }
    .sms-tekst { max-width: none; }
}

.udfald-celle { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.udfald-celle .badge { white-space: normal; text-align: left; }
.fejltekst { font-size: 13px; overflow-wrap: anywhere; }
@media (max-width: 800px) {
    .table td > .udfald-celle { flex: 1 1 0; align-items: flex-end; text-align: right; }
    .udfald-celle .badge { text-align: right; }
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
