@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* CSS Variables for consistent theming - Enhanced */
:root {
    /* Enhanced Color Palette */
    --color-primary: #1a237e;
    --color-primary-dark: #0d1b5c;
    --color-primary-light: #534bae;
    --color-secondary: #455a64;
    --color-accent: #1565c0;
    --color-accent-light: #5e92f3;
    --color-success: #2e7d32;
    --color-success-light: #4caf50;
    --color-warning: #f57c00;
    --color-warning-light: #ff9800;
    --color-danger: #c62828;
    --color-danger-light: #ef5350;
    --color-info: #00838f;
    --color-info-light: #26c6da;
    
    /* Enhanced Grayscale */
    --color-light: #f5f7fa;
    --color-light-gray: #e0e0e0;
    --color-gray: #9e9e9e;
    --color-dark-gray: #616161;
    --color-dark: #212121;
    --color-text: #424242;
    
    /* Backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    
    /* Enhanced Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.18);
    
    /* Spacing */
    --spacing-xxs: 0.25rem;
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --spacing-xxl: 4rem;
    
    /* Border Radius */
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* 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);
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-mono: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    
    /* Z-index layers */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 1000;
    --z-modal-top: 1100;
    --z-popover: 2000;
    --z-tooltip: 3000;
}

/* Inter font imported at top of file */

/* Reset and Base Styles - Enhanced */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: var(--color-text);
    line-height: 1.6;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Dashboard Layout - Enhanced */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

/* Enhanced Sidebar */
.dashboard-sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 50;
    transition: width var(--transition-base);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-xs);
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: var(--font-size-xl);
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    letter-spacing: 1px;
}

.sidebar-brand h2 {
    background: linear-gradient(135deg, #fff 0%, #e2e8f0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.8rem;
}

/* Rail toggle. Rotates its chevron when the sidebar is collapsed. */
.sidebar-collapse-btn {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 0.8rem;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-base);
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.sidebar-collapse-btn i {
    transition: transform var(--transition-base);
}

/* Identity card — avatar initials + name + role chip. */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: var(--spacing-sm) var(--spacing-sm) 0;
    padding: 0.6rem 0.7rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
}

.sidebar-avatar {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-accent-light) 0%, var(--color-accent) 100%);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.sidebar-user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.sidebar-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: rgba(255, 255, 255, 0.6);
}

/* The nav is the only scrolling region, so the brand / identity card / footer stay
   put while a long queue list scrolls. */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: var(--spacing-md) 0;
    gap: var(--spacing-xs);
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.35); }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.875rem 1.5rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: background var(--transition-base), color var(--transition-base), transform var(--transition-base);
    margin: 0 var(--spacing-sm);
    border-radius: var(--radius-md);
    position: relative;
    font-weight: 500;
}

/* Left accent bar. Scales in from the vertical centre so the sidebar can stay
   overflow-visible (needed for the collapsed-rail tooltips). */
.sidebar-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
    background: var(--color-accent-light);
    transform: scaleY(0);
    transition: transform var(--transition-base);
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: translateX(4px);
}

.sidebar-link:hover::before {
    transform: scaleY(1);
}

.sidebar-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sidebar-link.active::before {
    transform: scaleY(1);
}

.sidebar-link > i {
    width: 20px;
    flex-shrink: 0;
    text-align: center;
    font-size: 1.1rem;
    transition: transform var(--transition-base);
}

.sidebar-link:hover > i {
    transform: scale(1.1);
}

.sidebar-link-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Action buttons (exports + bulk operations) rendered inside the sidebar. They reuse
   .sidebar-link for layout/hover, so here we only strip the native <button> chrome and
   make them line up like the <a> nav links. Visibility is toggled from dashboard.js. */
.sidebar-nav button.sidebar-action {
    background: none;
    border: none;
    width: auto;
    text-align: left;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    cursor: pointer;
}

/* ── Collapsible groups (Work Queues / Exports / Bulk Actions) ───────────────── */

.sidebar-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    margin-top: 0.35rem;
}

.sidebar-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: auto;
    margin: 0 var(--spacing-sm);
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: rgba(255, 255, 255, 0.55);
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-group-header:hover {
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.9);
}

.sidebar-group-icon {
    width: 16px;
    text-align: center;
    font-size: 0.8rem;
}

.sidebar-group-title {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Running total shown next to the "Work Queues" heading. */
.sidebar-group-total {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0;
    color: rgba(255, 255, 255, 0.45);
}

.sidebar-group-chevron {
    font-size: 0.65rem;
    transition: transform var(--transition-base);
}

.sidebar-group.is-collapsed .sidebar-group-chevron {
    transform: rotate(-90deg);
}

.sidebar-group-items {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    max-height: 1200px;
    opacity: 1;
    overflow: hidden;
    transition: max-height var(--transition-slow), opacity var(--transition-fast);
}

.sidebar-group.is-collapsed .sidebar-group-items {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

/* ── Queue links + count badges ──────────────────────────────────────────────── */

.sidebar-queue {
    padding: 0.6rem 1.5rem;
    font-size: 0.83rem;
    font-weight: 500;
}

.sidebar-queue > i {
    font-size: 0.95rem;
}

/* Queue with nothing in it stays visible but recedes. */
.sidebar-queue.is-empty {
    color: rgba(255, 255, 255, 0.42);
}

.sidebar-badge {
    flex-shrink: 0;
    margin-left: auto;
    min-width: 22px;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
    font-variant-numeric: tabular-nums;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-badge--warn    { background: rgba(255, 152, 0, 0.9);  color: #1a1a1a; }
.sidebar-badge--danger  { background: rgba(239, 83, 80, 0.95); color: #fff; }
.sidebar-badge--success { background: rgba(76, 175, 80, 0.85); color: #06210a; }
.sidebar-badge--info    { background: rgba(94, 146, 243, 0.9); color: #06152e; }
.sidebar-badge--zero {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
}

/* One-shot pulse when a queue count changes on refresh. */
@keyframes sidebarBadgeBump {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.35); }
    100% { transform: scale(1); }
}

.sidebar-badge.is-bumping {
    animation: sidebarBadgeBump 450ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Thin separator between the nav links and the action groups. */
.sidebar-divider {
    height: 1px;
    margin: 0.5rem 1.25rem;
    background: rgba(255, 255, 255, 0.12);
}

/* ── Sidebar footer: manual refresh + last-updated stamp ─────────────────────── */

.sidebar-footer {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.75rem var(--spacing-sm) var(--spacing-sm);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.12);
}

.sidebar-refresh-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-refresh-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.sidebar-refresh-btn:disabled {
    cursor: progress;
    opacity: 0.75;
}

.sidebar-refresh-btn.is-spinning i {
    animation: sidebarSpin 800ms linear infinite;
}

@keyframes sidebarSpin {
    to { transform: rotate(360deg); }
}

.sidebar-updated {
    font-size: 0.66rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Collapsed rail ──────────────────────────────────────────────────────────── */

.dashboard-sidebar.is-collapsed { width: 76px; }

.dashboard-sidebar.is-collapsed .sidebar-brand {
    flex-direction: column;
    gap: 0.5rem;
    padding: var(--spacing-sm) 0.5rem;
}

.dashboard-sidebar.is-collapsed .sidebar-brand h2 { font-size: 1.15rem; }
.dashboard-sidebar.is-collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }

.dashboard-sidebar.is-collapsed .sidebar-link-text,
.dashboard-sidebar.is-collapsed .sidebar-user-meta,
.dashboard-sidebar.is-collapsed .sidebar-group-title,
.dashboard-sidebar.is-collapsed .sidebar-group-total,
.dashboard-sidebar.is-collapsed .sidebar-group-chevron,
.dashboard-sidebar.is-collapsed .sidebar-updated {
    display: none;
}

.dashboard-sidebar.is-collapsed .sidebar-user,
.dashboard-sidebar.is-collapsed .sidebar-link,
.dashboard-sidebar.is-collapsed .sidebar-group-header,
.dashboard-sidebar.is-collapsed .sidebar-refresh-btn {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.dashboard-sidebar.is-collapsed .sidebar-link:hover { transform: none; }

/* Counts shrink to a dot badge pinned to the icon. */
.dashboard-sidebar.is-collapsed .sidebar-badge {
    position: absolute;
    top: 4px;
    right: 10px;
    margin: 0;
    min-width: 0;
    padding: 0;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    font-size: 0;
    line-height: 0;
    overflow: hidden;
}

.dashboard-sidebar.is-collapsed .sidebar-badge--zero { display: none; }

/* Hover tooltips replace the labels in the rail. Rendered into <body> by
   dashboard.js so the nav's own scroll overflow can't clip them. */
.sidebar-tooltip {
    position: fixed;
    z-index: var(--z-tooltip);
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-xs);
    background: rgba(15, 23, 42, 0.96);
    color: #fff;
    font-family: var(--font-family);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    pointer-events: none;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.sidebar-tooltip.is-visible {
    opacity: 1;
    transform: translateX(0);
}

/* In the horizontal mobile sidebar the labels/dividers/chrome would break the row —
   the groups flatten into the same scrolling strip as the plain links. */
@media (max-width: 768px) {
    .sidebar-divider,
    .sidebar-group-header,
    .sidebar-collapse-btn,
    .sidebar-user,
    .sidebar-footer {
        display: none;
    }

    .sidebar-group:not(.hidden),
    .sidebar-group-items {
        display: contents;
    }

    /* The rail state is desktop-only — undo it if it was left collapsed on a
       larger screen, so the mobile row keeps its labels and padding. */
    .dashboard-sidebar.is-collapsed { width: 100%; }
    .dashboard-sidebar.is-collapsed .sidebar-link-text { display: inline; }
    .dashboard-sidebar.is-collapsed .sidebar-link {
        padding-left: var(--spacing-sm);
        padding-right: var(--spacing-sm);
    }
    .dashboard-sidebar.is-collapsed .sidebar-badge {
        position: static;
        width: auto;
        height: auto;
        min-width: 22px;
        padding: 0.1rem 0.4rem;
        font-size: 0.68rem;
        line-height: 1.5;
    }
    .sidebar-tooltip { display: none; }
}

/* Enhanced Dashboard Container */
.dashboard-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Enhanced Header Styles */
.dashboard-header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    color: white;
    padding: var(--spacing-md) var(--spacing-xl);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(10px);
    background-blend-mode: overlay;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

#dashboard-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 0%, #e2e8f0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auto-refresh-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    font-size: var(--font-size-xs);
    font-weight: 500;
    letter-spacing: 0.2px;
    white-space: nowrap;
    min-width: 150px;
    justify-content: center;
    transition: all var(--transition-base);
}

.auto-refresh-indicator .refresh-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ae6b4;
    box-shadow: 0 0 0 4px rgba(154, 230, 180, 0.2);
}

.auto-refresh-indicator.refreshing .refresh-dot {
    background: #fbd38d;
    box-shadow: 0 0 0 4px rgba(251, 211, 141, 0.2);
    animation: pulseRefresh 1s ease-in-out infinite;
}

.auto-refresh-indicator.paused .refresh-dot {
    background: #feb2b2;
    box-shadow: 0 0 0 4px rgba(254, 178, 178, 0.2);
}

@keyframes pulseRefresh {
    0%, 100% {
        transform: scale(1);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.6;
    }
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.user-role {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 500;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all var(--transition-base);
}

.user-role:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.logout-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    backdrop-filter: blur(10px);
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Enhanced Main Content */
.dashboard-main {
    flex: 1;
    padding: var(--spacing-xl);
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Enhanced State Containers */
.state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--spacing-xl);
}

.loading-state .loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(var(--color-accent-light), 0.2);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: var(--spacing-md);
    box-shadow: 0 4px 20px rgba(var(--color-accent), 0.2);
}

.loading-text {
    color: var(--color-gray);
    font-size: var(--font-size-lg);
    font-weight: 500;
    margin-top: var(--spacing-md);
}

/* ── First-load welcome panel ──────────────────────────────────────────────
   Lives inside #loading-state as a sibling of the spinner. Shown only while
   dashboard-welcome.js has .is-welcome on the host; removing that class
   restores the plain spinner above with no other change. */

.welcome-panel {
    display: none;
}

.loading-state.is-welcome .loading-spinner,
.loading-state.is-welcome .loading-text {
    display: none;
}

.loading-state.is-welcome {
    text-align: left;
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.loading-state.is-welcome.is-leaving {
    opacity: 0;
    transform: translateY(-8px);
}

.loading-state.is-welcome .welcome-panel {
    display: block;
    width: 100%;
    max-width: 480px;
}

.welcome-greeting {
    font-size: var(--font-size-3xl);
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--color-dark);
    animation: welcomeRise var(--transition-slow) ease-out both;
}

.welcome-subline {
    margin-top: var(--spacing-xxs);
    font-size: var(--font-size-base);
    color: var(--color-gray);
    animation: welcomeRise var(--transition-slow) ease-out 60ms both;
}

.welcome-steps {
    list-style: none;
    margin: var(--spacing-lg) 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.welcome-step {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: var(--font-size-sm);
    color: var(--color-gray);
    transition: color var(--transition-base);
}

.welcome-step-icon {
    flex: none;
    width: 18px;
    height: 18px;
    position: relative;
    border-radius: var(--radius-full);
}

/* Pending: a quiet ring that spins. Deliberately smaller and calmer than the
   full-page spinner it replaces. */
.welcome-step-icon::before {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: var(--radius-full);
    border: 2px solid var(--color-light-gray);
    border-top-color: var(--color-accent-light);
    animation: spin 900ms linear infinite;
}

.welcome-step.is-done,
.welcome-step.is-failed {
    color: var(--color-text);
}

.welcome-step.is-done .welcome-step-icon::before,
.welcome-step.is-failed .welcome-step-icon::before {
    content: none;
}

.welcome-step.is-done .welcome-step-icon::after {
    content: '\2713';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    background: var(--color-success);
    border-radius: var(--radius-full);
    animation: welcomeTick var(--transition-base) cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.welcome-step.is-done .welcome-step-label {
    animation: welcomeRise var(--transition-base) ease-out both;
}

/* Failed: an em dash, not a tick. The request behind this row did not succeed. */
.welcome-step.is-failed {
    color: var(--color-gray);
}

.welcome-step.is-failed .welcome-step-icon::after {
    content: '\2014';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--color-gray);
}

@keyframes welcomeRise {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@keyframes welcomeTick {
    from { opacity: 0; transform: scale(0.4); }
    to   { opacity: 1; transform: scale(1); }
}

/* Reduced motion: same information, no movement. The JS drops its stagger too,
   so every row lands at once. */
@media (prefers-reduced-motion: reduce) {
    .welcome-greeting,
    .welcome-subline,
    .welcome-step.is-done .welcome-step-label,
    .welcome-step.is-done .welcome-step-icon::after {
        animation: none;
    }

    .welcome-step-icon::before {
        animation: none;
        border-top-color: var(--color-light-gray);
    }

    .loading-state.is-welcome {
        transition: none;
    }
}

@media (max-width: 480px) {
    .welcome-greeting {
        font-size: var(--font-size-2xl);
    }
}

.error-state {
    background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
    border: 2px solid var(--color-danger-light);
}

.error-state i {
    font-size: 3.5rem;
    color: var(--color-danger);
    margin-bottom: var(--spacing-md);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

#error-message {
    color: var(--color-dark);
    margin-bottom: var(--spacing-lg);
    max-width: 500px;
    font-size: var(--font-size-base);
    line-height: 1.6;
}

#retry-btn {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-light) 100%);
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-weight: 600;
    transition: all var(--transition-base);
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(var(--color-accent), 0.3);
}

#retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--color-accent), 0.4);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Enhanced Sections Container */
.sections-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: var(--spacing-xl);
    margin-top: var(--spacing-md);
    animation: fadeIn 0.5s ease-out;
}

/* Section cards that contain invoice tables always span full width */
.section-card:has(.invoice-table-container) {
    grid-column: 1 / -1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced Section Card Styles */
.section-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, #f8fafc 100%);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: var(--spacing-xl);
    transition: all var(--transition-base);
    border: 1px solid rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
}

/* Tighter padding for cards that hold wide invoice tables */
.section-card:has(.invoice-table-container) {
    padding: var(--spacing-lg);
}

.section-card:has(.invoice-table-container) .invoice-table-container {
    margin-top: var(--spacing-sm);
}

/* No lift animation on wide table cards — avoids clipping */
.section-card:has(.invoice-table-container):hover {
    transform: none;
    box-shadow: var(--shadow-lg);
}

.section-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--color-accent), var(--color-accent-light));
    opacity: 0;
    transition: opacity var(--transition-base);
}

.section-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
    border-color: rgba(var(--color-accent), 0.2);
}

.section-card:hover::before {
    opacity: 1;
}

/* Landing offset + flash used when a sidebar "Work Queues" entry jumps to a section.
   The sticky header is ~88px tall, so leave room for it above the card. */
.section-card {
    scroll-margin-top: 104px;
}

@keyframes sectionJumpFlash {
    0%   { box-shadow: 0 0 0 0 rgba(21, 101, 192, 0.55), var(--shadow-md); }
    60%  { box-shadow: 0 0 0 8px rgba(21, 101, 192, 0); }
    100% { box-shadow: 0 0 0 0 rgba(21, 101, 192, 0), var(--shadow-md); }
}

.section-card.is-jump-target {
    animation: sectionJumpFlash 1s ease-out;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid #eef0f5;
}

.section-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.section-title::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background: var(--color-accent);
    border-radius: 50%;
}

.section-count {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-light) 100%);
    color: white;
    padding: 0.375rem 1rem;
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 700;
    min-width: 32px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(var(--color-accent), 0.3);
}

/* Enhanced Table Styles */
.invoice-table-container {
    overflow: auto;
    max-height: 580px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-light-gray);
    box-shadow: var(--shadow-sm);
}

.invoice-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--font-size-sm);
    min-width: 900px;
}

.invoice-table th {
    text-align: left;
    padding: 0.875rem 1.1rem;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
    color: rgba(255, 255, 255, 0.92);
    border-bottom: 2px solid rgba(255, 255, 255, 0.15);
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.invoice-table th:first-child {
    border-radius: var(--radius-sm) 0 0 0;
}

.invoice-table th:last-child {
    border-radius: 0 var(--radius-sm) 0 0;
}

/* Sticky Actions column — pins the last column to the right edge during horizontal scroll */
.invoice-table.has-sticky-actions th:last-child {
    position: sticky;
    right: 0;
    z-index: 11; /* above the regular sticky header (z-index: 10) */
    background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
    box-shadow: -3px 0 8px rgba(0, 0, 0, 0.18);
}

.invoice-table.has-sticky-actions td:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #ffffff;
    box-shadow: -3px 0 8px rgba(0, 0, 0, 0.08);
}

/* Keep zebra striping on the sticky cell */
.invoice-table.has-sticky-actions tbody tr:nth-child(even) td:last-child {
    background: #f9f9f9;
}

/* ── Feature: Overdue scheduled-payment indicator ────────────────────────── */
.overdue-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: linear-gradient(135deg, #c62828 0%, #ef5350 100%);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-full);
    margin-top: 0.3rem;
    white-space: nowrap;
}

.invoice-table tbody tr.overdue-row td {
    background-color: rgba(198, 40, 40, 0.04) !important;
}

.invoice-table.has-sticky-actions tbody tr.overdue-row td:last-child {
    background: #fdf3f3 !important;
}

/* ── Feature: Invoice age warning badge ───────────────────────────────────── */
.age-warning-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: linear-gradient(135deg, #e65100 0%, #ff9800 100%);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-full);
    margin-top: 0.3rem;
    white-space: nowrap;
}

/* Escalated state — invoice waiting 14+ days. Red to separate "stuck" from merely "aging". */
.age-warning-badge--urgent {
    background: linear-gradient(135deg, #c62828 0%, #ef5350 100%);
    animation: pulseRefresh 1.6s ease-in-out infinite;
}

/* ── Feature: Client-side column sort ────────────────────────────────────── */
.invoice-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.invoice-table th.sortable:hover {
    background: linear-gradient(135deg, #283593 0%, #3949ab 100%);
}

.invoice-table th.sortable::after {
    content: ' ⇅';
    font-size: 0.65rem;
    opacity: 0.5;
    font-weight: 400;
}

.invoice-table th.sort-asc::after {
    content: ' ▲';
    opacity: 1;
}

.invoice-table th.sort-desc::after {
    content: ' ▼';
    opacity: 1;
}

/* ── Feature: Section collapse / expand ──────────────────────────────────── */
.section-header {
    cursor: pointer;
}

.section-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    color: var(--color-dark-gray);
    border-radius: var(--radius-xs);
    line-height: 1;
    flex-shrink: 0;
}

.section-collapse-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

.section-collapse-btn i {
    transition: transform var(--transition-base);
    font-size: 0.8rem;
}

.section-card.collapsed .section-collapse-btn i {
    transform: rotate(-90deg);
}

.section-card.collapsed .section-content,
.section-card.collapsed .empty-state {
    display: none;
}

/* ── Section-level inline search ────────────────────────────────────────── */
.section-search-wrap {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 0.2rem 0.55rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    margin-right: 0.4rem;
}
.section-search-wrap:focus-within {
    border-color: var(--color-accent, #6366f1);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
    background: #fff;
}
.section-search-icon {
    color: #9ca3af;
    font-size: 0.72rem;
    flex-shrink: 0;
    pointer-events: none;
}
.section-search-input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.8rem;
    color: var(--color-text, #1f2937);
    width: 140px;
    padding: 0;
}
.section-search-input::placeholder {
    color: #b0b7c3;
}
.section-search-clear {
    background: none;
    border: none;
    padding: 0 2px;
    cursor: pointer;
    color: #9ca3af;
    font-size: 0.7rem;
    display: inline-flex;
    align-items: center;
    line-height: 1;
    transition: color 0.1s;
}
.section-search-clear:hover {
    color: #ef4444;
}
/* Shrink the input on small screens */
@media (max-width: 768px) {
    .section-search-input { width: 90px; }
}

/* Table cell base */
.invoice-table td {
    padding: 0.875rem 1.1rem;
    border-bottom: 1px solid #eef0f5;
    vertical-align: top;
    line-height: 1.5;
    color: var(--color-text);
}

/* Zebra striping for readability — transparent so it works in both light & dark mode */
.invoice-table tbody tr:nth-child(even) td {
    background-color: rgba(0, 0, 0, 0.025);
}

/* First column — Invoice ID */
.invoice-table td:first-child,
.invoice-table th:first-child {
    min-width: 130px;
    padding-left: 1.25rem;
}

/* Amount columns — right-align with monospace */
.invoice-table td:nth-child(6),
.invoice-table td:nth-child(7) {
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--color-text);
}

.invoice-table th:nth-child(6),
.invoice-table th:nth-child(7) {
    text-align: right;
}

/* Enhanced UTR Number Styling */
.utr-list {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #eef6ff 0%, #ddeafe 100%);
    border: 1px solid rgba(59, 130, 246, 0.5);
    border-radius: var(--radius-md);
    padding: 0.3rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #1e3a8a;
    font-family: var(--font-mono);
    margin-top: 0.4rem;
    margin-left: 0;
    line-height: 1.3;
    max-width: 220px;
    white-space: normal;
    word-break: break-all;
    box-shadow: 0 1px 6px rgba(59, 130, 246, 0.12);
}

.utr-list::before {
    content: 'UTR';
    background: #1e40af;
    color: white;
    padding: 0.1rem 0.35rem;
    border-radius: var(--radius-xs);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Enhanced small muted text for secondary info */
.small.muted {
    font-size: 0.72rem;
    color: var(--color-gray);
    font-weight: 400;
    margin-top: 0.25rem;
    margin-left: 0;
    display: block;
    line-height: 1.3;
}

/* text-muted utility */
.text-muted {
    color: var(--color-gray) !important;
    font-size: var(--font-size-xs);
}

/* small utility inside tables */
.invoice-table small,
.invoice-table .small {
    font-size: 0.72rem;
    color: var(--color-gray);
    display: block;
    margin-top: 0.2rem;
    line-height: 1.3;
}

.utr-has-tooltip {
    position: relative;
    cursor: help;
}

.utr-has-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    max-width: 280px;
    white-space: normal;
    word-break: break-all;
    background: #0f172a;
    color: #f8fafc;
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-size: 0.7rem;
    line-height: 1.3;
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: all var(--transition-fast);
    z-index: var(--z-tooltip);
}

.utr-has-tooltip:hover::after {
    opacity: 1;
    transform: translateY(0);
}

.small.muted.utr-list {
    margin-left: 0;
}

/* Enhanced Total Company Spend Section */
.spend-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-lg);
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-light);
}

.spend-metric {
    text-align: center;
    padding: var(--spacing-md);
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-base);
}

.spend-metric:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.metric-label {
    font-size: var(--font-size-sm);
    color: var(--color-gray);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-xs);
}

.metric-value {
    font-size: var(--font-size-xl);
    font-weight: 800;
    color: var(--color-text);
}

.metric-value.primary {
    color: var(--color-primary);
}

.metric-value.success {
    color: var(--color-success);
}

.metric-value.warning {
    color: var(--color-warning);
}

.department-spend-table {
    margin-top: var(--spacing-lg);
}

.table-subtitle {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: var(--spacing-md);
    text-align: center;
}

.completion-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 45px;
}

.completion-badge.success {
    background: linear-gradient(135deg, var(--color-success) 0%, var(--color-success-light) 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(var(--color-success), 0.3);
}

.completion-badge.warning {
    background: linear-gradient(135deg, var(--color-warning) 0%, var(--color-warning-light) 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(var(--color-warning), 0.3);
}

.completion-badge.danger {
    background: linear-gradient(135deg, var(--color-danger) 0%, var(--color-danger-light) 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(var(--color-danger), 0.3);
}

/* Enhanced column widths for better layout */
.invoice-table th:nth-child(1) { /* Invoice ID */
    min-width: 120px;
    width: 120px;
}

.invoice-table tbody tr {
    transition: background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.invoice-table tbody tr:hover td {
    /* Transparent overlay so text stays visible in both light & dark mode */
    background-color: rgba(99, 102, 241, 0.12) !important;
    box-shadow: inset 3px 0 0 var(--color-accent);
}

.invoice-table tbody tr:last-child td {
    border-bottom: none;
}

/* Enhanced Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 1rem;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 80px;
    gap: 0.25rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.status-pending {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    border: 1px solid #ffd166;
}

.status-approved {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border: 1px solid #b7efb7;
}

.status-rejected {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border: 1px solid #f1aeb5;
}

.status-paid {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
    border: 1px solid #86cfda;
}

.status-scheduled {
    background: linear-gradient(135deg, #e2e3e5 0%, #d6d8db 100%);
    color: #383d41;
    border: 1px solid #c6c8ca;
}

/* CXO enhancements: property/department emphasis */
.meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.28rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    white-space: nowrap;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.8);
}

.meta-badge i {
    font-size: 0.75rem;
    opacity: 0.9;
}

.meta-property {
    color: #ffffff;
    background: linear-gradient(135deg, #1565c0 0%, #1976d2 100%);
    border-color: rgba(21, 101, 192, 0.5);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}

.meta-department {
    color: #065f46;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-color: rgba(6, 95, 70, 0.25);
}

/* Physical Invoice Status Badges */
.status-physical-submitted {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border: 1px solid #b7efb7;
}

.status-physical-not-submitted {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    border: 1px solid #ffd166;
}

/* Enhanced Button Styles */
.action-buttons {
    display: flex;
    gap: 0.4rem;
    flex-wrap: nowrap;
    align-items: center;
    min-width: max-content;
}

/* Stack vertically in narrow cells */
.invoice-table td .action-buttons {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    min-width: 120px;
}

/* Buttons: colour, size, padding, radius and typography now come from
   css/components.css (this page opts in via <body class="ui-theme">).
   The ripple ::after and the coloured glow/lift are dropped with them — the
   shared system is flat. .btn-info went too: nothing in the markup used it.
   Only the disabled reset is kept; components.css sets opacity and cursor but
   cannot know this page animates transform/box-shadow on hover. */
.btn:disabled {
    transform: none !important;
    box-shadow: none !important;
}


/* Enhanced Empty State */
.empty-state {
    text-align: center;
    padding: var(--spacing-xxl) var(--spacing-xl);
    color: var(--color-gray);
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--color-light-gray);
}

.empty-icon {
    font-size: 3rem;
    color: var(--color-light-gray);
    margin-bottom: var(--spacing-md);
    opacity: 0.7;
}

.empty-icon i {
    font-size: 4rem;
}

.empty-message {
    font-size: var(--font-size-lg);
    font-weight: 500;
    color: var(--color-dark-gray);
    margin-bottom: var(--spacing-xs);
}

.empty-state p {
    color: var(--color-gray);
    font-size: var(--font-size-sm);
    max-width: 300px;
    margin: 0 auto;
}

/* Enhanced Invoice Row */
.invoice-row {
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

/* Enhanced Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    animation: modalFadeIn var(--transition-base);
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(4px);
    }
}

.modal.show {
    display: flex;
}

/* Invoice detail modal must always sit above the bulk-accounts modal */
#invoice-modal {
    z-index: var(--z-modal-top);
}

.modal-content {
    background: linear-gradient(135deg, var(--bg-card) 0%, #f8fafc 100%);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.8);
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-xl);
    border-bottom: 1px solid var(--color-light);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-header h3 {
    font-size: var(--font-size-xl);
    font-weight: 600;
    background: linear-gradient(135deg, #fff 0%, #e2e8f0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 1.5rem;
    cursor: pointer;
    color: white;
    transition: all var(--transition-base);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-body {
    padding: var(--spacing-xl);
}

.modal-details {
    display: grid;
    gap: var(--spacing-md);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-md) 0;
    border-bottom: 1px solid var(--color-light);
    transition: all var(--transition-fast);
}

.detail-row:hover {
    background: var(--bg-hover);
    padding-left: var(--spacing-sm);
    padding-right: var(--spacing-sm);
    border-radius: var(--radius-sm);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 600;
    color: var(--color-primary);
    min-width: 160px;
    font-size: var(--font-size-sm);
}

.detail-value {
    color: var(--color-dark);
    text-align: right;
    flex: 1;
    font-weight: 500;
}

/* Split View Styles */
.split-view-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
    height: 100%;
}

.split-panel {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    padding: var(--spacing-md) 0;
}

.split-panel:first-child {
    border-right: 2px solid var(--color-light);
    padding-right: var(--spacing-lg);
}

.split-panel:last-child {
    padding-left: var(--spacing-lg);
}

.panel-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-primary);
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 2px solid var(--color-accent);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.invoice-panel .panel-title::before {
    content: '\f571';
    font-family: 'Font Awesome 6 Free';
    font-weight: 600;
    color: var(--color-primary);
}

.vendor-panel .panel-title::before {
    content: '\f54f';
    font-family: 'Font Awesome 6 Free';
    font-weight: 600;
    color: var(--color-primary);
}

.invoice-details,
.vendor-details {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.bank-details-section {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 2px solid var(--color-light);
}

.bank-details-title {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: var(--spacing-md);
    padding: 0 var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.bank-details-title::before {
    content: '\f19a';
    font-family: 'Font Awesome 6 Free';
    font-weight: 600;
}

.modal-pdf-section {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-light);
    text-align: center;
}

.modal-pdf-section .btn {
    margin-top: var(--spacing-md);
}

/* Enhanced Footer */
.dashboard-footer {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    text-align: center;
    padding: var(--spacing-lg) var(--spacing-xl);
    margin-top: var(--spacing-xl);
    position: relative;
    overflow: hidden;
}

.dashboard-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}

.dashboard-footer p {
    position: relative;
    z-index: 1;
    font-size: var(--font-size-sm);
    opacity: 0.9;
    font-weight: 500;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
    background: var(--color-accent);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent-light);
}

/* Selection Styling */
::selection {
    background-color: rgba(var(--color-accent), 0.3);
    color: var(--color-primary);
}

/* Focus Styles */
*:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

/* Print Styles */
@media print {
    .dashboard-sidebar,
    .dashboard-header,
    .dashboard-footer,
    .action-buttons,
    .logout-btn {
        display: none !important;
    }
    
    .dashboard-container {
        padding: 0;
    }
    
    .section-card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }
}

/* Enhanced Responsive Design */
@media (max-width: 1024px) {
    .sections-container {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: var(--spacing-lg);
    }
    
    .dashboard-sidebar {
        width: 220px;
    }
    
    .dashboard-header {
        padding: var(--spacing-md) var(--spacing-lg);
    }
}

@media (max-width: 768px) {
    .dashboard-layout {
        flex-direction: column;
    }
    
    .dashboard-sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 0.5rem;
        gap: 0;
    }
    
    .sidebar-link {
        white-space: nowrap;
        flex: 1;
        min-width: 120px;
        justify-content: center;
        margin: 0 var(--spacing-xs);
        padding: 0.75rem var(--spacing-sm);
    }
    
    .sections-container {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    .header-content {
        flex-direction: column;
        gap: var(--spacing-sm);
        text-align: center;
    }
    
    .user-info {
        flex-direction: column;
        gap: var(--spacing-sm);
        width: 100%;
    }
    
    .user-role,
    .logout-btn {
        width: 100%;
        justify-content: center;
    }
    
    .dashboard-main {
        padding: var(--spacing-md);
    }
    
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: var(--spacing-sm);
    }

    /* Responsive split view */
    .split-view-container {
        grid-template-columns: 1fr;
    }

    .split-panel:first-child {
        border-right: none;
        border-bottom: 2px solid var(--color-light);
        padding-right: 0;
        padding-bottom: var(--spacing-lg);
    }

    .split-panel:last-child {
        padding-left: 0;
        padding-top: var(--spacing-lg);
    }
}

@media (max-width: 480px) {
    .section-card {
        padding: var(--spacing-md);
        border-radius: var(--radius-lg);
    }
    
    .invoice-table-container {
        max-height: 300px;
    }
    
    .invoice-table {
        min-width: 500px;
        font-size: var(--font-size-xs);
    }
    
    .invoice-table th,
    .invoice-table td {
        padding: 0.5rem 0.75rem;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: var(--spacing-xs);
    }
    
    .btn {
        width: 100%;
        justify-content: center;
        padding: 0.75rem 1rem;
    }
    
    .detail-row {
        flex-direction: column;
        gap: var(--spacing-xs);
    }
    
    .detail-label,
    .detail-value {
        text-align: left;
        width: 100%;
    }
    
    .status-badge {
        min-width: 70px;
        padding: 0.25rem 0.75rem;
        font-size: 0.7rem;
    }
    
    .modal-header,
    .modal-body {
        padding: var(--spacing-lg);
    }
    
    .modal-header {
        flex-direction: column;
        gap: var(--spacing-sm);
        text-align: center;
    }
    
    .modal-close {
        position: absolute;
        top: var(--spacing-sm);
        right: var(--spacing-sm);
    }
}

/* Payment Scheduling Modal Styles */
.invoice-summary {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid var(--color-light-gray);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) 0;
    font-size: var(--font-size-base);
}

.summary-row strong {
    color: var(--color-primary);
    font-weight: 600;
}

.summary-row.tds-deduction {
    padding: var(--spacing-sm) var(--spacing-md);
    margin: var(--spacing-sm) 0;
    background-color: rgba(255, 152, 0, 0.1);
    border-left: 4px solid var(--color-warning);
    border-radius: var(--radius-sm);
}

.summary-row.tds-deduction .tds-amount {
    color: var(--color-warning);
    font-weight: 700;
}

.summary-row.net-payable {
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: rgba(46, 125, 50, 0.1);
    border-left: 4px solid var(--color-success);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-lg);
}

.summary-row.net-payable .highlight {
    color: var(--color-success);
    font-weight: 700;
    font-size: var(--font-size-xl);
}

#remaining-amount {
    color: var(--color-success);
    font-weight: 700;
    font-size: var(--font-size-lg);
}

.payment-schedule-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.payment-entry {
    background: var(--bg-card);
    border: 2px solid var(--color-light-gray);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    position: relative;
    transition: all var(--transition-base);
}

.payment-entry:hover {
    border-color: var(--color-accent-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.payment-entry h4 {
    color: var(--color-primary);
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.payment-entry h4::before {
    content: '\f53d';
    font-family: 'Font Awesome 6 Free';
    font-weight: 600;
    color: var(--color-accent);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.form-group label {
    font-weight: 600;
    color: var(--color-primary);
    font-size: var(--font-size-sm);
}

.form-control {
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-light-gray);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    transition: all var(--transition-base);
    background: var(--bg-card);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(var(--color-accent), 0.1);
}

.form-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    padding: var(--spacing-md) 0;
    border-top: 1px solid var(--color-light);
    border-bottom: 1px solid var(--color-light);
}

/* .btn-outline-primary / -danger: supplied by components.css. */

.modal-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: flex-end;
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 2px solid var(--color-light);
}

/* .btn-secondary and a duplicate .btn:disabled: supplied by components.css. */

/* Responsive adjustments for payment scheduling */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }
    
    .form-actions {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .modal-actions {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .invoice-table-container {
        max-height: 400px;
    }
    
    .invoice-table {
        min-width: 600px;
    }
    
    .invoice-table th,
    .invoice-table td {
        padding: 0.75rem 1rem;
        font-size: var(--font-size-xs);
    }
}

/* Dark mode support */
/* Dark theme — triggered by data-theme on <html>, which js/theme.js sets from
   localStorage or the OS preference. Converted from an OS-level colour-scheme
   media query so that this page, tokens.css and components.css all respond to
   ONE signal; previously the shared components could not see the media query,
   so an adopted page rendered light cards and inputs on a dark background. */

:root[data-theme="dark"] {
    --color-primary: #6366f1;
    --color-primary-dark: #4f46e5;
    --color-primary-light: #818cf8;
    --color-secondary: #64748b;
    --color-accent: #3b82f6;
    --color-accent-light: #60a5fa;
    --color-success: #10b981;
    --color-success-light: #34d399;
    --color-warning: #f59e0b;
    --color-warning-light: #fbbf24;
    --color-danger: #ef4444;
    --color-danger-light: #f87171;
    --color-info: #06b6d4;
    --color-info-light: #22d3ee;
    --color-light: #1e293b;
    --color-light-gray: #334155;
    --color-gray: #64748b;
    --color-dark-gray: #cbd5e1;
    --color-dark: #f1f5f9;
    --color-text: #e2e8f0;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-hover: #334155;
}

:root[data-theme="dark"] body {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

:root[data-theme="dark"] .dashboard-sidebar {
    background: linear-gradient(180deg, #1e1b4b 0%, #0f172a 100%);
}

:root[data-theme="dark"] .dashboard-header {
    background: linear-gradient(135deg, #1e1b4b 0%, #3730a3 100%);
}

:root[data-theme="dark"] .section-card {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

:root[data-theme="dark"] .modal-content {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

:root[data-theme="dark"] .empty-state {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 2px dashed var(--color-light-gray);
}


/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn,
    .status-badge,
    .user-role {
        border: 2px solid currentColor;
    }
    
    .sidebar-link.active {
        outline: 2px solid white;
        outline-offset: -2px;
    }
}

/* Performance optimizations */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .sidebar-link,
    .invoice-row {
        min-height: 44px;
    }
    
    .action-buttons .btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    .invoice-table th,
    .invoice-table td {
        padding: 0.75rem;
    }
}
/* Add these styles to dashboard.css - Enhanced Search Bar Section */

/* Enhanced Global Search */
.dashboard-search {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 var(--spacing-lg);
    transition: all var(--transition-base);
}

.dashboard-search.focused {
    max-width: 600px;
}

.search-wrapper {
    position: relative;
    width: 100%;
}

#global-search-input {
    width: 100%;
    padding: 0.875rem 1.25rem 0.875rem 3.5rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    color: white;
    font-size: var(--font-size-base);
    font-weight: 500;
    transition: all var(--transition-base);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

#global-search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
}

#global-search-input:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

#global-search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 
        0 8px 30px rgba(0, 0, 0, 0.2),
        0 0 0 4px rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

/* Enhanced Search Icon */
.search-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    z-index: 1;
    pointer-events: none;
    transition: all var(--transition-base);
}

#global-search-input:focus ~ .search-icon {
    color: white;
    transform: translateY(-50%) scale(1.1);
}

/* Search Suggestions Dropdown */
.search-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-light-gray);
    max-height: 400px;
    overflow-y: auto;
    z-index: var(--z-dropdown);
    display: none;
    animation: fadeInUp 0.2s ease-out;
}

.search-suggestions.show {
    display: block;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.suggestion-header {
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--color-light-gray);
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-dark-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.suggestion-category {
    padding: 0.5rem 1.25rem;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-secondary);
    margin-top: 0.5rem;
}

.suggestion-category:first-child {
    margin-top: 0;
}

.suggestion-item {
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-bottom: 1px solid var(--color-light);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: var(--bg-hover);
    transform: translateX(4px);
}

.suggestion-icon {
    width: 20px;
    text-align: center;
    color: var(--color-accent);
    font-size: 0.9rem;
}

.suggestion-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.suggestion-title {
    font-weight: 500;
    color: var(--color-dark);
    font-size: var(--font-size-sm);
}

.suggestion-subtitle {
    font-size: var(--font-size-xs);
    color: var(--color-gray);
}

.suggestion-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.suggestion-badge {
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.suggestion-badge.invoice {
    background: rgba(var(--color-accent), 0.1);
    color: var(--color-accent);
    border: 1px solid rgba(var(--color-accent), 0.2);
}

.suggestion-badge.vendor {
    background: rgba(var(--color-success), 0.1);
    color: var(--color-success);
    border: 1px solid rgba(var(--color-success), 0.2);
}

.suggestion-badge.user {
    background: rgba(var(--color-info), 0.1);
    color: var(--color-info);
    border: 1px solid rgba(var(--color-info), 0.2);
}

/* Search Actions */
.search-actions {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--color-light-gray);
    background: var(--bg-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-shortcuts {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.shortcut-hint {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: var(--font-size-xs);
    color: var(--color-gray);
    padding: 0.25rem 0.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-light);
}

.shortcut-hint kbd {
    font-family: var(--font-mono);
    padding: 0.125rem 0.375rem;
    background: var(--color-dark);
    color: white;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.clear-search {
    padding: 0.375rem 0.75rem;
    background: var(--color-danger-light);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.clear-search:hover {
    background: var(--color-danger);
    transform: translateY(-1px);
}

/* Search Loading Indicator */
.search-loading {
    display: none;
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.search-loading.active {
    display: block;
}

/* Recent Searches */
.recent-searches {
    margin-top: 0.5rem;
}

.recent-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--color-light);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    color: var(--color-dark);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin: 0.125rem;
}

.recent-tag:hover {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
    transform: translateY(-1px);
}

.recent-tag i {
    font-size: 0.8rem;
}

/* Search Results Header */
.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) 0;
    margin-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--color-light);
}

.search-results-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.search-query {
    color: var(--color-accent);
    font-weight: 700;
}

.search-results-count {
    font-size: var(--font-size-sm);
    color: var(--color-gray);
    font-weight: 500;
}

/* Empty Search Results */
.empty-search {
    text-align: center;
    padding: var(--spacing-xl);
}

.empty-search-icon {
    font-size: 3rem;
    color: var(--color-light-gray);
    margin-bottom: var(--spacing-md);
    opacity: 0.7;
}

.empty-search-title {
    font-size: var(--font-size-lg);
    font-weight: 500;
    color: var(--color-dark-gray);
    margin-bottom: var(--spacing-xs);
}

.empty-search-tip {
    color: var(--color-gray);
    font-size: var(--font-size-sm);
    max-width: 300px;
    margin: 0 auto;
}

/* Responsive Search */
@media (max-width: 1024px) {
    .dashboard-search {
        max-width: 400px;
        margin: 0 var(--spacing-md);
    }
    
    .dashboard-search.focused {
        max-width: 500px;
    }
}

@media (max-width: 768px) {
    .dashboard-search {
        max-width: 100%;
        margin: var(--spacing-sm) 0;
        order: 3;
    }
    
    #global-search-input {
        padding: 0.75rem 1rem 0.75rem 3rem;
    }
    
    .search-suggestions {
        position: fixed;
        top: calc(100% + 4px);
        left: var(--spacing-sm);
        right: var(--spacing-sm);
        max-height: 60vh;
    }
    
    .search-icon {
        left: 1rem;
    }
}

@media (max-width: 480px) {
    .search-actions {
        flex-direction: column;
        gap: var(--spacing-xs);
        align-items: stretch;
    }
    
    .search-shortcuts {
        justify-content: center;
    }
    
    .suggestion-item {
        padding: 0.625rem 1rem;
    }
    
    .recent-tag {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Dark mode search adjustments */
/* Dark theme — triggered by data-theme on <html>, which js/theme.js sets from
   localStorage or the OS preference. Converted from an OS-level colour-scheme
   media query so that this page, tokens.css and components.css all respond to
   ONE signal; previously the shared components could not see the media query,
   so an adopted page rendered light cards and inputs on a dark background. */

:root[data-theme="dark"] .search-suggestions {
    background: var(--bg-card);
    border: 1px solid var(--color-light-gray);
}

:root[data-theme="dark"] #global-search-input {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    color: white;
}

:root[data-theme="dark"] #global-search-input:hover,
:root[data-theme="dark"] #global-search-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

:root[data-theme="dark"] .recent-tag {
    background: var(--bg-secondary);
    border-color: var(--color-light-gray);
    color: var(--color-dark);
}

:root[data-theme="dark"] .recent-tag:hover {
    background: var(--color-accent);
    color: white;
}


/* Search focus animation */
@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 
            0 4px 20px rgba(0, 0, 0, 0.1),
            0 0 0 0 rgba(255, 255, 255, 0.1);
    }
    50% {
        box-shadow: 
            0 4px 20px rgba(0, 0, 0, 0.1),
            0 0 0 4px rgba(255, 255, 255, 0.1);
    }
}

.dashboard-search.pulse {
    animation: pulseGlow 2s ease-in-out;
}

/* ================================================
   CXO FILTER PANEL
   ================================================ */

.filter-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    background: var(--bg-card);
    border: 1.5px solid var(--color-light-gray);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.filter-toggle-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(26, 35, 126, 0.05);
}

.filter-toggle-btn.active {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: #fff;
}

.filter-toggle-btn.active:hover {
    background: var(--color-primary-dark);
}

.filter-count-badge {
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--color-warning);
    color: #fff;
    border-radius: var(--radius-full);
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 1.15rem;
    height: 1.15rem;
    padding: 0 0.2rem;
    line-height: 1;
}

.filter-toggle-btn.active .filter-count-badge,
.filter-count-badge.visible {
    display: inline-flex;
}

/* ── Header property switcher ─────────────────────────────────────────────
   Narrows the whole dashboard to one property in a single click. Sits in the
   dark header, so it is styled on the translucent-white system the header's
   other controls use rather than the light panel below. */
.property-switcher {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    transition: background var(--transition-base), border-color var(--transition-base);
}

.property-switcher:hover,
.property-switcher:focus-within {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.45);
}

.property-switcher > i {
    font-size: 0.85rem;
    opacity: 0.85;
    flex-shrink: 0;
}

.property-switcher select {
    border: none;
    outline: none;
    background: transparent;
    color: #fff;
    font-family: inherit;
    font-size: var(--font-size-sm);
    font-weight: 500;
    max-width: 190px;
    cursor: pointer;
    /* The native menu renders on the OS surface, so its options need readable
       colours of their own — they do not inherit the header's white-on-blue. */
    padding-right: 0.25rem;
}

.property-switcher select option {
    color: var(--color-text);
    background: var(--bg-card);
}

/* Focused on one property — make the narrowed state obvious, so nobody reads a
   filtered dashboard as the whole company. */
.property-switcher select.is-focused {
    font-weight: 700;
}

.property-switcher:has(select.is-focused) {
    background: rgba(255, 255, 255, 0.26);
    border-color: rgba(255, 255, 255, 0.6);
}

@media (max-width: 768px) {
    .property-switcher select { max-width: 120px; }
}

/* Panel container */
.cxo-filter-panel {
    background: #f8faff;
    border-bottom: 2px solid #dce3f5;
    padding: 0.85rem 1.5rem;
    box-shadow: 0 2px 6px rgba(26, 35, 126, 0.07);
}

.filter-panel-body {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: flex-end;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1 1 155px;
    min-width: 130px;
    max-width: 210px;
}

.filter-field--narrow {
    flex: 1 1 120px;
    max-width: 155px;
}

.filter-field label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-dark-gray);
    text-transform: uppercase;
    letter-spacing: 0.055em;
}

.filter-field input,
.filter-field select {
    padding: 0.42rem 0.6rem;
    border: 1.5px solid var(--color-light-gray);
    border-radius: var(--radius-xs);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    background: #fff;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
    font-family: var(--font-family);
}

.filter-field input:focus,
.filter-field select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(26, 35, 126, 0.1);
}

.filter-field input.filter-active,
.filter-field select.filter-active {
    border-color: var(--color-primary);
    background: #eef1fb;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    padding-bottom: 0;
    margin-left: auto;
}

/* Multi-select vendor chips (bulk invoice PDF export) */
.vendor-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.4rem;
}

.vendor-chips:empty {
    display: none;
}

.vendor-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.5rem;
    background: #eef1fb;
    border: 1px solid var(--color-primary);
    border-radius: 999px;
    font-size: 0.8rem;
    color: var(--color-primary);
    max-width: 100%;
}

.vendor-chip__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 16rem;
}

.vendor-chip__remove {
    border: none;
    background: transparent;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
}

.vendor-chip__remove:hover {
    color: #c0392b;
}

/* Responsive: stack on small screens */
@media (max-width: 768px) {
    .cxo-filter-panel {
        padding: 0.75rem 1rem;
    }
    .filter-field {
        flex: 1 1 100%;
        max-width: 100%;
    }
    .filter-field--narrow {
        flex: 1 1 100%;
        max-width: 100%;
    }
    .filter-actions {
        margin-left: 0;
        width: 100%;
    }
}

/* ============================================================
   Bulk Accounts Operations (bulk-accounts.js)
   ============================================================ */

.modal-content--wide {
    width: 99vw;
    max-width: 99vw;
    height: 97vh;
    max-height: 97vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--radius-lg);
}

/* Body fills remaining space; only the table wrap scrolls */
.modal-content--wide .modal-body {
    flex: 1;
    min-height: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Search/merge bars stay pinned above the scrolling table */
.modal-content--wide .bulk-pay-search-bar,
.modal-content--wide .bulk-tally-search-bar,
.modal-content--wide .bulk-merge-bar {
    flex-shrink: 0;
}

/* Table wrap takes all remaining vertical space and scrolls */
.modal-content--wide .bulk-table-wrap {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* The paste tools (Bulk Settle, Bulk Tally, Pay FIFO, Bulk Pay Vendors) have no
   pinned table to delegate to — help, textarea and preview are one long column,
   so the panel itself is the scroller. Without this the body's overflow:hidden
   clips the expanded preview and nothing scrolls. */
.modal-content--wide .bulk-settle {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border, #e5e7eb);
}

/* Footer left cluster: shortcut hints (top) + live selection summary (bottom) */
.bulk-footer-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    min-width: 0;
    margin-right: auto;
}
.bulk-footer-right {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}
.bulk-shortcut-hints {
    font-size: 0.72rem;
    color: #9ca3af;
    white-space: nowrap;
}
.bulk-shortcut-hints kbd {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 0 0.3rem;
    font-size: 0.68rem;
    font-family: var(--font-mono, monospace);
    color: #374151;
}
.bulk-selection-summary {
    font-size: 0.82rem;
    color: #6b7280;
    min-height: 1.1em;
    white-space: nowrap;
}
.bulk-selection-summary.has-selection {
    color: #1d4ed8;
}
.bulk-selection-summary strong {
    color: inherit;
    font-weight: 700;
}
@media (max-width: 768px) {
    .bulk-shortcut-hints { display: none; }
}

/* Alert bar inside modal */
.bulk-modal-alert {
    margin: 0 1.5rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
}
.bulk-alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.bulk-alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.bulk-alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.bulk-alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ----- Bulk Settle (paste UTRs) ----- */
.bulk-settle { padding: 1rem 1.5rem; }
.bulk-settle-help {
    font-size: 0.875rem;
    color: #475569;
    line-height: 1.5;
    margin: 0 0 0.75rem;
}
.bulk-settle-actions { margin-bottom: 0.75rem; }
.bulk-settle-textarea {
    width: 100%;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    padding: 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    resize: vertical;
    box-sizing: border-box;
}
.bulk-settle-preview-actions { margin: 0.75rem 0; }
.bulk-settle-summary { font-size: 0.9rem; }
.bulk-settle-counts { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.bulk-settle-counts li { padding: 0.2rem 0; }
.bulk-settle-counts .bulk-settle-ok   { color: #065f46; }
.bulk-settle-counts .bulk-settle-info { color: #1e40af; }
.bulk-settle-counts .bulk-settle-warn { color: #92400e; }
.bulk-settle-total {
    font-size: 1rem;
    margin: 0.5rem 0;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
    border-radius: 6px;
}
/* Summary chips above the preview table */
.bulk-settle-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
}
.bulk-settle-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    border: 1px solid transparent;
}
.bulk-settle-chip strong { font-size: 0.85rem; }
.bulk-settle-chip--ok   { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.bulk-settle-chip--info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.bulk-settle-chip--warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }

/* Parsed-rows preview table */
.bulk-settle-table-wrap {
    margin-top: 0.6rem;
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}
.bulk-settle-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.bulk-settle-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8fafc;
    text-align: left;
    font-weight: 600;
    color: #334155;
    padding: 0.5rem 0.7rem;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}
.bulk-settle-table td {
    padding: 0.45rem 0.7rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.bulk-settle-table tbody tr:last-child td { border-bottom: none; }
.bulk-settle-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
}
.bulk-settle-utr {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: #334155;
}
.bulk-settle-muted { color: #94a3b8; }

/* Tint skipped/not-found rows so they're visibly inert */
.bulk-settle-row--warn td { background: #fffdf6; color: #78716c; }
.bulk-settle-row--info td { background: #fbfdff; }

/* Yes/No flag for the Mark in Tally column */
.bulk-tally-flag {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}
.bulk-tally-flag--yes { background: #dcfce7; color: #15803d; }
.bulk-tally-flag--no  { background: #f1f5f9; color: #64748b; }

/* Per-row status badge */
.bulk-settle-badge {
    display: inline-block;
    padding: 0.12rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}
.bulk-settle-badge--ok   { background: #dcfce7; color: #15803d; }
.bulk-settle-badge--info { background: #dbeafe; color: #1d4ed8; }
.bulk-settle-badge--warn { background: #fef3c7; color: #92400e; }

.bulk-settle-detail { margin: 0.25rem 0; font-size: 0.85rem; }
.bulk-settle-detail summary { cursor: pointer; color: #475569; }
.bulk-settle-codes {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
    color: #334155;
    padding: 0.4rem 0;
    word-break: break-word;
}
.bulk-settle-note { padding: 0.6rem 0.8rem; border-radius: 6px; font-size: 0.875rem; }
.bulk-settle-result .bulk-alert-success,
.bulk-settle-result .bulk-alert-warning {
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}
.bulk-settle-fail-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.bulk-settle-fail-table th,
.bulk-settle-fail-table td {
    text-align: left;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #e2e8f0;
}
.bulk-settle-fail { color: #991b1b; }

/* Anomaly badge: marked in Tally but not yet paid */
.tally-unpaid-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
    white-space: nowrap;
}

/* Search bar inside bulk pay / tally modals */
.bulk-tally-search-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: #fafafa;
}
.bulk-tally-search-bar i {
    color: #9ca3af;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.bulk-pay-search-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: #fafafa;
}
.bulk-pay-search-bar i {
    color: #9ca3af;
    font-size: 0.875rem;
    flex-shrink: 0;
}
.bulk-search-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    outline: none;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.bulk-search-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}
.bulk-search-count {
    font-size: 0.78rem;
    color: #6b7280;
    white-space: nowrap;
    min-width: 5rem;
    text-align: right;
}

/* Merge bar (shared UTR for checkbox-selected rows) */
.bulk-merge-bar {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    margin: 0.75rem 1.5rem 0;
    flex-wrap: wrap;
}
.bulk-merge-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #0369a1;
    white-space: nowrap;
}
.bulk-merge-input,
.bulk-merge-select {
    flex: 1 1 140px;
    min-width: 120px;
    padding: 0.375rem 0.625rem;
    border: 1px solid #93c5fd;
    border-radius: 5px;
    font-size: 0.8125rem;
}

/* Table */
.bulk-table-wrap {
    overflow-x: auto;
    padding: 0.75rem 1.5rem 1rem;
}
.bulk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}
.bulk-table th {
    background: #f9fafb;
    padding: 0.625rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
    /* Pin the header while the table body scrolls inside the wide modal */
    position: sticky;
    top: 0;
    z-index: 3;
}
.bulk-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.bulk-table tbody tr:hover {
    background: #f9fafb;
}

/* Pay modal: rows with a UTR entered are "ready" to submit — subtle blue cue */
.bulk-pay-row.bulk-row-ready td {
    background: #f0f9ff;
}
.bulk-pay-row.bulk-row-ready .bulk-utr-input {
    border-color: #38bdf8;
}

/* Column widths */
.bulk-col-check    { width: 36px; }
.bulk-col-inv      { min-width: 120px; }
.bulk-col-vendor   { min-width: 140px; }
.bulk-col-amount   { min-width: 100px; text-align: right; }
.bulk-col-net      { min-width: 100px; text-align: right; }
.bulk-col-stage    { min-width: 130px; }
.bulk-col-date     { min-width: 140px; }
.bulk-col-utr      { min-width: 160px; }
.bulk-col-bank     { min-width: 180px; }
.bulk-col-status   { min-width: 120px; }
.bulk-col-category { min-width: 140px; }
.bulk-col-tds      { min-width: 90px; text-align: right; }
.bulk-col-desc     { min-width: 180px; max-width: 260px; white-space: normal; word-break: break-word; }
.bulk-col-state    { min-width: 120px; }
.bulk-col-actions  { width: 48px; text-align: center; }
.bulk-col-dept     { min-width: 120px; }

/* Tally-specific table tweak */
.bulk-table--tally { font-size: 0.78rem; }

/* State badges inside tally grid */
.bulk-state-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}
.bulk-state-PAID             { background: #dcfce7; color: #15803d; }
.bulk-state-PAYMENT_SCHEDULED { background: #dbeafe; color: #1d4ed8; }
.bulk-state-PENDING_ACCOUNTS { background: #fef9c3; color: #92400e; }
.bulk-state-PENDING_HOD      { background: #f3e8ff; color: #6d28d9; }
.bulk-state-PENDING_CXO      { background: #e0f2fe; color: #0369a1; }
.bulk-state-APPROVED         { background: #d1fae5; color: #065f46; }
.bulk-state-REJECTED_HOD,
.bulk-state-REJECTED_ACCOUNTS { background: #fee2e2; color: #b91c1c; }
.bulk-state-DRAFT            { background: #f3f4f6; color: #6b7280; }

/* ── Grouped, collapsible Tally grid ─────────────────────────────────────── */
/* "Select all shown" control in the search bar */
.bulk-select-all-shown {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: #4b5563;
    white-space: nowrap;
    cursor: pointer;
}
.bulk-select-all-shown input { cursor: pointer; }

/* Group header row (one per state) */
.bulk-group-header { cursor: pointer; }
.bulk-group-header:hover { background: #f3f4f6; }
.bulk-group-headcell {
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}
.bulk-group-caret {
    display: inline-block;
    width: 1rem;
    color: #9ca3af;
    transition: transform 0.15s ease;
}
.bulk-group.collapsed .bulk-group-caret { transform: rotate(-90deg); }
.bulk-group-title { margin-right: 0.5rem; }
.bulk-group-tag {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 600;
    margin-right: 0.5rem;
}
.bulk-group-tag--ok   { background: #dcfce7; color: #15803d; }
.bulk-group-tag--warn { background: #fef3c7; color: #92400e; }
.bulk-group-meta { color: #6b7280; font-weight: 500; }

/* Recommended (PAID) group: subtle green accent on its header */
.bulk-group--recommended .bulk-group-header td {
    background: #f0fdf4;
    border-top: 2px solid #bbf7d0;
}
/* Unusual (unpaid) groups: muted amber header so they read as "be deliberate" */
.bulk-group--unusual .bulk-group-header td {
    background: #fffbeb;
    border-top: 2px solid #fde68a;
}
.bulk-group--unusual .bulk-tally-row td { color: #6b7280; }

/* Loading state inside modal */
.bulk-loading {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
    font-size: 0.9rem;
}
.bulk-loading i { margin-right: 0.5rem; }

/* No-file placeholder */
.bulk-no-file { color: #d1d5db; font-size: 0.85rem; }

/* Inline inputs inside table */
.bulk-utr-input {
    width: 100%;
    padding: 0.375rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 0.8125rem;
}
.bulk-utr-input:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 2px rgba(99,102,241,0.15); }

.bulk-bank-select {
    width: 100%;
    padding: 0.375rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 0.8125rem;
    background: #fff;
}
.bulk-bank-select:focus { outline: none; border-color: #6366f1; }

.bulk-date-input {
    width: 100%;
    padding: 0.375rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 0.8125rem;
    background: #fff;
}
.bulk-date-input:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 2px rgba(99,102,241,0.15); }
.bulk-date-display { font-size: 0.8125rem; color: #374151; }

.bulk-state-filter-select {
    padding: 0.375rem 0.625rem;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 0.8125rem;
    background: #fff;
    color: #374151;
    cursor: pointer;
    flex-shrink: 0;
}
.bulk-state-filter-select:focus { outline: none; border-color: #6366f1; }

/* Row states */
.bulk-row-success td { background: #f0fdf4 !important; }
.bulk-row-success .bulk-utr-input,
.bulk-row-success .bulk-bank-select { opacity: 0.5; pointer-events: none; }

.bulk-row-failed td { background: #fef2f2 !important; }

.bulk-row-status {
    font-size: 0.75rem;
    font-weight: 600;
}
.bulk-row-success .bulk-row-status { color: #16a34a; }
.bulk-row-failed  .bulk-row-status { color: #dc2626; }

/* Empty state */
.bulk-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}
.bulk-empty i {
    font-size: 2.5rem;
    color: #10b981;
    margin-bottom: 0.75rem;
}

/* btn sizes: supplied by components.css. */

/* ===========================================================================
   FIFO payment allocation — Pay Vendor + Bulk Pay Vendors
   ===========================================================================
   Reuses the .bulk-settle shell (modal, textarea, chips, tables) so the FIFO
   tools look like the bulk tools Accounts already know. Only what those styles
   do not already provide is defined here: the expandable vendor→invoice groups,
   the allocation form, and the On Account emphasis. */

/* ---- Pay Vendor modal ---- */

.fifo-pay-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.fifo-pay-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
}

.fifo-pay-field > span { font-weight: 600; color: #374151; }
.fifo-pay-field em { font-weight: 400; font-style: normal; color: #6b7280; }

.fifo-pay-tablewrap { overflow-x: auto; }

.fifo-pay-table .fifo-num { text-align: right; white-space: nowrap; }
.fifo-pay-table .fifo-closes { white-space: nowrap; }

/* An editable allocation cell — narrow, so the table still reads as a table
   rather than a form. */
.fifo-alloc-input {
    width: 120px;
    text-align: right;
    padding: 0.25rem 0.4rem;
}

.fifo-pay-table .is-closing { color: #065f46; font-weight: 600; }

.fifo-empty {
    text-align: center;
    color: #6b7280;
    padding: 1rem;
}

/* On Account is money already out of the bank with no invoice against it, so it
   is deliberately prominent rather than a footnote. */
.fifo-pay-onaccount {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
    color: #92400e;
}

/* ---- Bulk Pay Vendors: the expanded preview ---- */

.bulk-fifo-groups {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

.bulk-fifo-group {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.bulk-fifo-group--skipped { background: #fafafa; opacity: 0.85; }

.bulk-fifo-group-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.85rem;
}

.bulk-fifo-group--skipped .bulk-fifo-group-head { border-bottom: none; }

.bulk-fifo-code { font-weight: 700; color: #111827; }
.bulk-fifo-name { color: #374151; }
.bulk-fifo-paid { margin-left: auto; font-weight: 600; }
.bulk-fifo-utr { color: #6b7280; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.bulk-fifo-reason { color: #92400e; }

.bulk-fifo-lines {
    list-style: none;
    margin: 0;
    padding: 0.25rem 0.75rem 0.5rem;
}

/* The child rows are the point of the expanded preview: one line per invoice the
   lump sum will touch. */
.bulk-fifo-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.28rem 0;
    font-size: 0.82rem;
    border-bottom: 1px dashed #f3f4f6;
}

.bulk-fifo-line:last-child { border-bottom: none; }

.bulk-fifo-line-ref { font-weight: 600; min-width: 11rem; }
.bulk-fifo-line-date { color: #6b7280; min-width: 4rem; }
.bulk-fifo-line-out { color: #6b7280; }
.bulk-fifo-line-amt { font-weight: 600; margin-left: auto; }
.bulk-fifo-line-close { min-width: 4.5rem; text-align: right; color: #6b7280; }
.bulk-fifo-line-close.is-closing { color: #065f46; font-weight: 600; }

.bulk-fifo-line--empty { color: #6b7280; font-style: italic; }

.bulk-fifo-line--onaccount {
    color: #92400e;
    background: #fffbeb;
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    margin-top: 0.25rem;
}



/* ---- Vendor statement ---- */

.statement-table .num { text-align: right; white-space: nowrap; }
.statement-row--allocation { color: #065f46; }
.statement-row--note { color: #6b7280; font-style: italic; }

/* ---- Bulk Pay Vendors: input-source toggle ---- */
/* Two ways in (bank statement / vendor worklist), one way out. The toggle is a
   tab strip rather than a dropdown so both options — and which one is active —
   are visible without a click. */

.bulk-fifo-modes {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.9rem;
    border-bottom: 1px solid #e5e7eb;
}

.bulk-fifo-mode {
    appearance: none;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.5rem 0.9rem;
    font-size: 0.86rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
}

.bulk-fifo-mode:hover { color: #374151; }

.bulk-fifo-mode.is-active {
    color: #1d4ed8;
    border-bottom-color: #1d4ed8;
}

/* The account picker is the single control that scopes every pasted row to an
   entity, so it gets a little more weight than an ordinary field. */
.bulk-fifo-account {
    margin: 0.5rem 0 0.9rem;
    max-width: 480px;
}

/* ===========================================================================
   On Account — money paid but not yet matched to an invoice
   ===========================================================================
   This section exists to answer three questions at a glance: whose money is it,
   is it stuck, and will pressing the button do anything. The amber treatment is
   deliberate — On Account is not an error (paying early is normal) but it is
   money the books cannot yet attribute, so it should not blend into the page. */

.on-account-card {
    /* Spans the grid like the invoice-table cards do: the row needs the width. */
    grid-column: 1 / -1;
    border-color: rgba(245, 158, 11, 0.3);
}

/* The amber accent bar replaces the blue one the other cards animate in. */
.on-account-card::before {
    background: linear-gradient(90deg, var(--color-warning), var(--color-warning-light));
    opacity: 1;
}

.on-account-card .section-title { color: #92400e; }
.on-account-card .section-title::before { background: var(--color-warning); }

.on-account-card .section-count {
    background: linear-gradient(135deg, #b45309 0%, #f59e0b 100%);
    box-shadow: 0 4px 12px rgba(180, 83, 9, 0.25);
    font-variant-numeric: tabular-nums;
}

/* One short paragraph doing the teaching, so the table below needs no legend. */
.on-account-explainer {
    margin: calc(-1 * var(--spacing-xs)) 0 var(--spacing-md);
    padding: 0.7rem 0.9rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 3px solid var(--color-warning);
    border-radius: var(--radius-sm);
    color: #78350f;
    font-size: var(--font-size-sm);
    line-height: 1.55;
    max-width: 78ch;
}

.on-account-table { min-width: 720px; }

.on-account-table-wrap { max-height: none; }

.on-account-num { text-align: right; }

.on-account-vendor { font-weight: 600; color: var(--color-dark); }

.on-account-ref {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-dark-gray);
}

/* The unapplied figure is the number the eye should land on first. */
.on-account-amount {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.9rem;
    color: #92400e;
    white-space: nowrap;
}

/* The "can be applied now" hint carries the state, so it is colour-coded rather
   than relying on the operator reading the sentence. Text says it too — colour is
   never the only signal. */
.on-account-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.73rem;
    font-weight: 600;
    line-height: 1.45;
    white-space: nowrap;
}

.on-account-hint::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

/* Ready: the balance has invoices to settle and covers them. */
.on-account-hint.is-ready {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.on-account-hint.is-ready::before { background: var(--color-success-light); }

/* Partial: some of it can be applied, the rest keeps waiting. */
.on-account-hint.is-partial {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}
.on-account-hint.is-partial::before { background: var(--color-accent-light); }

/* Waiting: nothing owed yet. Deliberately calm — this is the advance working as
   intended, not a problem to chase. */
.on-account-hint.is-waiting {
    background: #f8fafc;
    color: var(--color-dark-gray);
    border: 1px solid var(--color-light-gray);
}
.on-account-hint.is-waiting::before { background: var(--color-gray); }

.on-account-action { text-align: right; white-space: nowrap; }

/* A row with work to do is nudged forward; a waiting row recedes so the eye goes
   to the ones that need a decision. */
.on-account-row.has-work .on-account-vendor { color: var(--color-primary); }
.on-account-row:not(.has-work) { opacity: 0.72; }

.on-account-allocate:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ---- The KPI tile ---- */

.on-account-kpi { border-color: rgba(245, 158, 11, 0.3); }
.on-account-kpi::before {
    background: linear-gradient(90deg, var(--color-warning), var(--color-warning-light));
    opacity: 1;
}
.on-account-kpi .section-title { color: #92400e; }
.on-account-kpi .section-title::before { background: var(--color-warning); }
.on-account-kpi .section-count {
    background: linear-gradient(135deg, #b45309 0%, #f59e0b 100%);
    box-shadow: 0 4px 12px rgba(180, 83, 9, 0.25);
}

@media (max-width: 768px) {
    .on-account-explainer { font-size: var(--font-size-xs); }
    .on-account-hint { white-space: normal; }
}

/* Blocked: the vendor IS owed money, but under a different entity, so this
   balance can never reach it. Red rather than grey — grey would read as "nothing
   to do here", and this genuinely needs someone to look at it. */
.on-account-hint.is-blocked {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}
.on-account-hint.is-blocked::before { background: var(--color-danger-light); }

/* A blocked row is not dimmed like a merely-waiting one — it needs attention. */
.on-account-row:has(.on-account-hint.is-blocked) { opacity: 1; }
