/* ================================================================
   BRUTALIST / TERMINAL — No decoration. No chrome. All data.
   ================================================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ---- Design tokens ----
   A restrained palette + spacing rhythm so panels read as distinct and a
   single accent carries interaction/section cues. */
:root {
    --accent: #0057b8;
    --accent-hover: #c00;
    --accent-wash: #eef4fb;
    --ink: #000;
    --muted: #666;
    --muted-2: #888;
    --border: #d8d8d8;
    --border-light: #e4e4e4;
    --tile-bg: #fcfcfc;
    --zebra: #f7f7f7;
    --pos: #157347;
    --neg: #c0392b;
    --nav-h: 34px;
    --section-gap: 22px;
}

body {
    font-family: ui-monospace, 'Cascadia Mono', Menlo, Consolas, 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #000;
    background: #fff;
    min-height: 100vh;
}

a             { color: #0057b8; text-decoration: underline; }
a:visited     { color: #0057b8; }
a:hover       { color: #c00; }

/* ---- Layout ----
   The header/footer bars themselves stay full-bleed (the border reads as a
   clean edge-to-edge rule), but their content — and all of `main` — is capped
   at a comfortable reading/scanning width and centered. */
:root {
    --page-max-width: 1400px;
}

header {
    border-bottom: 2px solid #000;
}

header nav.main-nav {
    max-width: var(--page-max-width);
    margin: 0 auto;
    padding: 4px 12px;
}

main {
    max-width: var(--page-max-width);
    margin: 0 auto;
    padding: 8px 12px;
}

footer {
    border-top: 1px solid #000;
    margin-top: 24px;
}

footer p {
    max-width: var(--page-max-width);
    margin: 0 auto;
    padding: 4px 12px;
    font-size: 11px;
    color: #666;
}

/* ---- Navigation ---- */

nav.main-nav {
    display: flex;
    align-items: baseline;
    gap: 0;
    flex-wrap: wrap;
}

.site-title {
    font-weight: bold;
    color: #000;
    text-decoration: none;
    margin-right: 1.5rem;
    font-size: 14px;
}

.site-title:hover { color: #c00; }

.site-tagline {
    font-size: 11px;
    color: #666;
    margin-right: 1.5rem;
    letter-spacing: 0.02em;
}

/* ---- Tables ---- */

table {
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 2px 8px 3px 0;
    font-weight: bold;
    border-bottom: 2px solid #000;
    white-space: nowrap;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 3px 8px 3px 0;
    border-bottom: 1px solid #e8e8e8;
    vertical-align: middle;
}

tr:hover td {
    background: #fffff0;
}

/* ---- Inputs & Selects ---- */

input[type="text"],
input[type="password"],
input[type="number"],
select {
    font-family: inherit;
    font-size: 12px;
    border: 1px solid #000;
    padding: 1px 4px;
    background: #fff;
    color: #000;
    height: 22px;
    vertical-align: middle;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
    outline: 2px solid #00c;
    outline-offset: -1px;
}

input[type="checkbox"] {
    vertical-align: middle;
    cursor: pointer;
}

/* ---- Buttons ---- */

button,
.btn {
    font-family: inherit;
    font-size: 12px;
    border: 1px solid #000;
    padding: 1px 8px;
    background: #fff;
    color: #000;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    height: 22px;
    line-height: 18px;
    vertical-align: middle;
    white-space: nowrap;
}

button:hover,
.btn:hover {
    background: #000;
    color: #fff;
    text-decoration: none;
}

button:disabled,
.btn:disabled {
    background: #eee;
    color: #999;
    border-color: #999;
    cursor: not-allowed;
}

button:disabled:hover,
.btn:disabled:hover {
    background: #eee;
    color: #999;
}

/* ---- Status ---- */

.status-ok,
.status-captured  { color: #060; }

.status-error,
.status-failed    { color: #c00; }

.status-pending   { color: #840; }

/* ---- Filter / search row ---- */

.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    margin: 4px 0;
    font-size: 12px;
}

.filter-row label {
    color: #666;
    white-space: nowrap;
}

.filter-row input[type="text"],
.filter-row select {
    width: auto;
}

/* ---- Result table columns ---- */

.domain-col {
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: top;
}

.city-col {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #444;
}

.code-col {
    white-space: nowrap;
    color: #444;
    font-size: 12px;
}

.date-col {
    white-space: nowrap;
    font-size: 12px;
    color: #333;
}

/* ---- Pivot count links ---- */

.pivot-count {
    font-size: 11px;
    margin-left: 0.6em;
    white-space: nowrap;
}

.pivot-count a {
    color: #0057b8;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.pivot-count a:hover {
    color: #c00;
    text-decoration-style: solid;
}

/* ---- Detail page ---- */

.detail-domain {
    font-size: 20px;
    font-weight: bold;
    line-height: 1.25;
    margin: 6px 0 4px 0;
    word-break: break-word;
}

.detail-nav {
    font-size: 12px;
    margin-bottom: 4px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.detail-nav button {
    height: 20px;
    line-height: 16px;
    padding: 0 6px;
}

/* Sticky in-page nav (table of contents) for long profile/actor pages. */
.page-nav {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin: 4px 0 8px 0;
    padding: 4px 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.page-nav a {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    text-decoration: none;
    padding: 3px 8px;
    border: 1px solid transparent;
    border-radius: 2px;
}

.page-nav a:hover { color: var(--accent-hover); }

.page-nav a.is-current {
    color: var(--accent);
    border-color: var(--border);
    background: var(--accent-wash);
    font-weight: bold;
}

.hr-light {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 6px 0;
}

/* ---- Key-value table (detail page) ---- */

.kv-table {
    border-collapse: collapse;
    margin: 6px 0;
}

.kv-table td {
    padding: 2px 16px 2px 0;
    border: none;
    vertical-align: top;
    font-size: 13px;
    border-bottom: none;
}

.kv-table td.kv-key {
    color: #666;
    white-space: nowrap;
    min-width: 90px;
    font-size: 12px;
}

.kv-table td.kv-val {
    word-break: break-word;
}

/* Section header: a large, bold heading with a plain bottom rule that segments
   the page. ``scroll-margin-top`` keeps anchored jumps clear of the sticky
   in-page nav. */
.kv-section-label {
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.2;
    margin: var(--section-gap) 0 8px 0;
    padding: 0 0 5px 0;
    border-bottom: 2px solid var(--ink);
    scroll-margin-top: calc(var(--nav-h) + 8px);
}

/* The first heading in a column shouldn't push a big gap above itself. */
.profile-col > .kv-section-label:first-child {
    margin-top: 4px;
}

/* ---- Active filter chips ---- */

.active-filters {
    font-size: 12px;
    margin: 4px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
}

.filter-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    border: 1px solid #0057b8;
    background: #eaf1fa;
    padding: 1px 4px 1px 7px;
    font-size: 11px;
}

.filter-chip a {
    text-decoration: none;
    color: #c00;
    font-weight: bold;
    padding: 0 3px;
}

.filter-chip a:hover { color: #fff; background: #c00; }

.filter-chip.active {
    background: #333;
    color: #fff;
    border-radius: 3px;
}

.filter-chip.active a {
    color: #fff;
}

/* Every search/reverse-search view defaults to active-only companies (see
   DEFAULT_STATUS_FILTER) — this is the one-click "vis ophørte" opt-out. */
.results-toolbar {
    margin: 4px 0 8px 0;
}

.status-toggle {
    display: inline-block;
    font-size: 11px;
    color: #444;
    border: 1px solid #999;
    background: #f4f4f4;
    padding: 2px 8px;
    text-decoration: none;
}

.status-toggle:hover {
    color: #fff;
    background: #444;
    border-color: #444;
}

/* ---- Pagination ---- */

.pagination {
    font-size: 12px;
    margin: 8px 0;
    display: flex;
    gap: 1rem;
    align-items: baseline;
    flex-wrap: wrap;
}

.page-info {
    color: #666;
}

/* ---- Empty state ---- */

.empty-state {
    padding: 2rem 0;
    color: #666;
    font-size: 13px;
}

/* ---- Pivot page heading ---- */

.pivot-heading {
    font-size: 15px;
    font-weight: bold;
    margin: 4px 0 2px 0;
}

/* Table cell pivot links (branche, address columns) */
td a.cell-pivot {
    color: #333;
    text-decoration: none;
    border-bottom: 1px dotted #999;
}

td a.cell-pivot:hover {
    color: #0057b8;
    border-bottom-color: #0057b8;
}

/* ---- Sub-tables (roles, owned, history, financials) ---- */

.sub-table {
    border-collapse: collapse;
    margin: 0 0 0 0;
    font-size: 12px;
}

.sub-table td {
    padding: 1px 8px 1px 0;
    border: none;
    vertical-align: top;
}

.sub-table a {
    color: #0057b8;
}

.sub-table th {
    text-align: left;
    padding: 2px 8px 2px 0;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #000;
    white-space: nowrap;
}

/* Consistent numeric alignment across all sub-tables (owned, history, roles). */
.sub-table td.num,
.sub-table th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding-left: 16px;
}

/* Zebra only for the larger, header-bearing sub-tables (owned/history/figures);
   the small stacked role-group tables stay clean. */
.sub-table:has(thead) tbody tr:nth-child(even) td {
    background: var(--zebra);
}

.hidden {
    display: none !important;
}

/* ---- CVR financials (key figures) table ---- */

.fin-scroll {
    overflow-x: auto;
}

/* Size to content (not the full container) so the year columns sit close
   together instead of being spread across the whole width. */
.fin-table {
    width: auto;
    max-width: 100%;
}

.fin-table td.kv-key {
    padding-right: 24px;
    white-space: nowrap;
}

.fin-table td.num,
.fin-table th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding-left: 16px;
}

.fin-table tbody tr:nth-child(even) {
    background: #f7f7f7;
}

/* Signed financial figures: subtle green (profit) / red (loss). */
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* Keep anchored jumps to non-header targets clear of the sticky in-page nav. */
.prev-toggle-wrap[id] {
    scroll-margin-top: calc(var(--nav-h) + 8px);
}

/* Condensed key-figures table (regnskabstal): tighter rows + smaller type so
   the multi-year matrix stays compact. */
.fin-condensed { font-size: 12px; }
.fin-condensed td,
.fin-condensed th {
    padding-top: 1px;
    padding-bottom: 1px;
}
.fin-condensed td.kv-key { font-size: 11px; }

/* ---- Employment (CVR monthly) tile (rendered inside a facts info-box) ---- */

.emp-headline {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 5px;
    margin-bottom: 5px;
    font-size: 12px;
}

.emp-headline .emp-month {
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

.emp-headline .emp-sep { color: #bbb; }
.emp-headline .emp-figure strong { font-variant-numeric: tabular-nums; }

.emp-scroll {
    max-height: 220px;
    overflow-y: auto;
}

.emp-table { margin: 0; }
.emp-table td.num,
.emp-table th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding-left: 16px;
}

.emp-table tbody tr:nth-child(even) { background: #f7f7f7; }
.emp-table tbody tr.emp-latest {
    background: var(--accent-wash);
    font-weight: bold;
}

/* ---- Shared results table (search + reverse search) ----
   Sticky header, zebra rows, right-aligned tabular numerics and a primary-weight
   name column, so long result lists stay scannable. */
.results-table {
    width: 100%;
}

.results-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
}

.results-table tbody tr:nth-child(even) td {
    background: #f7f7f7;
}

.results-table tbody tr:hover td {
    background: #fffff0;
}

.results-table td.domain-col a {
    font-weight: bold;
}

.results-table td.code-col,
.results-table td.city-col {
    color: var(--muted);
}

.results-table td.num,
.results-table th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding-left: 16px;
}

/* ---- CVR company directory ---- */

.company-subline {
    font-size: 12px;
    color: #444;
    margin: 2px 0 6px 0;
}

.muted {
    color: #888;
}

.note {
    font-size: 11px;
    color: #777;
    margin: 3px 0 0 0;
    line-height: 1.4;
}

.data-note {
    max-width: 70ch;
}

/* ---- CVR search-first landing ---- */

.company-search {
    margin: 10px 0 8px 0;
}

.search-main {
    display: flex;
    gap: 6px;
    align-items: center;
}

.search-main input[type="text"] {
    font-size: 15px;
    padding: 6px 8px;
    max-width: 32ch;
}

.search-main button {
    font-size: 14px;
    padding: 6px 14px;
}

.search-refine {
    margin-top: 6px;
    font-size: 12px;
}

.search-refine > summary {
    color: #666;
    cursor: pointer;
    user-select: none;
    width: fit-content;
}

.search-refine[open] > summary {
    margin-bottom: 4px;
}

.search-landing {
    margin: 14px 0;
    max-width: 70ch;
}

.search-hint {
    font-size: 13px;
    color: #222;
    line-height: 1.6;
}

.top-earners {
    margin: 20px 0 8px 0;
    max-width: 70ch;
}

.top-earners-table td.code-col:first-child {
    color: var(--muted);
    width: 2em;
}

.te-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.te-date {
    flex: 0 0 auto;
}

.te-nav {
    font-family: inherit;
    font-size: 13px;
    line-height: 1;
    padding: 2px 8px;
    cursor: pointer;
}

.te-spinner {
    font-size: 11px;
    color: var(--muted);
}

.te-more {
    font-family: inherit;
    font-size: 12px;
    margin: 8px 0 0 0;
    padding: 4px 10px;
    cursor: pointer;
}

/* ---- CVR relations / actor profile ---- */

.role-group {
    margin: 8px 0;
}

.role-group-label {
    font-size: 12px;
    font-weight: bold;
    color: #444;
    margin-bottom: 2px;
}

/* ---- Grouped info boxes (company / actor stamdata) ---- */

.info-boxes {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 8px 0;
    align-items: flex-start;
}

/* Centered, readable-width container for the CVR detail pages so content does
   not stretch edge-to-edge on wide monitors. */
.cvr-detail {
    max-width: 1024px;
    margin: 0 auto;
}

/* ---- Soft-navigation skeleton ----
   Placeholder shapes swapped into `<main>` the instant a company/actor
   profile link is clicked (see base.html), before the real HTML has even
   finished fetching — so the *click* feels instant even though the data
   behind it hasn't loaded yet. Loosely mirrors the real profile layout
   (title/subline/fact-tiles/relation-rows) so there's no layout jolt once
   real content replaces it. */
.skel {
    display: block;
    background: linear-gradient(90deg, #eee 25%, #f2f2f2 37%, #eee 63%);
    background-size: 400% 100%;
    animation: skel-shimmer 1.3s ease infinite;
    border-radius: 2px;
}

@keyframes skel-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

.skeleton-page .skel-btn { width: 110px; height: 20px; }
.skeleton-page .skel-title { width: 45%; height: 22px; }
.skeleton-page .skel-line { height: 12px; width: 220px; margin: 4px 0; }
.skeleton-page .skel-heading { width: 140px; height: 15px; margin-bottom: 12px; }
.skeleton-page .skel-box { height: 92px; }
.skeleton-page .skel-row { height: 18px; margin-bottom: 9px; }
.skeleton-page .skel-row:nth-child(odd) { width: 92%; }

/* ---- Company profile two-column layout ----
   Facts (stamdata/beliggenhed/branche/revisor/ansatte) stack in one column so
   the eye reads top-to-bottom; relations (aktører, ejerskaber) fill the other.
   Read each column vertically instead of scanning a wrapped grid. */
.profile-grid {
    display: grid;
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
    gap: 32px;
    align-items: start;
    margin: 12px 0;
}

.profile-col { min-width: 0; }

.profile-facts .info-box {
    display: block;
    width: 100%;
    margin: 0 0 12px 0;
    flex: none;
}

@media (max-width: 760px) {
    .profile-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

.info-box {
    border: 1px solid #d8d8d8;
    background: #fcfcfc;
    padding: 6px 10px 8px 10px;
    min-width: 240px;
    flex: 1 1 260px;
}

.info-box-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #444;
    font-weight: bold;
    border-bottom: 1px solid #e4e4e4;
    padding-bottom: 3px;
    margin-bottom: 4px;
}

.info-box .kv-table { margin: 0; }
.info-box .kv-table td.kv-val.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---- Per-company relation cards (actor page) ---- */

.rel-card {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    border: 1px solid #e0e0e0;
    border-left: 3px solid #0057b8;
    background: #fcfcfc;
    padding: 6px 10px;
    margin: 6px 0;
    align-items: flex-start;
}

.rel-card-main {
    flex: 1 1 320px;
    min-width: 0;
}

.rel-card-company {
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 2px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
}

.rel-card-company a { color: #0057b8; }

.rel-card-cvr {
    font-size: 11px;
    font-weight: normal;
    color: #888;
    font-variant-numeric: tabular-nums;
}

.rel-roles {
    border-collapse: collapse;
    font-size: 12px;
}

.rel-roles td {
    padding: 1px 12px 1px 0;
    border: none;
    vertical-align: top;
}

.rel-roles td.rel-role { color: #222; white-space: nowrap; }
.rel-roles td.rel-own {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: #444;
    white-space: nowrap;
}

.rel-dates {
    color: #666;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.rel-card-fin {
    flex: 0 0 auto;
    min-width: 190px;
    border-left: 1px solid #ececec;
    padding-left: 10px;
}

.rel-fin-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #888;
    margin-bottom: 2px;
}

.rel-fin {
    border-collapse: collapse;
    font-size: 12px;
    width: 100%;
}

.rel-fin td {
    padding: 1px 0;
    border: none;
}

.rel-fin td.rel-fin-key { color: #666; padding-right: 12px; }
.rel-fin td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.rel-fin-empty { font-size: 11px; }

/* ---- Show/hide previous relations toggle ---- */

.toggle-link {
    font-size: 12px;
    margin: 6px 0;
}

.toggle-link a {
    color: #0057b8;
    text-decoration: none;
    border-bottom: 1px dotted #0057b8;
}

.toggle-link a:hover { color: #c00; border-bottom-color: #c00; }

.prev-heading {
    color: #888;
    margin-top: 8px;
}

/* ---- Async "vis tidligere" toggle ---- */

.prev-toggle-wrap {
    margin: 6px 0;
    display: flex;
    gap: 8px;
    align-items: baseline;
}

.ajax-spinner {
    font-size: 12px;
    color: #888;
}

.prev-content:not(:empty) {
    margin-top: 4px;
}

/* ---- Per-year annual-report link + hover card (nøgletal table) ---- */

.fin-doc-row td { border-top: 1px solid #e4e4e4; }

.hover-card {
    position: relative;
    display: inline-block;
}

.hover-card-body {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 20;
    min-width: 190px;
    margin-top: 2px;
    padding: 6px 8px;
    background: #fff;
    border: 1px solid #bbb;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    font-size: 11px;
    font-weight: normal;
    line-height: 1.5;
    text-align: left;
    white-space: nowrap;
    color: #333;
}

.hover-card:hover .hover-card-body,
.hover-card:focus-within .hover-card-body {
    display: block;
}

/* Marks an ownership % that carries earlier bands (shown on hover). */
.hist-marker {
    color: #888;
    cursor: help;
    font-size: 10px;
    vertical-align: super;
}

@media (max-width: 768px) {
    .rel-card-fin {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid #ececec;
        padding-top: 4px;
        width: 100%;
    }
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
    header { padding: 4px 8px; }
    main   { padding: 6px 8px; }

    .filter-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    th, td { padding: 3px 6px 3px 0; }

    .detail-nav { flex-wrap: wrap; gap: 6px; }

    .domain-col     { max-width: 160px; }
}

/* ---- Global page loading (navigation + fetch) ---- */

.page-loading {
    position: fixed;
    inset: 0;
    z-index: 2500;
    background: rgba(255, 255, 255, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: all;
}

.page-loading[hidden] {
    display: none !important;
}

.page-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: #000;
    transform-origin: left center;
    animation: page-loading-bar 1.2s ease-in-out infinite;
}

@keyframes page-loading-bar {
    0%   { transform: scaleX(0.08); opacity: 0.5; }
    50%  { transform: scaleX(0.55); opacity: 1; }
    100% { transform: scaleX(0.08); opacity: 0.5; }
}

.page-loading-panel {
    border: 2px solid #000;
    background: #fff;
    padding: 12px 18px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-loading-spinner {
    font-weight: bold;
    width: 1ch;
    text-align: center;
}

.page-loading-text {
    color: #333;
}
