/* ============================================
   INVENTORY MANAGER - PREMIUM DARK THEME
   ============================================ */

/* CSS Variables */
:root {
    /* Colors */
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-card: rgba(26, 26, 46, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.05);

    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6c6c7c;

    --accent-blue: #f97316;
    /* FOOD HUT Orange */
    --accent-blue-hover: #fb923c;
    --accent-green: #22c55e;
    /* FOOD HUT Green */
    --accent-orange: #f97316;
    --accent-red: #ef4444;
    --accent-purple: #16a34a;
    /* FOOD HUT Darker Green */

    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.3);

    /* Spacing */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --header-height: 70px;
    --border-radius: 12px;
    --border-radius-sm: 8px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 10px;
    border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox Support */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) var(--bg-primary);
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background Gradient Effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(77, 124, 254, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(168, 85, 247, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.hidden {
    display: none !important;
}

/* Utils */
.text-right {
    text-align: right !important;
}

.text-center {
    text-align: center !important;
}

.text-left {
    text-align: left !important;
}

/* Fixed column widths for multi-card alignment */
.amount-col {
    width: 140px;
    min-width: 140px;
}

.prev-col {
    width: 120px;
    min-width: 120px;
}

/* ============================================
   APP LAYOUT
   ============================================ */

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: all var(--transition-normal);
    overflow-x: visible;
    /* Ensure pop-out is visible */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.sidebar::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-toggle {
    position: absolute;
    right: -12px;
    top: 25px;
    width: 24px;
    height: 24px;
    background: var(--accent-blue);
    border: none !important;
    outline: none !important;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 101;
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: transform var(--transition-normal);
}

.sidebar.collapsed .sidebar-toggle {
    transform: rotate(180deg);
}

.toggle-icon {
    width: 14px;
    height: 14px;
}

.sidebar.active~.sidebar-overlay {
    display: block;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 90;
    animation: fadeIn 0.3s ease;
}


.logo {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

.logo-image {
    max-width: 100%;
    height: 40px;
    object-fit: contain;
    transition: all var(--transition-normal);
}

.icon-logo {
    display: none !important;
}

.sidebar.collapsed .full-logo {
    display: none !important;
}

.sidebar.collapsed .icon-logo {
    display: block !important;
    height: 32px;
}

.nav-menu {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    /* gap: 4px; REMOVED to prevent hover glitches */
    overflow-y: auto;
    overflow-x: visible;
    /* Crucial for pop-out menu */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.nav-menu:hover {
    overflow: visible !important;
    /* Force visible on hover for pop-out */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.nav-menu::-webkit-scrollbar {
    display: none;
}

.sidebar.collapsed .nav-menu {
    overflow: visible;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 4px;
    /* Move gap to margin/padding for better hover continuity */
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    position: relative;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.2), rgba(34, 197, 94, 0.1));
    color: var(--text-primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--accent-blue);
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    font-size: 18px;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px;
    width: 100%;
    transition: width var(--transition-normal), background var(--transition-fast);
}

.sidebar.collapsed .nav-item span:not(.badge) {
    display: none;
    white-space: nowrap;
    opacity: 0;
}

/* Hover Pop-out Rectangle */
.sidebar.collapsed .nav-item:hover {
    width: 240px;
    background: var(--bg-secondary);
    box-shadow: 10px 5px 20px var(--shadow-color);
    z-index: 1000;
    justify-content: flex-start;
    padding: 12px 20px;
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
    border: 1px solid var(--border-color);
    border-left: none;
}

.sidebar.collapsed .nav-item:hover span:not(.badge) {
    display: inline;
    opacity: 1;
    margin-left: 12px;
}

.sidebar.collapsed .nav-icon {
    margin: 0;
    flex-shrink: 0;
}

.sidebar.collapsed .nav-item:hover .nav-icon {
    margin-right: 0;
    /* Already handled by span margin */
}

.sidebar.collapsed .badge {
    position: absolute;
    top: 5px;
    right: 5px;
    margin: 0;
    font-size: 9px;
    padding: 1px 4px;
    min-width: 16px;
}

.sidebar.collapsed .nav-item:hover .badge {
    position: static;
    margin-left: auto;
    font-size: 11px;
    padding: 2px 8px;
}

.badge {
    margin-left: auto;
    background: var(--accent-red);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.footer-actions {
    display: flex;
    gap: 8px;
}

.btn-icon-only.logout:hover {
    background: rgba(255, 71, 87, 0.2);
    /* Assuming --status-critical-bg is rgba(255, 71, 87, 0.2) */
    color: var(--accent-red);
    /* Assuming --status-critical-text is var(--accent-red) */
}

.nav-section {
    padding: 16px 16px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

/* Dropdown Styles (Right Side Pop-out) */
.nav-dropdown {
    position: relative;
    display: flex;
    flex-direction: column;
}

.dropdown-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    /* Match standard nav-item gap */
}

.dropdown-toggle span {
    flex: 1;
    /* Allow span to take up space but stay after icon */
}

.dropdown-chevron {
    transition: transform var(--transition-normal);
    opacity: 0.6;
    transform: rotate(-90deg);
    /* Point right */
    margin-left: auto;
    /* Push to the absolute right */
}

.dropdown-toggle.active {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.2), rgba(34, 197, 94, 0.1));
    color: var(--text-primary);
}

.dropdown-toggle.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--accent-blue);
    border-radius: 0 3px 3px 0;
}

.dropdown-content {
    position: absolute;
    left: calc(100% + 15px);
    /* Position outside the sidebar edge */
    top: 0;
    width: 240px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 15px 10px 40px var(--shadow-color);
    backdrop-filter: blur(20px);
    opacity: 0;
    visibility: hidden;
    transform: translateX(5px);
    transition: all var(--transition-normal) 0.1s;
    /* transition-delay via shorthand: prevent accidental closure */
    z-index: 10000;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Robust hover bridge to prevent flickering during diagonal mouse movement */
.dropdown-content::before {
    content: '';
    position: absolute;
    top: -20px;
    left: -40px;
    /* Bridge the gap to the sidebar */
    width: 60px;
    height: calc(100% + 40px);
    z-index: -1;
}

.nav-dropdown:hover {
    z-index: 10001;
    /* Ensure current hovered menu is above siblings */
}

.nav-dropdown:hover .dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    transition-delay: 0s;
    /* Open immediately on hover */
}

.sub-item {
    margin: 0 8px;
    padding: 10px 16px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-radius: var(--border-radius-sm);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: flex-start !important;
    /* Ensure icons and text are left-aligned */
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: visible;
    width: auto !important;
    /* Reset nav-item 100% width if needed */
}

.sub-item span {
    display: inline !important;
    opacity: 1 !important;
    visibility: visible !important;
    white-space: nowrap;
    margin-left: 0 !important;
    /* Force override to prevent parent hover from shifting text */
}

.sub-item:hover {
    color: var(--text-primary);
    transform: translateX(4px) translateY(-2px);
    background: var(--bg-glass) !important;
    border-radius: var(--border-radius-sm) !important;
    /* Subtle bounce effect with glass background and subtly rounded corners */
}

.sub-item:hover span {
    color: var(--text-primary);
}

/* Completely decouple sub-items from collapsed generic nav-item styles */
.sidebar.collapsed .sub-item {
    padding: 10px 16px !important;
    /* Lock to exact expanded padding */
    width: auto !important;
    border-radius: var(--border-radius-sm);
    /* Reset to default when not hovered */
}

.sidebar.collapsed .sub-item:hover {
    transform: translateX(4px) translateY(-2px) !important;
    background: var(--bg-glass) !important;
    box-shadow: none !important;
    border: none !important;
    width: auto !important;
    border-radius: var(--border-radius-sm) !important;
}

.sub-item.active {
    background: rgba(249, 115, 22, 0.1) !important;
    color: var(--text-primary);
    border-left: 3px solid var(--accent-blue);
}

/* Adjust for Collapsed Sidebar */
.sidebar.collapsed .dropdown-content {
    left: var(--sidebar-collapsed-width);
    /* Align with collapsed sidebar edge */
    top: 0;
    /* Align perfectly with the top of the toggle */
}

/* Overlap Fix: Prevent the Inventory toggle itself from expanding in collapsed mode */
.sidebar.collapsed .nav-dropdown:hover .dropdown-toggle {
    width: var(--sidebar-collapsed-width);
    /* Keep it narrow */
    background: var(--bg-glass);
    box-shadow: none;
    /* No shadow needed as it's not popping out */
    justify-content: center;
    padding: 12px;
    border-radius: var(--border-radius-sm);
    border: none;
}

/* Hide the label for the toggle itself in collapsed mode on hover */
.sidebar.collapsed .nav-dropdown:hover .dropdown-toggle span {
    display: none !important;
}

.sidebar.collapsed .dropdown-chevron {
    display: none;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    overflow: hidden;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.user-avatar:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .user-name {
    display: none;
}

.sidebar.collapsed .user-info:hover .user-name {
    display: flex;
    position: absolute;
    left: var(--sidebar-collapsed-width);
    background: var(--bg-secondary);
    padding: 12px 20px;
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
    box-shadow: 10px 5px 20px var(--shadow-color);
    white-space: nowrap;
    opacity: 1;
    visibility: visible;
    border: 1px solid var(--border-color);
    border-left: none;
}

.sidebar.collapsed .sidebar-footer {
    flex-direction: column;
    gap: 16px;
    padding: 16px 8px;
    align-items: center;
}

.sidebar.collapsed .footer-actions {
    flex-direction: column;
    width: 100%;
    align-items: center;
}

.sidebar.collapsed .btn-action.logout {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
}

.sidebar.collapsed .btn-action.logout:hover span {
    display: flex;
    position: absolute;
    left: var(--sidebar-collapsed-width);
    background: var(--bg-secondary);
    padding: 12px 20px;
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
    box-shadow: 10px 5px 20px var(--shadow-color);
    white-space: nowrap;
    opacity: 1;
    visibility: visible;
    border: 1px solid var(--border-color);
    border-left: none;
}

.btn-action.logout span {
    display: none;
}

.btn-icon-only {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius-sm);
    transition: background var(--transition-fast);
}

.btn-icon-only:hover {
    background: var(--bg-glass);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: all var(--transition-normal);
}

.app-container:has(.sidebar.collapsed) .main-content {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

.sidebar.collapsed~.main-content {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

/* Header */
.header {
    height: var(--header-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: rgba(15, 15, 26, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box {
    position: relative;
}

.search-box input {
    width: 240px;
    padding: 8px 12px 8px 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-fast);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(77, 124, 254, 0.1);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--text-muted);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), #6366f1);
    color: white;
    box-shadow: 0 4px 15px rgba(77, 124, 254, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(77, 124, 254, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-green), #00b57a);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-red), #e83e4c);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-refresh-themed {
    background: var(--bg-tertiary);
    color: var(--accent-orange);
    border: 1px solid rgba(249, 115, 22, 0.3);
    transition: all var(--transition-normal);
}

.btn-refresh-themed:hover {
    background: rgba(249, 115, 22, 0.1);
    border-color: var(--accent-orange);
    color: var(--accent-orange);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.15);
}

.btn-refresh-themed svg {
    transition: transform 0.5s ease;
}

.btn-refresh-themed:hover svg {
    transform: rotate(180deg);
}

.btn-icon {
    font-size: 16px;
}

/* ============================================
   VIEWS & CONTENT
   ============================================ */

.view {
    display: none;
    padding: 24px;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.chart-card {
    display: flex;
    flex-direction: column;
}


.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(10px);
    transition: all var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 40px var(--shadow-color);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-icon.blue {
    background: rgba(77, 124, 254, 0.2);
}

.stat-icon.green {
    background: rgba(0, 214, 143, 0.2);
}

.stat-icon.orange {
    background: rgba(255, 170, 0, 0.2);
}

.stat-icon.purple {
    background: rgba(34, 197, 94, 0.2);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
}

/* Header Tabs */
.header-tabs {
    display: flex;
    gap: 8px;
}

.tab-btn {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.stat-card[onclick] {
    cursor: pointer;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}



/* Sub Sections */
.sub-section {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sub-section:last-child {
    border-bottom: none;
}

.sub-section h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* Alert Item Type Badge */
.alert-item-type {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
}

.alert-item-type.product {
    background: rgba(77, 124, 254, 0.2);
    color: var(--accent-blue);
}

.alert-item-type.material {
    background: rgba(0, 214, 143, 0.2);
    color: var(--accent-green);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    backdrop-filter: blur(10px);
    margin-bottom: 16px;
}

.card-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.link {
    color: var(--accent-blue);
    text-decoration: none;
    font-size: 14px;
    transition: color var(--transition-fast);
}

.link:hover {
    color: var(--accent-blue-hover);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    white-space: nowrap;
}

.data-table td {
    font-size: 13.5px;
}

/* Item Name column optimization */
.data-table td:nth-child(2) {
    white-space: normal;
    min-width: 150px;
    max-width: 250px;
    line-height: 1.4;
}

/* Specific column adjustments to save space */
.data-table td:first-child code {
    font-size: 11px;
    opacity: 0.8;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--bg-glass);
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

/* Status Badges */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-ok {
    background: rgba(0, 214, 143, 0.15);
    color: var(--accent-green);
}

.status-low {
    background: rgba(255, 170, 0, 0.15);
    color: var(--accent-orange);
}

.status-critical {
    background: rgba(255, 71, 87, 0.15);
    color: var(--accent-red);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
    min-width: 80px;
}

.btn-action {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--bg-glass);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-action:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: translateY(-2px);
    border-color: var(--accent-blue);
}

.btn-action.logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
    border-color: var(--accent-red);
}

.btn-action.delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
    border-color: var(--accent-red);
}

/* Quantity Controls */
.qty-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    line-height: 1;
}

.qty-btn:hover {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.qty-val {
    font-weight: 500;
    min-width: 20px;
    text-align: center;
}

/* Quick Stock Buttons */
.quick-stock {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-stock button {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quick-stock .minus {
    background: rgba(255, 71, 87, 0.2);
    color: var(--accent-red);
}

.quick-stock .minus:hover {
    background: var(--accent-red);
    color: white;
}

.quick-stock .plus {
    background: rgba(0, 214, 143, 0.2);
    color: var(--accent-green);
}

.quick-stock .plus:hover {
    background: var(--accent-green);
    color: white;
}

.quick-stock .stock-btn {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.quick-stock .stock-btn:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

/* Low Stock Alert Card */
.alert-card {
    border-color: rgba(255, 170, 0, 0.3);
}

.alert-items {
    padding: 16px 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 170, 0, 0.1);
    border: 1px solid rgba(255, 170, 0, 0.2);
    border-radius: var(--border-radius-sm);
}

.alert-item-name {
    font-weight: 500;
}

.alert-item-qty {
    color: var(--accent-orange);
    font-weight: 600;
}

/* ============================================
   MODALS
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

.modal-sm {
    max-width: 380px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}



.modal-body {
    padding: 24px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(77, 124, 254, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Setup Modal */
.modal-content.setup-modal,
.modal-content.login-modal {
    max-width: 400px;
    padding: 32px;
}

.setup-info {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.95rem;
    line-height: 1.5;
}

input[type="password"] {
    letter-spacing: normal;
    font-family: inherit;
    font-size: 14px;
    text-align: left;
}

.password-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-group input {
    padding-right: 45px !important;
}

.password-toggle {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
    z-index: 5;
}

.password-toggle:hover {
    color: var(--text-primary);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

.setup-help {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.setup-help summary {
    color: var(--accent-blue);
    cursor: pointer;
    font-weight: 500;
}

.setup-help ol {
    margin-top: 16px;
    padding-left: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 2;
}

.setup-help code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* Stock Modal */
.stock-item-name {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 8px;
}

.stock-current {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.stock-current span {
    color: var(--accent-blue);
    font-weight: 600;
}

.stock-adjust-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.stock-input {
    width: 80px !important;
    text-align: center;
    font-size: 18px !important;
    font-weight: 600;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast {
    position: fixed;
    bottom: 32px;
    right: 32px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 16px 24px;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 40px var(--shadow-color);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-color: var(--accent-green);
}

.toast.error {
    border-color: var(--accent-red);
}

/* ============================================
   LOADING OVERLAY
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 26, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 3000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state-text {
    font-size: 16px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .sidebar {
        width: 70px;
    }

    .logo-text,
    .nav-item span:not(.nav-icon),
    .user-name {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .badge {
        position: absolute;
        top: 4px;
        right: 4px;
        padding: 2px 4px;
        font-size: 9px;
    }

    .main-content {
        margin-left: 70px;
    }

    .search-box input {
        width: 200px;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .header {
        padding: 0 16px;
    }

    .view {
        padding: 16px;
    }

    .data-table th,
    .data-table td {
        padding: 12px 16px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .header-right {
        gap: 8px;
    }

    .search-box input {
        width: 180px;
    }
}

/* Tablet & Mobile Layouts */
@media (max-width: 992px) {
    :root {
        --sidebar-width: 280px;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar.active+.sidebar-overlay {
        display: block;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }


    .view {
        padding: 24px 16px;
    }
}

@media (max-width: 600px) {
    .header {
        padding: 0 16px;
    }

    .header h1 {
        font-size: 18px;
    }

    .search-box input {
        width: 140px;
        padding-left: 36px;
    }

    .search-icon {
        left: 10px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .header-tabs {
        overflow-x: auto;
        padding-bottom: 4px;
        width: 100%;
    }

    .tab-btn {
        flex-shrink: 0;
    }

    .data-table th,
    .data-table td {
        padding: 12px 16px;
    }
}

/* Modal Widths */
.modal-lg {
    max-width: 900px !important;
}

.modal-sm {
    max-width: 400px;
}

/* Bulk Entry Styles */
.bulk-entry-container {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background: var(--bg-secondary);
    margin-top: 10px;
}

#financeOverviewView .data-table {
    table-layout: fixed;
}

.bulk-entry-container thead {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg-tertiary);
}

.bulk-entry-container input[type="number"] {
    width: 70px;
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.bulk-entry-container input[type="text"] {
    width: 100%;
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.bulk-log-row:hover {
    background: var(--bg-tertiary);
}

/* Batch Styles */
.batch-selection-area {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
}

.batch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.batch-header h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 16px;
}

.batch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.batch-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.batch-card:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.batch-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.batch-actions {
    display: flex;
    gap: 4px;
}

.batch-btn-delete,
.batch-btn-edit {
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.batch-btn-edit:hover {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    background: rgba(77, 124, 254, 0.1);
    transform: translateY(-2px);
}

.batch-btn-delete:hover {
    color: var(--accent-red);
    border-color: var(--accent-red);
    background: rgba(239, 68, 68, 0.1);
    transform: translateY(-2px);
}

.multiplier-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.multiplier-options .btn {
    padding: 10px;
}

.modal-xs {
    max-width: 320px !important;
}

.batch-items-container {
    margin-top: 15px;
    max-height: 380px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--bg-secondary);
}

.batch-items-container input[type="number"].batch-item-qty {
    width: 80px;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-align: center;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.batch-items-container input[type="number"].batch-item-qty:focus {
    outline: none;
    border-color: var(--accent-blue);
    background: var(--bg-glass);
}

.batch-items-container td:nth-child(2) {
    text-align: center;
}

.batch-items-container th:nth-child(2) {
    text-align: center;
}

/* Alert Banner */
.alert-banner {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--border-radius-md);
    padding: 12px 20px;
    margin-bottom: 24px;
}

.alert-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    font-size: 14px;
    font-weight: 500;
}

.alert-banner.hidden {
    display: none;
}

.header-actions {
    display: flex;
    align-items: center;
}

.btn-icon-only {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.btn-icon-only:hover {
    background: var(--bg-tertiary);
}

/* Profile Modal Styles */
.profile-pic-section {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 12px;
    background: var(--bg-glass);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.profile-pic-btn-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.profile-preview {
    width: 80px;
    height: 80px;
    border-radius: var(--border-radius-sm);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid var(--border-color);
    aspect-ratio: 1 / 1;
}

.profile-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-pic-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

#profileModal .form-group {
    margin-bottom: 12px;
}

#profileModal .form-actions {
    margin-top: 16px !important;
}

#profileModal .modal-body {
    padding-top: 16px;
    padding-bottom: 16px;
}

.profile-placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

/* Insights Card */
/* Insights Card - Header Integrated */
.insights-card {
    display: flex;
    align-items: center;
    gap: 32px;
    background: var(--bg-card);
    padding: 4px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px var(--shadow-color);
    flex: 1;
    min-width: 0;
    height: 38px;
    overflow: hidden;
}

.insight-item {
    display: flex;
    align-items: baseline;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.insight-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.insight-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.insight-value.highlight {
    color: var(--accent-blue);
}

.insight-value.positive {
    color: var(--accent-green);
}

.insight-value.negative {
    color: var(--accent-red);
}

/* Overview Styles */
.overview-summary-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.overview-category-row h4 {
    margin: 0 0 12px 0;
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.overview-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.overview-stats-grid.three-cols {
    grid-template-columns: repeat(3, 1fr);
}

.overview-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.text-success {
    color: #10b981 !important;
}

.text-danger {
    color: #f43f5e !important;
}

.text-warning {
    color: #f59e0b !important;
}

.text-center {
    text-align: center !important;
}

@media (max-width: 1024px) {
    .overview-details-grid {
        grid-template-columns: 1fr;
    }

    .overview-stats-grid.three-cols {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .header-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .date-range-picker {
        width: 100%;
        flex-wrap: wrap;
    }
}

.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    width: 100%;
}

/* Perfect Grid Alignment for Finance & Inventory Headers on Desktop */
@media (min-width: 1025px) {

    #financeOverviewView .header-actions,
    #financeOverviewView .stats-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 16px;
    }

    #overviewView .header-actions {
        display: flex;
        justify-content: flex-end;
    }

    #financeOverviewView .insights-card {
        grid-column: span 2;
        max-width: none;
        width: 100%;
        margin: 0;
    }

    #financeOverviewView .date-range-picker {
        grid-column: span 1;
        max-width: none;
        width: 100%;
        margin: 0;
    }

    #overviewView .date-range-picker {
        max-width: 500px;
        /* Limit width now that it's flexed */
    }
}

.date-range-picker {
    display: flex;
    gap: 12px;
    align-items: center;
    background: var(--bg-card);
    padding: 6px 12px;
    border-radius: 12px;
    /* Smoother rounding */
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px var(--shadow-color);
    width: 100%;
    height: 44px;
    /* Slightly taller for breathing room */
    flex-shrink: 0;
}

.filter-group {
    display: flex;
    flex: 1;
    min-width: 0;
}

.date-range-picker select.form-input {
    flex: 1;
    min-width: 90px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0 10px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    height: 32px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
    padding-right: 28px;
}

.date-range-picker select.form-input:focus {
    border-color: var(--accent-blue);
    outline: none;
    box-shadow: 0 0 0 2px rgba(77, 124, 254, 0.1);
}

.date-range-picker select.form-input option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.date-range-picker .overview-date-input {
    flex: 1;
    min-width: 140px;
    /* Reduced min-width to fit better */
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13.5px;
    cursor: pointer;
    transition: all 0.2s;
    height: 32px;
}

.date-range-picker .overview-date-input:focus {
    border-color: var(--accent-blue);
    outline: none;
    box-shadow: 0 0 0 2px rgba(77, 124, 254, 0.1);
}

.btn-apply {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 0 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    height: 32px;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    flex-shrink: 0;
}

.btn-apply:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(77, 124, 254, 0.3);
}

.overview-category-row h4 {
    margin: 0 0 12px 0;
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.overview-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.overview-stats-grid.three-cols {
    grid-template-columns: repeat(3, 1fr);
}

.overview-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.text-success {
    color: #10b981 !important;
}

.text-danger {
    color: #f43f5e !important;
}

.text-warning {
    color: #f59e0b !important;
}

.text-center {
    text-align: center !important;
}

@media (max-width: 1024px) {
    .overview-details-grid {
        grid-template-columns: 1fr;
    }

    .overview-stats-grid.three-cols {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .header-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .date-range-picker {
        width: 100%;
        flex-wrap: wrap;
    }
}


.overview-date-input:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.1);
}

.overview-date-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

.btn-apply {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    height: 38px;
    /* Match input height roughly */
}

.btn-apply:hover {
    background: var(--primary-hover);
}

.text-success {
    color: #10b981 !important;
}

.text-danger {
    color: #f43f5e !important;
}

.text-warning {
    color: #f59e0b !important;
}

.text-center {
    text-align: center !important;
}

@media (max-width: 1024px) {
    .overview-details-grid {
        grid-template-columns: 1fr;
    }

    .overview-stats-grid.three-cols {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

.date-range-picker {
    display: flex;
    gap: 12px;
    align-items: center;
}

.overview-date-input {
    min-width: 180px;
    background: var(--bg-tertiary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.overview-date-input:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.1);
}

.overview-date-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

/* ============================================
   FINANCE SETUP STYLES
   ============================================ */

.finance-setup-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

/* New card-based category item */
.finance-category-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: border-color 0.2s, background 0.2s;
    animation: slideIn 0.25s ease-out;
}

.finance-category-card:hover {
    border-color: var(--accent-blue);
    background: var(--bg-tertiary);
}

.finance-cat-info {
    flex: 1;
}

.finance-cat-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.finance-cat-subcats {
    font-size: 13px;
    color: var(--text-muted);
}

.finance-cat-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.btn-action {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-action:hover {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    background: rgba(77, 124, 254, 0.1);
}

.btn-action.delete:hover {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.1);
}

.setup-container {
    padding: 24px;
}

.empty-state {
    text-align: center;
}

.empty-state-text {
    color: var(--text-muted);
    font-size: 14px;
}

/* ============================================
   CATEGORY TYPE TOGGLE (Earning / Spending)
   ============================================ */

.category-type-toggle {
    display: flex;
    gap: 12px;
    margin-top: 6px;
}

.type-option {
    flex: 1;
    cursor: pointer;
}

.type-option input[type="radio"] {
    display: none;
}

.type-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.earning-option input[type="radio"]:checked~.type-label {
    background: rgba(16, 185, 129, 0.12);
    border-color: #10b981;
    color: #10b981;
}

.spending-option input[type="radio"]:checked~.type-label {
    background: rgba(244, 63, 94, 0.12);
    border-color: #f43f5e;
    color: #f43f5e;
}

/* Interactive Subcategories */
.subcategories-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    min-height: 48px;
}

.subcategory-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 6px 10px 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.subcategory-chip:hover {
    border-color: var(--accent-blue);
    background: rgba(77, 124, 254, 0.05);
}

.subcategory-chip.editing {
    border-color: var(--accent-blue);
    background: rgba(77, 124, 254, 0.1);
    box-shadow: 0 0 0 2px rgba(77, 124, 254, 0.2);
}

.chip-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
    padding-left: 8px;
    border-left: 1px solid var(--border-color);
}

.btn-chip-action {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.1s;
}

.btn-chip-action:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-chip-action.edit:hover {
    color: var(--accent-blue);
}

.btn-chip-action.delete:hover {
    color: #fb7185;
}

.btn-chip-action svg {
    opacity: 0.8;
}

.inline-add-group {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.inline-add-group .form-input {
    margin-bottom: 0;
    flex: 1;
}

.btn-add-inline {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 0 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    height: 42px;
}

.btn-add-inline:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.empty-subcats-hint {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    width: 100%;
}

.type-option:hover .type-label {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

/* Type badges shown on category cards and overview headers */
.type-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    vertical-align: middle;
    margin-left: 6px;
}

.badge-earning {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-spending {
    background: rgba(244, 63, 94, 0.15);
    color: #f43f5e;
    border: 1px solid rgba(244, 63, 94, 0.3);
}

/* Bulk Actions */
.checkbox-col {
    width: 40px;
    text-align: center;
}

/* Finance and Stock checkbox column: hidden by default, shown in select mode */
.finance-checkbox-col,
.logs-checkbox-col {
    display: none !important;
}

#financeTransactionsTable.select-mode .finance-checkbox-col,
#logsTable.select-mode .logs-checkbox-col {
    display: table-cell !important;
}

/* Custom Checkboxes */
.checkbox-col input[type="checkbox"],
.row-checkbox {
    cursor: pointer;
    width: 18px;
    height: 18px;
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    position: relative;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox-col input[type="checkbox"]:checked,
.row-checkbox:checked {
    background: var(--accent-orange);
    border-color: var(--accent-orange);
}

.checkbox-col input[type="checkbox"]:checked::after,
.row-checkbox:checked::after {
    content: '';
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.checkbox-col input[type="checkbox"]:hover,
.row-checkbox:hover {
    border-color: var(--accent-orange);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.bulk-actions-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(249, 115, 22, 0.1);
    padding: 8px 15px;
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(249, 115, 22, 0.2);
    margin: 0 15px;
    animation: slideDown 0.3s ease;
}

.selected-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-orange);
}

@keyframes slideDown {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Bulk Edit Modal Table */
.bulk-edit-container {
    max-height: 60vh;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
}

.bulk-edit-modal {
    max-width: 900px;
}

.bulk-edit-modal .modal-content {
    max-width: 900px;
    width: 90%;
}

.bulk-edit-modal .data-table input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--border-radius);
    font-size: 13px;
    transition: all var(--transition-fast);
}

.bulk-edit-modal .data-table input:focus {
    border-color: var(--accent-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(77, 124, 254, 0.15);
}

/* Multi Transaction Add Modal */
.multi-transaction-container {
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
}

#multiTransactionTable input,
#multiTransactionTable select {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 10px;
    border-radius: var(--border-radius);
    font-size: 13px;
    transition: all var(--transition-fast);
}

#multiTransactionTable input:focus,
#multiTransactionTable select:focus {
    border-color: var(--accent-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(77, 124, 254, 0.15);
}

#multiTransactionTable select:invalid,
#multiTransactionTable select:has(option[value=""]:checked) {
    color: var(--text-muted);
}

#multiTransactionTable select option {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

#multiTransactionTable input::placeholder {
    color: var(--text-muted);
}

#multiTransactionTable td {
    padding: 8px 6px;
    vertical-align: middle;
}

#multiTransactionTable .btn-action {
    width: 32px;
    height: 32px;
}

/* Themed close button */
.btn-close {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--border-radius-sm);
    font-size: 18px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.btn-close:hover {
    background: rgba(255, 71, 87, 0.15);
    color: var(--accent-red);
    border-color: var(--accent-red);
}

/* Annual Finance Report View */
.finance-annual-view {
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: fadeIn 0.4s ease-out;
}

.annual-report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 10px 20px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    margin-bottom: 8px;
}

.year-selector {
    display: flex;
    align-items: center;
    gap: 12px;
}

.year-selector label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.year-selector .form-input {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    padding: 6px 12px;
    font-size: 14px;
    outline: none;
    transition: all var(--transition-fast);
}

.year-selector .form-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
}

.header-actions-btns .btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), #6366f1);
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.3);
    padding: 10px 24px;
    font-weight: 600;
    border-radius: var(--border-radius);
    color: #ffffff;
    border: none;
}

.header-actions-btns .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(77, 124, 254, 0.4);
    filter: brightness(1.1);
}

.annual-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

.stat-card.annual {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: 20px;
    /* More rounded as requested */
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.3s ease;
}

.stat-card.annual:hover {
    transform: translateY(-3px);
    border-color: var(--accent-blue);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.annual-charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    min-height: 400px;
}

@media (max-width: 1200px) {
    .annual-charts-grid {
        grid-template-columns: 1fr;
    }
}

.annual-data-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    /* More rounded to match summary cards */
    padding: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.annual-table-wrapper {
    overflow-x: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    max-height: 600px;
    overflow-y: auto;
}

.annual-report-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.annual-report-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.annual-report-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.annual-report-table .sticky-col {
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 5;
    border-right: 1px solid var(--border-color);
    min-width: 180px;
}

.annual-report-table th.sticky-col {
    z-index: 15;
}

.annual-report-table .total-col {
    background: rgba(255, 255, 255, 0.03);
    font-weight: 600;
}

.annual-report-table .row-earning {
    background: rgba(0, 214, 143, 0.02);
}

.annual-report-table .summary-row {
    font-weight: 700;
    background: var(--bg-tertiary);
}

.annual-report-table .summary-row.income td {
    color: var(--accent-green);
}

.annual-report-table .summary-row.expense td {
    color: var(--accent-red);
}

.annual-report-table .summary-row.net td {
    font-size: 14px;
    background: rgba(77, 124, 254, 0.05);
}

.annual-report-table .spacer-row td {
    height: 30px;
    background: transparent;
    border: none;
}

.annual-report-table .no-val {
    color: var(--text-muted);
    opacity: 0.4;
}

.annual-report-table .has-val {
    font-weight: 500;
}

.annual-report-table tbody tr:hover td {
    background: var(--bg-tertiary);
}

/* Scrollbar for the table wrapper */
.annual-table-wrapper::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.annual-table-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.annual-table-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.annual-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
