/*
 * US Federal Contract Flow module styles.
 *
 * Shared shell, layout, panel and table primitives come from flowlens.css.
 */

.fl-module-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--fl-space-5);
}

.rankCell {
    width: 2rem;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

.tickerCell {
    width: 3rem;
    color: var(--fl-accent);
    font-weight: 500;
}

.module-loading {
    padding: var(--fl-space-3);
    color: var(--fl-text-muted);
    font-style: italic;
}

.module-error {
    color: var(--fl-error);
}

.module-chart-placeholder {
    min-height: 200px;
    border: 1px solid var(--fl-border);
    border-radius: var(--fl-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fl-text-subtle);
    background: var(--fl-bg);
    font-size: 0.8rem;
}

#sectorLeaderboardTable th,
#sectorLeaderboardTable td {
    font-size: 0.8rem;
    padding: 0.45rem 0.6rem;
}

#sectorLeaderboardTable tbody tr:nth-child(1) td {
    font-weight: 600;
}

#sectorLeaderboardTable tbody tr:nth-child(1) td:nth-child(2) {
    color: var(--fl-warning);
}

.card-leaders {
    display: flex;
    flex-direction: column;
}

#sectorLeadersContainer {
    flex: 1;
    overflow-y: auto;
    padding-right: var(--fl-space-1);
    min-height: 0;
}

.sector-group {
    margin-bottom: var(--fl-space-4);
    border-top: 1px solid var(--fl-border);
    padding-top: var(--fl-space-3);
}

.sector-group:first-of-type {
    border-top: none;
    padding-top: 0;
}

.sector-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--fl-text-soft);
    margin-bottom: var(--fl-space-1);
}

.sector-subtitle {
    font-size: 0.75rem;
    color: var(--fl-text-subtle);
    margin-bottom: var(--fl-space-2);
}

.sector-group .fl-table {
    font-size: 0.8rem;
}

.sector-group .fl-table th,
.sector-group .fl-table td {
    padding: 0.4rem 0.5rem;
}

@media (max-width: 700px) {
    .fl-module-heading {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Listed Company Explorer */

.government-explorer {
    display: flex;
    flex-direction: column;
    gap: 1.6rem;
    padding: 1.75rem;
}

.government-explorer .fl-panel__title {
    margin-bottom: -0.9rem;
}

.government-explorer > .fl-panel__subtitle {
    margin: 0;
    max-width: 52rem;
}

.explorer-controls {
    display: grid;
    grid-template-columns:
        minmax(9rem, 0.8fr)
        minmax(9rem, 0.8fr)
        minmax(15rem, 1.3fr)
        minmax(20rem, 1.7fr)
        auto;
    align-items: end;
    gap: 1rem;
}

.explorer-control {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 0.45rem;
}

.explorer-control label {
    color: var(--fl-text-muted);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.explorer-control input,
.explorer-control select {
    box-sizing: border-box;
    width: 100%;
    height: 2.8rem;
    padding: 0 0.8rem;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 0.45rem;
    outline: none;
    background: rgba(15, 23, 42, 0.55);
    color: var(--fl-text);
    font: inherit;
}

.explorer-control input::placeholder {
    color: var(--fl-text-muted);
}

.explorer-control input:focus,
.explorer-control select:focus {
    border-color: var(--fl-accent);
}

.explorer-control select option {
    background: #111827;
    color: #f8fafc;
}

.explorer-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    white-space: nowrap;
}

.explorer-actions .fl-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 5rem;
    height: 2.8rem;
}

.explorer-reset {
    background: transparent;
}

.explorer-summary {
    display: grid;
    grid-template-columns:
        repeat(3, minmax(0, 1fr));
    border-top: 1px solid rgba(148, 163, 184, 0.16);
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.explorer-summary > div {
    min-width: 0;
    padding: 1rem 1.25rem;
}

.explorer-summary > div:first-child {
    padding-left: 0;
}

.explorer-summary > div + div {
    border-left: 1px solid rgba(148, 163, 184, 0.16);
}

.explorer-summary span {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--fl-text-muted);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.explorer-summary strong {
    display: block;
    color: var(--fl-text);
    font-size: 1.4rem;
    line-height: 1.25;
}

.explorer-results {
    display: grid;
    grid-template-columns:
        minmax(18rem, 0.8fr)
        minmax(0, 1.45fr);
    align-items: start;
    gap: 2rem;
}

.explorer-results > section {
    min-width: 0;
}

.explorer-results h3 {
    margin: 0 0 0.9rem;
    color: var(--fl-text);
    font-size: 1rem;
}

#explorerCompanyResults td {
    vertical-align: middle;
}

@media (max-width: 1200px) {
    .explorer-controls {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .explorer-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 900px) {
    .explorer-results {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .government-explorer {
        padding: 1.1rem;
    }

    .explorer-controls,
    .explorer-summary {
        grid-template-columns: 1fr;
    }

    .explorer-summary > div {
        padding: 0.8rem 0;
    }

    .explorer-summary > div + div {
        border-left: 0;
        border-top:
            1px solid rgba(148, 163, 184, 0.16);
    }
}

/* Searchable ticker/company slicer uses native datalist behaviour. */

/* Explorer company results viewport */

.explorer-company-table {
    max-height: 31rem;
    overflow-y: auto;
}

.explorer-company-table table {
    margin: 0;
}

.explorer-company-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--fl-panel, #182338);
    box-shadow:
        0 1px 0 rgba(148, 163, 184, 0.18);
}

.explorer-company-count {
    margin-top: 0.65rem;
    color: var(--fl-text-muted);
    font-size: 0.78rem;
    text-align: right;
}

/* Explorer monthly contract flow */

.explorer-monthly-table {
    max-height: 31rem;
    overflow-y: auto;
}

.explorer-monthly-table table {
    margin: 0;
}

.explorer-monthly-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--fl-panel, #182338);
    box-shadow:
        0 1px 0 rgba(148, 163, 184, 0.18);
}

.explorer-monthly-table th:last-child,
.explorer-monthly-table td:last-child {
    padding-right: 1.4rem;
}

.explorer-month-value {
    white-space: nowrap;
}

.explorer-month-count {
    margin-top: 0.65rem;
    color: var(--fl-text-muted);
    font-size: 0.78rem;
    text-align: right;
}


/* Contract-flow period comparison */
.flow-change {
    white-space: nowrap;
}

.flow-trend {
    display: inline-flex;
    align-items: center;
    min-height: 1.6rem;
    padding: 0.15rem 0.45rem;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.flow-trend--new,
.flow-trend--increased {
    color: var(--fl-accent);
}

.flow-trend--decreased {
    color: var(--fl-text);
}

.flow-trend--stable {
    color: var(--fl-text-muted);
}


/* Canonical listed-company new entrants */

.new-entrants-panel {
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
}

.new-entrants-panel > .fl-panel__subtitle {
    margin-top: -0.7rem;
}

.new-entrants-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid rgba(148, 163, 184, 0.16);
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.new-entrants-summary > div {
    padding: 1rem 1.25rem;
}

.new-entrants-summary > div:first-child {
    padding-left: 0;
}

.new-entrants-summary > div + div {
    border-left: 1px solid rgba(148, 163, 184, 0.16);
}

.new-entrants-summary span {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--fl-text-muted);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.new-entrants-summary strong {
    display: block;
    color: var(--fl-text);
    font-size: 1.4rem;
}

.new-entrants-content {
    display: grid;
    grid-template-columns:
        minmax(18rem, 0.8fr)
        minmax(0, 1.45fr);
    gap: 2rem;
    align-items: start;
}

.new-entrants-content > section {
    min-width: 0;
}

.new-entrants-content h3 {
    margin: 0 0 0.9rem;
    color: var(--fl-text);
    font-size: 1rem;
}

.new-entrants-chart {
    display: flex;
    align-items: stretch;
    gap: 0.55rem;
    min-height: 15rem;
    padding: 1rem 0.4rem 0;
    overflow-x: auto;
}

.new-entrants-chart__column {
    display: grid;
    grid-template-rows: auto 1fr auto;
    flex: 1 0 3.2rem;
    min-width: 3.2rem;
    min-height: 13rem;
    text-align: center;
}

.new-entrants-chart__value {
    min-height: 1.5rem;
    color: var(--fl-text);
    font-size: 0.78rem;
    font-weight: 700;
}

.new-entrants-chart__track {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-height: 9rem;
    border-bottom: 1px solid var(--fl-border);
}

.new-entrants-chart__bar {
    width: min(2.1rem, 70%);
    min-height: 0;
    background: var(--fl-accent);
    border-radius: 0.3rem 0.3rem 0 0;
}

.new-entrants-chart__label {
    padding-top: 0.55rem;
    color: var(--fl-text-muted);
    font-size: 0.7rem;
    white-space: nowrap;
}

.new-entrants-table {
    max-height: 22rem;
    overflow-y: auto;
}

.new-entrants-table table {
    margin: 0;
}

.new-entrants-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--fl-panel, #182338);
    box-shadow:
        0 1px 0 rgba(148, 163, 184, 0.18);
}

.new-entrants-status {
    margin-top: 0.65rem;
    color: var(--fl-text-muted);
    font-size: 0.78rem;
    text-align: right;
}

@media (max-width: 900px) {
    .new-entrants-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .new-entrants-summary {
        grid-template-columns: 1fr;
    }

    .new-entrants-summary > div {
        padding: 0.8rem 0;
    }

    .new-entrants-summary > div + div {
        border-left: 0;
        border-top:
            1px solid rgba(148, 163, 184, 0.16);
    }
}
