/* ims_root/static/css/theme.css */

/* --- LIGHT MODE (Stronger Pastels & Higher Contrast) --- */
:root, [data-bs-theme="light"] {
    --ims-bg-body: #f1f5f9;         
    --ims-bg-sidebar: #ffffff;
    --ims-box-identity: #D6EAF8;    
    --ims-box-tribunal: #E8DAEF;    
    --ims-box-timeline: #D4EFDF;    
    --ims-box-reps: #FCF3CF;        
    --ims-border: #cbd5e1;          
    --ims-text-main: #0f172a;       
    --ims-text-muted: #475569;
}

/* --- DARK MODE (Deep Rich Tints) --- */
[data-bs-theme="dark"] {
    --ims-bg-body: #0f172a;
    --ims-bg-sidebar: #1e293b;
    --ims-box-identity: #1e293b;    
    --ims-box-tribunal: #262338;    
    --ims-box-timeline: #182F24;    
    --ims-box-reps: #2E2718;        
    --ims-border: #334155;
    --ims-text-main: #f8fafc;
    --ims-text-muted: #94a3b8;
}

body {
    background-color: var(--ims-bg-body);
    color: var(--ims-text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Box Styling */
.ims-card {
    border: 1px solid var(--ims-border);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    overflow: visible;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); 
    background-color: var(--ims-bg-sidebar); /* Respects theme automatically */
}

.ims-card-header {
    padding: 1rem 1.5rem;
    font-weight: 600;
    border-bottom: 1px solid var(--ims-border);
    color: #000000; 
    background-color: transparent !important;
}

.ims-card-body {
    padding: 1.5rem;
    background-color: transparent !important;
}

[data-bs-theme="dark"] .ims-card-header {
    color: #f8fafc !important; 
}

/* Apply specific colors to headers */
.box-identity .ims-card-header { background-color: var(--ims-box-identity) !important; }
.box-tribunal .ims-card-header { background-color: var(--ims-box-tribunal) !important; }
.box-timeline .ims-card-header { background-color: var(--ims-box-timeline) !important; }
.box-reps .ims-card-header { background-color: var(--ims-box-reps) !important; }

/* Global Fix for Hardcoded Backgrounds & Texts in Dark Mode */
[data-bs-theme="dark"] .text-dark {
    color: var(--ims-text-main) !important; 
}
[data-bs-theme="dark"] .bg-light, [data-bs-theme="dark"] .bg-white {
    background-color: rgba(255,255,255,0.03) !important; 
}

.ims-card-header:first-child {
    border-top-left-radius: 11px;
    border-top-right-radius: 11px;
}

/* Targeted clipping override for action headers with dropdowns */
.ims-card.overflow-visible {
    overflow: visible !important;
}


/* --- SPRINT 3: STANDARDIZED UI COMPONENTS --- */
.ims-action-footer {
    position: sticky; bottom: 0; background-color: var(--ims-bg-sidebar);
    border-top: 1px solid var(--ims-border); padding: 1rem 1.5rem;
    display: flex; justify-content: space-between; align-items: center;
    z-index: 1020; margin: 2rem -1.5rem -1.5rem -1.5rem;
    border-bottom-left-radius: 11px; border-bottom-right-radius: 11px;
}
.megaphone-pulse {
    position: absolute; top: -2px; right: -2px; width: 10px; height: 10px;
    background: #ef4444; border-radius: 50%; box-shadow: 0 0 0 0 rgba(239,68,68,0.7);
    animation: pulse-red 2s infinite;
}
@keyframes pulse-red {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239,68,68,0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239,68,68,0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

/* Scoped Typography for CKEditor Output in SOP Drawer */
.sop-content {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--ims-text-main);
}
.sop-content h1, .sop-content h2, .sop-content h3 {
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--ims-text-main);
}
.sop-content h1 { font-size: 1.25rem; border-bottom: 1px solid var(--ims-border); padding-bottom: 0.25rem; }
.sop-content h2 { font-size: 1.15rem; }
.sop-content h3 { font-size: 1.05rem; }

.sop-content ul, .sop-content ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}
.sop-content li { margin-bottom: 0.5rem; }
.sop-content p { margin-bottom: 1rem; }
.sop-content strong, .sop-content b { font-weight: 700; color: #000; }
[data-bs-theme="dark"] .sop-content strong { color: #fff; }

.sop-content a { color: #0d6efd; text-decoration: underline; }
.sop-content a:hover { color: #0a58ca; }

.spp-field-tooltip {
    cursor: help; color: #64748b; margin-left: 5px; position: relative; display: inline-block;
}
.spp-field-tooltip:hover::after {
    content: attr(data-spp-tip); position: absolute; bottom: 120%; left: 50%;
    transform: translateX(-50%); background: #1e293b; color: #f8fafc;
    padding: 8px 12px; border-radius: 6px; font-size: 0.75rem; font-weight: normal;
    white-space: pre-wrap; width: max-content; max-width: 280px; z-index: 1060;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.spp-field-tooltip:hover::before {
    content: ''; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    border-width: 6px; border-style: solid; border-color: #1e293b transparent transparent transparent;
}
/* Force Bootstrap Offcanvas to sit below the 60px Top Navbar */
#sopDrawer.offcanvas, #quickLogDrawer.offcanvas {
    top: 60px !important;
    height: calc(100vh - 60px) !important;
}
.offcanvas-backdrop {
    top: 60px !important;
}

/* === EXTRACTED FROM BASE.HTML === */
body { overflow-x: hidden; overflow-y: auto; display: flex; flex-direction: column; min-height: 100vh; }
.ims-navbar { z-index: 1050; background-color: #131926 !important; border-bottom: 1px solid #1e293b !important; color: #cbd5e1; flex-shrink: 0; }
.ims-wrapper { flex-grow: 1; display: flex; }
.ims-sidebar { background-color: #131926 !important; border-right: 1px solid #1e293b !important; color: #cbd5e1 !important; position: sticky; top: 0; height: calc(100vh - 60px); overflow-y: auto; }
.ims-main { background-color: var(--ims-bg-body); flex-grow: 1; padding-bottom: 2rem; }

/* Sidebar Styling — Deep Midnight Navy (#131926) & Sub-Menu Well (#0d121c) */
.accordion-button::after { display: none; }
.accordion-chevron { transition: transform 0.3s ease; color: #cbd5e1; }
.accordion-button:not(.collapsed) .accordion-chevron { transform: rotate(180deg); color: #ffffff !important; }
.sidebar-group-title { font-size: 0.92rem; color: #cbd5e1 !important; background-color: transparent !important; border-left: 3px solid transparent !important; border-radius: 6px; }
.sidebar-group-title:hover, .sidebar-group-title:not(.collapsed) { background-color: #1e293b !important; color: #ffffff !important; border-left: 3px solid #3b82f6 !important; }
#sidebar .accordion-collapse, #sidebar .accordion-body { background-color: #0d121c !important; border-radius: 6px; }
.sidebar-nav-link { transition: all 0.15s ease-in-out; border-radius: 6px; margin-bottom: 2px; color: #cbd5e1 !important; border-left: 3px solid transparent !important; }
.sidebar-nav-link i { color: #cbd5e1 !important; }
.sidebar-nav-link:hover { background-color: #1e293b !important; color: #ffffff !important; border-left: 3px solid #3b82f6 !important; }
.sidebar-nav-link:hover i, .sidebar-nav-link:hover .sidebar-label-text { color: #ffffff !important; }
.sidebar-nav-link.active { background-color: #1e293b !important; color: #ffffff !important; border-left: 3px solid #3b82f6 !important; font-weight: 600 !important; box-shadow: none !important; }
.sidebar-nav-link.active i, .sidebar-nav-link.active .sidebar-label-text { color: #ffffff !important; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid #0d6efd !important; outline-offset: 2px !important;
}

/* Form fixes & Select2 Clipping Guard */
.select2-container--default .select2-selection--single, .select2-container--default .select2-selection--multiple { border: 1px solid #ced4da; border-radius: 0.375rem; min-height: 38px; }
.select2-dropdown { z-index: 1070 !important; }
.table-responsive { overflow: visible !important; }
input[type="radio"].form-control, input[type="checkbox"].form-control { width: 1.25em !important; height: 1.25em !important; display: inline-block !important; padding: 0 !important; margin-right: 10px !important; vertical-align: middle !important; cursor: pointer; box-shadow: none !important; }
input[type="radio"] { border-radius: 50% !important; }
ul#id_action_type { list-style-type: none; padding-left: 0; margin-top: 10px; }
ul#id_action_type li { padding: 12px 16px; margin-bottom: 10px; background-color: #f8f9fa; border: 1px solid #dee2e6; border-radius: 6px; cursor: pointer; transition: all 0.2s ease-in-out; }
ul#id_action_type li:hover { background-color: #e9ecef; border-color: #b1bcc4; }
ul#id_action_type li label { cursor: pointer; margin: 0; font-weight: 600; color: #2b3a4a; display: flex; align-items: center; width: 100%; }

/* Utilities */
.bg-deep-navy { background-color: #000080 !important; }
.bg-deep-slate { background-color: #2F4F4F !important; }
.fade-in { animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

/* W3C Print Accessibility */
@media print {
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    body, html { height: auto !important; overflow: visible !important; background-color: #fff !important; }
    .ims-wrapper, .ims-main { height: auto !important; overflow: visible !important; display: block !important; }
    .ims-navbar, .ims-sidebar, .btn, #themeToggleBtn, nav[aria-label="breadcrumb"] { display: none !important; }
    .ims-main { margin: 0 !important; padding: 0 !important; width: 100% !important; }
    .ims-card { border: 1px solid #ccc !important; box-shadow: none !important; page-break-inside: avoid; }
    .table { page-break-inside: auto; }
    tr { page-break-inside: avoid; page-break-after: auto; }
    thead { display: table-header-group; }
    tfoot { display: table-footer-group; }
    a { text-decoration: none !important; color: #000 !important; }
}

/* --- R-075: MOBILE NAVIGATION & TOUCH TARGET POLISH --- */
@media (max-width: 768px) {
    .dropdown-item, .sidebar-nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    .btn-sm {
        min-height: 38px; /* Improve touch targets on small buttons */
    }
    .table-responsive {
        border: 0;
        margin-bottom: 1rem;
        -webkit-overflow-scrolling: touch;
    }
}

/* ==========================================================================
   GOLD-STANDARD ADAPTIVE 2-COLUMN <-> 1-COLUMN HORIZONTAL KEY-VALUE FORM GRID
   - Wide Container (>= 820px): 2 Column Sets side-by-side (36% Label / 64% Input)
   - Narrow / Laptop Container (< 820px): Auto-stacks into 1 Column Set (32% Label / 68% Input)
   - Full-Width Row (.ims-kv-full): 18% Label / 82% Input in 2-col mode so the
     input left edge aligns mathematically with the 2-column rows above/below.
   ========================================================================== */
.ims-kv-container {
    container-type: inline-size;
    width: 100%;
}

.ims-kv-section-title {
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #1e3a8a;
    background-color: #f8fafc;
    border-left: 4px solid #2563eb;
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.65rem;
    border-radius: 0 6px 6px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

[data-bs-theme="dark"] .ims-kv-section-title {
    color: #93c5fd;
    background-color: rgba(30, 41, 59, 0.7);
    border-top-color: #334155;
    border-bottom-color: #334155;
}

.ims-kv-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 1.5rem;
    row-gap: 0.55rem;
    align-items: start;
}

.ims-kv-col {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-width: 0;
}

.ims-kv-col-divider {
    border-right: 1px dashed #cbd5e1;
    padding-right: 1.25rem;
}

[data-bs-theme="dark"] .ims-kv-col-divider {
    border-right-color: #334155;
}

.ims-kv-row {
    display: grid;
    grid-template-columns: 36% 64%;
    align-items: start;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.36rem 0.55rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ims-kv-row:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}

[data-bs-theme="dark"] .ims-kv-row {
    background-color: rgba(15, 23, 42, 0.45);
    border-color: #334155;
}

.ims-kv-full {
    grid-column: 1 / -1;
    grid-template-columns: 18% 82%;
}

.ims-kv-panel-full {
    grid-column: 1 / -1;
    display: block;
    width: 100%;
    min-width: 0;
}

.ims-kv-label {
    font-size: 0.79rem;
    font-weight: 600;
    color: #1e293b;
    padding-right: 0.65rem;
    padding-top: 0.24rem;
    line-height: 1.25;
    word-break: break-word;
}

[data-bs-theme="dark"] .ims-kv-label {
    color: #e2e8f0;
}

.ims-kv-input {
    min-width: 0;
    width: 100%;
}

.ims-kv-help {
    font-size: 0.69rem;
    color: #64748b;
    margin-top: 0.18rem;
    line-height: 1.25;
}

/* Auto-Switch to 1-Column Set when Card Container Width < 820px */
@container (max-width: 820px) {
    .ims-kv-grid {
        grid-template-columns: 1fr !important;
    }
    .ims-kv-col-divider {
        border-right: 0 !important;
        padding-right: 0 !important;
    }
    .ims-kv-row,
    .ims-kv-full {
        grid-template-columns: 34% 66% !important;
    }
}

/* Fallback Viewport Query for Browsers Without Container Query Support */
@media (max-width: 1140px) {
    .ims-kv-grid {
        grid-template-columns: 1fr;
    }
    .ims-kv-col-divider {
        border-right: 0;
        padding-right: 0;
    }
    .ims-kv-row,
    .ims-kv-full {
        grid-template-columns: 34% 66%;
    }
}

/* Ultra-Narrow / Mobile Stack (< 576px) */
@media (max-width: 576px) {
    .ims-kv-row,
    .ims-kv-full {
        grid-template-columns: 1fr !important;
        gap: 0.25rem;
    }
    .ims-kv-label {
        padding-top: 0;
    }
}


/* ==========================================================================
   GOLD STANDARD UI OVERLAP & AI DRAWER CO-EXISTENCE FIXES
   ========================================================================== */
:root {
    --ims-navbar-height: 56px;
}

/* Prevent sticky table headers and sub-navbars from colliding with top navbar */
.claims-subnav-sticky,
.sticky-subnav {
    position: sticky !important;
    top: var(--ims-navbar-height) !important;
    z-index: 1020 !important;
}

.table-responsive .sticky-top,
.table thead.sticky-top {
    top: 0 !important;
    z-index: 10 !important;
}

/* Standardize all Right-Side Offcanvas Drawers to match #quickLogDrawer & #sopDrawer:
   - Sit cleanly below the 60px Top Navbar (never covering top bar or clock)
   - Fixed overlay geometry with internal scrolling and zero <main> flex-row wrapping */
.offcanvas.offcanvas-end {
    top: 60px !important;
    height: calc(100vh - 60px) !important;
    max-height: calc(100vh - 60px) !important;
    display: flex !important;
    flex-direction: column !important;
}

.offcanvas.offcanvas-end .offcanvas-header {
    flex-shrink: 0;
}

.offcanvas.offcanvas-end .offcanvas-body {
    flex-grow: 1;
    overflow-y: auto !important;
    overflow-x: hidden;
}

/* === GOLD STANDARD AI DRAWER SCROLL CONTAINMENT (PREVENTS TABLE OVERLAP) === */
.offcanvas .table-responsive,
.spp-ai-scroll-box {
    overflow-y: auto !important;
    overflow-x: auto !important;
    position: relative;
    display: block;
    width: 100%;
}

/* === GOLD-STANDARD AI DRAWER EQUAL-WIDTH DIFF TABLE (COMPACT & EXPANDED VIEWS) === */
.spp-ai-diff-scroll {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: 100% !important;
}
.spp-ai-diff-table {
    table-layout: fixed !important;
    width: 100% !important;
    border-collapse: collapse !important;
}
.spp-ai-diff-table th,
.spp-ai-diff-table td {
    vertical-align: top !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    white-space: normal !important;
    padding: 0.38rem 0.45rem !important;
}
.spp-ai-diff-table th:nth-child(1),
.spp-ai-diff-table td:nth-child(1) {
    width: 6% !important;
    text-align: center !important;
}
.spp-ai-diff-table th:nth-child(2),
.spp-ai-diff-table td:nth-child(2) {
    width: 22% !important;
}
.spp-ai-diff-table th:nth-child(3),
.spp-ai-diff-table td:nth-child(3) {
    width: 36% !important;
}
.spp-ai-diff-table th:nth-child(4),
.spp-ai-diff-table td:nth-child(4) {
    width: 36% !important;
}
.spp-ai-present-cell {
    max-height: 92px;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: pre-wrap !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    font-size: 0.72rem;
    line-height: 1.35;
}
.spp-ai-diff-table input.form-control,
.spp-ai-diff-table textarea.form-control,
.spp-ai-diff-table select.form-select {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    white-space: pre-wrap !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    line-height: 1.35 !important;
}

/* === GOLD-STANDARD EYE-SAFE DARK MODE, COMPACT CLAIMS BAR & SINGLE-COL VERIFICATION === */
[data-bs-theme="dark"] {
    --ims-bg-body: #0b1120;
    --ims-bg-sidebar: #111827;
    --ims-box-identity: #172554;
    --ims-box-tribunal: #2e1065;
    --ims-box-timeline: #064e3b;
    --ims-box-reps: #451a03;
    --ims-border: #334155;
    --ims-text-main: #e2e8f0;
    --ims-text-muted: #94a3b8;
}

/* Eliminate glaring pure-white cards, tables, headers & inputs in Dark Mode */
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .ims-card,
[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .list-group-item {
    background-color: #111827 !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .card-header,
[data-bs-theme="dark"] .card-footer,
[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer,
[data-bs-theme="dark"] .bg-body-tertiary,
[data-bs-theme="dark"] .bg-body-secondary,
[data-bs-theme="dark"] .bg-light-subtle {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .bg-light,
[data-bs-theme="dark"] .bg-white {
    background-color: #162032 !important;
    color: #e2e8f0 !important;
}

/* Fix Bootstrap .table and .table-light glaring white rows in Dark Mode */
[data-bs-theme="dark"] .table {
    --bs-table-bg: #111827;
    --bs-table-color: #e2e8f0;
    --bs-table-border-color: #334155;
    --bs-table-striped-bg: #162032;
    --bs-table-striped-color: #e2e8f0;
    --bs-table-hover-bg: #1e293b;
    --bs-table-hover-color: #ffffff;
    color: #e2e8f0 !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] thead.table-light th,
[data-bs-theme="dark"] tfoot.table-light th,
[data-bs-theme="dark"] tfoot.table-light td,
[data-bs-theme="dark"] tr.table-light,
[data-bs-theme="dark"] tr.table-light > td,
[data-bs-theme="dark"] tr.table-light > th {
    background-color: #1e293b !important;
    --bs-table-bg: #1e293b !important;
    color: #cbd5e1 !important;
    border-color: #334155 !important;
}

/* Eye-friendly form controls, selects, and key-value rows in Dark Mode */
[data-bs-theme="dark"] .ims-kv-row {
    background-color: #162032 !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .ims-kv-label {
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .ims-kv-help,
[data-bs-theme="dark"] .text-muted {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .input-group-text {
    background-color: #0f172a !important;
    border-color: #475569 !important;
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    border-color: #38bdf8 !important;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2) !important;
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #64748b !important;
}

/* Fix invisible .btn-outline-dark & badge text contrast in Dark Mode */
[data-bs-theme="dark"] .btn-outline-dark {
    color: #e2e8f0 !important;
    border-color: #64748b !important;
}
[data-bs-theme="dark"] .btn-outline-dark:hover {
    background-color: #334155 !important;
    color: #ffffff !important;
}

/* Keep dark text on bright solid buttons/badges in Dark Mode */
[data-bs-theme="dark"] .btn-warning.text-dark,
[data-bs-theme="dark"] .btn-info.text-dark,
[data-bs-theme="dark"] .btn-light.text-dark,
[data-bs-theme="dark"] .badge.bg-warning.text-dark,
[data-bs-theme="dark"] .badge.bg-info.text-dark {
    color: #0f172a !important;
}

[data-bs-theme="dark"] .badge.bg-light,
[data-bs-theme="dark"] .badge.bg-secondary-subtle,
[data-bs-theme="dark"] .badge.bg-info-subtle,
[data-bs-theme="dark"] .badge.bg-warning-subtle {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

/* Keep AI Drawer diff-table readable inside offcanvas */
[data-bs-theme="dark"] .offcanvas .spp-ai-diff-table th {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
}

/* Single-Column-Set Key-Value Mode for Expert Verification Forms */
.ims-kv-single-col .ims-kv-grid {
    grid-template-columns: 1fr !important;
    row-gap: 0.45rem;
}
.ims-kv-single-col .ims-kv-col-divider {
    border-right: 0 !important;
    padding-right: 0 !important;
}
.ims-kv-single-col .ims-kv-row,
.ims-kv-single-col .ims-kv-full {
    grid-template-columns: 28% 72% !important;
}
@media (max-width: 768px) {
    .ims-kv-single-col .ims-kv-row,
    .ims-kv-single-col .ims-kv-full {
        grid-template-columns: 1fr !important;
    }
}

/* Contextual Right-Side AI Reasoning & Justification Panel */
.spp-ai-context-panel {
    background: linear-gradient(180deg, rgba(30, 58, 138, 0.06) 0%, rgba(15, 23, 42, 0.03) 100%);
    border: 1px solid #93c5fd;
    border-left: 4px solid #2563eb;
    border-radius: 8px;
    padding: 0.75rem 0.9rem;
    font-size: 0.79rem;
    line-height: 1.45;
}
[data-bs-theme="dark"] .spp-ai-context-panel {
    background: linear-gradient(180deg, rgba(30, 58, 138, 0.22) 0%, rgba(15, 23, 42, 0.65) 100%);
    border-color: #1d4ed8;
    border-left-color: #38bdf8;
    color: #e2e8f0;
}
.spp-ai-context-title {
    font-size: 0.73rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #1d4ed8;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
[data-bs-theme="dark"] .spp-ai-context-title {
    color: #38bdf8;
}

/* Compact Claims Command Ribbon & Inline KPI Pills */
.spp-claims-compact-ribbon {
    border: 1px solid var(--ims-border);
    border-left: 4px solid #2563eb;
    border-radius: 8px;
    background-color: var(--ims-bg-sidebar);
    padding: 0.45rem 0.75rem;
    margin-bottom: 0.55rem;
}
.spp-inline-kpi-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--ims-border);
    background-color: rgba(148, 163, 184, 0.08);
    font-size: 0.76rem;
    white-space: nowrap;
}

/* === GOLD-STANDARD UNIVERSAL PAGINATION & PAGE-SIZE BAR (LIGHT & DARK MODE) === */
.spp-pagination-bar,
.spp-pagination-top {
    font-size: 0.78rem;
    border-color: var(--ims-border) !important;
}
[data-bs-theme="dark"] .spp-pagination-bar,
[data-bs-theme="dark"] .spp-pagination-top {
    background-color: #162032 !important;
    color: #e2e8f0 !important;
}
[data-bs-theme="dark"] .spp-pagination-bar .page-link,
[data-bs-theme="dark"] .spp-pagination-top .page-link {
    background-color: #0f172a;
    border-color: #334155;
    color: #93c5fd;
}
[data-bs-theme="dark"] .spp-pagination-bar .page-item.active .page-link,
[data-bs-theme="dark"] .spp-pagination-top .page-item.active .page-link {
    background-color: #2563eb;
    border-color: #1d4ed8;
    color: #ffffff;
}
[data-bs-theme="dark"] .spp-pagination-bar .page-item.disabled .page-link,
[data-bs-theme="dark"] .spp-pagination-top .page-item.disabled .page-link {
    background-color: #111827;
    border-color: #1e293b;
    color: #475569;
}

/* === STAGE 1.1: CIRP 13-NODE SIDEBAR SUBTEXT & STAGE SCOPE PILLS === */
.sidebar-nav-subtext {
    font-size: 0.71rem;
    line-height: 1.28;
    color: #64748b;
    margin-top: 2px;
    padding-left: 1.55rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-weight: 400;
}
[data-bs-theme="dark"] .sidebar-nav-subtext {
    color: #94a3b8;
}
.sidebar-nav-link.active .sidebar-nav-subtext {
    color: rgba(255, 255, 255, 0.90) !important;
    -webkit-line-clamp: 3;
}
.cirp-stage-scope-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.55rem;
    border-radius: 50px;
    font-size: 0.74rem;
    font-weight: 600;
    background-color: #f1f5f9;
    color: #1e293b;
    border: 1px solid #cbd5e1;
}
[data-bs-theme="dark"] .cirp-stage-scope-pill {
    background-color: #1e293b;
    color: #e2e8f0;
    border-color: #475569;
}

/* === STAGE 1.1: GOLD-STANDARD CIRP DASHBOARD & 12-STAGE STEPPER === */
.cirp-kpi-card {
    border: 1px solid var(--ims-border);
    border-radius: 10px;
    background-color: var(--ims-bg-sidebar);
    padding: 0.65rem 0.85rem;
    height: 100%;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cirp-kpi-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}
.cirp-stepper-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.45rem;
}
@media (max-width: 1199px) {
    .cirp-stepper-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
@media (max-width: 767px) {
    .cirp-stepper-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
.cirp-step-node {
    display: block;
    text-decoration: none;
    padding: 0.36rem 0.52rem;
    border-radius: 7px;
    border: 1px solid var(--ims-border);
    background-color: var(--ims-bg-sidebar);
    color: var(--ims-text-main);
    font-size: 0.74rem;
    line-height: 1.25;
    transition: all 0.15s ease;
}
.cirp-step-node:hover {
    border-color: #2563eb;
    transform: translateY(-1px);
}
.cirp-step-node.step-completed {
    border-left: 4px solid #16a34a;
    background-color: rgba(22, 163, 74, 0.06);
}
.cirp-step-node.step-current {
    border: 2px solid #2563eb;
    background-color: rgba(37, 99, 235, 0.09);
    font-weight: 700;
}
.cirp-step-node.step-overdue {
    border: 2px solid #dc2626;
    background-color: rgba(220, 38, 38, 0.08);
}
.cirp-radar-row-focused {
    border-left: 4px solid #2563eb !important;
    background-color: rgba(37, 99, 235, 0.04) !important;
}

/* === STAGE 1.1: CLEAN DARK-OUTLINED CASE COMMAND BAR & 3-TAB COCKPIT === */
.spp-compact-case-bar {
    background-color: var(--ims-bg-sidebar);
    color: var(--ims-text-main);
    border: 1.5px solid #1e293b;
    border-left: 5px solid #0f172a;
    border-radius: 8px;
    padding: 0.52rem 0.85rem;
    margin-bottom: 0.65rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
[data-bs-theme="dark"] .spp-compact-case-bar {
    border-color: #475569;
    border-left-color: #38bdf8;
}
/* STAGE_1_1_ZERO_NOISE_EXCEPTION_PILL_STYLES */
.spp-exception-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.14rem 0.55rem;
    border-radius: 50px;
    font-size: 0.69rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}
.spp-exception-pill.pill-danger {
    background-color: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.spp-exception-pill.pill-warning {
    background-color: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}
.spp-exception-pill.pill-info {
    background-color: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}
.cirp-cockpit-nav .nav-link {
    font-size: 0.79rem;
    font-weight: 600;
    padding: 0.38rem 0.85rem;
    border-radius: 6px;
    color: var(--ims-text-muted);
    border: 1px solid transparent;
}
.cirp-cockpit-nav .nav-link.active {
    background-color: #2563eb !important;
    color: #ffffff !important;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
}

/* === STAGE 1.1 UNIFIED 12-STAGE SUB-TAB GRID, TYPOGRAPHY & COLOUR SYSTEM === */
.cirp-subtab-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    width: 100%;
}
@media (max-width: 991px) {
    .cirp-subtab-grid {
        grid-template-columns: 1fr;
    }
}
.cirp-subtab-pill {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.45rem;
    height: 36px;
    padding: 0 0.85rem;
    border-radius: 6px;
    font-size: 0.79rem;
    font-weight: 600;
    text-decoration: none;
    background-color: #f8fafc;
    color: #334155;
    border: 1px solid #cbd5e1;
    transition: all 0.15s ease;
    overflow: hidden;
}
.cirp-subtab-pill:hover {
    border-color: #2563eb;
    color: #1d4ed8;
    background-color: #eff6ff;
}
.cirp-subtab-pill.active {
    background-color: #1e293b;
    color: #ffffff !important;
    border-color: #1e293b;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}
[data-bs-theme="dark"] .cirp-subtab-pill {
    background-color: #1e293b;
    color: #cbd5e1;
    border-color: #475569;
}
[data-bs-theme="dark"] .cirp-subtab-pill.active {
    background-color: #2563eb;
    border-color: #3b82f6;
    color: #ffffff !important;
}
.cirp-stat-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.16rem 0.55rem;
    border-radius: 5px;
    font-size: 0.72rem;
    font-weight: 600;
    background-color: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}
.cirp-activity-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.16rem 0.52rem;
    border-radius: 5px;
    font-size: 0.71rem;
    font-weight: 700;
    background-color: #1e293b;
    color: #ffffff;
}
.cirp-purpose-banner {
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    border-left: 4px solid #2563eb;
    border-radius: 7px;
    padding: 0.48rem 0.85rem;
    font-size: 0.78rem;
}
[data-bs-theme="dark"] .cirp-purpose-banner {
    background-color: #162032;
    border-color: #334155;
    border-left-color: #38bdf8;
}
.cirp-next-step-footer {
    background-color: var(--ims-bg-sidebar);
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.6rem 0.95rem;
    margin-top: 0.85rem;
}

/* Uniform Card, Label, Input & Table Standardization Across All 12 CIRP Stages */
.cirp-unified-stage-scope .card {
    border-radius: 8px;
    border-color: #cbd5e1 !important;
}
.cirp-unified-stage-scope .card-header {
    background-color: #f8fafc !important;
    color: #0f172a !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 0.5rem 0.85rem !important;
}
.cirp-unified-stage-scope .card-header h6 {
    font-size: 0.83rem !important;
    font-weight: 700 !important;
    letter-spacing: -0.01em;
    color: #0f172a !important;
}
.cirp-unified-stage-scope .form-label {
    font-size: 0.74rem !important;
    font-weight: 600 !important;
    color: #334155 !important;
    margin-bottom: 0.15rem !important;
}
.cirp-unified-stage-scope .form-control-sm,
.cirp-unified-stage-scope .form-select-sm {
    font-size: 0.78rem !important;
    border-color: #cbd5e1;
}
.cirp-unified-stage-scope .table thead th {
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #475569 !important;
    background-color: #f8fafc !important;
}
.cirp-unified-stage-scope .table tbody td {
    font-size: 0.78rem !important;
}

/* === STAGE 1.1: APPLICABLE LAW & REGULATIONS RIGHT-SIDE DRAWER & TRIGGER === */
.spp-law-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.32rem;
    padding: 0.14rem 0.62rem;
    border-radius: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    background-color: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}
.spp-law-trigger-btn:hover {
    background-color: #1d4ed8;
    color: #ffffff;
    border-color: #1e40af;
}
[data-bs-theme="dark"] .spp-law-trigger-btn {
    background-color: #1e3a8a;
    color: #e0f2fe;
    border-color: #3b82f6;
}
.spp-law-drawer {
    width: 460px !important;
    max-width: 92vw !important;
    border-left: 3px solid #1e293b !important;
}
.spp-law-drawer .offcanvas-header {
    background-color: #0f172a;
    color: #f8fafc;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #334155;
}
.spp-law-drawer .law-sec-card {
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background-color: #ffffff;
    padding: 0.65rem 0.8rem;
    margin-bottom: 0.65rem;
}
[data-bs-theme="dark"] .spp-law-drawer .law-sec-card {
    background-color: #1e293b;
    border-color: #334155;
}

/* ==========================================================================
   GOLD-STANDARD ENTERPRISE TABLE LAYOUT & 4-ARCHETYPE COLUMN PROPORTION ENGINE
   1. Strict Top-Alignment (`vertical-align: top`) on all multi-line data rows
   2. 4-Archetype Semantic Columns (Shrink-Wrap Date/Action, Title, Meta, Fluid Narrative)
   3. Smart 4-Line Clamp with 1-Click Expand/Collapse (.ims-narrative-clamp)
   ========================================================================== */
.ims-pastel-strip-table > tbody > tr > td,
.ims-table-std > tbody > tr > td,
.tab-pane .table > tbody > tr > td {
    vertical-align: top !important;
}

.ims-pastel-strip-table > thead > tr > th,
.ims-table-std > thead > tr > th,
.tab-pane .table > thead > tr > th {
    vertical-align: middle !important;
    white-space: nowrap;
}

/* Archetype A: Shrink-Wrap Columns (Dates, Codes, Badges, Action Buttons) */
.ims-col-shrink,
.ims-col-date,
.ims-col-actions {
    width: 1% !important;
    white-space: nowrap !important;
}

/* Archetype B: Primary Title / Identity Column (Balanced 26-28% Width) */
.ims-col-title {
    width: 27%;
    min-width: 210px;
    max-width: 360px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Archetype C: Secondary Metadata / Forum / Category Column */
.ims-col-meta {
    width: 16%;
    min-width: 140px;
    overflow-wrap: anywhere;
}

/* Archetype D: Fluid Narrative / Legal Substance Column (Absorbs Extra Monitor Width) */
.ims-col-narrative {
    width: 46%;
    min-width: 280px;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.48;
}

/* Archetype E: Tabular Right-Aligned Currency Column */
.ims-col-amount {
    width: 12%;
    white-space: nowrap !important;
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

/* Smart 4-Line Narrative Clamp with 1-Click Expand/Collapse */
.ims-narrative-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-line;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.48;
}

.ims-narrative-clamp.ims-narrative-expanded {
    display: block !important;
    -webkit-line-clamp: unset !important;
    max-height: 320px;
    overflow-y: auto;
    padding: 0.4rem 0.55rem;
    border-radius: 6px;
    border: 1px solid var(--ims-border);
    background-color: rgba(148, 163, 184, 0.08);
}

.ims-narrative-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    margin-top: 0.22rem;
    padding: 0.08rem 0.48rem;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 4px;
    color: #2563eb;
    background-color: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.25);
    cursor: pointer;
    text-decoration: none;
}

.ims-narrative-toggle-btn:hover {
    background-color: #2563eb;
    color: #ffffff;
}

[data-bs-theme="dark"] .ims-narrative-toggle-btn {
    color: #60a5fa;
    background-color: rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.3);
}
