/* ============================================
   ImportPanel v5.0 - Layout
   ============================================ */

/* Auth Layout */
#app-auth {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background-color: var(--color-bg);
}

#app-auth.active {
    display: flex;
}

/* App Shell Layout */
#app-shell {
    display: none;
    min-height: 100vh;
    overflow-x: hidden;
}

#app-shell.active {
    display: flex;
}

/* Sidebar */
#sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    z-index: var(--z-sidebar);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-base);
    overflow: hidden;
}

#sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

#sidebar.collapsed .sidebar-label,
#sidebar.collapsed .sidebar-logo-text,
#sidebar.collapsed .sidebar-version,
#sidebar.collapsed .sidebar-section-label,
#sidebar.collapsed .sidebar-user-info {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}

#sidebar.collapsed .sidebar-logo {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

#sidebar.collapsed .sidebar-nav-item {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

#sidebar.collapsed .sidebar-nav-item .nav-icon {
    margin-right: 0;
}

#sidebar.collapsed .sidebar-footer {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

/* ---- Sidebar Collapse Button ---- */
.sidebar-collapse-btn {
    width: 100%;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--color-text-muted);
    border-top: 1px solid var(--sidebar-border);
    transition: color 0.15s, background-color 0.15s;
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    color: var(--color-text);
    background: var(--color-surface-alt);
}

.sidebar-collapse-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

.sidebar-collapse-chevron {
    transition: transform 0.2s ease;
}

#sidebar.collapsed .sidebar-collapse-chevron {
    transform: rotate(180deg);
}

/* ---- Sidebar Badge positioning in collapsed mode ---- */
.sidebar-badge {
    transition: all 0.15s ease;
}

/* Red dot badge for notifications */
.sidebar-badge-dot {
    width: 8px !important;
    height: 8px !important;
    min-width: 8px !important;
    border-radius: 50% !important;
    background: var(--color-danger, #dc2626) !important;
    padding: 0 !important;
    font-size: 0 !important;
    line-height: 0 !important;
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4);
    }
    50% {
        box-shadow: 0 0 0 3px rgba(220, 38, 38, 0);
    }
}

#sidebar.collapsed .sidebar-badge {
    position: absolute;
    top: 2px;
    right: 6px;
    min-width: 16px;
    height: 16px;
    font-size: 9px;
    padding: 0 3px;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
}

#sidebar.collapsed .sidebar-badge-dot {
    top: 4px;
    right: 8px;
    width: 8px !important;
    height: 8px !important;
}

/* ---- Sidebar Nav Items ---- */
.sidebar-nav-item {
    position: relative;
    border-radius: 8px !important;
    transition: background-color 0.2s ease, color 0.15s ease, box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s ease;
}

.sidebar-nav-item .nav-icon {
    width: 22px !important;
    height: 22px !important;
    font-size: 18px;
}

.sidebar-nav-item .nav-icon svg {
    width: 18px;
    height: 18px;
}

.sidebar-nav-item.active {
    background-color: var(--sidebar-active-bg) !important;
    color: var(--sidebar-active-text) !important;
    font-weight: 600 !important;
    box-shadow: inset 3px 0 0 var(--color-primary);
    transition: background-color 0.2s ease, color 0.15s ease, box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s ease;
}

.sidebar-nav-item:not(.active) {
    box-shadow: inset 3px 0 0 transparent;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s ease;
}

.sidebar-nav-item.active .nav-icon {
    opacity: 1 !important;
    color: var(--sidebar-active-text) !important;
}

.sidebar-nav-item:hover:not(.active) {
    background-color: var(--color-surface-alt);
    color: var(--color-text);
    transform: translateX(4px);
}

.sidebar-nav-item:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
    border-radius: 8px;
}

/* ---- Sidebar Nav Spacing ---- */
.sidebar-nav {
    gap: 4px !important;
}

/* ---- Sidebar Tooltips (collapsed state) ---- */
.sidebar-tooltip {
    position: fixed;
    left: 76px;
    background: var(--sidebar-tooltip-bg, #1e293b);
    color: var(--sidebar-tooltip-text, #fff);
    font-size: 12px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    z-index: calc(var(--z-tooltip, 500) + 1);
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    line-height: 1.4;
    transform: translateX(-4px);
}

.sidebar-tooltip::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: var(--sidebar-tooltip-bg, #1e293b);
}

.sidebar-tooltip.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Only show tooltips when sidebar is collapsed (desktop) */
#sidebar:not(.collapsed) .sidebar-tooltip {
    display: none !important;
}

@media (max-width: 768px) {
    .sidebar-tooltip {
        display: none !important;
    }
}

/* ---- Sidebar Section Labels (Headers) ---- */
.sidebar-section-label {
    font-size: 11px !important;
    font-weight: 700 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase !important;
    color: var(--color-text-muted) !important;
    padding: 0 8px 8px !important;
    position: relative;
    transition: opacity var(--transition-base, 0.2s);
}

.sidebar-section-label::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: var(--sidebar-border, var(--color-border));
    opacity: 0.3;
}

.sidebar-section-divider {
    display: block;
    height: 1px;
    background: var(--sidebar-border, var(--color-border));
    margin: 12px 24px 8px;
    opacity: 0.3;
}

#sidebar.collapsed .sidebar-section-divider {
    margin: 12px 16px 8px;
    opacity: 0.5;
}

/* ---- Sidebar Logo Area ---- */
.sidebar-logo {
    padding: 20px 20px 18px !important;
}

.sidebar-logo-text {
    font-size: 17px !important;
    letter-spacing: -0.01em;
}

/* ---- Sidebar Footer (User + Version/Help) ---- */
.sidebar-footer-user {
    padding: 12px 16px !important;
}

.sidebar-footer {
    padding: 8px 16px !important;
    flex-shrink: 0;
}

.sidebar-user-avatar {
    width: 36px !important;
    height: 36px !important;
    font-size: 14px !important;
    box-shadow: 0 0 0 2px var(--color-primary-light, rgba(79, 143, 247, 0.15));
}

.sidebar-user-info div:first-child {
    font-size: 13px;
    font-weight: 600;
}

.sidebar-user-info div:last-child {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 1px;
}

/* ---- Sidebar Footer Help Button ---- */
.sidebar-help-btn:hover {
    color: var(--color-primary) !important;
    background: var(--color-primary-light, rgba(79, 143, 247, 0.08)) !important;
}

.sidebar-help-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

#sidebar.collapsed .sidebar-footer-user {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

#sidebar.collapsed .sidebar-footer {
    justify-content: center;
    padding-left: 4px;
    padding-right: 4px;
}

#sidebar.collapsed .sidebar-version,
#sidebar.collapsed .sidebar-help-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}

/* Main Content Area */
.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    max-width: calc(100vw - var(--sidebar-width));
    overflow-x: hidden;
    transition: margin-left var(--transition-base);
}

#sidebar.collapsed ~ .app-main {
    margin-left: var(--sidebar-collapsed);
    max-width: calc(100vw - var(--sidebar-collapsed));
}

/* Topbar */
#topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background-color: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: var(--z-topbar);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: box-shadow 0.2s ease, background-color 0.2s ease;
}

/* ---- Topbar Breadcrumb Enhancements ---- */
.topbar-breadcrumb-current {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: var(--color-text) !important;
    letter-spacing: -0.01em;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
}

.topbar-breadcrumb-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0 !important;
    color: var(--color-primary) !important;
    opacity: 0.8;
}

.topbar-breadcrumb-sep {
    color: var(--color-border) !important;
    opacity: 0.6 !important;
    margin: 0 2px;
}

.topbar-breadcrumb-link {
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.topbar-breadcrumb-link .topbar-breadcrumb-icon {
    opacity: 0.6;
}

.topbar-breadcrumb-link:hover .topbar-breadcrumb-icon {
    opacity: 1;
}

.topbar-breadcrumb-home {
    width: 28px;
    height: 28px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: color 0.15s ease, background-color 0.15s ease;
}

.topbar-breadcrumb-home:hover {
    background-color: var(--color-surface-alt);
}

/* ---- Breadcrumb Dropdown Navigation ---- */
.topbar-breadcrumb {
    position: relative;
}

.breadcrumb-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm, 4px);
    padding: 0;
    margin-left: 2px;
    transition: color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
    flex-shrink: 0;
}

.breadcrumb-dropdown-toggle:hover {
    color: var(--color-primary);
    background-color: var(--color-surface-alt);
}

.breadcrumb-dropdown-toggle.active {
    color: var(--color-primary);
    background-color: var(--color-primary-light, rgba(79, 143, 247, 0.1));
    transform: rotate(180deg);
}

.breadcrumb-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 240px;
    max-width: 300px;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg, 10px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.06);
    z-index: calc(var(--z-topbar, 100) + 10);
    padding: 6px 0;
    overflow-y: auto;
    max-height: 400px;
    animation: breadcrumbDropdownIn 0.15s ease;
}

.breadcrumb-dropdown.open {
    display: block;
}

@keyframes breadcrumbDropdownIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.breadcrumb-dropdown-section {
    padding: 2px 0;
}

.breadcrumb-dropdown-heading {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.breadcrumb-dropdown-divider {
    height: 1px;
    background: var(--color-border);
    margin: 4px 10px;
    opacity: 0.6;
}

.breadcrumb-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary, var(--color-text));
    text-decoration: none;
    transition: background-color 0.1s ease, color 0.1s ease;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumb-dropdown-item:hover {
    background-color: var(--color-surface-alt, #f1f5f9);
    color: var(--color-text);
}

.breadcrumb-dropdown-item--active {
    color: var(--color-primary) !important;
    font-weight: 600;
    background-color: var(--color-primary-light, rgba(79, 143, 247, 0.06));
}

.breadcrumb-dropdown-item--active:hover {
    background-color: var(--color-primary-light, rgba(79, 143, 247, 0.1));
}

.breadcrumb-dropdown-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.6;
}

.breadcrumb-dropdown-item:hover .breadcrumb-dropdown-item-icon {
    opacity: 1;
}

.breadcrumb-dropdown-item--active .breadcrumb-dropdown-item-icon {
    opacity: 1;
    color: var(--color-primary);
}

/* Dark theme */
[data-theme="dark"] .breadcrumb-dropdown {
    background: var(--color-surface, #1e293b);
    border-color: var(--color-border, #334155);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .breadcrumb-dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .breadcrumb-dropdown-item--active {
    background-color: rgba(79, 143, 247, 0.1);
}

[data-theme="dark"] .breadcrumb-dropdown-item--active:hover {
    background-color: rgba(79, 143, 247, 0.15);
}

[data-theme="dark"] .breadcrumb-dropdown-toggle:hover {
    background-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .breadcrumb-dropdown-toggle.active {
    background-color: rgba(79, 143, 247, 0.15);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .sidebar-nav-item.active {
        animation: none !important;
    }
    .breadcrumb-dropdown {
        animation: none !important;
    }
    .breadcrumb-dropdown-toggle {
        transition: none !important;
    }
}

/* Hide dropdown toggle on small screens (breadcrumb itself is hidden) */
@media (max-width: 640px) {
    .breadcrumb-dropdown-toggle {
        display: none !important;
    }
}

/* ---- Topbar Search Input Enhancements ---- */
.global-search-input-wrap {
    min-width: 280px !important;
    border-radius: 10px !important;
    padding: 7px 14px !important;
    border: 1.5px solid var(--color-border) !important;
    background: var(--color-surface) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, min-width 0.2s ease !important;
}

.global-search-input-wrap:hover {
    border-color: var(--color-text-muted) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06) !important;
}

.global-search-input-wrap:focus-within {
    min-width: 320px !important;
    border-color: var(--color-primary) !important;
    background: var(--color-surface) !important;
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1), 0 2px 8px rgba(0, 0, 0, 0.08) !important;
}

.global-search-input {
    width: 180px !important;
}

.global-search-input::placeholder {
    color: var(--color-text-muted) !important;
    font-weight: 400;
    font-size: 13px;
    opacity: 0.65;
}

/* ---- Ctrl+K Badge - Rounded Pill ---- */
.global-search-kbd {
    font-size: 10px !important;
    height: 20px !important;
    padding: 0 7px !important;
    border-radius: 6px !important;
    background: var(--color-surface-alt) !important;
    border: 1px solid var(--color-border) !important;
    color: var(--color-text-muted) !important;
    opacity: 0.7 !important;
    font-weight: 600;
    letter-spacing: 0.03em;
    transition: opacity 0.15s ease;
}

.global-search-input-wrap:focus-within .global-search-kbd {
    opacity: 0.4 !important;
}

/* ---- User Avatar Hover Ring ---- */
#user-dropdown-btn > div:first-child {
    transition: box-shadow 0.2s ease, transform 0.15s ease;
    border: 2px solid transparent;
}

#user-dropdown-btn:hover > div:first-child {
    box-shadow: 0 0 0 3px var(--color-primary-light);
    border-color: var(--color-primary);
    transform: scale(1.05);
}

/* ---- Notification Bell Hover ---- */
.notification-bell {
    position: relative;
    border-radius: 50% !important;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease !important;
}

.notification-bell:hover {
    background-color: var(--color-surface-alt) !important;
    color: var(--color-text) !important;
    transform: scale(1.05);
}

.notification-bell:active {
    transform: scale(0.95);
}

/* ---- Notification Dropdown (Topbar) ---- */
.notification-dd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    gap: 8px;
}

.notification-dd-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.notification-dd-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
}

.notification-dd-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.notification-dd-mark-all {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: inherit;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.notification-dd-mark-all:hover {
    background: var(--color-primary-light);
}

/* Dropdown items */
.notification-dd-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-border-light, rgba(0, 0, 0, 0.05));
    cursor: pointer;
    transition: background-color 0.12s ease;
    position: relative;
}

.notification-dd-item:last-child {
    border-bottom: none;
}

.notification-dd-item:hover {
    background: var(--color-surface-alt);
}

.notification-dd-item--read {
    opacity: 0.55;
}

.notification-dd-item--read:hover {
    opacity: 0.75;
}

.notification-dd-item-icon {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--color-text-muted);
}

.notification-dd-item--eta .notification-dd-item-icon {
    color: var(--color-warning);
}

.notification-dd-item--status .notification-dd-item-icon {
    color: var(--color-primary);
}

.notification-dd-item--comment .notification-dd-item-icon {
    color: var(--color-info, #3b82f6);
}

.notification-dd-item-body {
    flex: 1;
    min-width: 0;
}

.notification-dd-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.35;
}

.notification-dd-item--read .notification-dd-item-title {
    font-weight: 400;
}

.notification-dd-item-msg {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-dd-item-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--color-text-muted);
}

.notification-dd-item-type {
    font-weight: 500;
}

.notification-dd-item--eta .notification-dd-item-type {
    color: var(--color-warning);
}

.notification-dd-item--status .notification-dd-item-type {
    color: var(--color-primary);
}

.notification-dd-item--comment .notification-dd-item-type {
    color: var(--color-info, #3b82f6);
}

.notification-dd-item-sep {
    opacity: 0.4;
}

.notification-dd-item-time {
    color: var(--color-text-muted);
}

/* Unread dot indicator */
.notification-dd-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary);
    flex-shrink: 0;
    margin-top: 6px;
    animation: notifUnreadPulse 2s ease-in-out infinite;
}

@keyframes notifUnreadPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0); }
}

/* Dropdown footer */
.notification-dd-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--color-border);
    text-align: center;
}

.notification-dd-view-all {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-primary);
    text-decoration: none;
    transition: gap 0.15s ease;
}

.notification-dd-view-all:hover {
    gap: 6px;
}

/* Dropdown empty state */
.notification-dd-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--color-text-muted);
}

.notification-dd-empty-text {
    margin-top: 12px;
    font-size: 14px;
    font-weight: 500;
}

.notification-dd-empty-sub {
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.7;
}

/* Loading state */
.notification-dd-loading {
    padding: 24px 16px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
}

/* ---- Quick Actions Button ---- */
.quick-actions-btn {
    border-radius: 50% !important;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease !important;
}

.quick-actions-btn:hover {
    background-color: var(--color-surface-alt) !important;
    color: var(--color-primary) !important;
    transform: scale(1.05);
}

.quick-actions-btn:active {
    transform: scale(0.95);
}

/* ---- Theme Toggle Button ---- */
#theme-toggle {
    border-radius: 50% !important;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease !important;
}

#theme-toggle:hover {
    background-color: var(--color-surface-alt) !important;
    color: var(--color-accent) !important;
    transform: scale(1.05);
}

#theme-toggle:active {
    transform: scale(0.95);
}

/* Main Content */
#app-content {
    padding: 24px;
    flex: 1;
    min-height: calc(100vh - var(--topbar-height));
    overflow-x: hidden;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    font-size: 24px;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Grid System */
.grid {
    display: grid;
    gap: 20px;
}

.grid-cols-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.grid-cols-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.grid-cols-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* Flex utilities */
.flex {
    display: flex;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }

/* Large screens */
@media (min-width: 1920px) {
    #app-content {
        padding: 28px 32px;
    }
}

/* Responsive */
@media (max-width: 1200px) {
    .grid-cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    /* Sidebar overlay on mobile */
    #sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        width: var(--sidebar-width); /* Always full-width sidebar on mobile */
    }

    #sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    #sidebar.collapsed {
        transform: translateX(-100%);
        width: var(--sidebar-width); /* Don't collapse width on mobile */
    }

    /* Restore text visibility in mobile sidebar even when collapsed */
    #sidebar.collapsed .sidebar-label,
    #sidebar.collapsed .sidebar-logo-text,
    #sidebar.collapsed .sidebar-section-label,
    #sidebar.collapsed .sidebar-user-info {
        opacity: 1;
        width: auto;
        overflow: visible;
    }

    #sidebar.collapsed .sidebar-nav-item {
        justify-content: flex-start;
        padding-left: 12px;
        padding-right: 12px;
    }

    #sidebar.collapsed .sidebar-logo {
        justify-content: flex-start;
        padding-left: 20px;
        padding-right: 20px;
    }

    #sidebar.collapsed .sidebar-footer {
        justify-content: flex-start;
        padding-left: 16px;
        padding-right: 16px;
    }

    #sidebar.collapsed .sidebar-search-wrap {
        opacity: 1;
        height: auto;
        padding: 12px 16px 4px;
        pointer-events: auto;
    }

    /* Hide collapse toggle button on mobile - not needed with hamburger menu */
    .sidebar-collapse-btn {
        display: none;
    }

    .app-main {
        margin-left: 0 !important;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: calc(var(--z-sidebar) - 1);
        visibility: hidden;
        opacity: 0;
        transition: opacity 0.3s ease, visibility 0.3s;
    }

    .sidebar-overlay.active {
        visibility: visible;
        opacity: 1;
    }

    #app-content {
        padding: 16px;
    }

    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    #app-content {
        padding: 12px;
    }

    .page-header h1 {
        font-size: 20px;
    }
}

/* Exchange Rate in Topbar */
.topbar-exchange-rate {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-right: 12px;
    padding: 6px 14px;
    background: var(--color-bg-secondary);
    border-radius: 20px;
    border: 1px solid var(--color-border-light);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.topbar-exchange-rate:hover {
    border-color: var(--color-border);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.topbar-exchange-rate .rate-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.topbar-exchange-rate .rate-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
    font-family: 'Plus Jakarta Sans', monospace;
    font-variant-numeric: tabular-nums;
}
.topbar-exchange-rate .rate-currency {
    font-size: 11px;
    opacity: 0.6;
    font-weight: 500;
}
.rate-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.rate-dot-loading { background: var(--color-text-muted); }
.rate-dot-fresh {
    background: var(--color-success);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
    animation: rateDotGlow 2.5s ease-in-out infinite;
}
.rate-dot-stale { background: var(--color-warning); animation: ratePulse 2s infinite; }
.rate-dot-error { background: var(--color-danger); }

@keyframes ratePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes rateDotGlow {
    0%, 100% { box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15); }
    50% { box-shadow: 0 0 0 5px rgba(5, 150, 105, 0.08); }
}

/* ---- Dark Theme Tooltip Variables ---- */
[data-theme="dark"] .sidebar-tooltip {
    --sidebar-tooltip-bg: #e2e8f0;
    --sidebar-tooltip-text: #0f172a;
    background: var(--sidebar-tooltip-bg);
    color: var(--sidebar-tooltip-text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* ---- Dark Theme Solid Sidebar (Brutalist) ---- */
[data-theme="dark"] #sidebar {
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
}

/* ---- Dark Theme Frosted Topbar ---- */
[data-theme="dark"] #topbar {
    background-color: rgba(21, 21, 40, 0.85);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* ---- Dark Theme Sidebar Overlay ---- */
[data-theme="dark"] .sidebar-overlay.active {
    background: rgba(0, 0, 0, 0.7);
}

/* ---- Topbar Hamburger Button (Mobile) ---- */
.topbar-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: none;
    border-radius: var(--radius-md);
    background: none;
    color: var(--color-text);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.topbar-hamburger:hover {
    background: var(--color-surface-alt);
}

.topbar-hamburger:active {
    background: var(--color-border-light);
}

.topbar-hamburger svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .topbar-hamburger,
    #mobile-menu-btn {
        display: flex !important;
    }

    #topbar {
        padding: 0 12px;
        gap: 8px;
    }

    .topbar-right {
        gap: 4px !important;
    }

    /* Hide user name text, show only avatar */
    #user-dropdown-btn span {
        display: none;
    }

    #user-dropdown-btn svg:last-child {
        display: none;
    }

    #user-dropdown-btn {
        padding: 6px !important;
    }

    /* Ensure all interactive elements meet 44px touch target */
    #topbar .btn,
    #topbar button {
        min-width: 44px;
        min-height: 44px;
    }

    .app-main {
        max-width: 100vw !important;
    }

    /* Responsive search: collapse to icon on mobile */
    .global-search-input-wrap {
        min-width: 44px !important;
        padding: 6px 10px !important;
        transition: min-width 0.3s ease, padding 0.3s ease !important;
    }

    .global-search-input-wrap:focus-within {
        min-width: 240px !important;
        padding: 6px 14px !important;
    }

    .global-search-input {
        width: 0 !important;
        opacity: 0;
        transition: width 0.3s ease, opacity 0.3s ease;
    }

    .global-search-input-wrap:focus-within .global-search-input {
        width: 160px !important;
        opacity: 1;
    }

    .global-search-kbd {
        display: none !important;
    }

    .topbar-breadcrumb-current {
        font-size: 14px !important;
    }

    /* Hide exchange rate label on medium screens */
    .topbar-exchange-rate .rate-label {
        display: none;
    }

    /* Better hamburger menu transition */
    #sidebar {
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.35s ease;
    }

    #sidebar.mobile-open {
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    }

    .sidebar-overlay {
        transition: opacity 0.35s ease, visibility 0.35s;
    }
}

@media (max-width: 640px) {
    /* Hide exchange rate on small screens */
    .topbar-exchange-rate {
        display: none !important;
    }

    #topbar {
        padding: 0 8px;
        height: 56px;
    }

    #topbar-title {
        font-size: 15px !important;
    }

    #app-content {
        padding: 12px 8px;
    }

    /* Further shrink search on small screens */
    .global-search-input-wrap {
        min-width: auto !important;
        padding: 5px 10px !important;
    }
    .global-search-input-wrap:focus-within {
        min-width: 180px !important;
    }
    .global-search-input {
        width: 70px !important;
        font-size: 12px !important;
    }

    /* Hide breadcrumb on small screens */
    .topbar-breadcrumb {
        display: none !important;
    }

    /* Quick actions & theme toggle: smaller on mobile */
    .quick-actions-btn,
    #theme-toggle {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        min-height: 36px !important;
    }
}

@media (max-width: 480px) {
    #app-content {
        padding: 8px 6px;
    }

    .page-header h1 {
        font-size: 18px;
    }
}

/* Bottom Mobile Navigation */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--color-surface, #fff);
    border-top: 1px solid var(--color-border);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding: 0 4px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
    }

    /* Add padding to main content so it doesn't hide behind bottom nav */
    #app-content {
        padding-bottom: 72px !important;
    }
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
    border: none;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    min-width: 56px;
}

.bottom-nav-item.active {
    color: var(--color-primary);
}

.bottom-nav-item:hover {
    color: var(--color-primary);
    background: var(--color-primary-light, rgba(79, 143, 247, 0.08));
}

.bottom-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.bottom-nav-label {
    line-height: 1;
    white-space: nowrap;
}

/* ============================================
   Mobile Responsiveness Improvements
   ============================================ */

/* ---- Stat Cards: 2-column grid on mobile ---- */
@media (max-width: 768px) {
    .stats-row,
    .stat-cards,
    .stats-grid,
    .dashboard-stats {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 18px;
    }

    .stat-label {
        font-size: 10px;
    }

    .stat-icon {
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }

    .stat-icon svg {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 480px) {
    .stats-row,
    .stat-cards,
    .stats-grid,
    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-value {
        font-size: 16px;
    }

    .stat-icon {
        width: 28px;
        height: 28px;
    }

    .stat-icon svg {
        width: 14px;
        height: 14px;
    }
}

/* ---- Full-width modals on mobile ---- */
@media (max-width: 768px) {
    .modal-backdrop {
        padding: 0 !important;
        align-items: flex-end !important;
    }

    .modal {
        border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
        max-height: 92vh !important;
        animation: modalSlideUp 300ms ease forwards !important;
    }

    .modal-sm,
    .modal-md,
    .modal-lg {
        max-width: 100% !important;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-body {
        padding: 16px 20px;
    }

    .modal-footer {
        padding: 12px 20px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    /* Drag handle indicator on modal top */
    .modal::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--color-border);
        border-radius: 2px;
        margin: 8px auto 0;
        flex-shrink: 0;
    }
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Touch targets: min 44px for all interactive elements ---- */
@media (max-width: 768px) {
    .btn,
    button,
    a.btn,
    .dropdown-item,
    .tab,
    .pagination-btn,
    .sidebar-nav-item,
    .bottom-nav-item {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 40px;
        padding: 8px 14px;
    }

    .btn-icon {
        min-width: 44px;
        min-height: 44px;
    }

    .btn-icon.btn-sm {
        min-width: 40px;
        min-height: 40px;
    }

    /* Increase input heights for easier tapping */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="search"],
    input[type="url"],
    input[type="tel"],
    select,
    textarea {
        min-height: 44px;
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    /* Pagination touch targets */
    .pagination-btn {
        min-width: 44px;
        height: 44px;
    }

    /* Checkbox and radio touch targets */
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 20px;
        min-height: 20px;
    }

    /* Modal close button touch target */
    .modal-close {
        width: 44px;
        height: 44px;
    }

    /* Side panel buttons */
    .side-panel-close {
        width: 44px;
        height: 44px;
    }

    .side-panel-nav-btn {
        width: 40px;
        height: 40px;
    }

    /* Toast close button */
    .toast-close {
        width: 44px;
        height: 44px;
    }

    /* Attachment action buttons */
    .attachment-actions .btn-xs {
        width: 40px;
        height: 40px;
    }

    /* Tag color buttons */
    .tag-color-btn {
        width: 32px;
        height: 32px;
    }

    /* Tag add button */
    .tag-add-btn {
        width: 32px;
        height: 32px;
    }
}

/* ---- Bottom nav with badge support ---- */
.bottom-nav-item {
    position: relative;
}

.bottom-nav-badge {
    position: absolute;
    top: 2px;
    right: 50%;
    transform: translateX(calc(50% + 10px));
    background: var(--color-danger);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    pointer-events: none;
    font-variant-numeric: tabular-nums;
}

.bottom-nav-badge:empty {
    display: none;
}

.bottom-nav-badge.badge-muted {
    background: var(--color-text-muted);
}

.bottom-nav-badge.badge-primary {
    background: var(--color-primary);
}

/* ---- Swipe gesture hint indicator ---- */
@keyframes swipeHint {
    0% { opacity: 0; transform: translateX(0); }
    30% { opacity: 1; }
    60% { opacity: 1; transform: translateX(-12px); }
    100% { opacity: 0; transform: translateX(-12px); }
}

.swipe-hint {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 2px;
    pointer-events: none;
    z-index: 5;
    animation: swipeHint 2s ease-in-out 1s 2;
}

.swipe-hint::before {
    content: '';
    display: block;
    width: 20px;
    height: 2px;
    background: var(--color-text-muted);
    border-radius: 1px;
    opacity: 0.5;
}

.swipe-hint::after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-right: 6px solid var(--color-text-muted);
    opacity: 0.5;
}

@media (min-width: 769px) {
    .swipe-hint {
        display: none !important;
    }
}

/* ---- Table horizontal scroll shadow indicators ---- */
.table-scroll-container {
    position: relative;
}

.table-scroll-shadow-left,
.table-scroll-shadow-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 24px;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.table-scroll-shadow-left {
    left: 0;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.08), transparent);
}

.table-scroll-shadow-right {
    right: 0;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.08), transparent);
}

.table-scroll-shadow-left.visible,
.table-scroll-shadow-right.visible {
    opacity: 1;
}

[data-theme="dark"] .table-scroll-shadow-left {
    background: linear-gradient(to right, rgba(0, 0, 0, 0.25), transparent);
}

[data-theme="dark"] .table-scroll-shadow-right {
    background: linear-gradient(to left, rgba(0, 0, 0, 0.25), transparent);
}

/* CSS-only scroll shadows on table-wrapper */
@media (max-width: 768px) {
    .table-wrapper {
        position: relative;
        /* CSS scroll shadow trick using background-attachment */
        background:
            linear-gradient(to right, var(--color-surface, #fff) 30%, transparent) left center,
            linear-gradient(to left, var(--color-surface, #fff) 30%, transparent) right center,
            linear-gradient(to right, rgba(0, 0, 0, 0.1), transparent) left center,
            linear-gradient(to left, rgba(0, 0, 0, 0.1), transparent) right center;
        background-size: 40px 100%, 40px 100%, 16px 100%, 16px 100%;
        background-repeat: no-repeat;
        background-attachment: local, local, scroll, scroll;
    }

    [data-theme="dark"] .table-wrapper {
        background:
            linear-gradient(to right, var(--color-surface, #1e293b) 30%, transparent) left center,
            linear-gradient(to left, var(--color-surface, #1e293b) 30%, transparent) right center,
            linear-gradient(to right, rgba(0, 0, 0, 0.25), transparent) left center,
            linear-gradient(to left, rgba(0, 0, 0, 0.25), transparent) right center;
        background-size: 40px 100%, 40px 100%, 16px 100%, 16px 100%;
        background-repeat: no-repeat;
        background-attachment: local, local, scroll, scroll;
    }
}

/* ---- Hide less important table columns on mobile ---- */
@media (max-width: 768px) {
    /* Hide columns that are less critical on mobile */
    table th.col-hide-mobile,
    table td.col-hide-mobile {
        display: none !important;
    }

    /* Common columns to hide: notes, warehouse, labels, etc. */
    table th:nth-child(n+8),
    table td:nth-child(n+8) {
        display: none;
    }

    /* But always show the last column (actions) */
    table th:last-child,
    table td:last-child {
        display: table-cell !important;
    }

    /* Always show first column (checkbox) */
    table th:first-child,
    table td:first-child {
        display: table-cell !important;
    }

    /* Reduce min-width for table to fit mobile */
    table {
        min-width: 600px;
    }

    /* Compact cell padding */
    thead th {
        padding: 8px 10px;
        font-size: 10px;
    }

    tbody td {
        padding: 10px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    table {
        min-width: 480px;
    }

    /* Hide even more columns on very small screens */
    table th:nth-child(n+6),
    table td:nth-child(n+6) {
        display: none;
    }

    /* Keep actions column visible */
    table th:last-child,
    table td:last-child {
        display: table-cell !important;
    }

    /* Keep first column (checkbox) */
    table th:first-child,
    table td:first-child {
        display: table-cell !important;
    }

    thead th {
        padding: 6px 8px;
    }

    tbody td {
        padding: 8px;
    }
}

/* ---- Bottom sheet style dropdowns on mobile ---- */
@media (max-width: 768px) {
    /* Create bottom sheet overlay for dropdown menus */
    .dropdown-menu.open,
    .dropdown-menu.bottom-sheet {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        max-width: 100% !important;
        width: 100% !important;
        max-height: 60vh;
        overflow-y: auto;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
        border: none !important;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15) !important;
        z-index: 1100 !important;
        padding: 8px 0 !important;
        padding-bottom: max(8px, env(safe-area-inset-bottom)) !important;
        animation: bottomSheetSlideUp 250ms ease forwards !important;
    }

    /* Bottom sheet drag handle */
    .dropdown-menu.open::before,
    .dropdown-menu.bottom-sheet::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--color-border);
        border-radius: 2px;
        margin: 4px auto 8px;
    }

    /* Larger touch targets for dropdown items */
    .dropdown-item {
        padding: 14px 20px !important;
        font-size: 15px !important;
    }

    .dropdown-divider {
        margin: 4px 16px !important;
    }

    /* Bottom sheet backdrop */
    .dropdown-backdrop-mobile {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1099;
        animation: modalFadeIn 200ms ease forwards;
    }

    /* Notification dropdown as bottom sheet */
    .notification-dropdown.open {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-height: 70vh;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
        margin-top: 0 !important;
        z-index: 1100 !important;
        animation: bottomSheetSlideUp 250ms ease forwards !important;
    }

    .notification-dropdown.open::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--color-border);
        border-radius: 2px;
        margin: 4px auto 4px;
    }

    /* User dropdown as bottom sheet */
    .user-dropdown.open {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
        z-index: 1100 !important;
        animation: bottomSheetSlideUp 250ms ease forwards !important;
    }
}

@keyframes bottomSheetSlideUp {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Page-level header actions stacking on mobile ---- */
@media (max-width: 768px) {
    .page-header-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .page-header-actions .btn {
        flex: 1;
        min-width: 0;
        justify-content: center;
    }
}

/* ---- Filter bar mobile improvements ---- */
@media (max-width: 768px) {
    .filters-row,
    .filter-bar,
    .imports-filters {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .filters-row > *,
    .filter-bar > *,
    .imports-filters > * {
        min-width: calc(50% - 4px);
        flex: 1;
    }
}

/* Accessibility: Disable animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    #sidebar {
        transition: none !important;
    }
    .app-main {
        transition: none !important;
    }
    .sidebar-collapse-chevron {
        transition: none !important;
    }
    .sidebar-collapse-btn {
        transition: none !important;
    }
    .sidebar-overlay {
        transition: none !important;
    }
    .sidebar-nav-item,
    .sidebar-nav-item.active,
    .sidebar-nav-item:not(.active) {
        transition: none !important;
        transform: none !important;
    }
    .sidebar-tooltip {
        transition: none !important;
    }
    /* Disable new mobile animations */
    .modal {
        animation: none !important;
    }
    .dropdown-menu.open,
    .dropdown-menu.bottom-sheet {
        animation: none !important;
    }
    .notification-dropdown.open {
        animation: none !important;
    }
    .user-dropdown.open {
        animation: none !important;
    }
    .swipe-hint {
        animation: none !important;
        display: none !important;
    }
    .dropdown-backdrop-mobile {
        animation: none !important;
    }
    /* Disable topbar hover transforms */
    .notification-bell,
    .quick-actions-btn,
    #theme-toggle,
    #user-dropdown-btn > div:first-child {
        transition: none !important;
        transform: none !important;
    }
    .rate-dot-fresh {
        animation: none !important;
    }
}

/* ============================================
   Sidebar Search
   ============================================ */
.sidebar-search-wrap {
    padding: 12px 16px 4px;
    transition: opacity var(--transition-base, 0.2s);
}

.sidebar-search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.sidebar-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
    flex-shrink: 0;
}

.sidebar-search-input {
    width: 100%;
    height: 34px;
    padding: 0 30px 0 32px;
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: 8px;
    background: var(--color-bg, #f8fafc);
    color: var(--color-text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sidebar-search-input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.7;
}

.sidebar-search-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(79, 143, 247, 0.15);
}

.sidebar-search-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 4px;
    padding: 0;
    transition: color 0.15s, background 0.15s;
}

.sidebar-search-clear:hover {
    color: var(--color-text);
    background: var(--color-surface-alt, rgba(0,0,0,0.05));
}

/* Collapsed sidebar: hide search */
#sidebar.collapsed .sidebar-search-wrap {
    opacity: 0;
    height: 0;
    padding: 0;
    overflow: hidden;
    pointer-events: none;
}

/* ============================================
   Sidebar Favorites Section
   ============================================ */
.sidebar-favorites-section {
    transition: opacity var(--transition-base, 0.2s);
}

.sidebar-favorites-divider {
    height: 1px;
    background: var(--sidebar-border, var(--color-border));
    margin: 8px 24px;
    opacity: 0.6;
}

/* Collapsed sidebar: show only icons in favorites */
#sidebar.collapsed .sidebar-favorites-divider {
    margin: 8px 16px;
}

#sidebar.collapsed .sidebar-fav-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}

/* ============================================
   Sidebar Star (Pin/Unpin) Button
   ============================================ */
.sidebar-star-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    min-width: 24px;
    border: none;
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 4px;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease, transform 0.15s ease;
    flex-shrink: 0;
}

/* Show star on hover of the nav item */
.sidebar-nav-item:hover .sidebar-star-btn,
.sidebar-nav-item:focus-within .sidebar-star-btn {
    opacity: 0.6;
}

.sidebar-star-btn:hover {
    opacity: 1 !important;
    color: #f59e0b;
    transform: scale(1.15);
}

/* Always show filled stars */
.sidebar-star-btn.starred {
    opacity: 1 !important;
    color: #f59e0b;
}

.sidebar-star-btn.starred:hover {
    color: #d97706;
}

/* Hide star buttons when sidebar is collapsed */
#sidebar.collapsed .sidebar-star-btn {
    display: none;
}

/* ============================================
   Sidebar Favorites Drag & Drop
   ============================================ */
.sidebar-fav-item {
    position: relative;
    transition: background-color 0.15s ease, opacity 0.2s ease, transform 0.2s ease;
}

.sidebar-fav-item.dragging {
    opacity: 0.4 !important;
    background: var(--color-surface-alt, #f1f5f9) !important;
    cursor: grabbing;
}

/* Insertion indicator - above */
.sidebar-fav-item.drag-over-above {
    box-shadow: inset 0 2px 0 0 var(--color-primary) !important;
}

/* Insertion indicator - below */
.sidebar-fav-item.drag-over-below {
    box-shadow: inset 0 -2px 0 0 var(--color-primary) !important;
}

/* ---- Drag Handle (6 dots grip) ---- */
.sidebar-fav-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 20px;
    flex-shrink: 0;
    color: var(--color-text-muted, #94a3b8);
    cursor: grab;
    opacity: 0;
    transition: opacity 0.15s ease;
    margin-left: -4px;
    margin-right: -4px;
}

.sidebar-fav-drag-handle:active {
    cursor: grabbing;
}

/* Show drag handle on hover */
.sidebar-fav-item:hover .sidebar-fav-drag-handle {
    opacity: 0.5;
}

.sidebar-fav-item:hover .sidebar-fav-drag-handle:hover {
    opacity: 1;
}

/* ---- Edit Mode Toggle Button ---- */
.sidebar-fav-edit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: none;
    background: none;
    color: var(--color-text-muted, #94a3b8);
    cursor: pointer;
    border-radius: 4px;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.sidebar-fav-label:hover .sidebar-fav-edit-btn {
    opacity: 0.6;
}

.sidebar-fav-edit-btn:hover {
    opacity: 1 !important;
    color: var(--color-primary);
    background: var(--color-primary-light, rgba(79, 143, 247, 0.08));
}

.sidebar-fav-edit-btn.active {
    opacity: 1 !important;
    color: var(--color-primary);
    background: var(--color-primary-light, rgba(79, 143, 247, 0.1));
}

/* ---- Delete Button (X) in Favorites ---- */
.sidebar-fav-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: none;
    background: none;
    color: var(--color-text-muted, #94a3b8);
    cursor: pointer;
    border-radius: 4px;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}

/* Show delete button on hover of item (non-edit mode) */
.sidebar-fav-item:hover .sidebar-fav-delete-btn {
    opacity: 0;
}

.sidebar-fav-delete-btn:hover {
    color: var(--color-danger, #ef4444);
    background: var(--color-danger-light, rgba(239, 68, 68, 0.08));
}

/* ---- Edit Mode: always show handles and delete buttons ---- */
.sidebar-favorites-section.edit-mode .sidebar-fav-drag-handle {
    opacity: 0.6 !important;
}

.sidebar-favorites-section.edit-mode .sidebar-fav-item:hover .sidebar-fav-drag-handle {
    opacity: 1 !important;
}

.sidebar-favorites-section.edit-mode .sidebar-fav-delete-btn,
.sidebar-favorites-section.edit-mode .sidebar-fav-item:hover .sidebar-fav-delete-btn {
    opacity: 0.6 !important;
}

.sidebar-favorites-section.edit-mode .sidebar-fav-delete-btn:hover {
    opacity: 1 !important;
}

.sidebar-favorites-section.edit-mode .sidebar-fav-item {
    cursor: grab;
}

.sidebar-favorites-section.edit-mode .sidebar-fav-item:active {
    cursor: grabbing;
}

.sidebar-favorites-list.edit-mode {
    padding: 4px;
    border-radius: 8px;
    background: var(--color-surface-alt, rgba(0, 0, 0, 0.02));
    border: 1px dashed var(--color-border, #e2e8f0);
}

/* Hide drag handle and delete when sidebar is collapsed */
#sidebar.collapsed .sidebar-fav-drag-handle,
#sidebar.collapsed .sidebar-fav-delete-btn,
#sidebar.collapsed .sidebar-fav-edit-btn {
    display: none;
}

/* ============================================
   Sidebar Favorites: Dark Theme
   ============================================ */
[data-theme="dark"] .sidebar-search-input {
    background: var(--color-bg, #0f172a);
    border-color: var(--color-border, #334155);
    color: var(--color-text, #e2e8f0);
}

[data-theme="dark"] .sidebar-search-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(79, 143, 247, 0.2);
}

[data-theme="dark"] .sidebar-search-input::placeholder {
    color: var(--color-text-muted, #64748b);
}

[data-theme="dark"] .sidebar-search-clear:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text, #e2e8f0);
}

[data-theme="dark"] .sidebar-favorites-divider {
    background: var(--sidebar-border, #334155);
    opacity: 0.5;
}

[data-theme="dark"] .sidebar-star-btn {
    color: var(--color-text-muted, #64748b);
}

[data-theme="dark"] .sidebar-star-btn:hover {
    color: #fbbf24;
}

[data-theme="dark"] .sidebar-star-btn.starred {
    color: #fbbf24;
}

[data-theme="dark"] .sidebar-star-btn.starred:hover {
    color: #f59e0b;
}

[data-theme="dark"] .sidebar-fav-item.dragging {
    background: rgba(255, 255, 255, 0.05) !important;
}

[data-theme="dark"] .sidebar-fav-item.drag-over-above {
    box-shadow: inset 0 2px 0 0 var(--color-primary) !important;
}

[data-theme="dark"] .sidebar-fav-item.drag-over-below {
    box-shadow: inset 0 -2px 0 0 var(--color-primary) !important;
}

[data-theme="dark"] .sidebar-fav-drag-handle {
    color: var(--color-text-muted, #64748b);
}

[data-theme="dark"] .sidebar-fav-edit-btn {
    color: var(--color-text-muted, #64748b);
}

[data-theme="dark"] .sidebar-fav-edit-btn:hover {
    color: var(--color-primary);
    background: rgba(79, 143, 247, 0.12);
}

[data-theme="dark"] .sidebar-fav-edit-btn.active {
    color: var(--color-primary);
    background: rgba(79, 143, 247, 0.15);
}

[data-theme="dark"] .sidebar-fav-delete-btn {
    color: var(--color-text-muted, #64748b);
}

[data-theme="dark"] .sidebar-fav-delete-btn:hover {
    color: #f87171;
    background: rgba(239, 68, 68, 0.12);
}

[data-theme="dark"] .sidebar-favorites-list.edit-mode {
    background: rgba(255, 255, 255, 0.02);
    border-color: var(--color-border, #334155);
}

/* ============================================
   Sidebar Search & Favorites: Mobile
   ============================================ */
@media (max-width: 768px) {
    .sidebar-search-wrap {
        padding: 12px 16px 4px;
    }

    .sidebar-search-input {
        height: 40px;
        font-size: 16px; /* prevent iOS zoom */
    }

    .sidebar-star-btn {
        opacity: 0.5;
        width: 32px;
        height: 32px;
        min-width: 32px;
    }
}

/* Reduced motion: disable drag animations */
@media (prefers-reduced-motion: reduce) {
    .sidebar-fav-item {
        transition: none !important;
    }
    .sidebar-star-btn {
        transition: none !important;
    }
    .sidebar-search-input {
        transition: none !important;
    }
    .sidebar-fav-drag-handle {
        transition: none !important;
    }
    .sidebar-fav-edit-btn {
        transition: none !important;
    }
    .sidebar-fav-delete-btn {
        transition: none !important;
    }
}

/* ============================================
   TOPBAR ENHANCEMENTS - Session 19 Iteration 7
   ============================================ */

/* Global Search Dropdown */
.global-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg, 10px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    max-height: 480px;
    overflow-y: auto;
    display: none;
    z-index: calc(var(--z-topbar, 100) + 20);
    animation: searchDropdownIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.global-search-dropdown.open {
    display: block;
}

@keyframes searchDropdownIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Search Group Header */
.gs-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border-light);
}

.gs-group-header:first-child {
    border-top: none;
}

.gs-group-icon {
    display: flex;
    align-items: center;
    opacity: 0.5;
}

/* Search Result Items */
.gs-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background-color 0.12s ease;
    border-bottom: 1px solid var(--color-border-light, rgba(0, 0, 0, 0.04));
}

.gs-item:last-of-type {
    border-bottom: none;
}

.gs-item:hover,
.gs-item--active {
    background-color: var(--color-surface-alt, #f8fafc);
}

.gs-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--color-bg-secondary, #f1f5f9);
    color: var(--color-text-muted);
    padding: 8px;
}

.gs-item-icon--action {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.gs-item-content {
    flex: 1;
    min-width: 0;
}

.gs-item-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gs-item-title mark {
    background: var(--color-warning-light, #fef3c7);
    color: var(--color-text);
    font-weight: 600;
    padding: 0 2px;
    border-radius: 2px;
}

.gs-item-subtitle {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gs-item-arrow {
    display: flex;
    align-items: center;
    opacity: 0;
    color: var(--color-text-muted);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.gs-item:hover .gs-item-arrow,
.gs-item--active .gs-item-arrow {
    opacity: 1;
    transform: translateX(2px);
}

.gs-shortcut {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    color: var(--color-text-muted);
    font-weight: 500;
    font-family: 'Plus Jakarta Sans', monospace;
}

/* Search Status Badge */
.gs-status-badge {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Search Stars (Supplier Rating) */
.gs-stars {
    display: inline-flex;
    gap: 2px;
}

.gs-star {
    font-size: 14px;
    color: var(--color-border);
}

.gs-star--active {
    color: #fbbf24;
}

/* Search Empty State */
.gs-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    gap: 10px;
    color: var(--color-text-muted);
    font-size: 13px;
}

.gs-empty-icon {
    display: flex;
    opacity: 0.3;
    transform: scale(1.5);
}

.gs-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Search Footer (Result Count) */
.gs-footer {
    padding: 8px 14px;
    font-size: 11px;
    color: var(--color-text-muted);
    text-align: center;
    border-top: 1px solid var(--color-border-light);
    background: var(--color-bg-secondary, #f8fafc);
}

/* Recent Search Items */
.gs-item-recent {
    position: relative;
}

.gs-item-remove {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: none;
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.gs-item-recent:hover .gs-item-remove {
    display: flex;
}

.gs-item-remove:hover {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.gs-clear-history {
    padding: 8px 14px;
    font-size: 11px;
    color: var(--color-primary);
    text-align: center;
    cursor: pointer;
    font-weight: 500;
    border-top: 1px solid var(--color-border-light);
}

.gs-clear-history:hover {
    background: var(--color-primary-light);
}

/* User Dropdown Menu Enhancement */
.user-dropdown-menu {
    min-width: 260px;
}

.user-dropdown-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
}

.user-dropdown-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-primary-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.user-dropdown-details {
    flex: 1;
    min-width: 0;
}

.user-dropdown-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-email {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-role {
    font-size: 10px;
    color: var(--color-primary);
    font-weight: 500;
    margin-top: 4px;
    background: var(--color-primary-light);
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
}

/* Exchange Rate Trend Arrows */
.rate-trend {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
    vertical-align: middle;
}

.rate-trend-up {
    color: var(--color-success);
}

.rate-trend-down {
    color: var(--color-danger);
}

.rate-value.rate-up {
    color: var(--color-success);
}

.rate-value.rate-down {
    color: var(--color-danger);
}

/* Notification Badge Bounce Animation */
.notification-badge-bounce {
    animation: badgeBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes badgeBounce {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(0.9); }
    75% { transform: scale(1.1); }
}

/* Ctrl+K Badge - Hide on Focus */
.global-search-input:focus + .global-search-kbd,
.global-search-input:not(:placeholder-shown) + .global-search-kbd {
    opacity: 0;
    pointer-events: none;
}

/* Topbar Responsive Design */
@media (max-width: 768px) {
    /* Hide exchange rate on mobile */
    .topbar-exchange-rate {
        display: none !important;
    }

    /* Collapse search to icon on mobile */
    .global-search-container {
        position: relative;
    }

    .global-search-input-wrap {
        min-width: auto !important;
        width: 36px;
        padding: 6px;
        transition: width 0.3s ease, min-width 0.3s ease;
    }

    .global-search-input-wrap:focus-within {
        width: 240px;
        min-width: 240px !important;
    }

    .global-search-input {
        width: 0;
        opacity: 0;
        transition: width 0.3s ease, opacity 0.3s ease;
    }

    .global-search-input-wrap:focus-within .global-search-input {
        width: 160px !important;
        opacity: 1;
    }

    .global-search-kbd {
        display: none !important;
    }

    .global-search-clear {
        display: none !important;
    }

    .global-search-input-wrap:focus-within .global-search-clear {
        display: flex !important;
    }

    /* Compact quick actions */
    .topbar-quick-actions {
        display: none;
    }

    /* User dropdown - just avatar */
    #user-dropdown-btn span:not(.sr-only):not([aria-hidden]) {
        display: none !important;
    }

    #user-dropdown-btn svg {
        display: none !important;
    }
}

@media (max-width: 640px) {
    #topbar {
        padding: 0 12px;
    }

    .global-search-dropdown {
        left: -12px;
        right: -12px;
        border-radius: 0;
    }
}
