/* ── OIR Impact Report Page ─────────────────────────────── */

.oir-layout {
    max-width: 1400px;
    margin: 0 auto;
    padding: 14px 16px;
}

.oir-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
}

.oir-header h2 {
    font-size: 16px;
    color: var(--text-primary);
    margin: 0;
}

.oir-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.oir-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.oir-countdown {
    text-align: right;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 0;
    padding: 6px 12px;
}

.countdown-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.countdown-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.01em;
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.admin-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--text-muted);
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: "Inter", sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.admin-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.admin-btn.unlocked {
    border-color: var(--green);
    color: var(--green);
}

/* Admin panel */
.admin-login {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 0;
    margin-bottom: 12px;
}

.admin-login input {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--text-primary);
    padding: 5px 10px;
    font-size: 12px;
    font-family: "Inter", sans-serif;
    outline: none;
    width: 180px;
}

.admin-login input:focus {
    border-color: var(--accent);
}

.admin-login button {
    background: var(--accent);
    border: none;
    border-radius: 2px;
    color: var(--bg-deep);
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: "Inter", sans-serif;
}

#admin-status {
    font-size: 11px;
    color: var(--red);
}

/* OIR Section cards */
.oir-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 0;
    margin-bottom: 8px;
    overflow: hidden;
    transition: border-color var(--transition);
}

.oir-section:hover {
    border-color: var(--border-bright);
}

.oir-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    transition: all var(--transition);
}

.oir-section-header:hover {
    background: var(--bg-hover);
}

.oir-section-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.oir-section-badge {
    display: flex;
    gap: 6px;
    align-items: center;
}

.oir-section-badge .badge {
    font-size: 9px;
}

.oir-section-arrow {
    color: var(--text-muted);
    font-size: 11px;
    margin-left: 10px;
}

.oir-section-body {
    display: none;
    border-top: 1px solid var(--border);
}

.oir-section.open .oir-section-body {
    display: block;
}

/* ── IMPACT SUMMARY ─────────────────────────────────────── */

.impact-summary {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-base);
}

.impact-header {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

.impact-none {
    padding: 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

.impact-table-wrap {
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
}

.impact-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    white-space: nowrap;
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.impact-table th {
    position: sticky;
    top: 0;
    background: var(--bg-elevated);
    padding: 6px 8px;
    text-align: left;
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    z-index: 2;
    border-bottom: 1px solid var(--border);
    font-family: 'Inter', sans-serif;
}

.impact-table td {
    padding: 4px 8px;
    color: var(--text-primary);
    background: var(--bg-base);
    vertical-align: middle;
    border-bottom: 1px solid #1a1a1a;
}

.impact-table tbody tr:nth-child(odd) td {
    background: var(--bg-base);
}

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

.impact-table tbody tr {
    transition: all var(--transition);
}

.impact-table tbody tr:hover td {
    background: var(--bg-surface);
}

.impact-table tbody tr:hover td:first-child {
    box-shadow: inset 3px 0 0 var(--accent);
}

.impact-name {
    color: var(--text-primary) !important;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Inter', sans-serif;
}

.impact-baseline {
    color: var(--text-primary) !important;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.impact-cell {
    text-align: center !important;
    min-width: 72px;
    font-variant-numeric: tabular-nums;
}

.impact-bite-val {
    font-variant-numeric: tabular-nums;
}

/* Impact cells colored by OIR color — background + text */
td.impact-oir-red {
    background: rgba(255, 23, 68, 0.35) !important;
}
.impact-oir-red .impact-bite-val {
    color: #fff;
    font-weight: 700;
    font-size: 12px;
}
.impact-oir-red .impact-bite-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 9px;
}

td.impact-oir-purple {
    background: rgba(167, 139, 250, 0.35) !important;
}
.impact-oir-purple .impact-bite-val {
    color: #fff;
    font-weight: 700;
    font-size: 12px;
}
.impact-oir-purple .impact-bite-label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 9px;
}

td.impact-oir-yellow {
    background: rgba(251, 191, 36, 0.25) !important;
}
.impact-oir-yellow .impact-bite-val {
    color: #fbbf24;
    font-weight: 700;
    font-size: 12px;
}
.impact-oir-yellow .impact-bite-label {
    color: #fbbf24;
    font-size: 9px;
}

/* No OIR color — white numbers */
.impact-nocolor .impact-bite-val {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 12px;
}
.impact-nocolor .impact-bite-label {
    color: var(--text-primary);
    font-size: 9px;
    opacity: 0.7;
}

.impact-watch .impact-bite-val {
    color: var(--text-muted);
    font-size: 11px;
}

.impact-watch .impact-bite-label {
    color: var(--text-muted);
    font-size: 9px;
    opacity: 0.6;
}

.impact-safe .impact-bite-val {
    color: var(--text-muted);
    font-size: 10px;
    opacity: 0.5;
}

/* Full OIR table toggle */
.oir-table-toggle {
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-top: 1px solid var(--border);
    transition: all var(--transition);
    background: var(--bg-base);
}

.oir-table-toggle:hover {
    color: var(--accent);
    background: var(--bg-elevated);
}

.toggle-arrow-sm {
    font-size: 9px;
    margin-left: 4px;
}

.oir-full-table {
    display: none;
}

.oir-full-table.show {
    display: block;
    border-top: 1px solid var(--border);
}

/* Order toggle buttons */
.oir-order-toggle {
    display: flex;
    gap: 4px;
    padding: 10px 12px 4px;
}

.order-btn {
    padding: 4px 12px;
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.order-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.order-btn.active {
    background: var(--accent, #3b82f6);
    color: #fff;
    border-color: var(--accent, #3b82f6);
}

/* OIR data table */
.oir-table-wrap {
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
}

.oir-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    white-space: nowrap;
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.oir-table th {
    position: sticky;
    top: 0;
    background: var(--bg-elevated);
    padding: 6px 8px;
    text-align: left;
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    z-index: 2;
    border-bottom: 1px solid var(--border);
    font-family: 'Inter', sans-serif;
}

.oir-table td {
    padding: 4px 8px;
    color: var(--text-primary);
    background: var(--bg-base);
    vertical-align: middle;
    border-bottom: 1px solid #1a1a1a;
}

.oir-table tbody tr:nth-child(odd) td {
    background: var(--bg-base);
}

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

.oir-table tbody tr {
    transition: all var(--transition);
}

.oir-table tbody tr:hover td {
    background: var(--bg-surface);
}
.oir-table tbody tr:hover td.cell-color-red {
    background: rgba(255, 23, 68, 0.45) !important;
}
.oir-table tbody tr:hover td.cell-color-purple {
    background: rgba(167, 139, 250, 0.45) !important;
}
.oir-table tbody tr:hover td.cell-color-yellow {
    background: rgba(251, 191, 36, 0.40) !important;
}

.oir-table tbody tr:hover td:first-child {
    box-shadow: inset 3px 0 0 var(--accent);
}

/* Cell color fills — td qualifier for specificity over .oir-table td */
td.cell-color-red {
    background: rgba(255, 23, 68, 0.35) !important;
    color: #fff;
    font-weight: 700;
}
td.cell-color-purple {
    background: rgba(167, 139, 250, 0.35) !important;
    color: #fff;
    font-weight: 700;
}
td.cell-color-yellow {
    background: rgba(251, 191, 36, 0.25) !important;
    color: #fbbf24;
    font-weight: 700;
}

/* No OIR color — plain white numbers */
td.cell-cut {
    color: var(--text-primary);
    font-weight: 500;
}

td.cell-ok {
    color: var(--text-primary);
}

/* ── POINT MAPPINGS (Drag & Drop) ───────────────────────── */

.mappings-info {
    font-size: 11px;
    color: var(--text-muted);
    padding: 10px 12px 6px;
    line-height: 1.5;
}

.mappings-table-wrap {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 6px 6px;
}

.mappings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    table-layout: fixed;
}

.mappings-table td,
.mappings-table th {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.mappings-table th {
    position: sticky;
    top: 0;
    background: var(--bg-elevated);
    padding: 6px 8px;
    text-align: left;
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    z-index: 2;
    border-bottom: 1px solid var(--border);
}

.mappings-table td {
    padding: 4px 8px;
    color: var(--text-primary);
    background: var(--bg-base);
    vertical-align: middle;
    border-bottom: 1px solid #1a1a1a;
}

.mappings-table tbody tr {
    transition: all var(--transition);
}

.mappings-table tbody tr:hover td {
    background: var(--bg-surface);
}

.mappings-table tbody tr:hover td:first-child {
    box-shadow: inset 3px 0 0 var(--accent);
}

.mapping-unmatched {
    color: var(--text-muted);
    font-style: italic;
}

/* Drop zones */
.mapping-drop-zone {
    min-height: 28px;
    min-width: 180px;
    border-radius: 2px;
    transition: all 0.1s;
    position: relative;
}

.mapping-drop-zone.drag-over {
    background: rgba(96, 165, 250, 0.1);
    outline: 2px dashed var(--accent);
    outline-offset: -2px;
}

.drop-hint {
    color: var(--text-muted);
    font-size: 10px;
    font-style: italic;
    opacity: 0.6;
}

/* OIR chips (draggable) */
.oir-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(96, 165, 250, 0.08);
    border: 1px solid #444444;
    border-radius: 2px;
    font-size: 11px;
    color: var(--text-primary);
    white-space: nowrap;
    margin: 2px 3px;
    transition: all 0.1s;
}

.oir-chip.draggable {
    cursor: grab;
}

.oir-chip.draggable:hover {
    background: rgba(96, 165, 250, 0.15);
    border-color: var(--accent);
}

.oir-chip.dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.chip-meta {
    font-size: 9px;
    color: var(--text-muted);
    margin-left: 2px;
}

.chip-trash {
    display: none;
    font-size: 11px;
    cursor: pointer;
    margin-left: 4px;
    opacity: 0.5;
    transition: opacity 0.1s;
}

.oir-chip:hover .chip-trash {
    display: inline;
}

.chip-trash:hover {
    opacity: 1;
}

/* Unmatched OIR section */
.unmatched-section {
    padding: 12px;
    margin: 6px;
    background: rgba(255, 23, 68, 0.04);
    border: 1px solid #3d0a0a;
    border-radius: 0;
}

.unmatched-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--red);
    margin-bottom: 3px;
}

.unmatched-info {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.unmatched-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.unmatched-chips .oir-chip {
    background: rgba(255, 23, 68, 0.06);
    border-color: #552222;
}

.unmatched-chips .oir-chip:hover {
    background: rgba(255, 23, 68, 0.12);
    border-color: var(--red);
}

/* ── Mobile / iPhone Responsive ──────────────────────────── */

@media (max-width: 640px) {
    .oir-layout {
        padding: 8px 6px;
        overflow-x: hidden;
    }

    .oir-section {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .impact-table-wrap,
    .oir-table-wrap {
        -webkit-overflow-scrolling: touch;
    }

    /* Compact header */
    .oir-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 8px;
        gap: 6px;
    }

    .oir-header-left {
        display: none;
    }

    .oir-header-right {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    .oir-countdown {
        flex: 1;
        text-align: left;
    }

    .countdown-label {
        font-size: 8px;
    }

    .countdown-value {
        font-size: 12px;
    }

    .admin-btn {
        flex-shrink: 0;
    }

    .oir-section-header {
        padding: 8px 10px;
    }

    .oir-section-name {
        font-size: 11px;
    }

    .impact-summary {
        padding: 8px 6px;
    }

    .impact-table {
        font-size: 10px;
    }

    .impact-table th,
    .impact-table td {
        padding: 4px 6px;
    }

    .impact-name {
        max-width: 110px;
    }

    .oir-table {
        font-size: 10px;
    }

    .oir-table th,
    .oir-table td {
        padding: 3px 6px;
    }

    /* Admin login */
    .admin-login {
        flex-wrap: wrap;
    }

    .admin-login input {
        width: 100%;
    }

    .admin-btn {
        padding: 6px 10px;
        min-height: 40px;
    }

    /* Mappings */
    .mappings-table {
        font-size: 10px;
    }

    .mappings-table th,
    .mappings-table td {
        padding: 4px 6px;
    }

    .oir-chip {
        font-size: 10px;
        padding: 2px 6px;
    }
}

/* ── Sortable Table Headers ──────────────────────────────── */

th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th.sortable:hover {
    color: var(--accent, #60a5fa);
}

th.sortable .sort-icon {
    font-size: 10px;
    opacity: 0.4;
    margin-left: 2px;
}

th.sortable.sort-asc .sort-icon,
th.sortable.sort-desc .sort-icon {
    opacity: 1;
    color: var(--accent, #60a5fa);
}
