/* app.css - Premium Glassmorphism Dark Theme */

:root {
    --bg-main: #090a0f;
    --bg-gradient: linear-gradient(135deg, #07080d 0%, #0f121d 50%, #050609 100%);
    
    /* Glassmorphism panels */
    --panel-bg: rgba(18, 22, 37, 0.55);
    --panel-bg-hover: rgba(23, 28, 47, 0.7);
    --panel-border: 1px solid rgba(255, 255, 255, 0.06);
    --panel-border-focus: 1px solid rgba(139, 92, 246, 0.4);
    --backdrop-blur: blur(16px);
    
    /* Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-purple: #8b5cf6;
    --accent-indigo: #6366f1;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;
    --accent-amber: #f59e0b;
    
    /* Button gradients */
    --grad-primary: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    --grad-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --grad-danger: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    --grad-secondary: linear-gradient(135deg, #334155 0%, #1e293b 100%);
    
    /* Glows & Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-neon: 0 0 25px rgba(139, 92, 246, 0.25);
    --shadow-cyan: 0 0 25px rgba(6, 182, 212, 0.25);
    
    /* Spacing & Borders */
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base Setup */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    background-image: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    background-attachment: fixed;
}

/* Layout Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header & Navigation Styles */
.app-header {
    background: rgba(10, 12, 22, 0.7);
    backdrop-filter: var(--backdrop-blur);
    border-bottom: var(--panel-border);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    font-size: 1.8rem;
    animation: rotate 10s linear infinite;
}

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

.brand h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 50%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand h1 span {
    background: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-tabs {
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.35rem;
    border-radius: var(--radius-md);
    border: var(--panel-border);
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.nav-btn .icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    transition: var(--transition);
}

.nav-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
    color: #ffffff !important;
    background: var(--grad-primary);
    box-shadow: var(--shadow-neon);
}

.user-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    border: var(--panel-border);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online {
    background-color: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
}

.status-indicator.offline {
    background-color: var(--accent-rose);
    box-shadow: 0 0 8px var(--accent-rose);
}

/* Main Area Content */
.app-main {
    padding: 2rem;
    flex: 1;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* Tab visibility */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* KPI Cards Layout */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--panel-bg);
    border: var(--panel-border);
    backdrop-filter: var(--backdrop-blur);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.kpi-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow-md);
    background: var(--panel-bg-hover);
}

.kpi-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.kpi-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.kpi-icon {
    font-size: 1.8rem;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Layout Columns */
.content-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 1100px) {
    .content-layout {
        grid-template-columns: 1fr;
    }
}

/* Panel Styles */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: var(--backdrop-blur);
    border: var(--panel-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.glass-panel h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Form Styling */
.styled-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.required {
    color: var(--accent-rose);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="month"],
select {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: var(--panel-border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="month"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent-purple);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.15);
}

select option {
    background-color: #111422;
    color: var(--text-primary);
}

.help-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.warning-text {
    font-size: 0.85rem;
    color: #fda4af;
    background: rgba(244, 63, 94, 0.1);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(244, 63, 94, 0.2);
}

/* Checkbox Toggle */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    user-select: none;
    margin-top: auto;
    padding-bottom: 0.5rem;
}

.checkbox-container input {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: var(--panel-border);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.25);
    position: relative;
    transition: var(--transition);
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--accent-purple);
}

.checkbox-container input:checked ~ .checkmark {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
}

.checkbox-container input:checked ~ .checkmark::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.empty-label-group {
    justify-content: flex-end;
}

/* Real-time Calculation Panel */
.calc-preview {
    background: rgba(139, 92, 246, 0.05);
    border: 1px dashed rgba(139, 92, 246, 0.2);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.calc-preview h3 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--accent-purple);
    margin-bottom: 0.25rem;
    letter-spacing: 0.5px;
}

.calc-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.calc-row strong {
    color: var(--text-primary);
}

.calc-row.highlight {
    font-size: 0.95rem;
    font-weight: 600;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 0.5rem;
    color: var(--text-primary);
}

.calc-row.profit-row {
    font-size: 1rem;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.08);
    margin: 0.25rem -0.5rem 0 -0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    color: var(--accent-emerald);
}

.calc-row.profit-row.negative {
    background: rgba(244, 63, 94, 0.08);
    color: var(--accent-rose);
}

.font-sm {
    font-size: 0.8rem;
}

/* Buttons styling */
.btn-actions {
    display: flex;
    gap: 0.75rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--grad-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
}

.btn-secondary {
    background: var(--grad-secondary);
    color: var(--text-primary);
    border: var(--panel-border);
}

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

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

/* Tables Styling */
.table-container {
    display: flex;
    flex-direction: column;
    height: 650px;
    max-height: 65vh;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.table-tools {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.table-tools input[type="text"] {
    width: 220px;
}

.table-tools select {
    width: 180px;
}

.table-scroll {
    flex: 1;
    overflow: auto;
    border-radius: var(--radius-md);
    border: var(--panel-border);
    background: rgba(0, 0, 0, 0.15);
}

.styled-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

.styled-table th {
    background: rgba(15, 19, 36, 0.95);
    color: var(--text-primary);
    font-weight: 600;
    padding: 0.85rem 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.styled-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font-weight: 400;
}

.styled-table tbody tr {
    transition: var(--transition);
}

.styled-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.styled-table tbody tr.editing-row {
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid var(--accent-purple);
}

.styled-table .col-toggle {
    display: none;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge.clickable-status {
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.badge.clickable-status:hover {
    transform: scale(1.08);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.15);
}

.badge-chua {
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-amber);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-dangin {
    background: rgba(6, 182, 212, 0.12);
    color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.badge-xong {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-loi {
    background: rgba(244, 63, 94, 0.12);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.2);
}

/* Row Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.4rem;
}

.btn-action-icon {
    background: rgba(255, 255, 255, 0.04);
    border: var(--panel-border);
    color: var(--text-secondary);
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}

.btn-action-icon:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.btn-action-icon.edit-btn:hover {
    color: var(--accent-purple);
    border-color: rgba(139, 92, 246, 0.3);
}

.btn-action-icon.delete-btn:hover {
    color: var(--accent-rose);
    border-color: rgba(244, 63, 94, 0.3);
}

.btn-action-icon.complete-btn {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-emerald);
    border-color: rgba(16, 185, 129, 0.2);
    font-weight: 500;
}

.btn-action-icon.complete-btn:hover {
    background: var(--accent-emerald);
    color: white;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

/* Settings Tab Layout */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.settings-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.backup-actions {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.backup-actions .btn-group {
    display: flex;
    flex-direction: column;
}

.import-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-input-label {
    text-align: center;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.02);
    padding: 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.file-input-label:hover {
    border-color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.05);
    color: var(--text-primary);
}

#import-status {
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
}

.reset-section {
    margin-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Shop Management Modal & Styles */
.settings-filament {
    margin-top: 1.5rem;
}

.filament-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

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

.modal-content {
    width: 480px;
    max-width: 90%;
    position: relative;
    animation: modalContentSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

@keyframes modalContentSlide {
    from { transform: scale(0.9) translateY(-20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.close-btn {
    position: absolute;
    right: 1.5rem;
    top: 1.25rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--accent-rose);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Mobile Responsive Adjustments */
@media (max-width: 1024px) {
    .brand h1 {
        font-size: 1.25rem;
    }
    
    .app-header {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .nav-tabs {
        width: 100%;
        justify-content: space-around;
    }
    
    .nav-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
        flex: 1;
        justify-content: center;
    }
    
    .user-status {
        display: none; /* Ẩn cho gọn trên mobile */
    }
    
    .app-main {
        padding: 1rem;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .kpi-card {
        padding: 1rem;
    }
    
    .kpi-value {
        font-size: 1.15rem;
    }
    
    .kpi-icon {
        font-size: 1.4rem;
        width: 38px;
        height: 38px;
    }

    /* Table headers & tools */
    .table-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .table-header h2 {
        font-size: 1.1rem;
    }
    
    .table-tools {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 0.5rem;
    }
    
    .table-tools input[type="text"],
    .table-tools select,
    .table-tools button {
        width: 100% !important;
        margin: 0;
    }
    
    /* Toggle Add Draft Button on Mobile with explicit styles to prevent blank text rendering */
    #btn-add-draft-mobile-open {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        color: #ffffff !important;
        background: var(--grad-primary) !important;
        padding: 0.75rem 1rem !important;
        font-weight: 600 !important;
        font-size: 0.9rem !important;
        box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25) !important;
        border-radius: var(--radius-sm);
        border: none;
    }
    
    /* Transform table into mobile block cards */
    .table-container {
        height: auto !important;
        max-height: none !important;
    }
    
    .table-scroll {
        overflow: visible !important;
        background: transparent !important;
        border: none !important;
    }
    
    .styled-table, 
    .styled-table thead, 
    .styled-table tbody, 
    .styled-table th, 
    .styled-table td, 
    .styled-table tr {
        display: block !important;
    }
    
    .styled-table thead {
        display: none !important;
    }
    
    .styled-table tbody tr {
        background: rgba(255, 255, 255, 0.02);
        border: 1px solid rgba(255, 255, 255, 0.06);
        border-radius: var(--radius-md);
        margin-bottom: 1rem;
        padding: 0.75rem 1rem;
        box-shadow: var(--shadow-sm);
    }
    
    body.light-theme .styled-table tbody tr {
        background: rgba(0, 0, 0, 0.02);
        border: 1px solid rgba(0, 0, 0, 0.06);
    }
    
    .styled-table td {
        border-bottom: 1px solid rgba(255, 255, 255, 0.04) !important;
        padding: 0.6rem 0 !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        text-align: right !important;
        font-size: 0.88rem !important;
        width: 100% !important;
    }
    
    body.light-theme .styled-table td {
        border-bottom: 1px solid rgba(0, 0, 0, 0.04) !important;
        color: #0f172a;
    }
    
    .styled-table td:last-child {
        border-bottom: none !important;
        padding-top: 0.8rem !important;
        justify-content: center !important;
    }
    
    .styled-table td:last-child::before {
        display: none !important;
    }
    
    .styled-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        float: left;
        text-align: left;
    }
    
    .styled-table .col-detail {
        display: none !important;
    }
    
    .styled-table tr.show-details .col-detail {
        display: flex !important;
    }
    
    .styled-table .col-toggle {
        display: flex !important;
        justify-content: center !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04) !important;
        padding: 0.65rem 0 !important;
    }
    
    .styled-table .col-toggle::before {
        display: none !important;
    }
    
    body.light-theme .styled-table .col-toggle {
        border-bottom: 1px solid rgba(0, 0, 0, 0.04) !important;
    }
    
    .btn-toggle-detail {
        background: rgba(139, 92, 246, 0.08);
        border: 1px solid rgba(139, 92, 246, 0.3);
        color: #c084fc;
        padding: 0.5rem 1.25rem;
        font-size: 0.8rem;
        font-weight: 600;
        border-radius: var(--radius-sm);
        cursor: pointer;
        transition: var(--transition);
        width: 100%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.25rem;
    }
    
    .btn-toggle-detail:hover {
        background: rgba(139, 92, 246, 0.15);
        border-color: var(--accent-purple);
        color: #ffffff;
    }
    
    body.light-theme .btn-toggle-detail {
        background: rgba(139, 92, 246, 0.04);
        border-color: rgba(139, 92, 246, 0.25);
        color: var(--accent-purple);
    }
    
    body.light-theme .btn-toggle-detail:hover {
        background: rgba(139, 92, 246, 0.08);
        color: #6d28d9;
    }
    
    .action-buttons {
        width: 100%;
        justify-content: center;
    }
    
    .btn-action-icon {
        flex: 1;
        justify-content: center;
        padding: 0.5rem !important;
        font-size: 0.85rem !important;
    }
    
    /* Hide draft form column on Mobile, show as Popup modal when active */
    #draft-form-container {
        display: none;
    }
    
    #draft-form-container.show-as-modal {
        display: block !important;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        z-index: 1050;
        width: 92%;
        max-width: 480px;
        max-height: 85vh;
        overflow-y: auto;
        background: #111422;
        box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8);
        border: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: var(--radius-lg);
        padding: 1.5rem;
        animation: modalContentSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    body.light-theme #draft-form-container.show-as-modal {
        background: #ffffff;
        border: 1px solid rgba(0, 0, 0, 0.1);
        box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    }
    
    #btn-close-draft-form-mobile {
        display: block !important;
    }
    
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.75);
        backdrop-filter: blur(8px);
        z-index: 1040;
    }
    
    .mobile-overlay.active {
        display: block;
    }
}

/* Adjust grid layout when form is hidden */
#draft-tab .content-layout {
    grid-template-columns: 1fr;
}

@media (min-width: 1025px) {
    #draft-tab .content-layout {
        grid-template-columns: 350px 1fr;
    }
}

/* Custom Autocomplete Dropdown - Glassmorphism Theme */
.autocomplete-dropdown {
    position: absolute;
    z-index: 9999;
    background: rgba(15, 18, 30, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    max-height: 220px;
    overflow-y: auto;
    width: 100%;
}

.autocomplete-dropdown ul {
    list-style: none;
    margin: 0;
    padding: 0.35rem 0;
}

.autocomplete-dropdown li {
    padding: 0.65rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.autocomplete-dropdown li:last-child {
    border-bottom: none;
}

.autocomplete-dropdown li:hover,
.autocomplete-dropdown li.active {
    background: rgba(139, 92, 246, 0.2);
    color: var(--text-primary);
    padding-left: 1.25rem;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.04);
    border: var(--panel-border);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.theme-toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.08);
}

.theme-toggle-btn .icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* LIGHT THEME STYLES */
body.light-theme {
    --bg-main: #f8fafc;
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
    
    --panel-bg: rgba(255, 255, 255, 0.75);
    --panel-bg-hover: rgba(255, 255, 255, 0.9);
    --panel-border: 1px solid rgba(15, 23, 42, 0.08);
    --panel-border-focus: 1px solid rgba(139, 92, 246, 0.5);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.06);
    
    --grad-secondary: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

body.light-theme .app-header {
    background: rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

body.light-theme .brand h1 {
    background: linear-gradient(135deg, #0f172a 0%, #334155 50%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.light-theme .nav-tabs {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

body.light-theme .nav-btn:hover {
    background: rgba(0, 0, 0, 0.03);
}

body.light-theme .user-status {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

body.light-theme input[type="text"],
body.light-theme input[type="number"],
body.light-theme input[type="date"],
body.light-theme input[type="month"],
body.light-theme select {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(15, 23, 42, 0.12);
    color: #0f172a;
}

body.light-theme input[type="text"]:focus,
body.light-theme input[type="number"]:focus,
body.light-theme input[type="date"]:focus,
body.light-theme input[type="month"]:focus,
body.light-theme select:focus {
    background: #ffffff;
    border-color: var(--accent-purple);
}

body.light-theme select option {
    background-color: #ffffff;
    color: #0f172a;
}

body.light-theme .table-scroll {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(15, 23, 42, 0.08);
}

body.light-theme .styled-table th {
    background: rgba(226, 232, 240, 0.98);
    color: #0f172a;
    border-bottom: 1px solid rgba(15, 23, 42, 0.1);
}

body.light-theme .styled-table td {
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}

body.light-theme .styled-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.02);
}

body.light-theme .btn-action-icon {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(15, 23, 42, 0.06);
}

body.light-theme .btn-action-icon:hover {
    background: rgba(0, 0, 0, 0.08);
}

body.light-theme .close-btn {
    color: #475569;
}

body.light-theme .autocomplete-dropdown {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(15, 23, 42, 0.1);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.1);
}

body.light-theme .autocomplete-dropdown li {
    color: #475569;
    border-bottom: 1px solid rgba(15, 23, 42, 0.03);
}

body.light-theme .autocomplete-dropdown li:hover,
body.light-theme .autocomplete-dropdown li.active {
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-purple);
}

body.light-theme .modal {
    background-color: rgba(15, 23, 42, 0.4);
}

body.light-theme .modal-content {
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.1);
}

body.light-theme .glass-panel h2 {
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

body.light-theme .calc-row.highlight {
    border-top: 1px solid rgba(15, 23, 42, 0.08);
}

body.light-theme .reset-section {
    border-top: 1px solid rgba(15, 23, 42, 0.08);
}

body.light-theme .theme-toggle-btn {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(15, 23, 42, 0.08);
}

body.light-theme .theme-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* Toast Notification System */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
    width: calc(100% - 48px);
    pointer-events: none;
}

.toast {
    background: var(--panel-bg);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border: var(--panel-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.2), opacity 0.3s, margin 0.3s, padding 0.3s, height 0.3s;
    opacity: 0;
    pointer-events: auto;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.hide {
    transform: translateX(120%);
    opacity: 0;
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.toast-icon-svg {
    width: 22px;
    height: 22px;
}

.toast-body {
    flex-grow: 1;
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 2px;
    font-size: 0.95rem;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: var(--transition);
    align-self: flex-start;
}

.toast-close:hover {
    color: var(--text-primary);
}

/* Specific types */
.toast-success {
    border-left: 4px solid var(--accent-emerald);
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.08), var(--shadow-md);
}

.toast-error {
    border-left: 4px solid var(--accent-rose);
    box-shadow: 0 8px 30px rgba(244, 63, 94, 0.08), var(--shadow-md);
}

.toast-warning {
    border-left: 4px solid var(--accent-amber);
    box-shadow: 0 8px 30px rgba(245, 158, 11, 0.08), var(--shadow-md);
}

.toast-info {
    border-left: 4px solid var(--accent-indigo);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.08), var(--shadow-md);
}

/* Theme adaptation for toast container on mobile */
@media (max-width: 768px) {
    .toast-container {
        top: 80px;
        bottom: auto;
        right: 16px;
        left: 16px;
        width: calc(100% - 32px);
        max-width: none;
    }
    
    .toast {
        transform: translateY(-120%);
    }
    
    .toast.show {
        transform: translateY(0);
    }
    
    .toast.hide {
        transform: translateY(-120%);
    }
}

/* Customer Details Sub-Dashboard Panel */
.customer-details-panel {
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin: 0 2rem 1.5rem 2rem;
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
}

body.light-theme .customer-details-panel {
    background: rgba(0, 0, 0, 0.015);
    border: 1px dashed rgba(15, 23, 42, 0.08);
}

.cust-detail-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}

.cust-detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cust-detail-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cust-detail-item strong {
    font-size: 1.1rem;
    font-weight: 700;
}

@media (max-width: 1024px) {
    .customer-details-panel {
        margin: 0 1rem 1rem 1rem;
        padding: 12px 14px;
    }
}

@media (max-width: 768px) {
    .cust-detail-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .cust-detail-item:first-child {
        grid-column: span 2;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        padding-bottom: 6px;
        margin-bottom: 4px;
    }
    
    body.light-theme .cust-detail-item:first-child {
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }
}

/* Dynamic Date Filters Panel */
.dynamic-date-filters-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 2rem;
    margin: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(255, 255, 255, 0.01);
}

body.light-theme .dynamic-date-filters-panel {
    border-bottom: 1px solid rgba(15, 23, 42, 0.04);
    background: rgba(0, 0, 0, 0.005);
}

.dynamic-date-filters-panel .filter-date-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.dynamic-date-filters-panel label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.dynamic-date-filters-panel input[type="date"],
.dynamic-date-filters-panel input[type="month"] {
    width: 170px;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

@media (max-width: 768px) {
    .dynamic-date-filters-panel {
        padding: 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .dynamic-date-filters-panel .filter-date-group {
        justify-content: space-between;
    }
    .dynamic-date-filters-panel input[type="date"],
    .dynamic-date-filters-panel input[type="month"] {
        width: 60%;
    }
}
