:root {
    /* Color Palette - Professional Dual-Tone Theme */
    --bg-gradient: linear-gradient(135deg, #070d19 0%, #112040 100%); /* Premium Midnight Navy Gradient */
    --bg-main: #070d19; /* Base dark navy */
    --bg-card: rgba(17, 32, 64, 0.5); /* Translucent navy */
    --bg-sidebar: rgba(7, 13, 25, 0.6); 
    --accent: #3b82f6; /* blue-500 */
    --accent-hover: #2563eb; /* blue-600 */
    --text-primary: #f8fafc; 
    --text-secondary: #94a3b8; 
    --border: rgba(255, 255, 255, 0.08); 
    --border-hover: rgba(255, 255, 255, 0.2); 
    --bg-input: rgba(0, 0, 0, 0.2);
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --glass: blur(20px) saturate(150%);
    --card-shadow-hover: 0 12px 30px -5px rgba(0, 0, 0, 0.5);

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-lg: 12px; 
    --radius-md: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 20px -2px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
    --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%); /* Calmer slate */
    --bg-main: #f1f5f9; 
    --bg-card: rgba(248, 250, 252, 0.95); 
    --bg-sidebar: rgba(248, 250, 252, 0.85); 
    --accent: #3b82f6; 
    --accent-hover: #2563eb; 
    --text-primary: #1e293b; 
    --text-secondary: #475569; 
    --border: rgba(0, 0, 0, 0.08); 
    --border-hover: rgba(0, 0, 0, 0.15); 
    --bg-input: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 15px -2px rgba(0, 0, 0, 0.04);
    --card-shadow-hover: 0 12px 30px -5px rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    /* Dual-tone gradient background */
    background: var(--bg-gradient);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s ease, color 0.3s ease;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.025em;
}

h3 {
    font-size: 0.875rem;
    font-weight: 500;
}

/* Layout Structure */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
aside {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass);
    -webkit-backdrop-filter: var(--glass);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 2.5rem;
    color: var(--text-primary);
    padding: 0 10px;
}

.tr-flag {
    width: 22px;
    height: 15px;
    border-radius: 2px;
    object-fit: cover;
    margin-left: auto;
    opacity: 0.9;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    font-weight: 500;
    border-left: 2px solid transparent;
}

.nav-item:hover {
    background: var(--border);
    color: var(--text-primary);
}

/* Colorized Sidebar Nav Items */
.nav-item:nth-child(1) svg { color: #3b82f6; transition: color 0.2s; } /* Blue */
.nav-item:nth-child(2) svg { color: #10b981; transition: color 0.2s; } /* Green */
.nav-item:nth-child(3) svg { color: #06b6d4; transition: color 0.2s; } /* Cyan */
.nav-item:nth-child(4) svg { color: #8b5cf6; transition: color 0.2s; } /* Purple */
.nav-item:nth-child(5) svg { color: #f59e0b; transition: color 0.2s; } /* Amber */
.nav-item:nth-child(6) svg { color: #94a3b8; transition: color 0.2s; } /* Slate */

.nav-item:nth-child(1).active { background: linear-gradient(90deg, rgba(59, 130, 246, 0.15), transparent); border-left-color: #3b82f6; color: var(--text-primary); }
.nav-item:nth-child(2).active { background: linear-gradient(90deg, rgba(16, 185, 129, 0.15), transparent); border-left-color: #10b981; color: var(--text-primary); }
.nav-item:nth-child(3).active { background: linear-gradient(90deg, rgba(6, 182, 212, 0.15), transparent); border-left-color: #06b6d4; color: var(--text-primary); }
.nav-item:nth-child(4).active { background: linear-gradient(90deg, rgba(139, 92, 246, 0.15), transparent); border-left-color: #8b5cf6; color: var(--text-primary); }
.nav-item:nth-child(5).active { background: linear-gradient(90deg, rgba(245, 158, 11, 0.15), transparent); border-left-color: #f59e0b; color: var(--text-primary); }
.nav-item:nth-child(6).active { background: linear-gradient(90deg, rgba(148, 163, 184, 0.15), transparent); border-left-color: #94a3b8; color: var(--text-primary); }

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    /* Transparent to let the body dual-tone gradient show through */
    background: transparent; 
}

header {
    height: var(--header-height);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass);
    -webkit-backdrop-filter: var(--glass);
    z-index: 90;
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    width: 400px;
    transition: border-color 0.2s;
}

.search-bar:focus-within {
    border-color: var(--accent);
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    margin-left: 10px;
    width: 100%;
    outline: none;
    font-size: 0.875rem;
}

.search-bar input::placeholder {
    color: var(--text-secondary);
}

.content-area {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

/* Components */
.card {
    background: var(--bg-card);
    backdrop-filter: var(--glass);
    -webkit-backdrop-filter: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.25s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--card-shadow-hover);
    border-color: var(--border-hover);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border);
    color: var(--text-secondary);
}

.stat-info h3 {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.stat-info p {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Table Style */
.table-container {
    margin-top: 2rem;
}

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

th {
    text-align: left;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--border);
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    background: var(--border-hover);
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    border: 1px solid transparent;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-card);
    width: 500px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    animation: scaleIn 0.2s ease-out;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    color: var(--text-primary);
    outline: none;
    font-size: 0.875rem;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
}

/* Utilities & Animations */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Status colors overriden slightly for readability */
.status-badge {
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Locked Order Summary Card */
.locked-order-card {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.locked-order-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.locked-order-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.locked-order-detail {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

.locked-order-card:hover .locked-order-detail {
    max-height: 600px;
    opacity: 1;
}

.locked-order-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.locked-order-card:hover .locked-order-hint {
    opacity: 0;
    pointer-events: none;
}

/* Grid layout for locked order cards */
.locked-orders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

/* Responsive Design / Mobile Adaptations */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: 100dvh;
    }

    /* Transform sidebar to bottom navigation bar */
    aside {
        order: 2;
        width: 100%;
        height: auto;
        flex-direction: row;
        justify-content: space-around;
        padding: 0;
        border-right: none;
        border-top: 1px solid var(--border);
        background: var(--bg-card);
        z-index: 1000;
        padding-bottom: env(safe-area-inset-bottom); /* iOS safe area */
    }

    .logo {
        display: none;
    }

    #sidebar-nav {
        flex-direction: row;
        width: 100%;
        justify-content: flex-start;
        gap: 15px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0 10px;
    }
    
    #sidebar-nav::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        flex-direction: column;
        gap: 4px;
        padding: 8px 12px;
        font-size: 0.65rem;
        border-left: none;
        border-top: 2px solid transparent;
        border-radius: 0;
        justify-content: center;
        white-space: nowrap;
        min-width: max-content;
    }

    .nav-item i {
        margin: 0;
        width: 20px;
        height: 20px;
    }

    /* Restore theme toggle and logout in mobile, but hide their text if needed, actually we kept white-space nowrap */
    #theme-toggle {
        display: flex;
        flex-direction: column;
        margin: 0 !important;
        padding: 8px 12px;
        font-size: 0.65rem;
        min-width: max-content;
    }
    #theme-toggle span, .nav-item:last-child span {
        display: block; /* Show text since it's scrollable */
    }

    main {
        order: 1;
        padding-bottom: 0;
    }

    header {
        padding: 0 1rem;
        height: 65px;
    }

    .search-bar {
        width: 100%;
        max-width: none;
    }

    .content-area {
        padding: 1rem;
    }

    h1 { font-size: 1.3rem !important; }
    
    /* Layouts */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Tables scrollable horizontally */
    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

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

    /* Modals */
    .modal {
        width: 95%;
        padding: 1.5rem;
        margin: 1rem;
    }
}