:root {
    --color-bg: #fff;
    --color-text: #1a1a1a;
    --color-muted: #666;
    --color-header-bg: #1a5fb4;
    --color-link: var(--color-header-bg);
    --color-link-hover: #0d3d6b;
    --color-border: #ddd;
    --color-header-text: #fff;
    --color-badge-active: #0b6e4f;
    --color-badge-dissolved: #8a8a8a;
    --max-width: 1100px;
    --spacing: 1.5rem;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    line-height: 1.6;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
}

a {
    color: var(--color-link);
    text-decoration: underline;
    text-underline-offset: 2px;
}

a:hover {
    color: var(--color-link-hover);
}

/* Keyboard focus: a clear, consistent ring on interactive elements.
   :focus-visible means mouse clicks don't show the ring, only keyboard nav. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--color-link);
    outline-offset: 2px;
    border-radius: 2px;
}

/* The header is dark blue, so a blue ring would be invisible - use white. */
header :focus-visible {
    outline-color: #fff;
}

main:focus {
    outline: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip link: hidden until focused, then appears top-left for keyboard users. */
.skip-link {
    position: absolute;
    top: -4rem;
    left: 0.5rem;
    z-index: 1000;
    padding: 0.5rem 1rem;
    background: var(--color-bg);
    color: var(--color-link);
    border: 1px solid var(--color-link);
    border-radius: 4px;
    text-decoration: none;
    transition: top 0.15s ease;
}

.skip-link:focus {
    top: 0.5rem;
}

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

header {
    background: var(--color-header-bg);
    color: var(--color-header-text);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.75rem var(--spacing);
    min-height: 4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.site-title a {
    color: inherit;
    text-decoration: none;
}

.site-title a:hover {
    text-decoration: underline;
}

.site-title span {
    opacity: 0.7;
    font-weight: 600;
}

.header-search {
    display: flex;
    gap: 0.5rem;
}

.header-search input[type="search"] {
    width: 180px;
    max-width: 100%;
    padding: 0.4rem 0.6rem;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 4px;
    color: #fff;
    font-size: 1rem;
}

.header-search input[type="search"]::placeholder {
    color: rgba(255,255,255,0.7);
}

.header-search button {
    padding: 0.4rem 1rem;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 4px;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    white-space: nowrap;
}

.header-search button:hover {
    background: rgba(255,255,255,0.35);
}

main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--spacing) var(--spacing) calc(var(--spacing) * 3);
}

h1 { font-size: 1.75rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 0.5rem; border-bottom: 1px solid var(--color-border); padding-bottom: 0.25rem; }

main > h2:first-child,
article > h2:first-child {
    margin-top: 0;
}

p {
    margin: 0.5rem 0 1rem;
}

ul {
    margin: 0.25rem 0 1rem;
    padding-left: 1.25rem;
}

li {
    margin-bottom: 0.35rem;
}

address {
    font-style: normal;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
    background: #f5f7fa;
    padding: 0.1em 0.35em;
    border-radius: 4px;
}

dl.facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 1.25rem;
    margin: 0.5rem 0 1rem;
}

dl.facts dt {
    color: var(--color-muted);
    font-size: 0.875rem;
    font-weight: 600;
    padding-top: 0.1rem;
}

dl.facts dd {
    margin: 0;
    min-width: 0;
}

input[type="search"], input[type="text"] {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 1rem;
    background: var(--color-bg);
    color: var(--color-text);
}

select {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 1rem;
    background: var(--color-bg);
    color: var(--color-text);
}

button, input[type="submit"] {
    padding: 0.4rem 1rem;
    background: var(--color-link);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
}

button:hover, input[type="submit"]:hover {
    background: var(--color-link-hover);
}

.table-wrap {
    overflow-x: auto;
    margin: 0.5rem 0 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin: 0.5rem 0 1rem;
}

.table-wrap table {
    margin: 0;
}

th, td {
    text-align: left;
    vertical-align: top;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }

th {
    font-weight: 600;
    color: var(--color-muted);
    white-space: nowrap;
    border-bottom: 2px solid var(--color-border);
}

tbody tr:hover {
    background: #f5f7fa;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    color: #fff;
    background: var(--color-badge-active);
    vertical-align: middle;
}

.badge.dissolved {
    background: var(--color-badge-dissolved);
}

.pdf-icon {
    display: inline-block;
    width: 17px;
    height: 17px;
    margin-right: 0.3rem;
    vertical-align: -3px;
    color: var(--color-muted);
    background-color: currentColor;
    -webkit-mask: no-repeat center / contain;
    mask: no-repeat center / contain;
    -webkit-mask-image: url('../img/formats/pdf.svg');
    mask-image: url('../img/formats/pdf.svg');
}

.muted {
    color: var(--color-muted);
    font-size: 0.875rem;
}

.index-layout {
    display: grid;
    grid-template-columns: 1fr 15rem;
    gap: 0 2.5rem;
    align-items: start;
}

.stats-column {
    grid-row: 1 / 99;
    grid-column: 2;
}

.stats-panel {
    background: #f5f7fa;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
}

.stats-panel dl {
    display: block;
    margin: 0;
}

.stats-panel dt {
    font-size: 0.8rem;
    color: var(--color-muted);
    margin-top: 0.75rem;
}

.stats-panel dt:first-of-type {
    margin-top: 0;
}

.stats-panel dd {
    position: relative;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.stat-sub {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-muted);
    white-space: nowrap;
}

.info-tip {
    display: inline-block;
    vertical-align: 0.26em;
    margin-left: 0.3rem;
}

.info-tip > summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--color-muted);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    font-style: italic;
    font-family: Georgia, 'Times New Roman', serif;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.info-tip > summary::-webkit-details-marker {
    display: none;
}

.info-tip-content {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 1.4rem;
    z-index: 10;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    color: var(--color-text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    font-size: 0.8rem;
    font-weight: 400;
    font-variant-numeric: normal;
    line-height: 1.4;
    white-space: normal;
}

.info-tip[open] > .info-tip-content,
.info-tip:hover > .info-tip-content,
.info-tip:focus-within > .info-tip-content {
    display: block;
}

.hp-search-form {
    margin: 0 0 1.5rem;
}

.hp-search-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.hp-search-row input[type="search"] {
    flex: 1;
    max-width: none;
    font-size: 1.1rem;
    padding: 0.55rem 0.75rem;
}

.hp-search-row button {
    white-space: nowrap;
    font-size: 1.1rem;
    padding: 0.55rem 1.25rem;
}

.hp-advanced-link {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
}

.search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin: 1rem 0 0.5rem;
}

.search-form > input[type="search"] {
    flex: 1;
    min-width: 200px;
    font-size: 1.1rem;
    padding: 0.55rem 0.75rem;
}

.search-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 0 2.5rem;
    align-items: start;
}

.search-sidebar {
    position: sticky;
    top: 1.5rem;
}

.filter-form {
    margin: 0;
}

/* No query and no filters: the filter form takes the whole page rather than
   sitting in a narrow sidebar next to an empty results column. */
.search-layout-browse {
    display: block;
}

.search-layout-browse .search-sidebar {
    position: static;
}

.search-layout-browse .search-main {
    display: none;
}

.filters {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0.5rem 1rem 0.9rem;
    margin: 0;
}

.filters legend {
    padding: 0 0.4rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-muted);
}

.filters label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-muted);
}

.filters select,
.filters input[type="text"] {
    padding: 0.35rem 0.6rem;
    font-size: 0.875rem;
    width: 100%;
}

.search-tabs {
    display: flex;
    gap: 0.25rem;
    margin: 0 0 1.5rem;
    /* Baseline drawn as an inset shadow rather than border-bottom: overflow-x
       clips a child's overlapping border, so the active tab could never hide a
       real border-bottom. An inset shadow sits inside the box where the active
       tab's own background paints over it. */
    box-shadow: inset 0 -1px 0 var(--color-border);
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
}

.search-tabs::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.search-tabs a {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--color-muted);
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    margin-bottom: -1px;
}

.search-tabs a:hover {
    color: var(--color-link);
    background: #eef3fc;
}

.search-tabs a.active {
    color: var(--color-text);
    /* Opaque background covers the nav's inset baseline under this tab, so it
       opens into the content below. */
    background: var(--color-bg);
    border-color: var(--color-border);
}

.error {
    color: #b3261e;
    font-weight: 600;
}

.error-page {
    max-width: 34rem;
    margin: calc(var(--spacing) * 3) auto;
    text-align: center;
}

.error-page h1 {
    margin-bottom: 1rem;
}

.error-code {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1;
    color: var(--color-border);
    margin: 0;
}

.error-page .hp-search-form {
    margin: 1.5rem 0;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 2rem 0 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.9rem;
}

.pagination span {
    color: var(--color-muted);
    white-space: nowrap;
}

.pagination a[rel="next"] {
    margin-left: auto;
}

.pagination a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    text-decoration: none;
    color: var(--color-link);
    background: var(--color-bg);
    transition: background 0.15s, border-color 0.15s;
}

.pagination a:hover {
    background: #eef3fc;
    border-color: var(--color-link);
    color: var(--color-link-hover);
}

.entity-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 0 2.5rem;
    align-items: start;
}

.entity-content {
    min-width: 0;
}

.entity-sidebar {
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
}

.entity-nav {
    display: flex;
    flex-direction: column;
    margin-top: 0.75rem;
}

.entity-nav a {
    display: block;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    text-decoration: none;
    color: var(--color-muted);
    font-size: 0.875rem;
    transition: color 0.15s;
}

.entity-nav a:hover {
    color: var(--color-text);
    background: #f5f7fa;
}

.entity-nav a.active {
    color: var(--color-link);
    font-weight: 600;
    background: #eef3fc;
}

.entity-section {
    scroll-margin-top: 1.5rem;
}

.finance-chart {
    width: 100%;
    height: 240px;
    margin-bottom: 1rem;
}

.address-with-map {
    display: flex;
    gap: 1.5rem;
    align-items: start;
}

.address-with-map > .address-block {
    flex: 1;
    min-width: 0;
}

#company-map {
    width: 280px;
    height: 240px;
    flex-shrink: 0;
    border-radius: 4px;
    border: 1px solid var(--color-border);
}

#company-map .maplibregl-ctrl-attrib { font-size: 10px; }

.data-links {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.data-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: 0.875rem;
    text-decoration: none;
    color: var(--color-link);
    transition: background 0.15s, border-color 0.15s;
}

.data-links a:hover {
    background: #eef3fc;
    border-color: var(--color-link);
    color: var(--color-link-hover);
}

.data-links a::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: -0.2rem;
    background-color: currentColor;
    -webkit-mask: no-repeat center / contain;
    mask: no-repeat center / contain;
}

.data-links a.format-json::before { -webkit-mask-image: url('../img/formats/json.svg'); mask-image: url('../img/formats/json.svg'); }
.data-links a.format-md::before   { -webkit-mask-image: url('../img/formats/markdown.svg'); mask-image: url('../img/formats/markdown.svg'); }

.network-canvas {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: #fafafa;
    height: 420px;
    touch-action: none;
    overflow: hidden;
}
.network-canvas svg { width: 100%; height: 100%; display: block; }
.network-node text { pointer-events: none; user-select: none; }
.ownership-chain { font-size: 1.05rem; }

footer {
    background: #f5f5f5;
    font-size: 0.875rem;
    color: var(--color-muted);
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: calc(var(--spacing) * 1.5) var(--spacing);
}

.footer-inner p {
    margin: 0 0 0.5rem;
}

.footer-inner p:last-child {
    margin-bottom: 0;
}

@media (max-width: 640px) {
    /* Redefining --spacing (rather than hardcoding padding below) keeps the
       shared OpenCommons bar - which reads this same variable - flush with
       the logo instead of drifting out of alignment with it. */
    :root {
        --spacing: 0.75rem;
    }

    .header-inner {
        padding: 0.6rem var(--spacing);
        gap: 0.75rem;
        flex-wrap: nowrap;
    }

    .site-title {
        font-size: 1.1rem;
        flex-shrink: 0;
    }

    .header-search {
        gap: 0.4rem;
        min-width: 0;
    }

    .header-search input[type="search"] {
        width: auto;
        flex: 1;
        min-width: 0;
    }

    .header-search button {
        padding: 0.4rem 0.7rem;
    }

    main {
        padding: 0.6rem var(--spacing) 2rem;
    }

    .index-layout {
        grid-template-columns: 1fr;
    }

    .stats-column {
        grid-row: auto;
        grid-column: 1;
        margin-top: 1.5rem;
    }

    .search-layout {
        display: block;
    }

    .search-sidebar {
        position: static;
        margin-bottom: 1.5rem;
    }

    .entity-layout {
        display: block;
    }

    .entity-sidebar {
        position: static;
        max-height: none;
        margin-bottom: 1.5rem;
    }

    .entity-nav {
        display: none;
    }

    .finance-chart {
        height: 260px;
    }

    .address-with-map {
        flex-direction: column;
    }

    #company-map {
        width: 100%;
        height: 200px;
    }
}
