/* ------------------------------------------- Wave 3 (2026-10-23): design system
   Same tokens as the scanner (docs/DESIGN.md): brand #1668ac (5.6:1 on white),
   darker muted text, readable table heads and badges, one visible focus ring. */

:root {
    --brand: #1668ac;
    --brand-rgb: 22, 104, 172;
    --brand-dark: #11558d;
    --brand-tint: #e8f1f9;
    --muted: #4f5d6b;
    --sidebar-muted: #5b6876;
    --sidebar-active-text: #11558d;
    --sidebar-active-bar: #1668ac;
    --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand);
}
.btn-primary { --bs-btn-active-bg: #0e4675; --bs-btn-active-border-color: #0e4675; }

/* One focus ring for everything you can tab to. */
a:focus-visible, button:focus-visible, .btn:focus-visible, summary:focus-visible,
.nav-link:focus-visible, [tabindex]:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}
.form-control:focus-visible, .form-select:focus-visible, .form-check-input:focus-visible {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.35);
}

/* Table heads: 12 px, darker, still caps. */
.table > thead th,
.table-card .table > thead th {
    font-size: 0.75rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    color: #3f4c59;
}

/* Badges: 12 px, never smaller, darker text on the soft fills. */
.badge { font-size: 0.75rem; font-weight: 600; padding: 0.3em 0.62em; line-height: 1.25; }
.badge-role { font-size: 0.75rem; }
.text-bg-success, .badge.bg-success { color: #135633 !important; }
.text-bg-warning, .badge.bg-warning { color: #6a4400 !important; background-color: #ffefc7 !important; }
.text-bg-info, .badge.bg-info, .text-bg-primary, .badge.bg-primary { color: #11558d !important; }
.text-bg-secondary, .badge.bg-secondary { color: #36424e !important; }

/* Small print stays readable. */
.small, small { font-size: 0.8125rem; }
.form-text, .page-header__subtitle { color: var(--muted); }
.page-header__eyebrow, .page-header .eyebrow { font-size: 0.72rem; }
code { font-size: 0.8125rem; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ------------------------------------------------ Dashboard (2026-10-23)
   Åtgärder | i dag överst, tre kolumner under. Lika höga kort i varje rad. */
.dash-h { font-size: 0.875rem; font-weight: 700; margin: 0 0 0.6rem; display: flex; gap: 0.5rem; align-items: baseline; }
.dash-h__n { font-size: 0.8125rem; font-weight: 600; color: var(--muted); }
.dash-top, .dash-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; margin-bottom: 1.25rem; }
.dash-col { display: flex; flex-direction: column; min-width: 0; }
.dash-act, .dash-today { display: grid; gap: 0.65rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); grid-auto-rows: 1fr; flex: 1; }
.dash-act__card, .dash-tile {
    display: flex; flex-direction: column; justify-content: flex-start; gap: 0.15rem;
    min-height: 108px; padding: 0.8rem 0.95rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
    color: var(--text); text-decoration: none;
}
.dash-act__card { border-left: 4px solid #d99a0b; }
.dash-act__card.is-error { border-left-color: #d6382c; }
.dash-act__card:hover { box-shadow: var(--shadow); color: var(--text); }
.dash-act__top { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.dash-act__label { font-weight: 600; }
.dash-act__n, .dash-tile__n { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dash-act__hint, .dash-tile__hint { color: var(--muted); font-size: 0.8125rem; }
.dash-act__go { color: var(--brand); font-size: 0.8125rem; font-weight: 600; margin-top: auto; padding-top: 0.3rem; }
.dash-tile__label { color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
.dash-tile__hint { margin-top: auto; }
.dash-act__top { margin-bottom: 0.1rem; }
.dash-allok { display: flex; gap: 0.6rem; align-items: center; padding: 0.85rem 1rem; border-radius: var(--radius); background: #e5f5eb; color: #135633; font-weight: 600; }
.dash-card { flex: 1; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.dash-card > .table-responsive { flex: 1; }
.dash-card .table { height: 100%; }
.dash-row { flex: 1; display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.95rem; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; min-height: 56px; }
.dash-row:last-child { border-bottom: 0; }
a.dash-row:hover { background: var(--surface-muted); color: var(--text); }
.dash-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dash-row__main b { font-weight: 600; }
.dash-row__main span, .dash-row__side { color: var(--muted); font-size: 0.8125rem; }
.dash-row__side { white-space: nowrap; }
.dash-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #2f9e5a; }
.dash-dot.is-warn { background: #d99a0b; }
.dash-dot.is-error { background: #d6382c; }
.dash-prog { width: 42%; display: flex; flex-direction: column; gap: 0.3rem; }
.dash-bar { display: block; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.dash-bar > i { display: block; height: 100%; background: var(--brand); }
.dash-foot { color: var(--muted); font-size: 0.8125rem; }
/* Ärendena bakom korten (2026-11-13): kortet = länk + Hantera, listan i en modal. */
.dash-act__main { display: flex; flex-direction: column; gap: 0.15rem; color: var(--text); text-decoration: none; }
.dash-act__main:hover { color: var(--text); }
.dash-act__foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.35rem 0.5rem; margin-top: auto; padding-top: 0.3rem; }
.dash-act__foot .dash-act__go { flex: 1 1 auto; margin-top: 0; padding-top: 0; text-decoration: none; }
.dash-act__handle { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.55rem; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.dash-act__handle:hover { background: var(--brand-tint); border-color: var(--brand); color: var(--brand); }
.dash-act__more { margin: 0.5rem 0 0; font-size: 0.8125rem; }
.dash-items { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); }
.dash-item { display: flex; gap: 0.75rem; align-items: flex-start; justify-content: space-between; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); }
.dash-item:last-child { border-bottom: 0; }
.dash-item__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; overflow-wrap: anywhere; }
.dash-item__main b { font-weight: 600; }
.dash-item__main > span { font-size: 0.875rem; }
.dash-item__sub { color: var(--muted); font-size: 0.8125rem; }
.dash-item__mail { display: inline-flex; gap: 0.35rem; align-items: baseline; color: var(--brand); font-size: 0.8125rem; font-weight: 600; }
.dash-item__mail.is-failed { color: #b42318; }
.dash-item__act { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: flex-end; align-items: flex-start; flex: none; max-width: 52%; }
.dash-item__done { display: contents; }
.dash-item__done > summary { list-style: none; }
.dash-item__done > summary::-webkit-details-marker { display: none; }
.dash-item__done[open] > summary { background: var(--brand-tint); border-color: var(--brand); color: var(--brand); }
.dash-item__form { flex-basis: 100%; display: flex; flex-direction: column; gap: 0.35rem; align-items: flex-end; margin-top: 0.2rem; }
.dash-item__form .form-label { align-self: flex-start; }
.ai-wrap { max-width: 760px; display: flex; flex-direction: column; gap: 1rem; }
.ai-facts .dash-row { min-height: 0; }
.ai-seg { align-self: flex-start; }
.ai-other .form-control { max-width: 360px; }
@media (max-width: 719.98px) {
    .dash-item { flex-direction: column; }
    .dash-item__act { max-width: none; justify-content: flex-start; width: 100%; }
    .dash-item__form { align-items: stretch; }
}
@media (min-width: 1000px) {
    .dash-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1600px) {
    .dash-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
    .dash-cols { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1.2fr); }
    .dash-act { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-today { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 2400px) {
    .dash-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
    .dash-act { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .dash-today { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* ------------------------------------------------- Tabeller (2026-10-26)
   Långa listor (25+ rader) får egen scroll med fast huvud på skärmar från 720 px.
   Under 720 px blir enkla tabeller kort: rubriken som etikett framför värdet
   (admin-tables.js sätter data-label och .table-stack). */
@media (min-width: 720px) {
    .table-responsive:has(> .table > tbody > tr:nth-child(25)) {
        max-height: calc(100vh - 220px);
        overflow: auto;
    }
    .table-responsive > .table > thead th {
        position: sticky;
        top: 0;
        z-index: 2;
        background-clip: padding-box;
    }
}
@media (max-width: 719.98px) {
    .table-responsive:has(> .table-stack) { overflow: visible; border: 0 !important; }
    .table-stack > thead { display: none; }
    .table-stack, .table-stack > tbody, .table-stack > tbody > tr, .table-stack > tbody > tr > td { display: block; width: 100%; }
    .table-stack > tbody > tr {
        margin: 0 0 0.6rem;
        padding: 0.35rem 0;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
    }
    .table-stack > tbody > tr:last-child { margin-bottom: 0; }
    .table-stack > :not(caption) > * > * { border-bottom: 0 !important; padding: 0.28rem 0.85rem; text-align: left !important; }
    .table-stack > tbody > tr > td[data-label] {
        position: relative;
        padding-left: calc(40% + 0.75rem);
        min-height: 1.9rem;
    }
    .table-stack > tbody > tr > td[data-label]::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.75rem;
        font-weight: 650;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        overflow-wrap: anywhere;
        position: absolute;
        left: 0.85rem;
        top: 0.38rem;
        width: calc(40% - 0.85rem);
    }
    .table-stack > tbody > tr > td:not([data-label]):empty { display: none; }
    .table-stack > tbody > tr:hover > * { background: transparent; }
    .table-card:has(.table-stack), .dash-card:has(.table-stack) { background: transparent; border: 0; box-shadow: none; }
}

/* Åtgärder i tabellrader (2026-11-03): luft mellan knapparna, ingen radbrytning,
   länkknappar ser ut som knappar och Ta bort är röd först när man pekar på den. */
.table td.text-end { white-space: nowrap; }
.table td > :is(.btn, form, .dropdown, .btn-group) + :is(.btn, form, .dropdown, .btn-group) { margin-left: 0.375rem; }
.table td.text-end .btn-link.btn-sm {
    text-decoration: none; color: var(--brand);
    border: 1px solid var(--border-strong); background: transparent;
}
.table td.text-end .btn-link.btn-sm:hover { background: var(--brand-tint); border-color: var(--brand); }
.table td .btn-outline-danger.btn-sm:not(:hover):not(:focus-visible) {
    --bs-btn-border-color: var(--border-strong); --bs-btn-bg: transparent;
}
@media (max-width: 719.98px) {
    .table-stack > tbody > tr > td.text-end { white-space: normal; }
}

/* ------------------------------------------- Platskontroller (2026-10-27) */
.lc-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.65rem; margin-bottom: 1.1rem; }
.lc-stat { display: grid; gap: 0.1rem; padding: 0.75rem 0.95rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.lc-stat.is-attn { border-left: 4px solid #d99a0b; }
.lc-stat span { color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
.lc-stat b { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.lc-stat small { color: var(--muted); font-size: 0.8125rem; }
.lc-bar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 0.65rem; }
.lc-bar select { width: auto; }
.lc-seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.lc-seg a { padding: 0.4rem 0.85rem; font-size: 0.875rem; font-weight: 600; color: var(--text); text-decoration: none; border-right: 1px solid var(--border-strong); }
.lc-seg a:last-child { border-right: 0; }
.lc-seg a:hover { background: var(--surface-muted); color: var(--text); }
.lc-seg a.is-on { background: var(--brand-tint); color: var(--brand); }
.lc-seg__n { display: inline-block; margin-left: 0.4rem; padding: 0 0.45rem; border-radius: 999px; background: #b45309; color: #fff; font-size: 0.75rem; }
.lc-loc { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; font-size: 0.95rem; white-space: nowrap; }
.lc-kind { display: inline-block; margin-left: 0.35rem; padding: 0 0.4rem; border: 1px solid var(--border); border-radius: 5px; color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.lc-art { font-weight: 600; }
.lc-sub, .lc-who, .lc-why { color: var(--muted); font-size: 0.8125rem; }
.lc-who { white-space: nowrap; }
.lc-who b { color: var(--text); font-weight: 600; }
.lc-why { margin-top: 0.25rem; max-width: 34ch; }
.lc-qty { white-space: nowrap; font-variant-numeric: tabular-nums; }
.lc-arrow { margin: 0 0.4rem; color: var(--muted); }
.lc-diff { display: inline-block; min-width: 3em; margin-left: 0.4rem; padding: 0.1rem 0.45rem; border-radius: 6px; text-align: center; font-weight: 700; }
.lc-diff.is-up { background: #e3f1fb; color: #11558d; }
.lc-diff.is-down { background: #ffefc7; color: #6a4400; }
.lc-diff.is-same { background: #edf1f5; color: #36424e; }
.lc-done { color: #135633; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.lc-set { margin-top: 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.lc-set > summary { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; padding: 0.8rem 1rem; cursor: pointer; list-style: none; }
.lc-set > summary::-webkit-details-marker { display: none; }
.lc-set > summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
.lc-set[open] > summary::after { content: "▴"; }
.lc-set > summary span { color: var(--muted); font-size: 0.875rem; }
.lc-set__body { display: grid; gap: 0.9rem; padding: 0.9rem 1rem 1rem; border-top: 1px solid var(--border); }
.lc-set__body > .btn { justify-self: start; }
.lc-set__row { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: 0.5rem 1rem; align-items: start; }
.lc-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.lc-chip { display: inline-flex; gap: 0.4rem; align-items: center; padding: 0.2rem 0.25rem 0.2rem 0.7rem; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface-muted); font-size: 0.875rem; }
.lc-chip input { width: 4.5rem; }
.lc-chip__x { border: 0; background: none; color: var(--muted); padding: 0 0.4rem; font-size: 0.9rem; }
.lc-chip__x:hover { color: var(--text); }
.lc-add { width: auto; }
@media (max-width: 719.98px) {
    .lc-set__row { grid-template-columns: minmax(0, 1fr); }
    .lc-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .lc-seg { display: flex; width: 100%; }
    .lc-seg a { flex: 1; text-align: center; padding: 0.45rem 0.4rem; }
    .lc-bar form { margin-left: 0 !important; }
}
[data-bs-theme="dark"] .lc-diff.is-up { background: #132c44; color: #9ccdf5; }
[data-bs-theme="dark"] .lc-diff.is-down { background: #3a2c0c; color: #f3cd74; }
[data-bs-theme="dark"] .lc-diff.is-same { background: #233140; color: #c3cfda; }
[data-bs-theme="dark"] .lc-done { color: #8fe0ad; }
[data-bs-theme="dark"] .lc-seg__n { background: #d99a0b; color: #0f161d; }

/* ------------------------------------------------ Godsägare (2026-11-03) */
.go-bar .go-search { width: 16rem; margin-left: auto; }
.go-n { margin-left: 0.4rem; color: var(--muted); font-weight: 600; }
.lc-seg a.is-on .go-n { color: inherit; }
.go-name { font-weight: 600; color: var(--text); text-decoration: none; }
.go-name:hover { color: var(--brand); text-decoration: underline; }
.go-slug { display: block; color: var(--muted); font-size: 0.75rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.go-id { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }
.go-table .badge { margin: 0.1rem 0.25rem 0.1rem 0; }
.go-actions { white-space: nowrap; text-align: right; }
.go-actions > .btn, .go-actions > .dropdown { display: inline-block; vertical-align: middle; }
.go-actions > * + * { margin-left: 0.4rem; }
.go-actions .dropdown-menu form { margin: 0; }
.go-actions .dropdown-header { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
@media (max-width: 719.98px) {
    .go-bar .go-search { width: 100%; margin-left: 0; }
    .go-bar .lc-seg { overflow-x: auto; }
    .go-bar .lc-seg a { flex: 0 0 auto; white-space: nowrap; }
    .go-table .badge { white-space: normal; text-align: left; }
    .table-stack > tbody > tr > td.go-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; text-align: left; white-space: normal; }
    .go-actions > * + * { margin-left: 0; }
}
