/* ═══════════════════════════════════════════════════════════
   Tables — extracted from TNonline (DataTable / Settings)
   Card-wrapped data table with sticky uppercase headers, hover
   rows, and a pagination footer.
   ═══════════════════════════════════════════════════════════ */

.tn-table-wrapper {
    position: relative;
    background: var(--tn-bg-card);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius-lg);
    overflow: hidden;
}

.tn-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tn-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--tn-font-size-sm);
}

.tn-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

.tn-table th {
    padding: 10px var(--tn-space-md);
    text-align: left;
    font-weight: 600;
    font-size: var(--tn-font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tn-text-secondary);
    background: var(--tn-bg-page);
    border-bottom: 1px solid var(--tn-border);
    white-space: nowrap;
    user-select: none;
}

.tn-table td {
    padding: 9px var(--tn-space-md);
    color: var(--tn-text-primary);
    border-bottom: 1px solid var(--tn-border-light);
    vertical-align: middle;
}

.tn-table tbody tr {
    transition: background-color var(--tn-transition);
}

.tn-table tbody tr:hover {
    background-color: var(--tn-bg-hover);
}

.tn-table tbody tr:last-child td {
    border-bottom: none;
}

/* Highlighted / current row */
.tn-table tr.is-current {
    background: var(--tn-bg-active);
}

.tn-table tr.is-current:hover {
    background: var(--tn-bg-active);
}

/* Monospace cell (IDs, codes) */
.tn-cell-mono {
    font-family: var(--tn-font-mono);
    font-size: var(--tn-font-size-xs);
    color: var(--tn-text-secondary);
}

/* Alignment & emphasis helpers */
.tn-table .text-right,
.tn-cell-right {
    text-align: right;
}

.tn-table .text-muted {
    color: var(--tn-text-secondary);
}

/* Numeric cell — tabular figures, dimmed unless emphasised */
.tn-cell-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--tn-text-secondary);
}

.tn-cell-num strong {
    color: var(--tn-text-primary);
}

/* ═══════════════════════════════════════════════════════════
   Dividers & information elements
   (from the dense environment / fraction report tables)
   ═══════════════════════════════════════════════════════════ */

/* Group header row — strong top divider, teal icon, opens a section */
.tn-table tr.tn-group-header {
    background: var(--tn-bg-hover);
    border-top: 2px solid var(--tn-border);
}

.tn-table tr.tn-group-header td {
    padding: 10px var(--tn-space-md);
    font-size: var(--tn-font-size-base);
    font-weight: 600;
    color: var(--tn-text-primary);
}

.tn-table tr.tn-group-header .bi {
    margin-right: 6px;
    color: var(--tn-accent);
}

/* Subtotal row — closes a section with a strong bottom divider */
.tn-table tr.tn-subtotal-row {
    background: var(--tn-bg-hover);
    border-bottom: 2px solid var(--tn-border);
}

.tn-table tr.tn-subtotal-row td {
    padding: 8px var(--tn-space-md);
    font-size: var(--tn-font-size-sm);
    font-weight: 600;
    color: var(--tn-text-secondary);
}

/* Plain section divider row (a visual break with no content) */
.tn-table tr.tn-divider-row td {
    padding: 0;
    height: 0;
    border-bottom: 2px solid var(--tn-border);
}

/* Hazardous / flagged row — soft red wash */
.tn-table tr.tn-row--hazard {
    background-color: #FFF5F5;
}

.tn-table tr.tn-row--hazard:hover {
    background-color: #FEE2E2;
}

/* Category dot — small colored marker in a cell (set color inline) */
.tn-category-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 5px;
    flex-shrink: 0;
    vertical-align: middle;
}

/* Code pill — compact code/meta chip inside a cell */
.tn-code-pill {
    display: inline-block;
    padding: 1px 5px;
    margin-right: 3px;
    background: var(--tn-bg-page);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius-sm);
    font-size: var(--tn-font-size-xs);
    font-family: var(--tn-font-mono);
    color: var(--tn-text-secondary);
    vertical-align: middle;
}

.tn-code-pill--treat {
    background: #F0F9FF;
    border-color: #BAE6FD;
    color: #0369A1;
}

.tn-code-pill--hazard {
    background: var(--tn-danger-light);
    border-color: #FECACA;
    color: var(--tn-danger);
    font-weight: 600;
}

/* Truncating cell */
.tn-cell-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}

/* ── Summary band — headline figure above a table ── */
.tn-table-summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 18px;
    margin-bottom: var(--tn-space-md);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.06), rgba(13, 115, 119, 0.06));
    border: 1px solid rgba(16, 185, 129, 0.18);
    border-radius: var(--tn-radius);
    font-size: var(--tn-font-size-base);
}

.tn-table-summary .bi {
    font-size: 1.1em;
    color: var(--tn-success);
}

.tn-table-summary-label {
    color: var(--tn-text-secondary);
    font-weight: 500;
}

.tn-table-summary-value {
    font-weight: 700;
    color: var(--tn-text-primary);
    font-variant-numeric: tabular-nums;
}

/* ── Legend — keyed list of series, sits beside/above a table ── */
.tn-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tn-legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--tn-font-size-sm);
}

.tn-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: var(--tn-radius-sm);
    flex-shrink: 0;
}

.tn-legend-label {
    color: var(--tn-text-primary);
    font-weight: 500;
    min-width: 140px;
}

.tn-legend-value {
    color: var(--tn-text-secondary);
    font-variant-numeric: tabular-nums;
}

/* ── Totals footer band — sits below the table (the "Totalt" row) ── */
.tn-table-totals {
    display: flex;
    align-items: center;
    gap: var(--tn-space-md);
    flex-wrap: wrap;
    padding: 16px 24px;
    margin-top: var(--tn-space-md);
    background: var(--tn-bg-hover);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius);
}

.tn-table-totals-label {
    font-weight: 700;
    font-size: var(--tn-font-size-base);
    color: var(--tn-text-primary);
}

.tn-table-totals-values {
    display: flex;
    gap: var(--tn-space-lg);
    flex-wrap: wrap;
    font-size: var(--tn-font-size-sm);
    color: var(--tn-text-secondary);
}

.tn-table-totals-values strong {
    color: var(--tn-text-primary);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
    .tn-table-totals {
        flex-direction: column;
        align-items: flex-start;
    }

    .tn-table-totals-values {
        flex-direction: column;
        gap: var(--tn-space-sm);
    }
}

/* ── Dense modifier — compact reporting tables ── */
.tn-table--dense {
    font-size: var(--tn-font-size-xs);
    line-height: 1.25;
}

.tn-table--dense th {
    padding: 5px 6px;
    font-size: 0.62rem;
}

.tn-table--dense td {
    padding: 3px 6px;
}

/* ── Pagination footer ── */
.tn-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px var(--tn-space-md);
    border-top: 1px solid var(--tn-border);
    flex-wrap: wrap;
    gap: var(--tn-space-sm);
}

.tn-pagination-info {
    font-size: var(--tn-font-size-xs);
    color: var(--tn-text-secondary);
}

.tn-pagination-controls {
    display: flex;
    align-items: center;
    gap: 2px;
}

.tn-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 var(--tn-space-xs);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius-sm);
    background: var(--tn-bg-card);
    color: var(--tn-text-primary);
    font-size: var(--tn-font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--tn-transition);
}

.tn-page-btn:hover:not(:disabled):not(.is-active) {
    background: var(--tn-bg-hover);
    border-color: var(--tn-accent);
    color: var(--tn-accent);
}

.tn-page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.tn-page-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--tn-accent);
}

.tn-page-btn.is-active {
    background: var(--tn-accent);
    border-color: var(--tn-accent);
    color: #fff;
    cursor: default;
}

@media (max-width: 640px) {
    .tn-pagination {
        justify-content: center;
    }

    .tn-pagination-info {
        width: 100%;
        text-align: center;
    }

    /* Tighten cell gutters on phones so more of each row is content,
       not padding (pairs with .tn-bleed-mobile for the edge-to-edge look). */
    .tn-table th,
    .tn-table td {
        padding-left: 12px;
        padding-right: 12px;
    }
}
