/* ===== InfoDesk – grundstil ===== */
:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --border: #e2e6ec;
    --text: #1f2933;
    --text-muted: #6b7684;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --sidebar-bg: #0f1b2d;
    --sidebar-text: #c7d0dc;
    --sidebar-active: #1e3a8a;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --ok: #16a34a;
    --warn: #d97706;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1rem; margin: 0 0 .75rem; }
a { color: var(--primary); text-decoration: none; }

/* ===== App-shell ===== */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; }
.app-content { padding: 1.75rem 2rem; max-width: 1280px; }

/* ===== Sidebar ===== */
.sidebar {
    width: 232px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: 0 1.25rem 1.5rem; }
.brand-mark {
    background: var(--primary); color: #fff; font-weight: 700;
    width: 34px; height: 34px; border-radius: 8px;
    display: grid; place-items: center; font-size: .95rem;
}
.brand-name { font-size: 1.15rem; font-weight: 600; color: #fff; }
.nav-items { display: flex; flex-direction: column; gap: 2px; padding: 0 .75rem; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .75rem; border-radius: 6px;
    color: var(--sidebar-text); font-weight: 500;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-ico { width: 18px; text-align: center; }
.nav-footer { padding: 1rem 1rem 0; border-top: 1px solid rgba(255, 255, 255, .08); margin: 0 .75rem; }
.user-chip { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: grid; place-items: center; font-weight: 600; font-size: .8rem;
}
.user-name { color: #fff; font-weight: 600; font-size: .85rem; }
.user-role { color: var(--sidebar-text); font-size: .75rem; }
.logout-btn {
    width: 100%; background: transparent; color: var(--sidebar-text);
    border: 1px solid rgba(255, 255, 255, .15); border-radius: 6px;
    padding: .45rem; cursor: pointer; font-size: .8rem;
}
.logout-btn:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.app-version { margin-top: .75rem; font-size: .68rem; line-height: 1.3; color: var(--sidebar-text); opacity: .55; text-align: center; word-break: break-word; }

/* ===== Page head ===== */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.25rem; gap: 1rem; }
.subtitle { color: var(--text-muted); margin-top: .35rem; font-size: .85rem; }

/* ===== Knapper ===== */
.btn-primary, .btn-secondary {
    display: inline-block; border: none; border-radius: 6px;
    padding: .55rem 1rem; font-size: .85rem; font-weight: 600;
    cursor: pointer; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f8fafc; }
.btn-danger { background: #fff; color: #b91c1c; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fef2f2; border-color: #f87171; }
.btn-mini.btn-danger { border: 1px solid #fecaca; }

/* ===== Paneler ===== */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }

/* ===== Stat-kort ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--text-muted); margin-top: .4rem; font-size: .82rem; }
.stat-danger .stat-value { color: var(--danger); }

.dash-cols { display: grid; grid-template-columns: 320px 1fr; gap: 1.25rem; align-items: start; }
.dash-cols3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: start; margin-bottom: 1.25rem; }
.detail-cols { display: grid; grid-template-columns: 1fr 340px; gap: 1.25rem; align-items: start; }

/* ===== Søjlediagram ===== */
.barchart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 40px; align-items: center; gap: .6rem; }
.bar-label { font-size: .8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: #eef1f5; border-radius: 5px; height: 16px; }
.bar-fill { height: 100%; border-radius: 5px; background: var(--primary); min-width: 3px; transition: width .3s; }
.bar-value { text-align: right; font-weight: 600; font-size: .82rem; }
.bar-fill.c-accent { background: var(--primary); }
.bar-fill.c-critical { background: #dc2626; }
.bar-fill.c-high { background: #ea580c; }
.bar-fill.c-medium { background: #d97706; }
.bar-fill.c-low { background: #0284c7; }

/* ===== Trend (oprettet vs løst) ===== */
.trend-cols { display: flex; align-items: flex-end; gap: .5rem; height: 140px; padding-top: .5rem; }
.trend-day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .35rem; height: 100%; }
.trend-bars { display: flex; align-items: flex-end; gap: 3px; flex: 1; width: 100%; justify-content: center; }
.trend-bars .tb { width: 12px; border-radius: 4px 4px 0 0; min-height: 2px; }
.tb-created { background: var(--primary); }
.tb-resolved { background: var(--ok); }
.trend-label { font-size: .72rem; color: var(--text-muted); }
.legend { display: flex; align-items: center; gap: .4rem; margin-top: .6rem; font-size: .8rem; color: var(--text-muted); }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .dot + .dot, .legend .tb-resolved { margin-left: .8rem; }

/* ===== Timeseddel ===== */
.timesheet th.ts-day { text-align: center; min-width: 64px; }
.timesheet td.num, .timesheet th.num { text-align: right; }
.timesheet .total { font-weight: 700; }
.ts-today { background: #eff6ff; }
.timesheet tfoot .ts-totals td { border-top: 2px solid var(--border); font-weight: 600; background: #f8fafc; }
.ts-summary { display: flex; gap: 1.5rem; margin: 1rem 0 1.25rem; font-size: 1rem; }
.ts-summary strong { color: var(--primary); font-size: 1.15rem; }
.chk-field { display: flex; align-items: center; gap: .5rem; }
.chk-field input { width: auto; margin-top: 0; }
.alert-inline { color: var(--danger); font-size: .85rem; margin-left: .5rem; }

/* ===== Tabeller ===== */
.data-table, .mini-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: .5rem .6rem; border-bottom: 2px solid var(--border); }
.data-table td { padding: .6rem; border-bottom: 1px solid var(--border); }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: #f8fafc; }
.mini-table td { padding: .4rem .2rem; border-bottom: 1px solid var(--border); }
.mini-table td.num { text-align: right; font-weight: 600; }
.mono { font-family: "Cascadia Code", "Consolas", monospace; font-size: .82rem; color: var(--text-muted); }
.empty { color: var(--text-muted); text-align: center; padding: 1.5rem !important; }
.result-count { color: var(--text-muted); margin: 0 0 .5rem; }

/* ===== Badges ===== */
.badge { display: inline-block; padding: .18rem .55rem; border-radius: 20px; font-size: .72rem; font-weight: 600; }
.badge-muted { background: #eef1f5; color: var(--text-muted); }
/* Prioritet */
.prio-critical { background: #fee2e2; color: #b91c1c; }
.prio-high { background: #ffedd5; color: #c2410c; }
.prio-medium { background: #fef9c3; color: #a16207; }
.prio-low { background: #e0f2fe; color: #0369a1; }
/* Status (efter enum-værdi) */
.status-1 { background: #dbeafe; color: #1e40af; } /* Ny */
.status-2 { background: #e0e7ff; color: #4338ca; } /* I gang */
.status-3 { background: #fef3c7; color: #92400e; } /* Afventer kunde */
.status-4 { background: #fef3c7; color: #92400e; } /* Afventer leverandør */
.status-5 { background: #fee2e2; color: #b91c1c; } /* Eskaleret */
.status-6 { background: #dcfce7; color: #166534; } /* Løst */
.status-7 { background: #f1f5f9; color: #475569; } /* Afsluttet */
/* SLA */
.sla-breach { background: #fee2e2; color: #b91c1c; }
.sla-warn { background: #ffedd5; color: #c2410c; }
.sla-ok { background: #dcfce7; color: #166534; }
.sla-paused { background: #e5e7eb; color: #4b5563; }

/* ===== Hurtigfilter-chips ===== */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.chip { border: 1px solid var(--border); background: #fff; color: var(--text); border-radius: 20px; padding: .4rem .85rem; font-size: .82rem; font-weight: 600; cursor: pointer; }
.chip:hover { background: #f8fafc; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip-clear { color: var(--danger); border-color: #f3c2c2; }
.chip-clear:hover { background: var(--danger-bg); }

/* Link-tekst i tabeller (fx kundenavn) */
.link-text { color: var(--primary); font-weight: 600; }
tr.clickable:hover .link-text { text-decoration: underline; }

/* Sorterbare kolonner */
.data-table.sortable th { cursor: pointer; user-select: none; white-space: nowrap; }
.data-table.sortable th:hover { color: var(--text); }

/* stat-card som link */
a.stat-card { text-decoration: none; color: inherit; display: block; transition: border-color .15s; }
a.stat-card.clickable:hover { border-color: var(--primary); }

/* klikbare diagram-søjler */
.bar-link { text-decoration: none; color: inherit; cursor: pointer; }
.bar-link:hover .bar-fill { filter: brightness(1.12); }
.bar-link:hover .bar-label { color: var(--primary); }

/* ===== Multi-select (afkrydsning i dropdown) ===== */
.ms { position: relative; display: inline-block; }
.ms-toggle { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: .5rem .7rem; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.ms-toggle strong { color: var(--primary); }
.ms-caret { color: var(--text-muted); margin-left: .2rem; }
.ms-panel { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 210px; max-height: 300px; overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: .35rem; }
.ms-item { display: flex; align-items: center; gap: .5rem; padding: .35rem .5rem; font-weight: 500; cursor: pointer; border-radius: 5px; font-size: .85rem; }
.ms-item:hover { background: #f8fafc; }
.ms-item input { width: auto; margin: 0; }
.ms-clear { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--danger); font-size: .78rem; cursor: pointer; padding: .25rem .5rem; border-bottom: 1px solid var(--border); margin-bottom: .25rem; }

/* ===== Filtre & søgning ===== */
.filter-bar { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filter-bar select, .search {
    padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: .85rem;
}
.search { flex: 1; min-width: 220px; margin-bottom: 1rem; }
.filter-bar .search { margin-bottom: 0; }

/* ===== Formularer ===== */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.form-row { margin-bottom: 1rem; }
label { display: block; font-size: .82rem; font-weight: 600; color: var(--text); }
label input, label select, label textarea,
.mini-form input, .time-composer input, .time-composer select,
.note-composer textarea {
    width: 100%; margin-top: .35rem; padding: .5rem .65rem;
    border: 1px solid var(--border); border-radius: 6px; font-size: .85rem;
    font-family: inherit; background: #fff;
}
.form-actions { margin-top: 1.25rem; display: flex; gap: .6rem; }
.field { margin-bottom: 1rem; }
.field label { margin-bottom: .3rem; }
.field select { width: 100%; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 6px; font-size: .85rem; background: #fff; }

/* ===== Meta-lister ===== */
.meta-list { display: grid; grid-template-columns: auto 1fr; gap: .4rem .8rem; margin: 0; }
.meta-list dt { color: var(--text-muted); font-size: .82rem; }
.meta-list dd { margin: 0; font-size: .85rem; }
.muted { color: var(--text-muted); }
.small { font-size: .78rem; }

/* ===== Noter / timeline ===== */
.note-composer { margin-bottom: 1rem; }
.note-composer-actions { display: flex; justify-content: space-between; align-items: center; margin-top: .5rem; }
.chk { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; }
.chk input { width: auto; margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 3px solid var(--border); padding: .5rem 0 .75rem 1rem; margin-left: .25rem; }
.timeline li.internal { border-left-color: var(--warn); }
.timeline li.email { border-left-color: #7c3aed; }
.badge-email { background: #ede9fe; color: #6d28d9; }
.email-subject { font-weight: 600; margin: .1rem 0 .35rem; }
.link-btn { background: none; border: none; color: var(--primary); font-weight: 600; font-size: .82rem; cursor: pointer; padding: .25rem 0; }
.link-btn:hover { text-decoration: underline; }
.tl-quoted { white-space: pre-wrap; border-left: 2px solid var(--border); padding-left: .75rem; margin-top: .4rem; color: var(--text-muted); font-size: .85rem; }
.tl-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .25rem; }
.tl-time { color: var(--text-muted); font-size: .78rem; }
.tl-body { white-space: pre-wrap; }
.desc { white-space: pre-wrap; margin: 0; }

/* ===== Tidsregistrering ===== */
.hours-total { float: right; color: var(--text-muted); font-weight: 600; font-size: .85rem; }
.time-composer { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.time-composer .w-small { width: 90px; }
.time-composer .w-grow { flex: 1; min-width: 160px; }
.time-composer input, .time-composer select { margin-top: 0; }
.file-pick { display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; font-size: .82rem; white-space: nowrap; }
.file-pick input[type=file] { max-width: 150px; font-size: .74rem; }
.mini-form { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.contact-list { list-style: none; margin: 0 0 .5rem; padding: 0; }
.contact-list li { padding: .5rem 0; border-bottom: 1px solid var(--border); }

/* ===== Login ===== */
.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0f1b2d, #1e3a8a); padding: 1rem; }
.login-card { background: #fff; border-radius: 12px; padding: 2.25rem; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.login-brand { display: flex; align-items: center; gap: .7rem; margin-bottom: .25rem; }
.login-brand h1 { font-size: 1.6rem; }
.login-sub { color: var(--text-muted); margin: 0 0 1.5rem; }
.login-form label { margin-bottom: 1rem; }
.login-form .btn-primary { width: 100%; margin-top: .5rem; padding: .65rem; }
.login-hint { margin-top: 1.5rem; padding: .85rem; background: var(--bg); border-radius: 6px; font-size: .78rem; color: var(--text-muted); line-height: 1.6; }
.alert-error { background: var(--danger-bg); color: var(--danger); padding: .65rem .85rem; border-radius: 6px; margin-bottom: 1rem; font-size: .85rem; }

/* ===== Rapporter / kontrakter / opsætning ===== */
label.inline { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; }
label.inline input { margin-top: 0; width: auto; }
input[type="date"] { font-family: inherit; }
.num { text-align: right; }
.meter { background: #eef1f5; border-radius: 20px; height: 8px; overflow: hidden; margin-bottom: .25rem; }
.meter-fill { background: var(--ok); height: 100%; border-radius: 20px; }
.meter-fill.meter-warn { background: var(--warn); }
.meter-fill.meter-danger { background: var(--danger); }
.saved-hint { color: var(--ok); font-weight: 600; margin-left: .5rem; }
.sla-table input { width: 100px; margin-top: 0; }
.mini-form-row { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.mini-form-row input { margin-top: 0; width: auto; flex: 1; min-width: 120px; }

/* ===== Handlingsknapper & godkendelse ===== */
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn-mini { padding: .32rem .6rem; font-size: .76rem; font-weight: 600; border: none; border-radius: 5px; cursor: pointer; }
.row-actions { display: flex; gap: .35rem; white-space: nowrap; }
.approvals-bar { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; flex-wrap: wrap; }
.approvals-bar .result-count { margin: 0; }
.bulk-info { font-weight: 600; color: var(--primary); }
.chk-col { width: 34px; text-align: center; }
.chk-col input { cursor: pointer; }
tr.row-selected td { background: #eff6ff !important; }
.desc-cell { font-size: .82rem; color: var(--text-muted); max-width: 240px; }
.w-tiny { width: 72px; margin-top: 0 !important; }
.nowrap { white-space: nowrap; }
.data-table td input:not([type=checkbox]), .data-table td select { width: 100%; margin: 0; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 5px; font-size: .82rem; font-family: inherit; background: #fff; }
.data-table td .w-tiny { width: 84px; }
.edit-name { display: flex; gap: .25rem; }
.edit-name input { flex: 1; min-width: 60px; }
.audit-details { font-size: .82rem; color: var(--text-muted); max-width: 420px; }

/* ===== Fakturaudkast ===== */
.invoice { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); }
.invoice-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.invoice-head h2 { margin-top: .5rem; }
.invoice-meta { text-align: right; }
.invoice-subhead { margin: 1.25rem 0 .5rem; font-size: .95rem; }
.invoice-totals { margin-top: 1.25rem; margin-left: auto; max-width: 320px; }
.invoice-totals > div { display: flex; justify-content: space-between; padding: .4rem 0; }
.invoice-totals .grand { border-top: 2px solid var(--border); font-weight: 700; font-size: 1.05rem; margin-top: .25rem; padding-top: .6rem; }

@media print {
    .sidebar, .topbar, .nav-scrim, .no-print { display: none !important; }
    .app-content { padding: 0; max-width: none; }
    .invoice { border: none; box-shadow: none; padding: 0; }
    body { background: #fff; }
}

/* ===== Top-bjælke (kun mobil) + skub-ind-menu ===== */
.app-main { display: flex; flex-direction: column; }
.topbar { display: none; }
.nav-scrim { display: none; }
.brand-mark.sm { width: 26px; height: 26px; font-size: .78rem; }

/* Tabel-scroll på smalle skærme */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===== Responsivt ===== */
@media (max-width: 900px) {
    .dash-cols, .detail-cols, .dash-cols3 { grid-template-columns: 1fr; }
    .app-content { padding: 1rem; }

    /* Top-bjælke frem */
    .topbar {
        display: flex; align-items: center; gap: .75rem;
        background: var(--sidebar-bg); color: #fff;
        padding: .7rem 1rem; position: sticky; top: 0; z-index: 30;
    }
    .hamburger { font-size: 1.4rem; cursor: pointer; line-height: 1; user-select: none; padding: .1rem .3rem; }
    .topbar-brand { display: flex; align-items: center; gap: .5rem; font-weight: 600; font-size: 1.05rem; }

    /* Sidebar bliver til en skub-ind-skuffe */
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; width: 260px;
        transform: translateX(-100%); transition: transform .22s ease;
        z-index: 50; box-shadow: 2px 0 16px rgba(0, 0, 0, .3);
    }
    .nav-toggle:checked ~ .sidebar { transform: translateX(0); }
    .nav-toggle:checked ~ .nav-scrim {
        display: block; position: fixed; inset: 0;
        background: rgba(0, 0, 0, .5); z-index: 40;
    }

    /* Layout i én kolonne, større touch-mål */
    .page-head { flex-direction: column; align-items: stretch; }
    .page-head .btn-primary, .page-head .btn-secondary { text-align: center; }
    .filter-bar { flex-direction: column; }
    .filter-bar select, .filter-bar .search { width: 100%; }
    .form-grid { grid-template-columns: 1fr; }
    .time-composer { flex-direction: column; align-items: stretch; }
    .time-composer .w-small, .time-composer .w-grow { width: 100%; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .btn-primary, .btn-secondary, .logout-btn { padding: .65rem 1rem; }
    .mini-form-row { flex-direction: column; }
    .mini-form-row input { width: 100%; }
    label.inline { width: 100%; justify-content: space-between; }
}

@media (max-width: 420px) {
    .stat-grid { grid-template-columns: 1fr; }
}
