:root {
    /* Premium Color Palette */
    --bg-app: #f4f7f9;
    --bg-surface: #ffffff;
    --bg-surface-hover: #fcfcfd;
    --border-color: rgba(226, 232, 240, 0.8);
    --border-strong: #cbd5e1;
    
    /* Text Colors */
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    /* Brand Colors */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    
    /* Status Colors */
    --success: #059669;
    --success-bg: #ecfdf5;
    --danger: #e11d48;
    --danger-bg: #fff1f2;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    
    /* Sidebar (Dark Premium) */
    --sidebar-bg: #0b1120;
    --sidebar-text: #94a3b8;
    --sidebar-hover: #1e293b;
    --sidebar-active: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.08);
    
    /* Modern Shadows & Glass */
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
    --shadow-float: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 10px 10px -5px rgba(15, 23, 42, 0.04);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    
    /* Layout */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography Hierarchy */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.mono { font-family: 'JetBrains Mono', monospace; }

.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
    border-right: 1px solid var(--sidebar-border);
}

.sidebar-header {
    height: 76px;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--sidebar-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    color: white;
    font-weight: 700;
    font-size: 1.3rem;
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.01em;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    border: 1px solid rgba(255,255,255,0.2);
}

.sidebar-nav {
    padding: 1.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.nav-item:hover {
    background-color: var(--sidebar-hover);
    color: var(--sidebar-active);
    transform: translateX(2px);
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.nav-dropdown { position: relative; }
.nav-dropdown-content {
    display: none;
    flex-direction: column;
    padding-left: 2.25rem;
    margin-top: 0.25rem;
    gap: 0.25rem;
}
.nav-dropdown:hover .nav-dropdown-content { display: flex; }
.nav-dropdown-content .nav-item {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    color: #cbd5e1;
}
.nav-dropdown-content .nav-item:hover { color: white; background: transparent; transform: translateX(2px); }

/* ==========================================================================
   MAIN CONTENT & TOPBAR (Glassmorphism)
   ========================================================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.topbar {
    height: 76px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    transition: var(--transition);
    background: white;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.user-profile:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    font-size: 0.85rem;
}

/* ==========================================================================
   VIEWS & ANIMATIONS
   ========================================================================== */
.app-view {
    display: none;
    animation: fadeScale 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.app-view.active { display: block; }

@keyframes fadeScale {
    from { opacity: 0; transform: translateY(15px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.dashboard-content {
    flex: 1;
    overflow-y: auto;
    padding: 2.5rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* ==========================================================================
   CARDS & KPI WIDGETS
   ========================================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 4px;
    background: transparent;
    transition: var(--transition);
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.kpi-card:hover::before {
    background: linear-gradient(90deg, var(--primary), #818cf8);
}

.kpi-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.kpi-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.03em;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(248, 250, 252, 0.5);
}

.card-header h2 { font-size: 1.15rem; font-weight: 600; }
.card-body { padding: 2rem; }

/* Dashboard specifics */
.hero-kpis .hero-card {
    background: linear-gradient(to bottom right, #ffffff, #f8fafc);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   TABLES (Modern Data Grids)
   ========================================================================== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.erp-table, .data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
    background: white;
}

.erp-table th, .data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1;
}

.erp-table td, .data-table td {
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    transition: background 0.2s ease;
}

.erp-table tbody tr:hover, .data-table tbody tr:hover {
    background-color: #f8fafc;
}

.erp-table .num-col, .data-table .num-col { text-align: right; }

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* Badges */
.badge, .status-badge {
    padding: 0.35rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.status-badge.success { background: var(--success-bg); color: var(--success); }
.status-badge.info { background: var(--primary-light); color: var(--primary); }
.status-badge.danger, .badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }

/* ==========================================================================
   FORMS, INPUTS & BUTTONS
   ========================================================================== */
.form-group { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.25rem; }
.form-group.inline { flex-direction: row; align-items: center; gap: 1rem; margin-bottom: 0; }
.form-group label { font-size: 0.85rem; font-weight: 500; color: var(--text-main); }

input[type="text"], input[type="date"], input[type="number"], select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    background-color: white;
    transition: var(--transition);
    color: var(--text-main);
    box-shadow: 0 1px 2px rgba(0,0,0,0.02) inset;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.readonly-input {
    background-color: #f8fafc;
    color: var(--text-muted);
    cursor: not-allowed;
}

.form-row { display: flex; gap: 1.5rem; margin-bottom: 1.5rem; }
.form-row.two-col > * { flex: 1; }
.form-row.three-col > * { flex: 1; }
.form-row.four-col > * { flex: 1; }
.form-row .flex-2 { flex: 2; }
.align-end { align-items: flex-end; }

/* Buttons */
button {
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px -2px rgba(79, 70, 229, 0.4);
}
.btn-primary:active { transform: translateY(0); }

.btn-success {
    background: var(--success);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 4px 6px -1px rgba(5, 150, 105, 0.3);
}
.btn-success:hover {
    background: #047857;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px -2px rgba(5, 150, 105, 0.4);
}

.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border-strong);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.btn-text {
    background: transparent;
    color: var(--danger);
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
}
.btn-text:hover { background: var(--danger-bg); }
.btn-text.blue { color: var(--primary); }
.btn-text.blue:hover { background: var(--primary-light); }
.btn-text:disabled { color: var(--text-light); cursor: not-allowed; background: transparent; }

/* ==========================================================================
   UPLOAD BOX
   ========================================================================== */
.upload-box {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-md);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    background: #f8fafc;
    transition: var(--transition);
}
.upload-box:hover, .upload-box.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: scale(1.01);
}
.upload-icon { color: var(--primary); margin-bottom: 1rem; opacity: 0.8; }
.upload-box h3 { font-size: 1.1rem; font-weight: 600; color: var(--text-main); margin-bottom: 0.5rem; }
.upload-box p { font-size: 0.9rem; color: var(--text-muted); }

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

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

.modal-content {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-float);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-body { padding: 2rem; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background: #f8fafc;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ==========================================================================
   E-INVOICE & SPECIFIC COMPONENTS
   ========================================================================== */
.e-invoice-preview {
    font-family: 'Inter', sans-serif;
    color: #0f172a;
    padding: 3rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: var(--shadow-md);
}
.ei-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
}
.ei-title { font-size: 2.5rem; color: var(--primary); font-weight: 800; letter-spacing: -0.02em; }
.ei-table th { background: #f8fafc; color: #475569; }
.ei-summary-row.tot { color: var(--primary); border-top: 2px solid #e2e8f0; }

.action-list { list-style: none; }
.action-list li {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}
.action-list li:hover { background: #f8fafc; }

/* Filter Bars */
.dashboard-filter-bar, .date-filter-bar {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Print Media */
@media print {
    .sidebar, .topbar, .app-view:not(.active) { display: none !important; }
    .main-content { overflow: visible !important; }
    .modal-overlay { background: transparent !important; position: absolute; }
    .modal-content { box-shadow: none !important; }
}

/* Statement of Account specific overrides */
.table-container .data-table { table-layout: fixed !important; width: 100% !important; }
.table-container .data-table th, .table-container .data-table td { word-break: break-word !important; }
.table-container .data-table th.num-col, .table-container .data-table td.num-col { width: 120px !important; text-align: right !important; }
.table-container .data-table th:nth-child(1), .table-container .data-table td:nth-child(1) { width: 120px !important; }
.table-container .data-table th:nth-child(2), .table-container .data-table td:nth-child(2) { width: 140px !important; }
.table-container .data-table th:nth-child(3), .table-container .data-table td:nth-child(3) { width: auto !important; min-width: 150px !important; }

/* ==========================================================================
   TAX SUMMARY STYLING (VAT & Corporate Tax)
   ========================================================================== */
.vat-card {
    border: none;
    background: linear-gradient(145deg, var(--bg-surface), #f8fafc);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.vat-box {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.vat-box h3 {
    padding: 0.75rem 1rem;
    background: #f1f5f9;
    margin: 1.5rem -1.5rem 0.5rem -1.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}
.vat-box h3:first-child {
    margin-top: -1.5rem;
    border-top: none;
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
}

.vat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px dashed var(--border-color);
    transition: background-color 0.2s ease;
}

.vat-row:last-child {
    border-bottom: none;
}

.vat-row:hover {
    background-color: rgba(241, 245, 249, 0.6);
    border-radius: var(--radius-sm);
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    margin-left: -0.75rem;
    margin-right: -0.75rem;
}

.vat-row.divider {
    border-top: 2px solid var(--border-strong);
    border-bottom: none;
    margin-top: 0.5rem;
}

.vat-row.total-vat-row {
    background: linear-gradient(to right, #e0e7ff, #ede9fe);
    border-radius: var(--radius-md);
    padding: 1.25rem 1rem;
    margin: 1rem -0.5rem -0.5rem -0.5rem;
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.5);
}

.vat-row.total-vat-row:hover {
    background: linear-gradient(to right, #dbeafe, #e0e7ff);
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    padding-left: 1rem;
    padding-right: 1rem;
}

.vat-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-width: 75%;
}

.vat-label strong {
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 600;
}

.vat-label span {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.4;
}

.vat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    text-align: right;
    min-width: 120px;
}

.vat-row.total-vat-row .vat-value {
    font-size: 1.4rem;
    color: var(--primary);
    font-weight: 700;
}

/* Premium Filter Bar */
.filter-bar {
    background: var(--bg-surface);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: inline-flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: flex-end;
    margin-bottom: 1.5rem;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.filter-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.filter-group input {
    height: 42px;
    padding: 0 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    background: #f8fafc;
    transition: var(--transition);
}
.filter-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    background: #fff;
}
.filter-bar .btn-primary {
    height: 42px;
    padding: 0 1.5rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    white-space: nowrap;
}
