/* Compact industry and sub-industry company lists. */

.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;
}

.company-list-tools {
    margin: 0 0 0.4rem;
}

.company-list-heading {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.company-list-heading small {
    color: var(--pico-muted-color);
    font-size: 0.84rem;
    font-weight: normal;
}

.company-summary-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.25rem;
    padding: 0.55rem 0.8rem;
    margin: 0.4rem 0 0.65rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 10px;
    background: var(--pico-card-background-color);
}

.summary-metric {
    display: flex;
    flex-direction: column;
    min-width: 6rem;
    line-height: 1.2;
}

.summary-metric strong {
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
}

.summary-metric span {
    color: var(--pico-muted-color);
    font-size: 0.76rem;
}

.summary-filtered strong {
    color: var(--pico-primary);
}

.company-size-filters {
    gap: 0.3rem;
    margin-bottom: 0.4rem;
}

.company-size-filters strong {
    color: var(--pico-muted-color);
    font-size: 0.84rem;
}

.company-read-filters {
    gap: 0.3rem;
    margin-bottom: 0.65rem;
}

.company-read-filters strong {
    color: var(--pico-muted-color);
    font-size: 0.84rem;
}

.company-read-filters .filter-count {
    color: var(--pico-muted-color);
    font-size: 0.78rem;
}

.company-read-filters a.active .filter-count {
    color: inherit;
}

.company-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
    line-height: 1.28;
}

.company-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 0.4rem 0.45rem;
    background: var(--pico-background-color);
    box-shadow: 0 1px 0 var(--pico-muted-border-color);
    color: var(--pico-muted-color);
    font-size: 0.78rem;
    font-weight: 600;
    text-align: left;
    vertical-align: bottom;
    white-space: nowrap;
}

.company-table thead th.metric-cell {
    text-align: right;
}

.company-table thead th.size-cell,
.company-table thead th.favorite-cell {
    text-align: center;
}

.company-table thead th a {
    color: inherit;
    text-decoration: none;
}

.company-table thead th a:hover {
    color: var(--pico-primary);
}

.company-table .unit {
    font-size: 0.7rem;
    font-weight: normal;
}

.company-table .sort-arrow {
    font-size: 0.62rem;
}

.company-table tbody td {
    padding: 0.4rem 0.45rem;
    border-bottom: 1px solid var(--pico-muted-border-color);
    background-color: transparent;
    vertical-align: top;
}

.company-table tbody tr.company-row:nth-child(odd) {
    background-color: #edf3f8;
}

.company-table tbody tr.company-row:nth-child(even) {
    background-color: #ffffff;
}

.favorite-cell {
    width: 3rem;
    text-align: center;
}

.size-cell {
    width: 2.5rem;
    text-align: center;
}

.metric-cell {
    width: 6rem;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.metric-value {
    font-weight: 600;
    line-height: 1.35;
}

.metric-previous {
    color: var(--pico-muted-color);
    font-size: 0.76rem;
    line-height: 1.35;
}

.metric-change {
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.35;
}

.metric-forecast {
    color: var(--pico-muted-color);
    font-size: 0.76rem;
    line-height: 1.35;
}

.forecast-label {
    color: var(--pico-primary);
    font-size: 0.7rem;
    font-weight: 700;
}

.metric-change.positive {
    color: #1b7f3b;
}

.metric-change.negative {
    color: #b42318;
}

.segments-cell,
.ownership-cell {
    white-space: normal;
    color: var(--pico-muted-color);
    font-size: 0.76rem;
    line-height: 1.4;
}

.segments-cell {
    width: 9.5rem;
    min-width: 8rem;
}

.ownership-cell {
    width: 7rem;
    min-width: 6.5rem;
}

.company-fact-segments,
.company-fact-ratios {
    white-space: normal;
}

.company-fact-row {
    line-height: 1.35;
}

.company-fact-row + .company-fact-row {
    margin-top: 0.05rem;
}

.segment-heading {
    margin-top: 0.12rem;
    color: var(--pico-color);
    font-weight: 700;
}

.company-fact-period {
    margin-top: 0.1rem;
    color: var(--pico-muted-color);
    font-size: 0.7rem;
}

.fact-number {
    color: var(--pico-color);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.segments-cell .company-meta,
.ownership-cell .company-meta {
    color: var(--pico-muted-color);
}

.company-rank,
.company-industry {
    color: var(--pico-muted-color);
    font-size: 0.74rem;
}

.company-rank + .company-industry::before {
    content: " · ";
}

.company-cell {
    width: 50%;
    min-width: 22rem;
}

.company-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
}

.company-code {
    color: var(--pico-muted-color);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.78rem;
}

.company-name {
    color: var(--pico-color);
    font-weight: 700;
    text-decoration: none;
}

.company-name:hover {
    color: var(--pico-primary);
    text-decoration: underline;
}

.company-meta-lines {
    display: flex;
    flex-direction: column;
    gap: 0.06rem;
    margin-top: 0.08rem;
}

.company-meta-line {
    color: var(--pico-muted-color);
    font-size: 0.74rem;
    line-height: 1.35;
}

.company-period {
    color: var(--pico-muted-color);
    font-size: 0.74rem;
}

.read-mark {
    color: #1b7f3b;
    font-weight: 700;
}

.note-mark {
    color: #b8860b;
    font-weight: 700;
}

.company-note-preview {
    display: -webkit-box;
    margin-top: 0.1rem;
    overflow: hidden;
    color: #8a6d00;
    font-size: 0.8rem;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
}

.company-note-preview[hidden] {
    display: none;
}

.company-note-label {
    margin-right: 0.2rem;
    font-weight: 700;
}

.company-details {
    margin-top: 0.1rem;
}

.company-details > summary {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    cursor: pointer;
    color: var(--pico-primary);
    font-size: 0.76rem;
    list-style: none;
}

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

.company-details > summary::before {
    content: "▸";
}

.company-details[open] > summary::before {
    content: "▾";
}

.company-details-body {
    margin-top: 0.2rem;
    padding: 0.15rem 0 0.15rem 0.6rem;
    border-left: 2px solid var(--pico-muted-border-color);
    font-size: 0.82rem;
    line-height: 1.5;
}

.company-details-body p {
    margin: 0 0 0.3rem;
}

.company-details-body p:last-child {
    margin-bottom: 0;
}

.company-details-label {
    display: inline-block;
    min-width: 2.5rem;
    margin-right: 0.35rem;
    color: var(--pico-muted-color);
    font-weight: 700;
}

.company-empty {
    padding: 1rem;
    color: var(--pico-muted-color);
    text-align: center;
}

.favorite-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: #b8860b;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.row-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.read-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--pico-muted-color);
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
}

.favorite-toggle:hover,
.read-toggle:hover {
    transform: scale(1.1);
}

.favorite-toggle.active {
    color: #e0a000;
}

.read-toggle.active {
    color: #1b7f3b;
}

.favorite-toggle:focus-visible,
.read-toggle:focus-visible {
    outline: 2px solid var(--pico-primary);
    outline-offset: 1px;
}

.row-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0.1rem 0.35rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font-size: 0.76rem;
    line-height: 1.3;
    text-decoration: none;
    cursor: pointer;
}

.row-action:hover {
    border-color: var(--pico-primary);
    color: var(--pico-primary);
}

.row-controls .row-action {
    width: 2rem;
    height: 2rem;
    padding: 0;
    font-size: 0.72rem;
}

.company-pagination {
    margin-top: 0.75rem;
}

.company-compare-panel {
    margin-top: 0.75rem;
    font-size: 0.8rem;
}

.company-compare-panel > summary {
    cursor: pointer;
    color: var(--pico-muted-color);
}

.company-compare-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.75rem;
    margin: 0.5rem 0;
}

.company-compare-options label {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.78rem;
}

.company-compare-panel button {
    margin-bottom: 0;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.company-note-error {
    margin: 0.25rem 0 0;
    color: #b42318;
    font-size: 0.8rem;
}

@media (max-width: 1024px) {
    .company-table {
        display: table;
        white-space: normal;
    }
}

@media (max-width: 800px) {
    .company-table,
    .company-table tbody,
    .company-table tr,
    .company-table td {
        display: block;
        width: 100%;
    }

    .company-table thead {
        display: none;
    }

    .company-table tbody tr {
        position: relative;
        margin-bottom: 0.5rem;
        padding: 0.55rem 0.6rem;
        border: 1px solid var(--pico-muted-border-color);
        border-radius: 8px;
        background: var(--pico-card-background-color);
    }

    .company-table tbody td {
        padding: 0.12rem 0;
        border: 0;
        text-align: left;
        white-space: normal;
    }

    .company-table .favorite-cell {
        position: static;
        display: flex;
        align-items: center;
        gap: 0.35rem;
        width: auto;
        margin-bottom: 0.2rem;
    }

    .company-table .row-controls {
        flex-direction: row;
        gap: 0.3rem;
    }

    .company-table .company-cell {
        width: auto;
        min-width: 0;
    }

    .company-table .size-cell {
        display: inline-flex;
        gap: 0.3rem;
        width: auto;
        margin-right: 0.75rem;
        font-size: 0.82rem;
    }

    .company-table .metric-cell {
        display: block;
        width: auto;
        margin-right: 0;
        text-align: left;
        white-space: normal;
        font-size: 0.82rem;
    }

    .company-table .size-cell::before,
    .company-table .metric-cell::before {
        content: attr(data-label) ": ";
        color: var(--pico-muted-color);
        font-size: 0.74rem;
    }

    .company-table .metric-value,
    .company-table .metric-previous,
    .company-table .metric-change,
    .company-table .metric-forecast {
        display: inline;
        font-size: inherit;
        line-height: inherit;
    }

    .company-table .metric-previous,
    .company-table .metric-change,
    .company-table .metric-forecast {
        margin-left: 0.25rem;
    }

    .company-table .segments-cell,
    .company-table .ownership-cell {
        width: auto;
        min-width: 0;
        font-size: 0.82rem;
    }

    .company-table .company-empty {
        text-align: center;
    }
}

@media (max-width: 600px) {
    .company-summary-strip {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.4rem 0.75rem;
    }

    .summary-metric {
        min-width: 0;
    }

    .company-list-heading {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.1rem;
    }
}

/* Industry and sub-industry overview (/industries/). */
.industry-filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
    margin-bottom: 0.6rem;
}

.industry-filter-field {
    flex: 1 1 18rem;
    min-width: 0;
}

.industry-filter-form input[type="search"],
.industry-filter-form select,
.industry-filter-form button,
.industry-filter-form a[role="button"] {
    margin-bottom: 0;
}

.industry-filter-form select {
    width: auto;
}

.industry-filter-form button,
.industry-filter-form a[role="button"] {
    width: auto;
    white-space: nowrap;
}

.industry-filter-status {
    display: none;
    color: var(--pico-muted-color);
    font-size: 0.8rem;
}

.industry-filter-status.htmx-request {
    display: inline;
}

.industry-summary {
    margin-bottom: 0.75rem;
}

.industry-layout {
    display: grid;
    grid-template-columns: 14rem minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.industry-index {
    position: sticky;
    top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    max-height: calc(100vh - 1rem);
    overflow-y: auto;
    padding: 0.35rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 10px;
    background: var(--pico-card-background-color);
}

.industry-index a {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.26rem 0.5rem;
    border-radius: 6px;
    color: inherit;
    font-size: 0.82rem;
    line-height: 1.3;
    text-decoration: none;
}

.industry-index a:hover {
    background: var(--pico-muted-border-color);
}

.industry-index a.active {
    background: var(--pico-primary);
    color: var(--pico-primary-inverse);
    font-weight: 600;
}

.industry-index .count {
    color: var(--pico-muted-color);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.industry-index a.active .count {
    color: inherit;
    opacity: 0.85;
}

.industry-sections {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

.industry-section {
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 10px;
    background: var(--pico-card-background-color);
}

.industry-section-header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid var(--pico-muted-border-color);
    border-radius: 10px 10px 0 0;
    background: var(--pico-card-background-color);
}

.industry-section-header h2 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
}

.industry-counts {
    color: var(--pico-muted-color);
    font-size: 0.8rem;
}

.industry-all {
    margin-left: auto;
    font-size: 0.78rem;
    white-space: nowrap;
}

.subindustry-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.55rem 0.8rem 0.7rem;
}

.subindustry-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.18rem 0.55rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 999px;
    color: inherit;
    font-size: 0.82rem;
    line-height: 1.4;
    text-decoration: none;
}

.subindustry-chip:hover {
    border-color: var(--pico-primary);
    background: var(--pico-muted-border-color);
    color: var(--pico-primary);
}

.subindustry-chip .count {
    color: var(--pico-muted-color);
    font-size: 0.76rem;
    font-variant-numeric: tabular-nums;
}

.subindustry-chip:hover .count {
    color: inherit;
}

.industry-empty {
    padding: 1.5rem 1rem;
    color: var(--pico-muted-color);
    text-align: center;
}

@media (max-width: 900px) {
    .industry-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.6rem;
    }

    .industry-index {
        top: 0;
        z-index: 3;
        flex-direction: row;
        gap: 0.3rem;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0.3rem;
        border-radius: 8px;
    }

    .industry-index a {
        flex: 0 0 auto;
        padding: 0.22rem 0.55rem;
    }

    .industry-section {
        scroll-margin-top: 3rem;
    }

    .industry-section-header {
        position: static;
        padding: 0.4rem 0.6rem;
    }

    .industry-all {
        margin-left: 0;
    }

    .subindustry-chips {
        padding: 0.45rem 0.6rem 0.55rem;
    }
}

/* Keep the ownership guide available on hover, keyboard focus, and tap. */
.ownership-help {
    position: relative;
    display: inline-block;
}

.ownership-help-trigger {
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: help;
    text-decoration: underline dotted;
    text-underline-offset: 0.2em;
}

.ownership-help-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 10;
    width: min(30rem, 85vw);
    padding: 0.8rem;
    border: 1px solid var(--pico-muted-border-color);
    border-radius: 0.35rem;
    background: var(--pico-background-color);
    color: var(--pico-color);
    box-shadow: 0 0.3rem 1rem #0003;
    white-space: normal;
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
}

.ownership-help:hover .ownership-help-content,
.ownership-help:focus-within .ownership-help-content {
    display: block;
}

.ownership-help-content > span {
    display: block;
    margin-top: 0.5rem;
}

.ownership-help-note {
    color: var(--pico-muted-color);
    font-size: 0.75rem;
}

.header-help-left .ownership-help-content {
    right: auto;
    left: 0;
}
