/* ==========================================================================
   Design System & Variables
   ========================================================================== */
   :root {
    /* Color Palette - Premium Dark Theme */
    --bg-base: #0f111a;
    --bg-surface: rgba(30, 33, 43, 0.6);
    --bg-surface-hover: rgba(40, 44, 56, 0.8);
    
    --primary: #4f46e5;      /* Indigo */
    --primary-light: #6366f1;
    --secondary: #10b981;    /* Emerald */
    --accent: #f43f5e;       /* Rose */
    --rose-light: #fb7185;   /* Rose Light */
    --warning: #f59e0b;      /* Amber */
    --info: #0ea5e9;         /* Sky */

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    --border-color: rgba(255, 255, 255, 0.08);
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, var(--primary), var(--primary-light));
    --gradient-success: linear-gradient(135deg, #059669, var(--secondary));
    --gradient-danger: linear-gradient(135deg, #e11d48, var(--accent));
    
    /* Shadows & Glassmorphism */
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --glass-border: 1px solid rgba(255, 255, 255, 0.05);
    --glass-blur: blur(12px);

    /* Typography */
    --font-sans: 'Inter', sans-serif;
    
    /* Layout */
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    /* Subtle background glow effect */
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(79, 70, 229, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.1), transparent 25%);
    background-attachment: fixed;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.glass-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    padding: 1.15rem;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

p {
    color: var(--text-muted);
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary);
}

/* ==========================================================================
   Layout Structure
   ========================================================================== */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-right: var(--glass-border);
    z-index: 1000;
    position: fixed;
    top: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    background: #0f111a;
}

.sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.8);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: var(--glass-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo i {
    color: var(--primary-light);
    font-size: 1.5rem;
    -webkit-text-fill-color: initial;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-item i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--gradient-primary);
    color: var(--text-inverse);
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: var(--glass-border);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-main);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.user-role {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    min-width: 0;
}

/* Top Header */
.top-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1.5rem;
    padding: 0 2rem;
    border-bottom: var(--glass-border);
    z-index: 10;
}

.header-company-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    max-width: 60%;
}

.header-company-info .company-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-light);
    letter-spacing: 0.5px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    text-transform: uppercase;
}

.header-company-info .company-address {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-company-info .company-address i {
    color: var(--secondary);
    font-size: 0.7rem;
}

.header-company-info .company-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-company-info .detail-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.header-company-info .detail-item i {
    color: var(--secondary);
    font-size: 0.7rem;
}

.header-company-info .detail-divider {
    color: var(--border-color);
    font-size: 0.75rem;
    user-select: none;
}

.header-actions {
    display: flex;
    gap: 1rem;
    margin-left: auto;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1.1rem;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    transform: translateY(-2px);
}

/* View Container */
.view-container {
    flex: 1;
    padding: 1rem 2rem;
    overflow-y: auto;
    position: relative;
    z-index: 1;
    min-width: 0;
}

/* ==========================================================================
   UI Components (Forms, Tables, Buttons)
   ========================================================================== */

/* Page Header */
.page-header {
    margin-bottom: 1.15rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.page-title {
    font-size: 1.8rem;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    font-size: 0.95rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.btn-primary {
    background: var(--gradient-primary);
    color: var(--text-inverse);
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--gradient-success);
    color: var(--text-inverse);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
    background: rgba(0, 0, 0, 0.3);
}

.form-row {
    display: flex;
    gap: 1.5rem;
}

.form-row > * {
    flex: 1;
}

/* Grid Layouts */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1.5rem; }

/* Tables */
.table-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 225px);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th, .table td {
    padding: 0.65rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.88rem;
}

.table th {
    background: #1e212b; /* Solid background for sticky */
    position: sticky;
    top: 0;
    z-index: 5;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table-multi-header th {
    top: auto !important;
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Badges / Tags */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger { background: rgba(225, 29, 72, 0.15); color: #fb7185; border: 1px solid rgba(225, 29, 72, 0.3); }

/* Value displays */
.value-positive { color: #34d399; font-weight: 600; }
.value-negative { color: #fb7185; font-weight: 600; }

/* Dashboard Cards */
.stat-card {
    display: flex;
    flex-direction: column;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.icon-blue { background: rgba(14, 165, 233, 0.1); color: #38bdf8; }
.icon-green { background: rgba(16, 185, 129, 0.1); color: #34d399; }
.icon-purple { background: rgba(79, 70, 229, 0.1); color: #818cf8; }
.icon-rose { background: rgba(244, 63, 94, 0.1); color: #fb7185; }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-section {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Modal / Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-surface);
    border: var(--glass-border);
    border-radius: var(--radius-lg);
    width: 95%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    transform: scale(0.9);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 10;
    backdrop-filter: blur(10px);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Active Card highlight for Debts Report */
.active-card {
    background: rgba(99, 102, 241, 0.08) !important;
    box-shadow: 0 8px 32px 0 rgba(99, 102, 241, 0.2) !important;
}

/* Reports Overview Specific Styles */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.kpi-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.1);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
}

.kpi-card.kpi-primary::before { background: var(--gradient-primary); }
.kpi-card.kpi-success::before { background: var(--gradient-success); }
.kpi-card.kpi-danger::before { background: var(--gradient-danger); }
.kpi-card.kpi-info::before { background: var(--info); }

.kpi-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.kpi-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.kpi-icon-wrapper {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: rgba(255, 255, 255, 0.05);
}

.kpi-primary .kpi-icon-wrapper { color: var(--primary-light); background: rgba(99, 102, 241, 0.1); }
.kpi-success .kpi-icon-wrapper { color: var(--secondary); background: rgba(16, 185, 129, 0.1); }
.kpi-danger .kpi-icon-wrapper { color: var(--accent); background: rgba(244, 63, 94, 0.1); }
.kpi-info .kpi-icon-wrapper { color: var(--info); background: rgba(14, 165, 233, 0.1); }

/* Reports Chart Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card-wrapper {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 320px;
}

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-card-title {
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-card-body {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
}

/* ==========================================================================
   Login Screen Style
   ========================================================================== */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(79, 70, 229, 0.15), transparent 30%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.1), transparent 30%);
    background-color: var(--bg-base);
}

.login-card {
    width: 90%;
    max-width: 420px;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header .logo-icon {
    font-size: 3rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
    display: inline-block;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.4));
}

.login-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.login-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper .input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 1rem;
}

.input-wrapper .form-control {
    padding-left: 42px;
    height: 48px;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.08);
}

.input-wrapper .form-control:focus {
    border-color: var(--primary-light);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.login-btn {
    width: 100%;
    height: 48px;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    border-radius: var(--radius-md);
    margin-top: 1.5rem;
}

.login-error-msg {
    color: var(--accent);
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.2);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    text-align: center;
    animation: shake 0.3s ease;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ==========================================================================
   Responsive & Mobile Optimization
   ========================================================================== */

/* Static element default states on Desktop */
.sidebar-toggle-btn {
    display: flex !important; /* Visible on desktop */
}
.sidebar-close-btn {
    display: flex !important; /* Visible in sidebar header */
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    cursor: pointer;
    transition: color var(--transition-fast);
    padding: 5px;
    margin-left: auto;
}
.sidebar-close-btn:hover {
    color: var(--text-main);
}
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}
.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Tablet & Mobile Screens (<= 1024px) */
@media (max-width: 1024px) {
    :root {
        --header-height: 60px;
    }
    
    /* Toggle buttons display */
    .sidebar-toggle-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        margin-right: 15px;
    }
    
    .sidebar-close-btn {
        display: flex !important;
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 1.8rem;
        cursor: pointer;
        transition: color var(--transition-fast);
        padding: 5px;
        margin-left: auto;
    }
    
    .sidebar-close-btn:hover {
        color: var(--text-main);
    }
    
    /* Sidebar collapse off-screen */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        z-index: 1000;
        background: #111420; /* Solidify background so main content doesn't bleed through blur */
        border-right: 1px solid rgba(255, 255, 255, 0.08);
    }
    
    .sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 10px 0 40px rgba(0, 0, 0, 0.8);
    }
    
    /* Main Content takes full width */
    .main-content {
        width: 100vw;
        padding-left: 0;
    }
    
    .top-header {
        padding: 0 1.25rem;
    }
    
    .view-container {
        padding: 1rem;
    }
    
    .table-container {
        max-height: none !important;
    }
    
    .grid-2 .table-container {
        max-height: none !important;
    }
    
    /* Adjust grid layouts */
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .grid-3 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Mobile Devices (<= 768px) */
@media (max-width: 768px) {
    /* Main container elements resizing */
    .top-header {
        justify-content: space-between;
    }
    
    .header-company-info .company-address,
    .header-company-info .company-meta {
        display: none;
    }
    .header-company-info .company-name {
        font-size: 0.8rem;
        max-width: 150px;
    }
    
    /* Status indicators */
    .server-status span:last-child {
        display: none; /* Hide status text on mobile, keep just status dot */
    }
    
    /* Form fields stacking */
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    /* Grid stack */
    .grid-4, .grid-3, .grid-2 {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    /* KPI and list layout wrapping */
    .kpi-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .kpi-card {
        padding: 1.2rem;
    }
    
    .kpi-value {
        font-size: 1.4rem;
    }
    
    /* Buttons size adjustment */
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Tables adjustment for tiny screens */
    .table th, .table td {
        padding: 0.75rem 0.85rem;
        font-size: 0.8rem;
    }
    
    .chart-card-wrapper {
        min-height: 320px;
        padding: 1rem;
    }
}

/* Very Tiny Phones (<= 480px) */
@media (max-width: 480px) {
    .header-company-info {
        display: none !important; /* Hide company info entirely on micro screens */
    }
    .login-card {
        padding: 1.5rem;
    }
    .login-header h2 {
        font-size: 1.3rem;
    }
}

/* ==========================================================================
   Mobile Report Modal - Full responsive fix for debt report on phones
   ========================================================================== */
@media (max-width: 768px) {
    /* Force report modal to full screen on mobile */
    #report-modal.modal-overlay {
        align-items: flex-start !important;
        padding: 0 !important;
    }

    #report-modal .modal {
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        max-height: 100vh !important;
        height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        background: #ffffff !important;
        box-sizing: border-box !important;
    }

    /* Reduce padding on the print container */
    #report-modal .print-container {
        padding: 0.75rem !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
        background: #ffffff !important;
    }

    /* Shrink report title */
    #report-modal .print-header h2 {
        font-size: 1.1rem !important;
        line-height: 1.3 !important;
    }

    #report-modal .print-header p {
        font-size: 0.78rem !important;
    }

    /* Section headers */
    #report-modal .print-container h3 {
        font-size: 0.95rem !important;
    }

    /* Action buttons: stack vertically on mobile */
    #report-modal .print-actions {
        flex-direction: column !important;
        gap: 6px !important;
        align-items: stretch !important;
    }

    #report-modal .print-actions .btn {
        width: 100% !important;
        justify-content: center !important;
        font-size: 0.85rem !important;
        padding: 10px 12px !important;
    }

    /* Table font size reduction */
    #report-modal .report-print-table th,
    #report-modal .report-print-table td {
        padding: 5px 4px !important;
        font-size: 0.72rem !important;
        line-height: 1.3 !important;
    }

    #report-modal .report-print-table td div {
        font-size: 0.7rem !important;
        margin-bottom: 1px !important;
    }

    #report-modal .report-print-table td strong {
        font-size: 0.7rem !important;
    }

    /* Footer stacking */
    #report-modal .print-footer-section {
        flex-direction: column !important;
        gap: 1.5rem !important;
        font-size: 0.8rem !important;
    }

    #report-modal .print-footer-section > div:last-child {
        text-align: left !important;
    }
}

/* ==========================================================================
   Premium Scrollbar Styling & Compact Sizing Overrides
   ========================================================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.45);
}

/* For Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

/* Nested Table Container Sizing Overrides */
.grid-2 .table-container {
    max-height: 280px;
}

.modal .table-container {
    max-height: 380px;
}

/* ==========================================================================
   Print Styles for Reports
   ========================================================================== */
@media print {
    @page {
        size: A4 landscape;
        margin: 1.2cm;
    }
    
    /* Force background colors and colors to render in print */
    html, body {
        height: auto !important;
        overflow: visible !important;
        background: #ffffff !important;
        color: #000000 !important;
        font-family: 'Inter', sans-serif !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    .sidebar,
    .top-header,
    body:not(.printing-inline-report) .view-container,
    .sidebar-overlay,
    .modal-overlay:not(#report-modal),
    #login-screen,
    .report-container button,
    .report-container .btn,
    .no-print,
    .report-container div[style*="margin-top: 2rem; text-align: center; border-top: 1px solid"] {
        display: none !important;
    }

    /* Force App Container to display in normal document flow */
    .app-container {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Hide Main Content when printing full report (modal) */
    body:not(.printing-inline-report) .main-content {
        display: none !important;
    }

    /* Force Modal Overlay to take up normal flow */
    #report-modal.modal-overlay {
        position: static !important;
        display: block !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        background: transparent !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        padding: 0 !important;
        margin: 0 !important;
        height: auto !important;
        width: 100% !important;
        overflow: visible !important;
    }

    /* Redefine variables under the modal and body during print to ensure light theme and high contrast */
    :root, body, #report-modal .modal, .report-container {
        --bg-base: #ffffff !important;
        --bg-surface: #ffffff !important;
        --text-main: #000000 !important;
        --text-muted: #475569 !important;
        --border-color: #000000 !important;
        
        --primary: #1e1b4b !important;
        --primary-light: #312e81 !important;
        --secondary: #15803d !important;
        --accent: #b91c1c !important;
        --rose-light: #b91c1c !important;
        --warning: #b45309 !important;
        --info: #0369a1 !important;
    }

    /* Format Modal container to span the full page without rounded corners, shadows, or screen centering */
    #report-modal .modal {
        position: static !important;
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        background: #ffffff !important;
        color: #000000 !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        transform: none !important;
    }

    /* Reset the scrollable container layout */
    .report-container {
        max-height: none !important;
        overflow: visible !important;
        padding: 1.5cm !important; /* Proper margin for standard A4 printing */
        margin: 0 !important;
        background: #ffffff !important;
        color: #000000 !important;
        box-shadow: none !important;
        border: none !important;
    }

    /* Print-specific text overrides */
    .report-container * {
        color: #000000 !important;
        text-shadow: none !important;
        background-image: none !important;
    }

    /* Print-specific glass-card overrides to ensure high contrast and clear boundaries on paper */
    .glass-card {
        background: #ffffff !important;
        color: #000000 !important;
        border: 1px solid #cbd5e1 !important;
        box-shadow: none !important;
        margin-bottom: 1.5rem !important;
        padding: 1.25rem !important;
        page-break-inside: auto !important;
    }

    /* Compress the cover page (Page 1) to fit perfectly on A4 landscape print layout */
    .glass-card.page-break {
        min-height: auto !important;
        height: auto !important;
        padding: 0.75rem !important;
        font-size: 0.72rem !important;
    }
    .glass-card.page-break h1 {
        font-size: 1.15rem !important;
        margin-bottom: 0.2rem !important;
    }
    .glass-card.page-break h2 {
        font-size: 0.85rem !important;
        margin-top: 2px !important;
        margin-bottom: 2px !important;
    }
    .glass-card.page-break p {
        font-size: 0.68rem !important;
        margin: 2px 0 0 !important;
    }
    .glass-card.page-break h4 {
        font-size: 0.75rem !important;
        margin-top: 0 !important;
        margin-bottom: 0.25rem !important;
    }
    .glass-card.page-break table th,
    .glass-card.page-break table td {
        padding: 2px 4px !important;
        font-size: 0.6rem !important;
    }
    .glass-card.page-break div[style*="margin-bottom: 8px"],
    .glass-card.page-break div[style*="margin-bottom: 1.25rem"] {
        margin-bottom: 0.25rem !important;
    }
    .glass-card.page-break div[style*="padding-bottom: 6px"] {
        padding-bottom: 2px !important;
    }
    .glass-card.page-break div[style*="display: flex; align-items: center; gap: 6px; margin-bottom: 5px;"] {
        margin-bottom: 2px !important;
    }
    .glass-card.page-break div[style*="margin-bottom: 5px"] {
        margin-bottom: 2px !important;
    }
    .glass-card.page-break div[style*="gap: 12px"] {
        gap: 6px !important;
    }
    .glass-card.page-break div[style*="gap: 15px"] {
        gap: 8px !important;
    }
    .glass-card.page-break div[style*="padding: 10px 15px"] {
        padding: 4px 8px !important;
    }
    .glass-card.page-break div[style*="padding: 8px 12px"] {
        padding: 4px 6px !important;
    }
    .glass-card.page-break div[style*="font-size: 1.15rem"] {
        font-size: 0.9rem !important;
    }
    .glass-card.page-break div[style*="padding: 6px 10px"] {
        padding: 2px 4px !important;
    }
    .glass-card.page-break div[style*="font-size: 0.88rem"] {
        font-size: 0.75rem !important;
    }
    .glass-card.page-break div[style*="height: 8px"] {
        height: 4px !important;
    }
    .glass-card.page-break div[style*="height: 5px"] {
        height: 3px !important;
    }
    .glass-card.page-break div[style*="margin-bottom: 1.5rem; border-bottom: 3px double"] {
        margin-bottom: 0.4rem !important;
        padding-bottom: 0.3rem !important;
    }

    /* Avoid splitting table rows across page breaks */
    .report-container tr,
    .report-print-table tr {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    /* Eliminate sticky header positioning during print to prevent cell overlapping at page breaks */
    .table th,
    .report-container .table th {
        position: static !important;
        background: #cbd5e1 !important;
        color: #000000 !important;
        border-bottom: 2px solid #000000 !important;
        font-weight: bold !important;
        text-transform: uppercase !important;
    }

    /* Draw clear solid black borders on the table elements for paper layout (Kẻ bảng) */
    .report-print-table {
        border-collapse: collapse !important;
        width: 100% !important;
        margin-bottom: 1.5rem !important;
        border: 2px solid #000000 !important;
    }

    .report-print-table th,
    .report-print-table td {
        border: 1px solid #000000 !important;
        padding: 8px 10px !important;
        font-size: 0.9rem !important;
        color: #000000 !important;
    }

    /* Bôi đen/tô xám làm nổi bật doanh thu chi phí khi in */
    .report-print-table thead tr,
    .report-print-table tr.print-header-row {
        background-color: #cbd5e1 !important;
        font-weight: bold !important;
    }

    .report-print-table tr.print-bold-row {
        background-color: #cbd5e1 !important;
        font-weight: bold !important;
    }

    .report-print-table tr.print-sub-bold-row {
        background-color: #f1f5f9 !important;
        font-weight: bold !important;
    }

    .report-print-table tr.print-sub-row td:nth-child(2) {
        padding-left: 20px !important;
    }

    /* Định dạng ô nhập số biến thành text thường khi in (ẩn viền ô nhập) */
    .report-print-table input.print-input,
    .report-print-table input.print-input-desc {
        border: none !important;
        background: transparent !important;
        outline: none !important;
        font-family: inherit !important;
        font-size: inherit !important;
        font-weight: inherit !important;
        color: #000000 !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .report-print-table input.print-input {
        text-align: right !important;
    }
    
    /* Ẩn các nút thêm/xóa dòng chi phí khi in */
    .report-print-table .print-action-cell {
        display: none !important;
    }
    .report-print-table th.print-action-header {
        display: none !important;
    }

    /* Highlight total profit block professionally */
    .report-container div[style*="background: var(--primary-dark)"],
    .report-container div[style*="background:var(--primary-dark)"] {
        background: #cbd5e1 !important;
        border: 2px solid #000000 !important;
        border-radius: 0px !important;
        padding: 1.25rem !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-bottom: 2rem !important;
    }

    /* Adjust comparison block layouts with thick left-border indicator */
    .report-container div[style*="border-left"] {
        background: #f8fafc !important;
        border: 1px solid #000000 !important;
        border-left: 6px solid #000000 !important;
        padding: 1.25rem !important;
        border-radius: 0px !important;
        margin-bottom: 1.25rem !important;
    }

    .report-container div[style*="border-left: 4px solid var(--warning)"] {
        border-left-color: #000000 !important;
    }
    .report-container div[style*="border-left: 4px solid var(--primary)"] {
        border-left-color: #000000 !important;
    }
    .report-container div[style*="border-left: 4px solid var(--info)"] {
        border-left-color: #000000 !important;
    }

    /* High contrast color overrides for dynamic highlight tags */
    .report-container span[style*="color:var(--rose-light)"] {
        color: #000000 !important;
        font-weight: bold !important;
    }

    .report-container span[style*="color:var(--secondary)"] {
        color: #000000 !important;
        font-weight: bold !important;
    }

    .report-container span[style*="color:var(--info)"] {
        color: #000000 !important;
        font-weight: bold !important;
    }

    /* === Inline Monthly Report print support === */
    /* When printing from the 'Báo cáo Tháng' inline tab,
       hide all UI except the report card */
    body.printing-inline-report .sidebar,
    body.printing-inline-report .top-header,
    body.printing-inline-report .sidebar-overlay,
    body.printing-inline-report #login-screen {
        display: none !important;
    }

    /* Hide ALL view-container content except the inline report */
    #monthly-report-inline .no-print,
    #monthly-report-inline button,
    #fuel-report-inline .no-print,
    #fuel-report-inline button,
    #personal-report-inline .no-print,
    #personal-report-inline button,
    #summary-report-inline .no-print,
    #summary-report-inline button,
    .mi-custom-expense-row .no-print {
        display: none !important;
    }

    /* Full-page print: hide sidebar, header, nav tabs, filter bar */
    .sidebar,
    .top-header,
    .sidebar-overlay,
    #login-screen,
    .page-header,
    .view-section > .glass-card:first-child,
    div[style*="display:flex; gap:1rem; border-bottom"] {
        display: none !important;
    }

    /* Show only the monthly/fuel/personal/summary reports when printing */
    #monthly-report-inline,
    #fuel-report-inline,
    #personal-report-inline,
    #summary-report-inline {
        display: block !important;
        background: #ffffff !important;
        color: #000000 !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
    }

    /* Override table colors for print (white background, black text) */
    #monthly-report-inline table,
    #monthly-report-inline th,
    #monthly-report-inline td,
    #fuel-report-inline table,
    #fuel-report-inline th,
    #fuel-report-inline td,
    #personal-report-inline table,
    #personal-report-inline th,
    #personal-report-inline td,
    #summary-report-inline table,
    #summary-report-inline th,
    #summary-report-inline td {
        color: #000000 !important;
        background: transparent !important;
        border-color: #cbd5e1 !important;
    }

    #monthly-report-inline thead tr th,
    #fuel-report-inline thead tr th,
    #personal-report-inline thead tr th,
    #summary-report-inline thead tr th {
        background: #cbd5e1 !important;
        font-weight: bold !important;
    }

    #monthly-report-inline tr[style*="rgba(148,163,184,0.1)"],
    #monthly-report-inline tr[style*="rgba(148,163,184,0.15)"],
    #fuel-report-inline tr[style*="rgba(148,163,184,0.1)"],
    #fuel-report-inline tr[style*="rgba(148,163,184,0.15)"],
    #personal-report-inline tr[style*="rgba(148,163,184,0.1)"],
    #personal-report-inline tr[style*="rgba(148,163,184,0.15)"],
    #summary-report-inline tr[style*="rgba(148,163,184,0.1)"],
    #summary-report-inline tr[style*="rgba(148,163,184,0.15)"] {
        background: #f1f5f9 !important;
    }

    #monthly-report-inline tr[style*="#2d3a4a"],
    #fuel-report-inline tr[style*="#2d3a4a"],
    #personal-report-inline tr[style*="#2d3a4a"],
    #summary-report-inline tr[style*="#2d3a4a"] {
        background: #cbd5e1 !important;
    }

    #monthly-report-inline tr[style*="rgba(100,116,139"],
    #fuel-report-inline tr[style*="rgba(100,116,139"],
    #personal-report-inline tr[style*="rgba(100,116,139"],
    #summary-report-inline tr[style*="rgba(100,116,139"] {
        background: #e2e8f0 !important;
    }

    /* Inputs look like text when printed */
    #monthly-report-inline input,
    #fuel-report-inline input,
    #personal-report-inline input,
    #summary-report-inline input {
        border: none !important;
        background: transparent !important;
        color: #000000 !important;
        box-shadow: none !important;
        outline: none !important;
    }

    /* Scale print tables font size and padding to fit landscape A4 correctly */
    #monthly-report-inline table,
    #fuel-report-inline table,
    #personal-report-inline table,
    #summary-report-inline table {
        font-size: 8px !important;
        table-layout: auto !important;
    }
    #monthly-report-inline th,
    #monthly-report-inline td,
    #fuel-report-inline th,
    #fuel-report-inline td,
    #personal-report-inline th,
    #personal-report-inline td,
    #summary-report-inline th,
    #summary-report-inline td {
        padding: 4px 2px !important;
    }

    /* Make view-container scroll properly */
    .view-container {
        overflow: visible !important;
        height: auto !important;
    }

    .app-container {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
        padding: 0 !important;
    }

    :root, body {
        --bg-base: #ffffff !important;
        --bg-surface: #ffffff !important;
        --text-main: #000000 !important;
        --text-muted: #475569 !important;
        --border-color: #000000 !important;
    }
}

/* Định dạng màn hình thường cho các ô nhập số trên bảng xem trước */
.report-print-table input.print-input,
.report-print-table input.print-input-desc {
    border: 1px dashed var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    padding: 4px 6px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.report-print-table input.print-input {
    width: 140px;
    text-align: right;
}
.report-print-table input.print-input-desc {
    width: 100%;
}
.report-print-table input.print-input:focus,
.report-print-table input.print-input-desc:focus {
    border-color: var(--primary-light);
    background: var(--bg-base);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
    outline: none;
}
.report-print-table .btn-delete-row {
    padding: 0.2rem 0.4rem;
    color: var(--accent);
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 4px;
    cursor: pointer;
}
.report-print-table .btn-delete-row:hover {
    background: var(--accent);
    color: #ffffff;
}
