/* ── FEAT-107 Phase 3b — Puspakom Results review screen ─────────────────── */
/* ── FEAT-186 — Filter-bar beautify + badge + table polish ──────────────── */
/* ── FEAT-236 — Tabs: Results + Staged ──────────────────────────────────── */
/* ── FEAT-268 — Other Remarks / Failed / Attempt columns ────────────────── */

/* Page container */
.psr-page {
    padding: 24px;
    max-width: 1600px;
    margin: 0 auto;
}

/* ── Tabs ──────────────────────────────────────────────────── */
.psr-tabs {
    margin-top: 4px;
}

.psr-tab {
    background: #1e2537 !important;
    color: #9aa3b5 !important;
    border: 1px solid #2d3548 !important;
    border-radius: 4px 4px 0 0 !important;
    padding: 8px 20px !important;
}

.psr-tab--selected {
    background: #252b3b !important;
    color: #e8eaf0 !important;
    border-bottom-color: #252b3b !important;
    font-weight: 600 !important;
}

body[data-theme="light"] .psr-tab {
    background: #f0f2f5 !important;
    color: #6b7280 !important;
    border-color: #d1d5db !important;
}

body[data-theme="light"] .psr-tab--selected {
    background: #ffffff !important;
    color: #1a202c !important;
    border-bottom-color: #ffffff !important;
}

/* ── Staged tab content ─────────────────────────────────────── */
.psr-staged-container {
    padding: 16px 0;
}

.psr-staged-heading-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.psr-staged-heading {
    font-size: 14px;
    font-weight: 600;
    color: #9b59b6;
}

body[data-theme="light"] .psr-staged-heading {
    color: #7c3aed;
}

/* Status bar */
.psr-status-bar {
    font-size: 13px;
    color: #9aa3b5;
    margin-bottom: 16px;
    padding: 6px 10px;
    background: #1e2537;
    border-radius: 4px;
    border-left: 3px solid #4a90d9;
}

/* Filter bar — labels above, uniform groups (mirrors pt-filter-bar pattern) */
.psr-filter-bar {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    align-items: flex-end;
}

.psr-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
}

.psr-filter-label {
    font-size: 12px;
    color: #9aa3b5;
    white-space: nowrap;
}

body[data-theme="light"] .psr-filter-label {
    color: #4a5568;
}

.psr-filter-dropdown {
    min-width: 180px;
    color: #1a1f2e;
}

.psr-result-filter-dropdown {
    min-width: 120px;
    color: #1a1f2e;
}

/* Date inputs — consistent height with other filter inputs */
.psr-date-input {
    background: #1e2537;
    color: #e8eaf0;
    border: 1px solid #2d3548;
    border-radius: 4px;
    padding: 7px 10px;
    font-size: 13px;
    min-width: 140px;
    box-sizing: border-box;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
}

.psr-date-input:focus {
    border-color: #4a90d9;
}

.psr-date-input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

body[data-theme="light"] .psr-date-input {
    background: #f7f9fc;
    color: #1a202c;
    border-color: #d1d9e0;
}

body[data-theme="light"] .psr-date-input:focus {
    border-color: #4a90d9;
}

body[data-theme="light"] .psr-date-input[type="date"]::-webkit-calendar-picker-indicator {
    filter: none;
}

/* FEAT-258-P2: psr-date-picker is an alias for the shared .hi-date-picker class
   defined in style-01-base.css — kept here so existing classNames don't break. */
.psr-date-picker .DateInput_input {
    background: #1e2537;
    color: #e8eaf0;
    border: 1px solid #2d3548;
    border-radius: 4px;
    padding: 7px 10px;
    font-size: 13px;
    width: 140px;
    box-sizing: border-box;
    font-family: inherit;
}

.psr-date-picker .DateInput_input__focused {
    border-color: #4a90d9;
}

.psr-date-picker .DateInput,
.psr-date-picker .SingleDatePickerInput {
    background: transparent;
    border: none;
}

body[data-theme="light"] .psr-date-picker .DateInput_input {
    background: #f7f9fc;
    color: #1a202c;
    border-color: #d1d9e0;
}

body[data-theme="light"] .psr-date-picker .DateInput_input__focused {
    border-color: #4a90d9;
}

/* Actions row — export pair · Sync (primary) · Re-sync admin cluster */
.psr-actions-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.psr-resync-row {
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 2px solid #4a5268;
    padding-left: 12px;
}

/* Buttons */
.psr-refresh-btn,
.psr-sync-btn,
.psr-reconnect-btn,
.psr-action-btn {
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 7px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    transition: background 0.15s;
}

.psr-refresh-btn:hover,
.psr-sync-btn:hover,
.psr-reconnect-btn:hover,
.psr-action-btn:hover {
    background: #3a7fd9;
}

.psr-sync-btn {
    background: #28a745;
}

.psr-sync-btn:hover {
    background: #218838;
}

.psr-reconnect-btn {
    background: #6b7488;
}

.psr-reconnect-btn:hover {
    background: #5a6480;
}

.psr-cancel-btn {
    background: #6b7488;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 7px 14px;
    cursor: pointer;
    font-size: 13px;
}

.psr-cancel-btn:hover {
    background: #5a6480;
}

.psr-confirm-btn {
    background: #28a745;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    margin-right: 6px;
    transition: background 0.15s;
}

.psr-confirm-btn:hover {
    background: #218838;
}

.psr-reject-btn {
    background: transparent;
    color: #dc3545;
    border: 1px solid #dc354580;
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    margin-right: 6px;
    transition: background 0.15s, border-color 0.15s;
}

.psr-reject-btn:hover {
    background: #dc354518;
    border-color: #dc3545;
}

.psr-unreject-btn {
    background: transparent;
    color: #fd7e14;
    border: 1px solid #fd7e1480;
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    margin-right: 6px;
    transition: background 0.15s, border-color 0.15s;
}

.psr-unreject-btn:hover {
    background: #fd7e1418;
    border-color: #fd7e14;
}

.psr-reject-reason-text {
    display: inline-block;
    color: #dc3545;
    font-size: 11px;
    font-style: italic;
    margin-right: 8px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

body[data-theme="light"] .psr-reject-reason-text {
    color: #c82333;
}

.psr-reject-reason-input {
    background: #1a1f2e;
    color: #e8eaf0;
    border: 1px solid #4a5268;
    border-radius: 4px;
    padding: 7px 10px;
    font-size: 13px;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.15s;
}

.psr-reject-reason-input:focus {
    outline: none;
    border-color: #dc3545;
}

body[data-theme="light"] .psr-reject-reason-input {
    background: #f7f9fc;
    color: #1a202c;
    border-color: #b0bac8;
}

body[data-theme="light"] .psr-reject-reason-input:focus {
    border-color: #dc3545;
}

.psr-reject-modal-submit-btn {
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    transition: background 0.15s;
}

.psr-reject-modal-submit-btn:hover {
    background: #c82333;
}

@media (max-width: 390px) {
    .psr-reject-modal-submit-btn {
        width: 100%;
    }
}

.psr-pdf-btn {
    display: inline-block;
    background: transparent;
    color: #9aa3b5;
    border: 1px solid #4a5268;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: normal;
    text-decoration: none;
    margin-left: 6px;
    transition: border-color 0.15s, color 0.15s;
}

.psr-pdf-btn:hover {
    border-color: #7a8aaa;
    color: #c0c6d4;
    text-decoration: none;
}

body[data-theme="light"] .psr-pdf-btn {
    color: #6b7280;
    border-color: #b0bac8;
}

body[data-theme="light"] .psr-pdf-btn:hover {
    border-color: #8a95aa;
    color: #1a202c;
}

/* Action status */
.psr-action-status {
    min-height: 24px;
    font-size: 13px;
    color: #9aa3b5;
    margin-bottom: 10px;
}

/* Table */
.psr-table-wrap {
    overflow-x: auto;
}

.psr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.psr-empty {
    color: #9aa3b5;
    padding: 24px;
    text-align: center;
    background: #252b3b;
    border-radius: 6px;
}

/* Re-connect card */
.psr-reconnect-card {
    background: #252b3b;
    border: 1px solid #3a4252;
    border-radius: 8px;
    padding: 20px 24px;
    max-width: 560px;
    margin-top: 16px;
}

.psr-card-title {
    color: #e8eaf0;
    font-size: 15px;
    font-weight: bold;
    margin-bottom: 10px;
}

.psr-reconnect-hint {
    color: #9aa3b5;
    font-size: 13px;
    margin-bottom: 14px;
}

.psr-code-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
}

.psr-code-label {
    color: #9aa3b5;
    font-size: 12px;
    white-space: nowrap;
    min-width: 110px;
}

.psr-code-value {
    color: #e8eaf0;
    font-size: 14px;
    background: #1a1f2e;
    padding: 3px 8px;
    border-radius: 4px;
    word-break: break-all;
}

.psr-reconnect-btns {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.psr-reconnect-status {
    margin-top: 10px;
    font-size: 13px;
    color: #9aa3b5;
}

/* ── Busy overlay (FEAT-120) ─────────────────────────────────────────────── */

.psr-section-wrap {
    position: relative;
}

.psr-busy-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 31, 46, 0.82);
    z-index: 100;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    pointer-events: all;
    border-radius: 6px;
    min-height: 80px;
}

.psr-busy-spinner {
    width: 36px;
    height: 36px;
    border: 4px solid rgba(74, 158, 255, 0.25);
    border-top-color: #4a9eff;
    border-radius: 50%;
    animation: psr-spin 0.8s linear infinite;
}

@keyframes psr-spin {
    to { transform: rotate(360deg); }
}

.psr-busy-label {
    color: #e8eaf0;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 0.02em;
}

/* ── Edit & Save button (in table actions) ───────────────────────────────── */

.psr-edit-btn {
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    margin-right: 6px;
    transition: background 0.15s;
}

.psr-edit-btn:hover {
    background: #3a7fd9;
}

/* ── Edit & Save modal overlay (BUG-258) ─────────────────────────────────── */

.psr-edit-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.72);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
}

.psr-edit-modal {
    background: #252b3b;
    border-radius: 10px;
    padding: 0;
    min-width: 360px;
    max-width: 500px;
    width: 92%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
}

body[data-theme="light"] .psr-edit-modal {
    background: #ffffff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.psr-edit-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid #2d3548;
    flex-shrink: 0;
}

body[data-theme="light"] .psr-edit-modal-header {
    border-bottom-color: #d1d9e0;
}

.psr-edit-modal-title {
    color: #e8eaf0;
    font-size: 15px;
    font-weight: bold;
}

body[data-theme="light"] .psr-edit-modal-title {
    color: #1a202c;
}

.psr-edit-modal-close-btn {
    background: transparent;
    border: none;
    color: #9aa3b5;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.psr-edit-modal-close-btn:hover {
    background: #3a4252;
    color: #e8eaf0;
}

body[data-theme="light"] .psr-edit-modal-close-btn:hover {
    background: #e2e8f0;
    color: #1a202c;
}

.psr-edit-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

.psr-edit-modal-status {
    min-height: 18px;
    font-size: 12px;
    color: #dc3545;
    margin-bottom: 10px;
}

.psr-edit-field-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.psr-edit-label {
    font-size: 12px;
    color: #9aa3b5;
    font-weight: 600;
}

body[data-theme="light"] .psr-edit-label {
    color: #4a5568;
}

.psr-edit-input {
    background: #1a1f2e;
    color: #e8eaf0;
    border: 1px solid #4a5268;
    border-radius: 4px;
    padding: 7px 10px;
    font-size: 13px;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.15s;
}

.psr-edit-input:focus {
    outline: none;
    border-color: #4a90d9;
}

/* Dark theme — date input calendar icon */
.psr-edit-input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

body[data-theme="light"] .psr-edit-input {
    background: #f7f9fc;
    color: #1a202c;
    border-color: #b0bac8;
}

body[data-theme="light"] .psr-edit-input:focus {
    border-color: #4a90d9;
}

body[data-theme="light"] .psr-edit-input[type="date"]::-webkit-calendar-picker-indicator {
    filter: none;
}

.psr-edit-dropdown {
    font-size: 13px;
    color: #1a1f2e;
}

/* Dark-theme option-list contrast for result dropdown */
body:not([data-theme="light"]) .psr-edit-dropdown .VirtualizedSelectOption {
    background: #1e2537 !important;
    color: #e8eaf0 !important;
}
body:not([data-theme="light"]) .psr-edit-dropdown .VirtualizedSelectFocusedOption {
    background: #2d3548 !important;
    color: #e8eaf0 !important;
}
body:not([data-theme="light"]) .psr-edit-dropdown .VirtualizedSelectSelectedOption {
    background: #3a4a6b !important;
    color: #ffffff !important;
}

.psr-edit-modal-footer {
    display: flex;
    gap: 10px;
    padding: 12px 20px 16px;
    border-top: 1px solid #2d3548;
    flex-shrink: 0;
}

body[data-theme="light"] .psr-edit-modal-footer {
    border-top-color: #d1d9e0;
}

.psr-edit-modal-submit-btn {
    background: #28a745;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    transition: background 0.15s;
}

.psr-edit-modal-submit-btn:hover {
    background: #218838;
}

.psr-edit-modal-cancel-btn {
    background: #6b7488;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 20px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.psr-edit-modal-cancel-btn:hover {
    background: #5a6480;
}

/* Mobile */
@media (max-width: 390px) {
    .psr-edit-modal {
        width: 98%;
        min-width: unset;
    }

    .psr-edit-modal-footer {
        flex-direction: column;
    }

    .psr-edit-modal-submit-btn,
    .psr-edit-modal-cancel-btn {
        width: 100%;
    }
}

/* ── BUG-270 — Re-sync from + failed warning ─────────────────────────────── */

.psr-resync-btn {
    background: #fd7e14;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 7px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
    transition: background 0.15s;
}

.psr-resync-btn:hover {
    background: #e36a00;
}

body[data-theme="light"] .psr-resync-btn {
    background: #fd7e14;
}

body[data-theme="light"] .psr-resync-btn:hover {
    background: #e36a00;
}

.psr-sync-failed-warning {
    display: inline-block;
    margin-left: 12px;
    color: #dc3545;
    font-weight: bold;
    font-size: 12px;
    background: #dc354512;
    border: 1px solid #dc354555;
    border-radius: 4px;
    padding: 2px 8px;
}

body[data-theme="light"] .psr-sync-failed-warning {
    color: #c82333;
    background: #c8233310;
    border-color: #c8233340;
}

/* ── FEAT-167 — Plate filter + export buttons ────────────────────────────── */

.psr-plate-filter {
    background: #1e2537;
    color: #e8eaf0;
    border: 1px solid #4a5268;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    width: 130px;
    font-family: inherit;
    transition: border-color 0.15s;
}

.psr-plate-filter:focus {
    outline: none;
    border-color: #4a90d9;
}

.psr-plate-filter::placeholder {
    color: #6b7488;
}

body[data-theme="light"] .psr-plate-filter {
    background: #f7f9fc;
    color: #1a202c;
    border-color: #b0bac8;
}

body[data-theme="light"] .psr-plate-filter:focus {
    border-color: #4a90d9;
}

body[data-theme="light"] .psr-plate-filter::placeholder {
    color: #9aa3b5;
}

.psr-export-group {
    display: flex;
    gap: 6px;
    align-items: center;
}

.psr-export-btn {
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 7px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    transition: background 0.15s;
    white-space: nowrap;
}

.psr-export-csv-btn {
    background: #6b7488;
}

.psr-export-csv-btn:hover {
    background: #5a6480;
}

.psr-export-excel-btn {
    background: #1d7a4a;
}

.psr-export-excel-btn:hover {
    background: #166039;
}

body[data-theme="light"] .psr-export-csv-btn {
    background: #6b7488;
}

body[data-theme="light"] .psr-export-csv-btn:hover {
    background: #5a6480;
}

body[data-theme="light"] .psr-export-excel-btn {
    background: #1d7a4a;
}

body[data-theme="light"] .psr-export-excel-btn:hover {
    background: #166039;
}

@media (max-width: 390px) {
    .psr-plate-filter {
        width: 100%;
    }

    .psr-export-group {
        width: 100%;
    }

    .psr-export-btn {
        flex: 1;
    }
}

/* ── Light theme overrides ────────────────────────────────────────────────── */
body[data-theme="light"] .psr-status-bar {
    background: #f0f4f8;
    color: #4a5568;
    border-left-color: #4a90d9;
}

body[data-theme="light"] .psr-empty {
    background: #f7f9fc;
    color: #6b7280;
}

body[data-theme="light"] .psr-reconnect-card {
    background: #f7f9fc;
    border-color: #d1d9e0;
}

body[data-theme="light"] .psr-card-title {
    color: #1a202c;
}

body[data-theme="light"] .psr-reconnect-hint,
body[data-theme="light"] .psr-code-label,
body[data-theme="light"] .psr-reconnect-status,
body[data-theme="light"] .psr-action-status {
    color: #4a5568;
}

body[data-theme="light"] .psr-code-value {
    background: #e8edf2;
    color: #1a202c;
}

body[data-theme="light"] .psr-busy-overlay {
    background: rgba(240, 244, 248, 0.88);
}

body[data-theme="light"] .psr-busy-label {
    color: #1a202c;
}

/* ── FEAT-186 — Badge system (result + status) ───────────────────────────── */

.psr-badge {
    display: inline-block;
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    vertical-align: middle;
}

/* Result badges */
.psr-result-badge-pass {
    background: #5ec97e22;
    color: #5ec97e;
    border: 1px solid #5ec97e55;
}

.psr-result-badge-fail {
    background: #dc354522;
    color: #dc3545;
    border: 1px solid #dc354555;
}

.psr-result-badge-not-tested {
    background: #fd7e1422;
    color: #fd7e14;
    border: 1px solid #fd7e1455;
}

.psr-result-badge-unknown {
    background: #d4a84322;
    color: #d4a843;
    border: 1px solid #d4a84355;
}

/* Status badges */
.psr-status-badge-pending {
    background: #fd7e1422;
    color: #fd7e14;
    border: 1px solid #fd7e1455;
}

.psr-status-badge-confirmed {
    background: #5ec97e22;
    color: #5ec97e;
    border: 1px solid #5ec97e55;
}

.psr-status-badge-rejected {
    background: #dc354522;
    color: #dc3545;
    border: 1px solid #dc354555;
}

.psr-status-badge-auto-applied {
    background: #4a90d922;
    color: #4a90d9;
    border: 1px solid #4a90d955;
}

/* ── BUG-369-FE — Pending reason caption ────────────────────────────────── */

.psr-pending-reason {
    font-size: 11px;
    color: #9aa3b5;
    margin-top: 3px;
    line-height: 1.3;
}

.psr-pending-reason-more {
    cursor: help;
    opacity: 0.75;
}

body[data-theme="light"] .psr-pending-reason {
    color: #6b7280;
}

/* ── FEAT-186 — Table row polish ─────────────────────────────────────────── */

.psr-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.psr-table tbody tr {
    transition: background 0.1s;
}

.psr-table tbody tr:hover td {
    background: #2d3548 !important;
}

body[data-theme="light"] .psr-table tbody tr:hover td {
    background: #edf2f7 !important;
}

/* ── FEAT-186 — Mobile: filters wrap, no overflow ────────────────────────── */

@media (max-width: 390px) {
    .psr-filter-bar {
        gap: 10px;
    }

    .psr-filter-group {
        min-width: calc(50% - 5px);
        width: 100%;
    }

    .psr-date-input {
        width: 100%;
        min-width: unset;
    }

    .psr-actions-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .psr-resync-row {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid #4a5268;
        padding-top: 8px;
        width: 100%;
        flex-wrap: wrap;
    }
}

/* ── FEAT-188 — FAIL row expand toggle + detail row ─────────────────────── */

.psr-expand-toggle {
    background: transparent;
    border: none;
    color: #dc3545;
    font-size: 10px;
    cursor: pointer;
    padding: 0 4px 0 0;
    line-height: 1;
    vertical-align: middle;
    opacity: 0.75;
    transition: opacity 0.15s;
}

.psr-expand-toggle:hover {
    opacity: 1;
}

body[data-theme="light"] .psr-expand-toggle {
    color: #c82333;
}

.psr-expand-result-no {
    vertical-align: middle;
}

.psr-detail-row td {
    background: #1a1f2e !important;
}

body[data-theme="light"] .psr-detail-row td {
    background: #eef2f7 !important;
}

.psr-detail-row-cell {
    padding: 10px 20px 12px 32px !important;
    border-bottom: 2px solid #dc354555 !important;
}

.psr-detail-reasons-list {
    margin: 0;
    padding-left: 18px;
    list-style: disc;
}

.psr-detail-reason {
    color: #e8eaf0;
    font-size: 13px;
    padding: 2px 0;
    line-height: 1.5;
}

body[data-theme="light"] .psr-detail-reason {
    color: #1a202c;
}

.psr-detail-no-reasons {
    color: #6b7488;
    font-size: 12px;
    font-style: italic;
}

body[data-theme="light"] .psr-detail-no-reasons {
    color: #9aa3b5;
}

@media (max-width: 390px) {
    .psr-detail-row-cell {
        padding: 8px 12px !important;
    }
}

/* ── FEAT-190 — Component readings section in FAIL row expander ──────────── */

.psr-comp-section {
    margin-top: 14px;
    border-top: 1px solid #2d3548;
    padding-top: 10px;
}

body[data-theme="light"] .psr-comp-section {
    border-top-color: #c8d0de;
}

.psr-comp-section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #8a93a8;
    margin-bottom: 8px;
}

body[data-theme="light"] .psr-comp-section-title {
    color: #6b7488;
}

.psr-comp-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.psr-comp-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex-wrap: wrap;
}

.psr-comp-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 1px;
}

.psr-comp-badge-pass {
    background: #14532d44;
    color: #4ade80;
    border: 1px solid #4ade8055;
}

.psr-comp-badge-fail {
    background: #7f1d1d44;
    color: #f87171;
    border: 1px solid #f8717155;
}

.psr-comp-badge-not-tested {
    background: #1e2537;
    color: #6b7488;
    border: 1px solid #2d3548;
}

body[data-theme="light"] .psr-comp-badge-pass {
    background: #dcfce7;
    color: #15803d;
    border-color: #86efac;
}

body[data-theme="light"] .psr-comp-badge-fail {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
}

body[data-theme="light"] .psr-comp-badge-not-tested {
    background: #f1f5f9;
    color: #94a3b8;
    border-color: #cbd5e1;
}

.psr-comp-label {
    font-size: 13px;
    color: #c8d0de;
    min-width: 180px;
}

body[data-theme="light"] .psr-comp-label {
    color: #374151;
}

.psr-comp-reading-text {
    font-size: 12px;
    color: #8a93a8;
    font-variant-numeric: tabular-nums;
}

body[data-theme="light"] .psr-comp-reading-text {
    color: #6b7488;
}

.psr-comp-brek-table {
    border-collapse: collapse;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

.psr-comp-brek-table th,
.psr-comp-brek-table td {
    padding: 3px 8px;
    border: 1px solid #2d3548;
    text-align: center;
}

.psr-comp-brek-th {
    background: #1e2537;
    color: #8a93a8;
    font-weight: 700;
    font-size: 11px;
}

.psr-comp-brek-axle-th {
    background: #1e2537;
    color: #8a93a8;
    font-weight: 700;
    font-size: 11px;
    min-width: 28px;
}

.psr-comp-brek-axle-td {
    background: #1e2537;
    color: #8a93a8;
    font-weight: 600;
}

.psr-comp-brek-td {
    background: #252b3b;
    color: #e8eaf0;
    min-width: 36px;
}

body[data-theme="light"] .psr-comp-brek-table th,
body[data-theme="light"] .psr-comp-brek-table td {
    border-color: #c8d0de;
}

body[data-theme="light"] .psr-comp-brek-th,
body[data-theme="light"] .psr-comp-brek-axle-th,
body[data-theme="light"] .psr-comp-brek-axle-td {
    background: #e8edf5;
    color: #6b7488;
}

body[data-theme="light"] .psr-comp-brek-td {
    background: #f8fafc;
    color: #1a202c;
}

.psr-comp-loading {
    font-size: 12px;
    color: #6b7488;
    font-style: italic;
    margin-top: 10px;
}

.psr-comp-error {
    font-size: 12px;
    color: #f87171;
    margin-top: 10px;
}

body[data-theme="light"] .psr-comp-error {
    color: #b91c1c;
}

.psr-comp-empty {
    font-size: 12px;
    color: #6b7488;
    font-style: italic;
    margin-top: 10px;
}

@media (max-width: 390px) {
    .psr-comp-label {
        min-width: unset;
    }
    .psr-comp-brek-table {
        font-size: 11px;
    }
}

/* ── FEAT-268 — Other Remarks / Failed / Attempt columns ─────────────────── */

.psr-remarks-text,
.psr-remarks-capped {
    font-size: 12px;
    color: #c8cdd8;
    word-break: break-word;
    white-space: normal;
}

.psr-remarks-capped {
    cursor: help;
}

body[data-theme="light"] .psr-remarks-text,
body[data-theme="light"] .psr-remarks-capped {
    color: #4a5568;
}

.psr-failed-text {
    color: #e74c3c;
    font-size: 13px;
    font-weight: 500;
}

/* ── FEAT-273 — Inspection Type column ──────────────────────────────────── */
.psr-insp-type-text {
    display: inline-block;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    cursor: help;
}

body[data-theme="light"] .psr-insp-type-text {
    color: #374151;
}

@media (max-width: 420px) {
    .psr-insp-type-text {
        max-width: 90px;
    }
}

body[data-theme="light"] .psr-failed-text {
    color: #c0392b;
}


/* ═══════════════════════════════════════════════════════════════════════════
   FEAT-269-FE — Failure Analysis board
   ═══════════════════════════════════════════════════════════════════════════ */

/* Board container */
.psr-fa-board {
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── KPI row ─────────────────────────────────────────────────────────────── */
.psr-fa-kpi-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.psr-fa-kpi-card {
    flex: 1 1 160px;
    min-width: 140px;
    background: #1e2537;
    border: 1px solid #2d3548;
    border-radius: 8px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.psr-fa-kpi-card--clickable {
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.psr-fa-kpi-card--clickable:hover {
    border-color: #dc3545;
    background: rgba(220, 53, 69, 0.08);
}

.psr-fa-kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: #e8eaf0;
    line-height: 1.1;
}

.psr-fa-kpi-label {
    font-size: 12px;
    color: #9aa3b5;
    font-weight: 500;
}

.psr-fa-kpi-drill-hint {
    font-size: 10px;
    color: #dc3545;
    opacity: 0.8;
    margin-top: 2px;
}

/* ── Charts layout ───────────────────────────────────────────────────────── */
.psr-fa-charts-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.psr-fa-charts-row .psr-fa-chart-panel {
    flex: 1 1 360px;
    min-width: 300px;
}

.psr-fa-chart-panel {
    background: #1e2537;
    border: 1px solid #2d3548;
    border-radius: 8px;
    padding: 16px;
}

.psr-fa-full-width {
    width: 100%;
}

.psr-fa-chart-title {
    font-size: 14px;
    font-weight: 600;
    color: #e8eaf0;
    margin-bottom: 4px;
}

.psr-fa-chart-hint {
    font-size: 11px;
    color: #9aa3b5;
    margin-bottom: 8px;
}

.psr-fa-chart {
    width: 100%;
}

/* ── Sections and breakdown tables ───────────────────────────────────────── */
.psr-fa-sections-wrap,
.psr-fa-breakdown-wrap,
.psr-fa-repeat-wrap {
    overflow-x: auto;
}

/* Clickable row button (section/branch) */
.psr-fa-row-btn {
    background: none;
    border: none;
    color: #4a9eff;
    cursor: pointer;
    font-size: 13px;
    padding: 0;
    text-align: left;
    text-decoration: underline;
    white-space: normal;
    word-break: break-word;
}

.psr-fa-row-btn:hover {
    color: #dc3545;
}

/* ── Drill overlay ───────────────────────────────────────────────────────── */
.psr-fa-drill-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
}

.psr-fa-drill-modal {
    background: #1a1f2e;
    border: 1px solid #2d3548;
    border-radius: 10px;
    width: 92%;
    max-width: 1100px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

.psr-fa-drill-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #2d3548;
    flex-wrap: wrap;
    gap: 8px;
}

.psr-fa-drill-title {
    font-size: 15px;
    font-weight: 600;
    color: #e8eaf0;
    flex: 1;
}

.psr-fa-drill-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.psr-fa-drill-close-btn {
    background: none;
    border: 1px solid #4a5568;
    color: #9aa3b5;
    border-radius: 5px;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 13px;
    transition: border-color 0.15s, color 0.15s;
}

.psr-fa-drill-close-btn:hover {
    border-color: #dc3545;
    color: #dc3545;
}

.psr-fa-drill-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Light theme overrides ───────────────────────────────────────────────── */
body[data-theme="light"] .psr-fa-kpi-card {
    background: #f8f9fc;
    border-color: #e2e8f0;
}

body[data-theme="light"] .psr-fa-kpi-card--clickable:hover {
    background: rgba(220, 53, 69, 0.06);
    border-color: #dc3545;
}

body[data-theme="light"] .psr-fa-kpi-value {
    color: #1a202c;
}

body[data-theme="light"] .psr-fa-kpi-label {
    color: #6b7280;
}

body[data-theme="light"] .psr-fa-chart-panel {
    background: #ffffff;
    border-color: #e2e8f0;
}

body[data-theme="light"] .psr-fa-chart-title {
    color: #1a202c;
}

body[data-theme="light"] .psr-fa-chart-hint {
    color: #6b7280;
}

body[data-theme="light"] .psr-fa-drill-modal {
    background: #ffffff;
    border-color: #e2e8f0;
}

body[data-theme="light"] .psr-fa-drill-header {
    border-bottom-color: #e2e8f0;
}

body[data-theme="light"] .psr-fa-drill-title {
    color: #1a202c;
}

body[data-theme="light"] .psr-fa-drill-close-btn {
    color: #6b7280;
    border-color: #d1d5db;
}

body[data-theme="light"] .psr-fa-drill-close-btn:hover {
    border-color: #dc3545;
    color: #dc3545;
}

body[data-theme="light"] .psr-fa-row-btn {
    color: #2563eb;
}

body[data-theme="light"] .psr-fa-row-btn:hover {
    color: #dc3545;
}

/* ── Date filter bar (FEAT-274-FE) ──────────────────────────────────────── */
.psr-fa-date-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    background: #1e2537;
    border: 1px solid #2d3548;
    border-radius: 8px;
    padding: 12px 16px;
}

.psr-fa-date-bar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.psr-fa-date-label {
    font-size: 12px;
    color: #9aa3b5;
    white-space: nowrap;
}

.psr-fa-date-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
}

.psr-fa-preset-btn {
    background: #252b3b;
    border: 1px solid #3d4a6b;
    color: #9aa3b5;
    border-radius: 5px;
    padding: 5px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.psr-fa-preset-btn:hover {
    border-color: #4a9eff;
    color: #4a9eff;
}

.psr-fa-preset-btn--active {
    border-color: #4a9eff;
    color: #4a9eff;
    background: rgba(74, 158, 255, 0.1);
}

/* ── Showing label ───────────────────────────────────────────────────────── */
.psr-fa-kpi-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.psr-fa-showing-label {
    font-size: 12px;
    color: #9aa3b5;
    font-style: italic;
}

/* ── PnL section (FEAT-274-FE) ──────────────────────────────────────────── */
.psr-fa-pnl-wrap {
    overflow-x: auto;
}

/* ── Light theme overrides for new FEAT-274-FE elements ─────────────────── */
body[data-theme="light"] .psr-fa-date-bar {
    background: #f8f9fc;
    border-color: #e2e8f0;
}

body[data-theme="light"] .psr-fa-preset-btn {
    background: #ffffff;
    border-color: #d1d5db;
    color: #6b7280;
}

body[data-theme="light"] .psr-fa-preset-btn:hover {
    border-color: #2563eb;
    color: #2563eb;
}

body[data-theme="light"] .psr-fa-preset-btn--active {
    border-color: #2563eb;
    color: #2563eb;
    background: rgba(37, 99, 235, 0.08);
}

body[data-theme="light"] .psr-fa-showing-label {
    color: #6b7280;
}

/* ── 390px mobile ────────────────────────────────────────────────────────── */
@media (max-width: 440px) {
    .psr-fa-kpi-row {
        gap: 10px;
    }

    .psr-fa-kpi-card {
        flex: 1 1 130px;
        min-width: 120px;
        padding: 12px 14px;
    }

    .psr-fa-kpi-value {
        font-size: 22px;
    }

    .psr-fa-charts-row {
        flex-direction: column;
    }

    .psr-fa-charts-row .psr-fa-chart-panel {
        min-width: 0;
    }

    .psr-fa-drill-modal {
        width: 98%;
        max-height: 95vh;
    }

    .psr-fa-drill-header {
        padding: 10px 12px;
    }

    .psr-fa-drill-body {
        padding: 10px 12px;
    }

    .psr-fa-date-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .psr-fa-date-presets {
        margin-left: 0;
    }
}

/* ── FEAT-291 — Summary tab: batch filter, history, in-container scroll ─── */

.psr-sum-batch-group {
    flex: 2;
    min-width: 200px;
}

.psr-sum-batch-textarea {
    width: 100%;
    min-height: 58px;
    max-height: 120px;
    resize: vertical;
    background: #1e2537;
    color: #e8eaf0;
    border: 1px solid #3a4258;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 12px;
    font-family: inherit;
    line-height: 1.5;
    box-sizing: border-box;
}

.psr-sum-batch-textarea:focus {
    outline: none;
    border-color: #4a9eff;
}

.psr-sum-batch-info {
    font-size: 12px;
    color: #9aa3b5;
    padding: 4px 0 6px 0;
    min-height: 18px;
}

.psr-sum-scroll {
    max-height: 70vh;
    overflow-y: auto;
}

.psr-sum-history {
    font-size: 11px;
    color: #c5cad8;
    white-space: normal;
    max-width: 260px;
}

/* FEAT-295 — sticky plate column on Summary table */
.psr-sum-scroll .psr-table thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #1e2537 !important;
}

.psr-sum-scroll .psr-table tbody td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #252b3b !important;
}

.psr-sum-scroll .psr-table tbody tr:hover td:first-child {
    background: #2d3548 !important;
}

body[data-theme="light"] .psr-sum-scroll .psr-table thead th:first-child {
    background: #f0f2f5 !important;
}

body[data-theme="light"] .psr-sum-scroll .psr-table tbody td:first-child {
    background: #ffffff !important;
}

body[data-theme="light"] .psr-sum-scroll .psr-table tbody tr:hover td:first-child {
    background: #edf2f7 !important;
}

.psr-days-ok      { color: #5ec97e; font-size: 12px; }
.psr-days-urgent  { color: #f5a623; font-size: 12px; font-weight: bold; }
.psr-days-overdue { color: #dc3545; font-size: 12px; font-weight: bold; }

/* light theme */
body[data-theme="light"] .psr-sum-batch-textarea {
    background: #fff;
    color: #1a1f2e;
    border-color: #c8d0dc;
}

body[data-theme="light"] .psr-sum-batch-textarea:focus {
    border-color: #1976d2;
}

body[data-theme="light"] .psr-sum-batch-info {
    color: #6b7280;
}

body[data-theme="light"] .psr-sum-history {
    color: #4b5563;
}

@media (max-width: 390px) {
    .psr-sum-batch-group {
        min-width: 100%;
    }

    .psr-sum-scroll {
        max-height: 60vh;
    }
}
