/* ========================================
   PROCUREMENT SYSTEM - MAIN STYLESHEET
   Modern, Professional, Optimized Design
   ======================================== */

/* static\css\main.css
=========================
   CSS VARIABLES (Design System)
   ========================= */
:root {
    /* Primary Colors - Purple Gradient */
    --primary-gradient: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
    --primary-500: #7c3aed;
    --primary-600: #6d28d9;
    --primary-700: #5b21b6;
    --primary-400: #a78bfa;
    --primary-300: #c4b5fd;
    
    /* Neutral Colors */
    --dark-bg: #1a1d2e;
    --dark-secondary: #252938;
    --dark-hover: #2d3348;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Semantic Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    
    /* Background Colors */
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-card: #ffffff;
    
    /* Border & Shadow */
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Spacing */
    --sidebar-width: 260px;
    --sidebar-collapsed: 80px;
    --navbar-height: 70px;
    
    /* Typography */
    --font-family: 'Inter', 'Noto Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    
    /* Primary Tints (for themed backgrounds) */
    --primary-50: #faf5ff;
    --primary-100: #f5f3ff;
    --primary-200: #ede9fe;
    --primary-rgb: 124, 58, 237;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Z-index layers */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

/* ═══════════════════════════════════════════════════════════
   WORKFLOW TYPE COLOR THEMES
   Scoped via [data-workflow-theme] on .page-content.
   :root purple stays the APP-WIDE primary (sidebar, dashboards,
   and any non-PO page with no data-workflow-theme). PO pages set
   data-workflow-theme to the slug and get an explicit override:
     standard (+ legacy None, which emits "standard") = Indigo
     standard_v2                                       = Purple
   ═══════════════════════════════════════════════════════════ */

/* Standard (with Operations) / standard + legacy — Indigo
   The original 9-stage flow. Legacy POs (workflow_type None) emit
   data-workflow-theme="standard" via the template default, so this
   block colours them too — consistent with their standard fallback.
   --primary-500 #4f46e5 on white → 5.8:1 contrast ✓ WCAG AA        */
[data-workflow-theme="standard"] {
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #818cf8 100%);
    --primary-500: #4f46e5;
    --primary-600: #4338ca;
    --primary-700: #3730a3;
    --primary-400: #6366f1;
    --primary-300: #818cf8;
    --primary-200: #c7d2fe;
    --primary-100: #e0e7ff;
    --primary-50: #eef2ff;
    --primary-rgb: 79, 70, 229;
}

/* Timesheet — Emerald green
   --primary-500 #047857 on white → 5.46:1 contrast ✓ WCAG AA
   --primary-500 #047857 on white text → 5.46:1 ✓                */
[data-workflow-theme="timesheet"] {
    --primary-gradient: linear-gradient(135deg, #047857 0%, #34d399 100%);
    --primary-500: #047857;
    --primary-600: #065f46;
    --primary-700: #064e3b;
    --primary-400: #34d399;
    --primary-300: #6ee7b7;
    --primary-200: #a7f3d0;
    --primary-100: #d1fae5;
    --primary-50: #ecfdf5;
    --primary-rgb: 4, 120, 87;
}

/* Direct Assistance — Blue
   --primary-500 #2563eb on white → 5.18:1 contrast ✓ WCAG AA   */
[data-workflow-theme="direct_assistance"] {
    --primary-gradient: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%);
    --primary-500: #2563eb;
    --primary-600: #1d4ed8;
    --primary-700: #1e40af;
    --primary-400: #60a5fa;
    --primary-300: #93c5fd;
    --primary-200: #bfdbfe;
    --primary-100: #dbeafe;
    --primary-50: #eff6ff;
    --primary-rgb: 37, 99, 235;
}

/* Express — Amber / dark golden
   --primary-500 #b45309 on white → 5.02:1 contrast ✓ WCAG AA
   Uses dark amber so white text stays readable on buttons.      */
[data-workflow-theme="express"] {
    --primary-gradient: linear-gradient(135deg, #b45309 0%, #f59e0b 100%);
    --primary-500: #b45309;
    --primary-600: #92400e;
    --primary-700: #78350f;
    --primary-400: #f59e0b;
    --primary-300: #fbbf24;
    --primary-200: #fde68a;
    --primary-100: #fef3c7;
    --primary-50: #fffbeb;
    --primary-rgb: 180, 83, 9;
}

/* Standard Procurement / standard_v2 — Purple
   The operations-less flow is now the primary "Standard Procurement"
   users see, so it carries the house purple (matching :root). The
   original 9-stage 'standard' is differentiated with Indigo above.
   --primary-500 #7c3aed on white → 4.9:1 contrast ✓ WCAG AA        */
[data-workflow-theme="standard_v2"] {
    --primary-gradient: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
    --primary-500: #7c3aed;
    --primary-600: #6d28d9;
    --primary-700: #5b21b6;
    --primary-400: #a78bfa;
    --primary-300: #c4b5fd;
    --primary-200: #ede9fe;
    --primary-100: #f5f3ff;
    --primary-50: #faf5ff;
    --primary-rgb: 124, 58, 237;
}

/* ═══════════════════════════════════════════════════════════
   WORKFLOW TYPE PILL — Per-row badge in PO list tables
   Uses data-workflow-theme to scope --primary-* per element.
   ═══════════════════════════════════════════════════════════ */
.wf-type-pill {
    display: inline-block; vertical-align: middle;
    max-width: 140px;                 /* cap so long names can't blow out the column */
    padding: .18rem .5rem; border-radius: 8px;
    font-size: .64rem; font-weight: 700; line-height: 1.25;
    white-space: normal;              /* wrap instead of forcing the cell wide */
    text-align: center;
    background: var(--primary-100); color: var(--primary-700);
}
/* Roomier once there's horizontal space to spare (laptop and up) */
@media (min-width: 1200px) {
    .wf-type-pill { max-width: 180px; font-size: .66rem; }
}

/* ═══════════════════════════════════════════════════════════
   SEGMENTED TOGGLE — Workflow Type Selector
   Built with real <input type="radio"> + <label> pairs.
   ═══════════════════════════════════════════════════════════ */
.wt-toggle {
    display: flex;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 4px;
    gap: 0;
}
.wt-toggle input[type="radio"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
    padding: 0;
    margin: -1px;
}
.wt-toggle label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .65rem 1rem;
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all .2s ease;
    text-align: center;
    min-height: 44px;
    white-space: nowrap;
    user-select: none;
}
.wt-toggle label:hover {
    color: #475569;
    background: rgba(0, 0, 0, .04);
}
.wt-toggle label i {
    font-size: .9rem;
}
.wt-toggle input[type="radio"]:checked + label {
    background: var(--primary-500, #7c3aed);
    color: #fff;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb, 124, 58, 237), .3);
}
.wt-toggle input[type="radio"]:focus-visible + label {
    outline: 2px solid var(--primary-500, #7c3aed);
    outline-offset: 2px;
}
.wt-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 .35rem;
    border-radius: 100px;
    font-size: .65rem;
    font-weight: 700;
    background: rgba(0, 0, 0, .08);
    line-height: 1;
}
.wt-toggle input[type="radio"]:checked + label .wt-badge {
    background: rgba(255, 255, 255, .25);
    color: #fff;
}

/* Responsive — Segmented Toggle */
@media screen and (max-width: 767px) {
    .wt-toggle {
        flex-wrap: wrap;
    }
    .wt-toggle label {
        flex: 1 1 calc(50% - 4px);
        min-width: calc(50% - 4px);
        font-size: .78rem;
        padding: .6rem .65rem;
    }
}
@media screen and (max-width: 399px) {
    .wt-toggle label {
        padding: .55rem .4rem;
        font-size: .72rem;
        gap: .25rem;
    }
    .wt-toggle label i {
        font-size: .78rem;
    }
    .wt-badge {
        min-width: 18px;
        height: 18px;
        font-size: .6rem;
    }
}

/* =========================
   RESET & BASE STYLES
   ========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    overflow-x: hidden;
}

/* Arabic / RTL — prioritize Noto Sans Arabic.
   Scoped to <body> (not a bare :lang(ar)/[dir=rtl], which matches EVERY
   element) so the Arabic font cascades to text by inheritance but does NOT
   directly override elements that set their own font-family — most importantly
   FontAwesome icons (<i class="fas …">). The old universal rule out-specified
   and out-ordered FontAwesome's own font-family, so in Arabic every icon fell
   back to a text font and rendered as a tofu square. Body-scoping fixes that
   while keeping Arabic text in Noto. */
body:lang(ar),
body[dir="rtl"] {
    font-family: 'Noto Sans Arabic', 'Inter', sans-serif;
}


/* =========================
   AUTH PAGES (No Sidebar)
   ========================= */

.auth-page {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

.auth-content {
    width: 100%;
    min-height: 100vh;
}

/* Remove any sidebar-related padding/margins */
.auth-page .sidebar,
.auth-page .navbar,
.auth-page .main-content {
    display: none !important;
}

/* =========================
   CRP LOGO - PYTHAGOREAN TRIANGLE (LARGER + C LEFT)
   ========================= */

.logo-icon.crp-logo {
    width: 44px;
    height: 44px;
    background: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    border: 2px solid #f5f5f5;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.logo-icon.crp-logo:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

/* Triangle Container */
.crp-triangle {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    padding: 2px 0;
    padding-left: 2px;
}

/* Top Letter: C (Black) - LARGER */
.crp-c {
    font-size: 1rem;
    font-weight: 800;
    color: #2c3e50;
    letter-spacing: 0;
    line-height: 1;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Bottom Row: R + P */
.crp-bottom {
    display: flex;
    gap: 3px;
    align-items: center;
}

/* R Letter (Pink/Coral) - LARGER */
.crp-r {
    font-size: 1rem;
    font-weight: 800;
    color: #e85d75;
    letter-spacing: 0;
    line-height: 1;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* P Letter (Black) - LARGER */
.crp-p {
    font-size: 1rem;
    font-weight: 800;
    color: #2c3e50;
    letter-spacing: 0;
    line-height: 1;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Collapsed Sidebar */
.sidebar-collapsed .logo-icon.crp-logo {
    width: 38px;
    height: 38px;
    margin: 0 auto;
}

.sidebar-collapsed .crp-c,
.sidebar-collapsed .crp-r,
.sidebar-collapsed .crp-p {
    font-size: 0.85rem;
}

.sidebar-collapsed .crp-triangle {
    gap: 0px;
    padding-left: 1px;
}

.sidebar-collapsed .crp-bottom {
    gap: 2px;
}


/* =========================
   LOADING OVERLAY
   ========================= */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dark-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity var(--transition-base), visibility var(--transition-base);
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(124, 58, 237, 0.2);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =========================
   LAYOUT STRUCTURE
   ========================= */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
}

.main-content {
    flex: 1;
    /* min-width:0 is REQUIRED. Without it a flex item's min-width defaults to
       `auto`, so a wide items table stretches .main-content past the viewport.
       Combined with body{overflow-x:hidden} that clipped the right-hand item
       columns with no way to scroll to them. With min-width:0 the table's own
       overflow-x wrapper scrolls instead. */
    min-width: 0;
    max-width: 100%;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-base);
}

.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed);
}

.content-wrapper {
    flex: 1;
    padding: 2rem;
    margin-top: var(--navbar-height);
    min-width: 0;
    max-width: 100%;
}

/* Same reasoning one level down — page bodies must never widen the shell. */
.page-content,
.page-content > * {
    min-width: 0;
}

/* =========================
   SIDEBAR STYLES
   ========================= */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--dark-bg);
    z-index: var(--z-fixed);
    transition: all var(--transition-base);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}

/* Sidebar Header */
.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    min-height: var(--navbar-height);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

.sidebar-logo:hover {
    opacity: 0.8;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    flex-shrink: 0;
}

.logo-text {
    font-size: -0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition-fast);
}

.sidebar-collapsed .logo-text {
    opacity: 0;
    width: 0;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    padding: 0 1.5rem;
    margin-bottom: 0.5rem;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    opacity: 1;
    transition: opacity var(--transition-fast);
}

.sidebar-collapsed .nav-section-title {
    opacity: 0;
    height: 0;
    margin: 0;
    padding: 0;
}

/* =========================
   COLLAPSIBLE NAV SECTIONS
   ========================= */

.nav-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: 8px;
    margin: 0.25rem 0.5rem;
    user-select: none;
}

.nav-section-header:hover {
    background: var(--dark-hover);
}

.nav-section-header .nav-section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    flex: 1;
    padding: 0;
    margin: 0;
    opacity: 1;
    text-transform: none;
    letter-spacing: normal;
}

.nav-section-header .nav-section-title i:first-child {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-section-toggle {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.nav-section.expanded .nav-section-toggle {
    transform: rotate(180deg);
}

/* Submenu Styles */
.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-base) ease-in-out;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    margin: 0 0.5rem 0.5rem 0.5rem;
}

.nav-submenu.active {
    max-height: 600px;
}

.nav-submenu .nav-link {
    padding-left: 3.5rem;
    font-size: var(--font-size-sm);
}

/* Collapsed Sidebar Adjustments */
.sidebar-collapsed .nav-section-header {
    padding: 0.75rem;
    justify-content: center;
}

/* Use BEM methodology for flatter, more performant CSS */
.nav-section-header__title--collapsed {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* GPU acceleration for smooth animations */
.nav-submenu {
    will-change: max-height;
    transform: translateZ(0);
}

/* Optimize sidebar collapse animation */
.sidebar {
    transition: width var(--transition-base);
    transform: translateZ(0);
    backface-visibility: hidden;
}

.sidebar-collapsed .nav-submenu {
    display: none;
}

/* Badge for Pending Items */
.nav-badge-section {
    margin-left: auto;
    padding: 0.125rem 0.5rem;
    background: var(--primary-500);
    color: white;
    border-radius: 12px;
    font-size: 0.625rem;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}

.sidebar-collapsed .nav-badge-section {
    display: none;
}

/* Active Section Highlighting */
.nav-section.expanded {
    border-left: 3px solid var(--primary-500);
    margin-left: 0;
    padding-left: 0.5rem;
    transition: all var(--transition-base);
}

.sidebar-collapsed .nav-section.expanded {
    border-left: none;
    margin-left: 0;
    padding-left: 0;
}

/* =========================
   STANDARD NAV MENU
   ========================= */

.nav-menu {
    list-style: none;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    position: relative;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--dark-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--dark-hover);
    color: var(--primary-400);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-gradient);
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.nav-text {
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition-fast);
}

.sidebar-collapsed .nav-text {
    opacity: 0;
    width: 0;
}

.nav-badge {
    margin-left: auto;
    padding: 0.125rem 0.5rem;
    background: var(--primary-500);
    color: white;
    border-radius: 12px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    opacity: 1;
    transition: opacity var(--transition-fast);
}

.sidebar-collapsed .nav-badge {
    opacity: 0;
    width: 0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-toggle {
    width: 100%;
    padding: 0.625rem;
    background: var(--dark-secondary);
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.sidebar-toggle:hover {
    background: var(--dark-hover);
    color: var(--text-primary);
}

.sidebar-toggle i {
    transition: transform var(--transition-fast);
}

.sidebar-collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* =========================
   NAVBAR STYLES
   ========================= */
.navbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--navbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: var(--z-sticky);
    transition: left var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.sidebar-collapsed .navbar {
    left: var(--sidebar-collapsed);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.page-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--dark-bg);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.navbar-action {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.navbar-action:hover {
    background: var(--bg-secondary);
    color: var(--dark-bg);
}

.notification-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--error);
    border: 2px solid var(--bg-card);
    border-radius: 50%;
}

/* Enhanced Notification Styles */
.notification-count-badge {
    background: #ef4444;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 0.5rem;
}

.notification-item {
    position: relative;
    padding-right: 3rem;
}

.notification-item.unread {
    border-left: 3px solid #3b82f6;
}

.btn-mark-read-mini {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: #f3f4f6;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 0.75rem;
}

.btn-mark-read-mini:hover {
    background: #10b981;
    color: white;
}

.notification-time i {
    font-size: 0.7rem;
    opacity: 0.7;
}

.view-all-notifications i {
    margin-right: 0.4rem;
}

/* Icon color classes */
.notification-icon.success {
    background: #d1fae5;
    color: #059669;
}

.notification-icon.warning {
    background: #fef3c7;
    color: #d97706;
}

.notification-icon.error {
    background: #fee2e2;
    color: #dc2626;
}

.notification-icon.info {
    background: #dbeafe;
    color: #2563eb;
}

/* User Dropdown */
.user-dropdown {
    position: relative;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.user-avatar:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.user-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 220px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-base);
    z-index: var(--z-dropdown);
    border: 1px solid var(--border-color);
}

.user-dropdown.active .user-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.user-name {
    font-weight: 600;
    color: var(--dark-bg);
    margin-bottom: 0.25rem;
}

.user-role {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.user-menu-items {
    padding: 0.5rem;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--dark-bg);
    text-decoration: none;
    border-radius: 8px;
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
}

.user-menu-item:hover {
    background: var(--bg-secondary);
}

.user-menu-item i {
    width: 18px;
    color: var(--text-muted);
}

.user-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

/* =========================
   BREADCRUMB
   ========================= */
.breadcrumb-nav {
    margin-bottom: 2rem;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    flex-wrap: wrap;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.breadcrumb-item a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.breadcrumb-item a:hover {
    color: var(--primary-500);
}

.breadcrumb-item:not(:last-child)::after {
    content: '›';
    margin-left: 0.5rem;
    color: var(--text-muted);
}

.breadcrumb-item.active {
    color: var(--dark-bg);
    font-weight: 500;
}

/* =========================
   MESSAGES & ALERTS
   ========================= */
.messages-container {
    position: fixed;
    top: calc(var(--navbar-height) + 1rem);
    right: 1rem;
    z-index: var(--z-popover);
    max-width: 400px;
}

.alert {
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease-out;
    border-left: 4px solid;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.alert-content {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
}

.alert-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.alert-message {
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

.alert-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
    padding: 0;
    flex-shrink: 0;
}

.alert-close:hover {
    opacity: 1;
}

/* Alert Variants */
.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border-left-color: var(--success);
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border-left-color: var(--error);
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-left-color: var(--warning);
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border-left-color: var(--info);
}

/* =========================
   PAGE CONTENT
   ========================= */
.page-content {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================
   FOOTER
   ========================= */
.app-footer {
    padding: 1.5rem 2rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-content p {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: var(--primary-500);
}

/* =========================
   RESPONSIVE DESIGN
   ========================= */

/* Tablet */
@media screen and (max-width: 1024px) {
    .content-wrapper {
        padding: 1.5rem;
    }
    
    .navbar {
        padding: 0 1.5rem;
    }
}

/* Tablet + Mobile — sidebar off-canvas */
@media screen and (max-width: 1024px) {
    :root {
        --sidebar-width: 0;
        --navbar-height: 60px;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .navbar {
        left: 0;
    }

    .content-wrapper {
        padding: 1rem;
    }

    .page-title {
        font-size: var(--font-size-lg);
    }

    .messages-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    /* Mobile Nav Sections */
    .nav-submenu .nav-link {
        padding-left: 2.5rem;
        font-size: 0.8125rem;
    }

    .nav-section-header {
        padding: 0.625rem 1rem;
    }

    .nav-section.expanded {
        border-left: 2px solid var(--primary-500);
        padding-left: 0.25rem;
    }
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-fixed) - 1);
    opacity: 0;
    transition: opacity var(--transition-base);
}

@media screen and (max-width: 1024px) {
    .mobile-overlay.active {
        display: block;
        opacity: 1;
    }
}

/* =========================
   UTILITY CLASSES
   ========================= */
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary-500); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }

.bg-primary { background: var(--primary-gradient); }
.bg-card { background: var(--bg-card); }

.d-none { display: none; }
.d-flex { display: flex; }
.d-block { display: block; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }


/* =========================
   ENHANCED NAV SECTIONS - SMOOTH ANIMATIONS
   ========================= */

/* Subsection title styling */
.nav-subsection-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    padding-left: 3rem;
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.nav-subsection-title i {
    font-size: 0.875rem;
}

.sidebar-collapsed .nav-subsection-title {
    display: none;
}

/* Enhanced nav submenu with SMOOTH animations */
.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease,
                padding 0.3s ease;
    opacity: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    margin: 0 0.5rem 0.5rem 0.5rem;
}

.nav-submenu.active {
    max-height: 2000px;
    opacity: 1;
    padding: 0.5rem 0;
}

/* Smooth chevron rotation */
.nav-section-toggle {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    will-change: transform;
}

.nav-section.expanded .nav-section-toggle {
    transform: rotate(180deg);
}

/* Ensure chevrons are visible when sidebar is collapsed */
.sidebar-collapsed .nav-section-toggle {
    display: none;
}

/* Enhanced sidebar nav scrolling */
.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 150px);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Custom scrollbar for webkit browsers */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    transition: background 0.2s;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Smooth scroll behavior */
.sidebar-nav {
    scroll-behavior: smooth;
}

/* Nav divider inside submenu */
.nav-submenu .nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0.75rem 1.5rem;
    border: none;
    list-style: none;
}

/* Enhanced nav section header */
.nav-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
    margin: 0.25rem 0.5rem;
    user-select: none;
    position: relative;
}

.nav-section-header:hover {
    background: var(--dark-hover);
}

.nav-section-header:active {
    transform: scale(0.98);
}

/* Keyboard focus styles */
.nav-section-header:focus {
    outline: 2px solid var(--primary-400);
    outline-offset: 2px;
}

.nav-section-header .nav-section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    flex: 1;
    padding: 0;
    margin: 0;
    opacity: 1;
    text-transform: none;
    letter-spacing: normal;
}

.nav-section-header .nav-section-title i:first-child {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* Active section indicator */
.nav-section.expanded {
    position: relative;
}

.nav-section.expanded::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-gradient);
    border-radius: 0 3px 3px 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-section.expanded::before {
    opacity: 1;
}

/* ========================================
   ENHANCED ACTIVE LINK DETECTION
   ======================================== */

/* Active link highlight for submenu items */
.nav-submenu .nav-link.active {
    background: var(--dark-hover);
    color: var(--primary-400);
    position: relative;
}

.nav-submenu .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-gradient);
}

/* Keep section expanded when it contains active link */
/* Only apply ALL active-section styles when the section is actually expanded */
.nav-section.expanded:has(.nav-link.active) {
    border-left: 3px solid var(--primary-500);
    margin-left: 0;
    padding-left: 0.5rem;
}

.nav-section.expanded:has(.nav-link.active) .nav-submenu {
    max-height: 600px;
    opacity: 1;
    padding: 0.5rem 0;
}

.nav-section.expanded:has(.nav-link.active) .nav-section-header {
    background: var(--dark-hover);
}

.nav-section.expanded:has(.nav-link.active) .nav-section-toggle {
    transform: rotate(180deg);
}

/* ========================================
   COLLAPSED SIDEBAR - ICON ONLY MODE
   ======================================== */

.sidebar-collapsed .nav-section-header {
    padding: 0.75rem;
    justify-content: center;
    margin: 0.5rem;
    border-radius: 10px;
}

/* Hide ALL text when collapsed */
.sidebar-collapsed .nav-section-header .nav-section-title span,
.sidebar-collapsed .nav-section-title span,
.sidebar-collapsed .nav-text,
.sidebar-collapsed .nav-badge,
.sidebar-collapsed .nav-section-toggle {
    opacity: 0;
    width: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Show ONLY the icon */
.sidebar-collapsed .nav-section-header .nav-section-title {
    justify-content: center;
    width: 100%;
}

.sidebar-collapsed .nav-section-header .nav-section-title i:first-child {
    margin: 0;
    font-size: 1.25rem;
}

/* Hide submenus completely when collapsed */
.sidebar-collapsed .nav-submenu {
    display: none !important;
}

/* Center nav links and show only icons */
.sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar-collapsed .nav-icon {
    margin: 0;
}

/* Hide section titles when collapsed */
.sidebar-collapsed .nav-section-title:not(.nav-section-header .nav-section-title) {
    display: none;
}

/* Ensure consistent icon sizing in collapsed mode */
.sidebar-collapsed .nav-section-header i,
.sidebar-collapsed .nav-link i {
    font-size: 1.25rem;
}

/* Tooltip on hover for collapsed items */
.sidebar-collapsed .nav-section-header:hover::after,
.sidebar-collapsed .nav-link:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 1rem;
    padding: 0.5rem 0.75rem;
    background: var(--dark-bg);
    color: white;
    border-radius: 6px;
    white-space: nowrap;
    font-size: var(--font-size-xs);
    z-index: 1000;
    pointer-events: none;
    box-shadow: var(--shadow-lg);
}

/* Badge positioning in collapsed sidebar */
.sidebar-collapsed .nav-badge {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    min-width: 18px;
    height: 18px;
    padding: 0.125rem 0.375rem;
    font-size: 0.625rem;
}

/* Ensure smooth transitions for all nav elements */
.nav-section,
.nav-section-header,
.nav-submenu,
.nav-link,
.nav-section-toggle {
    will-change: transform, opacity, max-height;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Animation optimization */
@media (prefers-reduced-motion: reduce) {
    .nav-submenu,
    .nav-section-toggle {
        transition: none;
    }
}

/* Mobile optimizations */
@media screen and (max-width: 1024px) {
    .sidebar-nav {
        max-height: calc(100vh - 120px);
    }

    .nav-submenu.active {
        max-height: 1500px;
    }

    .nav-subsection-title {
        padding-left: 2.5rem;
        font-size: 0.7rem;
    }
}

/* =========================
   UNDO TOAST (Shortened Workflows)
   ========================= */
.undo-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: var(--z-popover);
    opacity: 0;
    visibility: hidden;
    transition: all .25s cubic-bezier(.22,1,.36,1);
    pointer-events: none;
    width: 90%;
    max-width: 440px;
}
.undo-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}
.undo-toast-inner {
    background: var(--dark-bg, #1a1d2e);
    color: #fff;
    border-radius: 12px;
    padding: .85rem 1.25rem;
    box-shadow: 0 8px 32px rgba(0,0,0,.28);
}
.undo-toast-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}
.undo-toast-label {
    font-size: .85rem;
    font-weight: 600;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.undo-toast-btn {
    background: rgba(255,255,255,.18);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,.35);
    border-radius: 6px;
    padding: .35rem .85rem;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
    min-height: 36px;
    min-width: 64px;
    text-align: center;
    font-family: inherit;
}
.undo-toast-btn:hover {
    background: rgba(255,255,255,.3);
}

/* Gmail-style circular countdown — purely visual, replaces the old bar.
   Reuses the existing toast colors: rgba white track + --primary-400 arc. */
.undo-ring {
    position: relative;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.undo-ring-svg {
    width: 34px;
    height: 34px;
    transform: rotate(-90deg);   /* start the arc at 12 o'clock */
    display: block;
}
.undo-ring-track {
    fill: none;
    stroke: rgba(255,255,255,.15);
    stroke-width: 3;
}
.undo-ring-progress {
    fill: none;
    stroke: var(--primary-400, #a78bfa);
    stroke-width: 3;
    stroke-linecap: round;
}
.undo-ring-num {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: 700;
    color: rgba(255,255,255,.85);
    font-variant-numeric: tabular-nums;
}

@media screen and (max-width: 480px) {
    .undo-toast {
        bottom: 1rem;
        width: calc(100% - 2rem);
        max-width: none;
    }
    .undo-toast-btn {
        min-height: 44px;
        min-width: 72px;
        font-size: .85rem;
    }
}

/* =========================
   PRINT BUTTON
   ========================= */
.btn-print {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .85rem;
    border: 1.5px solid var(--border-color, #e2e8f0);
    border-radius: 6px;
    background: white;
    color: var(--text-muted, #64748b);
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
}
.btn-print:hover {
    border-color: #7c3aed;
    color: #7c3aed;
}

/* =========================
   PRINT STYLESHEET
   -------------------------
   The single most important rule set here is the "unclip every scroll
   container" block. Every items table lives inside a wrapper with
   `overflow-x: auto` so it can scroll on screen. On paper there is no
   scrolling: an overflow container simply CLIPS, which is why wide POs
   (standard with prices, timesheet's 9-column roster) printed with the
   right-hand columns — unit price, total, wage — silently missing.
   ========================= */
@page {
    size: A4 portrait;
    margin: 12mm 10mm;
}

@media print {
    /* ── 1. Unclip every horizontal scroll container ──────────────────
       Covers .items-table-wrap, .prv-table-wrap, .mr2b-table-wrap,
       .pc-table-wrap, .resub-ro-table-wrap, .logs-table-wrap, .sit-wrap,
       .items-wrap, .ro-tbl-wrap, .tbl-scroll and the inline
       `style="overflow-x:auto"` divs in review_stage2.html. */
    [class*="table-wrap"],
    [class*="tbl-wrap"],
    [class*="-wrap"],
    [style*="overflow-x"],
    [style*="overflow:"],
    .sit-wrap,
    .items-wrap,
    .tbl-scroll,
    .table-responsive,
    .content-wrapper,
    .page-content,
    .main-content {
        overflow: visible !important;
        max-width: none !important;
    }

    html, body {
        overflow: visible !important;
        width: auto !important;
    }

    /* ── 2. Tables must fit the sheet, never overflow it ───────────── */
    table {
        table-layout: fixed !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        border-collapse: collapse !important;
        break-inside: auto;
    }
    th, td {
        /* nowrap is what makes a table wider than the page — always wrap
           on paper, and break long unbroken strings (URLs, wallet numbers). */
        white-space: normal !important;
        overflow-wrap: anywhere;
        word-break: break-word;
        max-width: none !important;
    }
    /* Repeat the header row on every printed page. */
    thead { display: table-header-group !important; }
    tfoot { display: table-footer-group !important; }
    tr    { break-inside: avoid; page-break-inside: avoid; }

    /* Dark table headers (#1a1d2e with white text) become black-on-grey so
       they stay legible whether or not the user prints backgrounds. */
    th {
        background: #ececec !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    /* Light-green money text is near-invisible on paper. */
    .mono-amount, .sit-mono-amount, .total-amount, .sit-total-amount,
    .num, [class*="amount"], [class*="price"] {
        color: #000 !important;
    }
    .mono-light, .sit-mono-light { color: #333 !important; }

    /* Dense schemas (timesheet = 10 columns) need a smaller face to fit A4. */
    .sit-tbl th, .sit-tbl td,
    .items-tbl th, .items-tbl td {
        font-size: 9px !important;
        padding: 4px 5px !important;
        line-height: 1.3 !important;
    }

    /* Never collapse to the mobile card layout on paper — a printed PO must
       be a real table. Overrides the <=640px stacked-card rules below. */
    .sit-tbl thead, .items-tbl thead, .rwd-tbl thead {
        display: table-header-group !important;
    }
    .sit-tbl tbody tr, .items-tbl tbody tr, .rwd-tbl tbody tr {
        display: table-row !important;
        border: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .sit-tbl td, .items-tbl td, .rwd-tbl td {
        display: table-cell !important;
        position: static !important;
    }
    .sit-tbl td::before, .items-tbl td::before, .rwd-tbl td::before {
        display: none !important;
    }
    /* Any column hidden for small screens comes back on paper. */
    .print-only { display: block !important; }
    /* "Swipe to see all columns" hints are screen affordances only. */
    [class*="scroll-hint"] { display: none !important; }

    .sidebar,
    .navbar,
    .breadcrumb-nav,
    .action-bar,
    .btn-submit,
    .btn-back,
    .btn-print,
    .queue-nav-bar,
    .settings-panel,
    .mobile-overlay,
    .loading-overlay,
    .messages-container,
    .app-footer,
    .track-section-header,
    .page-actions,
    .dpd-action-bar,
    .drv-back,
    .no-print,
    [class*="btn-"] {
        display: none !important;
    }

    body {
        background: white !important;
        color: #000 !important;
        font-size: 11px !important;
    }

    .app-wrapper {
        display: block !important;
    }

    .main-content,
    .page-content,
    .content-wrapper {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .content-wrapper {
        margin-top: 0 !important;
    }

    .card,
    .sec-card,
    .info-card,
    .dpd-section,
    .drv-section {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        break-inside: avoid;
    }

    table {
        border-collapse: collapse;
        width: 100%;
    }
    th, td {
        border: 1px solid #ccc !important;
        padding: 6px 8px !important;
        font-size: 11px !important;
        color: #000 !important;
    }

    .po-number,
    .pr-number-lg {
        font-size: 18px !important;
        font-weight: bold !important;
    }

    .sig-grid {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    .sig-card {
        border: 1px solid #ccc !important;
        break-inside: avoid;
    }

    .page-break-before { page-break-before: always; }
    .page-break-after  { page-break-after: always; }
    .no-break          { break-inside: avoid; }

    body::before {
        content: 'CRP \2014  Procurement System';
        display: block;
        text-align: center;
        font-size: 14px;
        font-weight: bold;
        color: #000;
        padding-bottom: 12px;
        border-bottom: 2px solid #333;
        margin-bottom: 16px;
    }

    body::after {
        content: 'Printed: ' attr(data-print-date);
        display: block;
        text-align: right;
        font-size: 9px;
        color: #666;
        margin-top: 20px;
        border-top: 1px solid #ccc;
        padding-top: 6px;
    }
}

/* ═══════════════════════════════════════════════════════════
   SHARED: PO List Table → Card Layout  (< 768px)
   Add class "rwd-tbl" to any <table> + data-label on <td>s.
   ═══════════════════════════════════════════════════════════ */
@media screen and (max-width: 768px) {
    .rwd-tbl thead { display: none; }
    .rwd-tbl tbody tr {
        display: block;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        margin-bottom: .625rem;
        padding: .75rem 1rem;
        box-shadow: 0 2px 8px rgba(0,0,0,.04);
        position: relative;
    }
    .rwd-tbl tbody tr:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,.08);
    }
    .rwd-tbl td {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: .3rem 0 !important;
        border-top: none !important;
        border-bottom: none !important;
        text-align: left !important;
    }
    .rwd-tbl td::before {
        content: attr(data-label);
        font-size: .65rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .06em;
        color: #868e96;
        flex-shrink: 0;
        min-width: 72px;
        margin-right: .75rem;
    }
    /* First cell = card header (PR / PO#), no label */
    .rwd-tbl td:first-child {
        padding-bottom: .5rem !important;
        margin-bottom: .25rem;
        border-bottom: 1px solid #f1f5f9 !important;
    }
    .rwd-tbl td:first-child::before { display: none; }
    .rwd-tbl td:first-child .pr-line { font-size: .9rem; }
    /* Last cell = action button, top-right of card */
    .rwd-tbl td:last-child {
        position: absolute;
        top: .75rem;
        right: .75rem;
        padding: 0 !important;
    }
    .rwd-tbl td:last-child::before { display: none; }
    /* Mobile-amount duplicate hidden — amount row visible in card */
    .rwd-tbl [class*="mobile-amount"] { display: none !important; }
    /* Empty-state row keeps block display */
    .rwd-tbl td[colspan] {
        display: block !important;
        text-align: center !important;
        padding: 2rem 1rem !important;
    }
    .rwd-tbl td[colspan]::before { display: none; }
}

/* =========================
   SHARED ACTION PANEL STYLES
   Used by _action_panel.html, _action_panel_shortened_manager.html,
   _action_panel_rejection_review.html
   ========================= */
.action-panel-wrapper {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}
.action-selector {
    margin-bottom: 1rem;
}
.action-select-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #868e96;
    margin-bottom: .35rem;
}
.action-select-label i { color: var(--primary-500); margin-right: .3rem; }
.action-select-input {
    width: 100%;
    max-width: 360px;
    padding: .6rem .85rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: #495057;
    background: #fff;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    padding-right: 2rem;
    cursor: pointer;
    transition: border-color .15s;
}
.action-select-input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb),.1);
}
.action-form {
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e9ecef;
    animation: fadeSlide .2s ease;
}
@keyframes fadeSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.approve-form { border-left: 3px solid #7fba8a; }
.reject-form { border-left: 3px solid #ef4444; }
.apanel-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1.25rem;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.apanel-green {
    background: #dcfce7;
    color: #16a34a;
    border-bottom: 1px solid #bbf7d0;
}
.apanel-red {
    background: #fee2e2;
    color: #dc2626;
    border-bottom: 1px solid #fecaca;
}
.apanel-body {
    padding: 1.25rem;
    background: #fff;
}
.apanel-field { margin-bottom: 1rem; }
.apanel-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #868e96;
    margin-bottom: .3rem;
}
.apanel-label .req { color: #ef4444; }
.apanel-label .opt { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 10px; color: #94a3b8; }
.apanel-input {
    width: 100%;
    padding: .55rem .85rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: #495057;
    background: #fff;
    transition: border-color .15s;
}
.apanel-input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb),.1);
}
select.apanel-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    padding-right: 2rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.apanel-textarea {
    min-height: 80px;
    resize: vertical;
}
.reject-textarea:invalid,
.reject-textarea.has-error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239,68,68,.1);
}
.char-counter {
    text-align: right;
    font-size: 10px;
    color: #94a3b8;
    margin-top: .2rem;
}
.field-error {
    color: #dc2626;
    font-size: 11px;
    font-weight: 600;
    margin-top: .3rem;
}
.field-error i { margin-right: .2rem; }
.apanel-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .6rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    transition: all .2s;
}
.apanel-btn-green {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    box-shadow: 0 4px 12px rgba(22,163,74,.3);
}
.apanel-btn-green:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(22,163,74,.4); }
.apanel-btn-red {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    box-shadow: 0 4px 12px rgba(220,38,38,.3);
}
.apanel-btn-red:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(220,38,38,.4); }
.apanel-btn:disabled { opacity: .6; pointer-events: none; }
.btn-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.info-banner, .warn-banner {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem .85rem;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 1rem;
}
.info-banner { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.warn-banner { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
@media screen and (max-width: 768px) {
    .apanel-body { padding: 1rem; }
    .apanel-btn { width: 100%; justify-content: center; }
}