﻿/* Production Management System - Main Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&display=swap');

/* CSS Variables */
:root {
    --white: #ffffff;
    --card-bg: #ffffff;
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --primary-light: #a3bffa;
    --secondary: #764ba2;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --sidebar-width: 220px;
    --header-height: 64px;
    --border-radius: 8px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --transition: all 0.2s ease;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-dark);
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--gray-900) 0%, var(--gray-800) 100%);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.sidebar-logo-img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    flex-shrink: 0;
    filter: brightness(0) invert(1);
    opacity: 0.92;
}

.sidebar-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.sidebar-logo-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.03em;
}

.sidebar-logo-sub {
    font-size: 8.5px;
    font-weight: 400;
    color: rgba(255,255,255,0.55);
    letter-spacing: 0.02em;
    margin-top: 2px;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.sidebar-nav::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}

.nav-section {
    padding: 0 8px;
    margin-bottom: 16px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    padding: 6px 10px;
    margin-bottom: 2px;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 4px;
    transition: color 0.15s;
}
.nav-section-title:hover { color: var(--gray-300); }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    color: var(--gray-400);
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-size: 13px;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}

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

.user-name {
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 10px;
    color: var(--gray-500);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Header */
.header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--gray-600);
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-800);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gray-500);
}

.breadcrumb a {
    color: var(--gray-500);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb-separator {
    color: var(--gray-400);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--gray-500);
    border-radius: var(--border-radius);
    transition: var(--transition);
    position: relative;
}

.header-btn:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.header-btn svg {
    width: 20px;
    height: 20px;
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
}

/* Content Area */
.content {
    flex: 1;
    padding: 24px;
    max-width: 100%;
    overflow-x: hidden;
    min-width: 0;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
}

.card-body {
    padding: 10px;
}

.card-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* Stat Cards */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.stat-icon.primary { background: rgba(102, 126, 234, 0.1); color: var(--primary); }
.stat-icon.success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stat-icon.danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.stat-icon.info { background: rgba(59, 130, 246, 0.1); color: var(--info); }

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

.stat-label {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1.2;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    margin-top: 4px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

.stat-sublabel {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

.stat-card-link {
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card-link .stat-sublabel {
    color: var(--primary);
}

[data-theme="dark"] .stat-sublabel {
    color: #8892a0;
}

[data-theme="dark"] .stat-card-link .stat-sublabel {
    color: #a5b4fc;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-decoration: none;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    color: white;
}

.btn-secondary {
    background: white;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    color: var(--gray-700);
}

.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }

.btn-outline {
    background: white;
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
}

.btn-outline svg {
    color: inherit;
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-outline:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.btn-outline.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-outline.active svg {
    color: white;
}

[data-theme="dark"] .btn-outline {
    background: #161b24;
    border-color: #374151;
    color: #e8edf2;
}

[data-theme="dark"] .btn-outline:hover {
    background: #242f3e;
    border-color: var(--primary);
    color: #a5b4fc;
}

[data-theme="dark"] .btn-outline:focus {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

[data-theme="dark"] .btn-outline.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 16px;
}

.btn-icon {
    padding: 8px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    transition: var(--transition);
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control::placeholder {
    color: var(--gray-400);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' 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 10px center;
    padding-right: 40px;
}

.form-hint {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
    background: var(--gray-50);
    white-space: nowrap;
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table td {
    font-size: 14px;
    color: var(--gray-700);
}

/* Compact Table - Analytics style */
.compact-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.compact-table th,
.compact-table td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.compact-table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
}

.compact-table tbody tr:hover {
    background: var(--gray-50);
}

.compact-table td {
    color: var(--gray-700);
}

.badge-sm {
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 3px;
    background: var(--gray-200);
    color: var(--gray-600);
}

/* Recent Reports List */
.recent-reports-list {
    display: flex;
    flex-direction: column;
}

.recent-report-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--gray-200);
    transition: background 0.15s ease;
}

.recent-report-item:last-child {
    border-bottom: none;
}

.recent-report-item:hover {
    background: var(--gray-50);
}

.recent-report-item .report-info {
    display: flex;
    flex-direction: row;
    gap: 4px;
    min-width: 0;
}

.recent-report-item .report-name {
    font-weight: 500;
    font-size: 13px;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-report-item:hover .report-name {
    color: var(--primary);
}

.recent-report-item .report-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--gray-500);
}

.recent-report-item .report-date {
    color: var(--gray-400);
}

.recent-report-item .report-arrow {
    color: var(--gray-300);
    flex-shrink: 0;
    transition: transform 0.15s ease, color 0.15s ease;
}

.recent-report-item:hover .report-arrow {
    color: var(--primary);
    transform: translateX(2px);
}

/* Column Selector - Enhanced Styling */
.column-selector {
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    background: white;
}

.column-selector-controls {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(to bottom, var(--gray-50), var(--gray-100));
    border-bottom: 1px solid var(--gray-200);
    align-items: center;
}

.column-selector-controls input {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 8px;
    border: 1px solid var(--gray-300);
    background: white;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.column-selector-controls input:focus {
    border-color: var(--primary);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05), 0 0 0 3px rgba(102, 126, 234, 0.15);
    outline: none;
}

.column-selector-controls .btn {
    white-space: nowrap;
    font-weight: 500;
}

.column-selector-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 16px;
    max-height: 280px;
    overflow-y: auto;
    background: linear-gradient(135deg, #fafbfc 0%, #f5f7fa 100%);
}

.column-selector-grid::-webkit-scrollbar {
    width: 6px;
}

.column-selector-grid::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 3px;
}

.column-selector-grid::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.column-selector-grid::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

.column-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    background: white;
    border: 1px solid var(--gray-200);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
    position: relative;
}

.column-checkbox-item:hover {
    border-color: var(--primary-light);
    background: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.12);
    transform: translateY(-1px);
}

.column-checkbox-item:has(input:checked) {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.06) 100%);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.column-checkbox-item:has(input:checked):hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.12) 0%, rgba(118, 75, 162, 0.08) 100%);
    border-color: var(--primary-dark);
}

.column-checkbox-item input[type="checkbox"] {
    margin: 0;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Custom checkbox styling */
.column-checkbox-item .checkbox-input {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--gray-300);
    border-radius: 5px;
    background: white;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.column-checkbox-item .checkbox-input:hover {
    border-color: var(--primary);
}

.column-checkbox-item .checkbox-input:checked {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-color: var(--primary);
}

.column-checkbox-item .checkbox-input:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.column-checkbox-item .checkbox-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.column-checkbox-item.hidden {
    display: none;
}

.column-checkbox-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    color: var(--gray-700);
    transition: color 0.2s ease;
}

.column-checkbox-item:has(input:checked) .column-checkbox-label {
    color: var(--primary-dark);
}

.column-selector-footer {
    padding: 12px 16px;
    background: linear-gradient(to top, var(--gray-50), var(--gray-100));
    border-top: 1px solid var(--gray-200);
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.column-selector-footer::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    margin-right: 8px;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* Dark mode column selector */
[data-theme="dark"] .column-selector {
    background: #161b24;
    border-color: #242f3e;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .column-selector-controls {
    background: linear-gradient(to bottom, #161b24, #0d1117);
    border-bottom-color: #242f3e;
}

[data-theme="dark"] .column-selector-controls input {
    background: #242f3e;
    border-color: #374151;
    color: #f0f4f8;
}

[data-theme="dark"] .column-selector-controls input:focus {
    border-color: var(--primary);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2), 0 0 0 3px rgba(102, 126, 234, 0.2);
}

[data-theme="dark"] .column-selector-grid {
    background: linear-gradient(135deg, #0d1117 0%, #161b24 100%);
}

[data-theme="dark"] .column-selector-grid::-webkit-scrollbar-track {
    background: #242f3e;
}

[data-theme="dark"] .column-selector-grid::-webkit-scrollbar-thumb {
    background: #374151;
}

[data-theme="dark"] .column-checkbox-item {
    background: #161b24;
    border-color: #242f3e;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .column-checkbox-item:hover {
    border-color: var(--primary);
    background: #242f3e;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

[data-theme="dark"] .column-checkbox-item:has(input:checked) {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.12) 100%);
    border-color: var(--primary);
}

[data-theme="dark"] .column-checkbox-item .checkbox-input {
    background: #242f3e;
    border-color: #374151;
}

[data-theme="dark"] .column-checkbox-item .checkbox-input:checked {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-color: var(--primary);
}

[data-theme="dark"] .column-checkbox-label {
    color: #e8edf2;
}

[data-theme="dark"] .column-checkbox-item:has(input:checked) .column-checkbox-label {
    color: #a5b4fc;
}

[data-theme="dark"] .column-selector-footer {
    background: linear-gradient(to top, #0d1117, #161b24);
    border-top-color: #242f3e;
    color: #8892a0;
}

@media (max-width: 768px) {
    .column-selector-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 12px;
        gap: 6px;
    }

    .column-checkbox-item {
        padding: 8px 10px;
        font-size: 12px;
    }

    .column-selector-controls {
        flex-wrap: wrap;
        padding: 12px;
    }

    .column-selector-controls input {
        width: 100%;
        flex: none;
    }

    .column-selector-controls .btn {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .column-selector-grid {
        grid-template-columns: 1fr;
    }
}

/* Calculated Fields */
.calculated-field-row {
    transition: var(--transition);
    background: linear-gradient(135deg, var(--gray-50) 0%, #f8fafc 100%);
}

.calculated-field-row:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.calc-field-name,
.calc-field-formula {
    font-size: 13px;
}

.calc-field-name {
    font-weight: 500;
}

.calc-field-formula {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    background: white;
    border: 1px solid var(--gray-300);
}

.calc-field-formula:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.calc-field-hint {
    opacity: 0.7;
}

/* Formula Builder */
.calc-formula-builder {
    background: white;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--gray-200);
}

.calc-column-select {
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--gray-300);
    background: white;
    cursor: pointer;
}

.calc-column-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
    outline: none;
}

.calc-operators {
    display: flex;
    gap: 4px;
}

.calc-op-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calc-op-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.calc-clear-btn {
    font-size: 12px;
    padding: 6px 12px;
}

/* Dark mode - Calculated Fields */
[data-theme="dark"] .calculated-field-row {
    background: linear-gradient(135deg, #161b24 0%, #0d1117 100%);
    border-color: #242f3e;
}

[data-theme="dark"] .calculated-field-row:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

[data-theme="dark"] .calc-formula-builder {
    background: #242f3e;
    border-color: #374151;
}

[data-theme="dark"] .calc-field-formula {
    background: #161b24;
    border-color: #374151;
    color: #f0f4f8;
}

[data-theme="dark"] .calc-column-select {
    background: #161b24;
    border-color: #374151;
    color: #f0f4f8;
}

[data-theme="dark"] .calc-op-btn {
    background: #242f3e;
    border-color: #374151;
    color: #e8edf2;
}

[data-theme="dark"] .calc-op-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Calculated column styling in tables */
.table th.calculated-column,
.table td.calculated-column {
    background: rgba(102, 126, 234, 0.05);
    border-left: 2px solid var(--primary);
}

.table th.calculated-column {
    color: var(--primary-dark);
    font-weight: 600;
}

[data-theme="dark"] .table th.calculated-column,
[data-theme="dark"] .table td.calculated-column {
    background: rgba(102, 126, 234, 0.1);
}

.table .text-right {
    text-align: right;
}

.table .text-center {
    text-align: center;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 100px;
}

.badge-primary { background: rgba(102, 126, 234, 0.1); color: var(--primary); }
.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-info { background: rgba(59, 130, 246, 0.1); color: var(--info); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #065f46;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #92400e;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #991b1b;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: #1e40af;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

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

.modal {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px;
}

.modal-close:hover {
    color: var(--gray-600);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination-btn {
    padding: 8px 14px;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: var(--border-radius);
    color: var(--gray-700);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--primary);
    color: var(--primary);
}

.pagination-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
}

.widget {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

/* Widget column sizes */
.widget-col-3 { grid-column: span 3; }
.widget-col-4 { grid-column: span 4; }
.widget-col-6 { grid-column: span 6; }
.widget-col-9 { grid-column: span 9; }
.widget-col-12 { grid-column: span 12; }

.widget-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.widget-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
}

.widget-description {
    font-size: 11px;
    color: var(--gray-500);
    padding-left: 22px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.widget-cache-time {
    font-size: 10px;
    color: var(--gray-400);
    margin-right: 4px;
    white-space: nowrap;
}

.widget-body {
    padding: 18px;
    overflow-x: auto;
    max-width: 100%;
}

/* Widget drag handle */
.widget-header {
    cursor: grab;
}

.widget-header:active {
    cursor: grabbing;
}

/* Widget drag and drop states */
.widget-ghost {
    opacity: 0.4;
    background: var(--primary-light);
    border: 2px dashed var(--primary);
}

.widget-chosen {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transform: scale(1.02);
}

.widget-drag {
    opacity: 0.9;
}

/* Chart containers */
.chart-container {
    position: relative;
    height: 250px;
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -21px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--primary);
}

.timeline-date {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.timeline-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-800);
}

.timeline-desc {
    font-size: 13px;
    color: var(--gray-600);
    margin-top: 4px;
}

/* Horizontal Timeline Widget */
.timeline-horizontal {
    position: relative;
    padding: 10px 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.timeline-line {
    position: absolute;
    left: 0;
    right: 0;
    top: 32px;
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
}

.timeline-items-row {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 0;
    min-width: max-content;
}

.timeline-item-h {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    min-width: 100px;
    max-width: 140px;
    flex: 0 0 auto;
    padding: 0 8px;
}

.timeline-date-h {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
    white-space: nowrap;
}

.timeline-dot-h {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--card-bg, white);
    flex-shrink: 0;
    z-index: 1;
    position: relative;
}

.timeline-label-h {
    font-size: 11px;
    color: var(--gray-700);
    text-align: center;
    margin-top: 8px;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    gap: 16px;
}

.loading-overlay.hidden {
    display: none;
}

.loading-overlay .spinner {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

.loading-overlay-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--gray-600);
}

.loading-overlay-subtext {
    font-size: 13px;
    color: var(--gray-400);
}

[data-theme="dark"] .loading-overlay {
    background: rgba(17, 24, 39, 0.95);
}

[data-theme="dark"] .loading-overlay-text {
    color: var(--gray-300);
}

[data-theme="dark"] .loading-overlay-subtext {
    color: var(--gray-500);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    color: var(--gray-300);
    margin-bottom: 20px;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.empty-state-desc {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 20px;
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    min-width: 180px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
}

.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(4px);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--gray-700);
    cursor: pointer;
    transition: var(--transition);
}

.dropdown-item:hover {
    background: var(--gray-50);
    color: var(--primary);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
}

.dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 8px 0;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 20px;
}

.tab {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    transition: var(--transition);
}

.tab:hover {
    color: var(--gray-700);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Filter Bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 16px 20px;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    margin-bottom: 20px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 100px;
    font-size: 13px;
    color: var(--gray-700);
}

.filter-tag-remove {
    cursor: pointer;
    color: var(--gray-400);
}

.filter-tag-remove:hover {
    color: var(--danger);
}

/* PMS */
.report-builder {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    min-height: 600px;
}

.report-sidebar {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.report-preview {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    max-width: 100%;
    overflow: hidden;
}

/* Report preview table container - enables horizontal scrolling for wide tables */
#report-preview {
    max-width: 100%;
    overflow: hidden;
}

#report-preview .table-container {
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

#report-preview .table {
    min-width: max-content; /* Ensure table doesn't shrink below content width */
}

.module-list {
    padding: 16px;
}

.module-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.module-item:hover {
    background: var(--gray-50);
}

.module-item.selected {
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary);
}

.module-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
}

.module-item.selected .module-icon {
    background: var(--primary);
    color: white;
}

.module-name {
    font-weight: 500;
    font-size: 14px;
}

/* Checkbox & Radio */
.checkbox-group,
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-item,
.radio-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-input,
.radio-input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .report-builder {
        grid-template-columns: 1fr;
    }

    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: repeat(6, 1fr) !important;
    }

    /* Limit large widgets to max 6 columns on tablet */
    .dashboard-grid .widget[style*="span 9"],
    .dashboard-grid .widget[style*="span 12"] {
        grid-column: span 6 !important;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .stat-cards {
        grid-template-columns: 1fr;
    }

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

    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    /* Force widgets to full width on mobile */
    .dashboard-grid .widget,
    .dashboard-grid .widget-col-3,
    .dashboard-grid .widget-col-4,
    .dashboard-grid .widget-col-6,
    .dashboard-grid .widget-col-9,
    .dashboard-grid .widget-col-12 {
        grid-column: span 1 !important;
        min-width: 0;
    }

    /* Ensure chart containers work on mobile */
    .widget .chart-container {
        height: 200px;
        min-height: 200px;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .header {
        padding: 0 16px;
    }

    .content {
        padding: 16px;
    }

    .table th,
    .table td {
        padding: 10px 12px;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .header,
    .btn,
    .filter-bar,
    .pagination {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Utility Classes */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--gray-500); }

.bg-primary { background-color: var(--primary); }
.bg-success { background-color: var(--success); }
.bg-warning { background-color: var(--warning); }
.bg-danger { background-color: var(--danger); }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.hidden { display: none; }
.block { display: block; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dark Mode Theme — finance system navy palette */
[data-theme="dark"] {
    --gray-50:  #161b24;   /* card / panel backgrounds */
    --gray-100: #1c2333;   /* sub-section / badge backgrounds */
    --gray-200: #242f3e;   /* light borders */
    --gray-300: #374151;   /* medium borders */
    --gray-400: #8892a0;   /* very muted text / icons */
    --gray-500: #8892a0;   /* muted text */
    --gray-600: #c0c8d4;   /* secondary text */
    --gray-700: #d8dfe8;   /* body text */
    --gray-800: #e8edf2;   /* strong secondary text */
    --gray-900: #f0f4f8;   /* primary / heading text */

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.55);
}

[data-theme="dark"] body {
    background: #0d1117;
    color: #f0f4f8;
}

[data-theme="dark"] .header {
    background: #161b24;
    border-bottom-color: #242f3e;
}

[data-theme="dark"] .page-title {
    color: #f0f4f8;
}

[data-theme="dark"] .card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .widget {
    background: #161b24;
    border-color: #242f3e;
}

[data-theme="dark"] .card-header,
[data-theme="dark"] .widget-header {
    border-bottom-color: #242f3e;
}

[data-theme="dark"] .card-footer {
    background: #0d1117;
    border-top-color: #242f3e;
}

[data-theme="dark"] .card-title,
[data-theme="dark"] .stat-value,
[data-theme="dark"] .widget-title {
    color: #f0f4f8;
}

[data-theme="dark"] .widget-description {
    color: #8892a0;
}

[data-theme="dark"] .widget-cache-time {
    color: #596370;
}

[data-theme="dark"] .table th {
    background: #0d1117;
    color: #d8dfe8;
}

[data-theme="dark"] .table td {
    color: #e8edf2;
    border-bottom-color: #242f3e;
}

[data-theme="dark"] .table tbody tr:hover {
    background: #242f3e;
}

[data-theme="dark"] .form-control {
    background: #242f3e;
    border-color: #374151;
    color: #f0f4f8;
}

[data-theme="dark"] .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

[data-theme="dark"] .form-control::placeholder {
    color: #8892a0;
}

[data-theme="dark"] select {
    color-scheme: dark;
    background-color: #242f3e;
    color: #f0f4f8;
    border-color: #374151;
}
[data-theme="dark"] select option {
    background-color: #242f3e;
    color: #f0f4f8;
}
[data-theme="dark"] select.form-control {
    color-scheme: dark;
    background-color: #242f3e;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' 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 10px center;
}
[data-theme="dark"] select.form-control option {
    background-color: #242f3e;
    color: #f0f4f8;
}

[data-theme="dark"] .filter-bar {
    background: #161b24;
    border-color: #242f3e;
}

[data-theme="dark"] .filter-label {
    color: #d8dfe8;
}

[data-theme="dark"] .btn-secondary {
    background: #242f3e;
    border-color: #374151;
    color: #e8edf2;
}

[data-theme="dark"] .btn-secondary:hover {
    background: #374151;
    border-color: #596370;
    color: #f0f4f8;
}

[data-theme="dark"] .filter-bar {
    background: #161b24;
}

[data-theme="dark"] .filter-tag {
    background: #242f3e;
    border-color: #374151;
    color: #e8edf2;
}

[data-theme="dark"] .dropdown-menu {
    background: #161b24;
    border-color: #242f3e;
}

[data-theme="dark"] .dropdown-item {
    color: #e8edf2;
}

[data-theme="dark"] .dropdown-item:hover {
    background: #242f3e;
}

[data-theme="dark"] .dropdown-divider {
    background: #242f3e;
}

[data-theme="dark"] .modal {
    background: #161b24;
}

[data-theme="dark"] .modal-header {
    border-bottom-color: #242f3e;
}

[data-theme="dark"] .modal-title {
    color: #f0f4f8;
}

[data-theme="dark"] .modal-footer {
    border-top-color: #242f3e;
}

[data-theme="dark"] .tabs {
    border-bottom-color: #242f3e;
}

[data-theme="dark"] .tab {
    color: #8892a0;
}

[data-theme="dark"] .tab:hover {
    color: #e8edf2;
}

[data-theme="dark"] .pagination-btn {
    background: #242f3e;
    border-color: #374151;
    color: #e8edf2;
}

[data-theme="dark"] .pagination-btn:hover:not(:disabled) {
    background: #374151;
}

[data-theme="dark"] .timeline::before {
    background: #242f3e;
}

[data-theme="dark"] .timeline-title {
    color: #f0f4f8;
}

[data-theme="dark"] .timeline-desc {
    color: #d8dfe8;
}

[data-theme="dark"] .alert-success {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    color: #34d399;
}

[data-theme="dark"] .alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

[data-theme="dark"] .alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

[data-theme="dark"] .alert-info {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    color: #60a5fa;
}

[data-theme="dark"] .empty-state svg {
    color: #374151;
}

[data-theme="dark"] .empty-state-title {
    color: #e8edf2;
}

[data-theme="dark"] .empty-state-desc {
    color: #8892a0;
}

[data-theme="dark"] .module-item:hover {
    background: #242f3e;
}

[data-theme="dark"] .header-btn {
    color: #8892a0;
}

[data-theme="dark"] .header-btn:hover {
    background: #242f3e;
    color: #f0f4f8;
}

/* Sidebar - keep dark in dark mode */
[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #0d1117 0%, #161b24 100%);
}

[data-theme="dark"] .sidebar-header {
    border-bottom-color: #242f3e;
}

[data-theme="dark"] .sidebar-logo-name { color: #f0f4f8; }
[data-theme="dark"] .sidebar-logo-sub  { color: rgba(255,255,255,0.45); }

[data-theme="dark"] .nav-section-title {
    color: #8892a0;
}

[data-theme="dark"] .nav-item {
    color: #d8dfe8;
}

[data-theme="dark"] .nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f0f4f8;
}

[data-theme="dark"] .nav-item.active {
    background: rgba(102, 126, 234, 0.2);
    color: #a5b4fc;
}

[data-theme="dark"] .sidebar-footer {
    border-top-color: #242f3e;
    background: #0d1117;
}

[data-theme="dark"] .user-name {
    color: #f0f4f8;
}

[data-theme="dark"] .user-role {
    color: #8892a0;
}

[data-theme="dark"] .user-avatar {
    background: var(--primary);
    color: white;
}

[data-theme="dark"] .loading-overlay {
    background: rgba(17, 24, 39, 0.9);
}

[data-theme="dark"] .report-sidebar,
[data-theme="dark"] .report-preview {
    background: #161b24;
    border-color: #242f3e;
}

[data-theme="dark"] .checkbox-item,
[data-theme="dark"] .radio-item {
    color: #e8edf2;
}

/* Theme toggle button styles */
.theme-toggle {
    position: relative;
    width: 48px;
    height: 28px;
    border-radius: 14px;
    background: var(--gray-400);
    border: 1.5px solid var(--gray-500);
    cursor: pointer;
    transition: var(--transition);
    padding: 3px;
}

.theme-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    transition: var(--transition);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .theme-toggle {
    background: var(--primary);
    border-color: var(--primary-dark, #4f46e5);
}

[data-theme="dark"] .theme-toggle::after {
    transform: translateX(20px);
}

.theme-toggle-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 13px;
    height: 13px;
}

.theme-toggle-icon.sun {
    left: 5px;
    color: #fbbf24;
}

.theme-toggle-icon.moon {
    right: 5px;
    color: #1e293b;
}

/* User Dropdown Styles */
.user-dropdown {
    position: relative;
}

.user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    color: var(--gray-700);
    overflow: hidden;
    max-height: 44px;
}

.user-dropdown-toggle:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.user-dropdown-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    max-width: 32px;
    max-height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    display: block;
    overflow: hidden;
}

.user-dropdown-avatar.user-dropdown-initials {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}

.user-dropdown-name {
    font-weight: 500;
    font-size: 14px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown-arrow {
    transition: transform 0.2s;
    color: var(--gray-400);
}

.user-dropdown.active .user-dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-dropdown.active .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 12px 16px;
}

.dropdown-header-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-800);
}

.dropdown-header-email {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}

.dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 4px 0;
}

.user-dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--gray-700);
    font-size: 14px;
    transition: var(--transition);
}

.user-dropdown-menu .dropdown-item:hover {
    background: var(--gray-50);
    color: var(--gray-900);
}

.user-dropdown-menu .dropdown-item svg {
    color: var(--gray-400);
    flex-shrink: 0;
}

.user-dropdown-menu .dropdown-item:hover svg {
    color: var(--gray-600);
}

.dropdown-item-danger {
    color: var(--danger) !important;
}

.dropdown-item-danger:hover {
    background: rgba(239, 68, 68, 0.1) !important;
}

.dropdown-item-danger svg {
    color: var(--danger) !important;
}

/* Dark mode - User Dropdown */
[data-theme="dark"] .user-dropdown-toggle {
    background: transparent;
    border-color: #242f3e;
    color: #e8edf2;
}

[data-theme="dark"] .user-dropdown-toggle:hover {
    background: #242f3e;
    border-color: #374151;
}

[data-theme="dark"] .user-dropdown-name {
    color: #f0f4f8;
}

[data-theme="dark"] .user-dropdown-arrow {
    color: #8892a0;
}

[data-theme="dark"] .user-dropdown-menu {
    background: #161b24;
    border-color: #242f3e;
}

[data-theme="dark"] .dropdown-header-name {
    color: #f0f4f8;
}

[data-theme="dark"] .dropdown-header-email {
    color: #8892a0;
}

[data-theme="dark"] .dropdown-divider {
    background: #242f3e;
}

[data-theme="dark"] .user-dropdown-menu .dropdown-item {
    color: #e8edf2;
}

[data-theme="dark"] .user-dropdown-menu .dropdown-item:hover {
    background: #242f3e;
    color: #f0f4f8;
}

[data-theme="dark"] .user-dropdown-menu .dropdown-item svg {
    color: #8892a0;
}

[data-theme="dark"] .user-dropdown-menu .dropdown-item:hover svg {
    color: #e8edf2;
}

[data-theme="dark"] .dropdown-item-danger:hover {
    background: rgba(239, 68, 68, 0.15) !important;
}

/* Improved Theme Toggle for both modes */
.theme-toggle:hover {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

[data-theme="dark"] .theme-toggle:hover {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

/* Hide/show icons based on theme */
.theme-toggle-icon.sun {
    opacity: 1;
}

.theme-toggle-icon.moon {
    opacity: 0.7;
}

[data-theme="dark"] .theme-toggle-icon.sun {
    opacity: 0.7;
}

[data-theme="dark"] .theme-toggle-icon.moon {
    opacity: 1;
    color: #fbbf24;
}

/* Responsive - hide user name on small screens */
@media (max-width: 640px) {
    .user-dropdown-name {
        display: none;
    }

    .user-dropdown-toggle {
        padding: 6px;
    }

    .user-dropdown-arrow {
        display: none;
    }
}

/* ── Collapsible Sidebar Sections ─────────────────────────────────────────── */
.nav-section-title .chevron {
    color: var(--gray-600);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.nav-section.collapsed .chevron {
    transform: rotate(-90deg);
}

.nav-section-body {
    overflow: hidden;
    max-height: 2000px;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    opacity: 1;
}

.nav-section.collapsed .nav-section-body {
    max-height: 0 !important;
    opacity: 0;
}

.nav-section-divider {
    font-size: 9px;
    font-weight: 600;
    color: var(--gray-600);
    padding: 10px 10px 3px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.07);
}

/* modal-box (improvement register + others) */
.modal-box {
    background: var(--card-bg, white);
    color: var(--gray-800);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 24px;
}
.modal-box h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--gray-900);
}
[data-theme="dark"] .modal-box {
    background: #161b24;
    color: #f0f4f8;
}
[data-theme="dark"] .modal-box h3 {
    color: #f9fafb;
}
[data-theme="dark"] {
    --card-bg: #161b24;
}

/* ── Waffle / Quick-Links button ─────────────────────────────────────────── */
.waffle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-500);
    transition: background .15s, color .15s;
    flex-shrink: 0;
}
.waffle-btn:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}
[data-theme="dark"] .waffle-btn { color: rgba(255,255,255,.55); }
[data-theme="dark"] .waffle-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

/* ── Quick Links Drawer (app-drawer panel) ───────────────────────────────── */
.ql-drawer {
    position: fixed;
    z-index: 1200;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.07);
    min-width: 272px;
    max-width: 320px;
    display: none;
    overflow: hidden;
}
.ql-drawer.open { display: block; }
.ql-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px 11px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
}
.ql-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--gray-400);
    transition: background .15s, color .15s;
}
.ql-drawer-close:hover { background: var(--gray-100); color: var(--gray-700); }
.ql-drawer-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 10px;
}
.ql-drawer-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 14px 8px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--gray-700);
    transition: background .15s;
    cursor: pointer;
}
.ql-drawer-tile:hover { background: var(--gray-50); }
.ql-drawer-tile-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ql-drawer-tile-name {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
    text-align: center;
    max-width: 76px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    color: var(--gray-700);
}
.ql-drawer-empty {
    grid-column: 1 / -1;
    padding: 18px 0;
    text-align: center;
    font-size: 13px;
    color: var(--gray-400);
    margin: 0;
}
[data-theme="dark"] .ql-drawer {
    background: #1e2536;
    border-color: rgba(255,255,255,.08);
    box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
[data-theme="dark"] .ql-drawer-header { color: rgba(255,255,255,.85); border-color: rgba(255,255,255,.06); }
[data-theme="dark"] .ql-drawer-close  { color: rgba(255,255,255,.4); }
[data-theme="dark"] .ql-drawer-close:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.85); }
[data-theme="dark"] .ql-drawer-tile:hover  { background: rgba(255,255,255,.06); }
[data-theme="dark"] .ql-drawer-tile-name   { color: rgba(255,255,255,.75); }

/* ── PM Record: Schedule row colours ────────────────────────────── */
.pm-row-green  { background: #bbf7d0 !important; }
.pm-row-red    { background: #fecaca !important; }
.pm-row-blue   { background: #bfdbfe !important; }
.pm-row-purple { background: #e9d5ff !important; }
[data-theme="dark"] .pm-row-green  { background: rgba(16,185,129,.28) !important; }
[data-theme="dark"] .pm-row-red    { background: rgba(239,68,68,.28)  !important; }
[data-theme="dark"] .pm-row-blue   { background: rgba(59,130,246,.28) !important; }
[data-theme="dark"] .pm-row-purple { background: rgba(139,92,246,.28) !important; }

/* Colour picker button group */
.pm-color-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.pm-color-btn {
    padding: 4px 10px;
    border-radius: 4px;
    border: 2px solid transparent;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color .15s;
}
.pm-color-btn.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(var(--primary-rgb,.37,.56,.99),.25); }

/* Shift group sub-header */
.pm-shift-group-header td {
    background: var(--gray-50);
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    letter-spacing: .04em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--gray-200);
}
[data-theme="dark"] .pm-shift-group-header td {
    background: #1a2233;
    color: var(--gray-400);
    border-color: #2d3748;
}

/* Day note under schedule day header */
.pm-day-note {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
    font-style: italic;
}

/* Drag handle for schedule row reorder */
.pm-drag-handle {
    cursor: grab;
    color: var(--gray-300);
    font-size: 14px;
    user-select: none;
    padding: 0 6px !important;
}
.pm-drag-handle:hover { color: var(--gray-500); }
.pm-drag-handle:active { cursor: grabbing; }
