/* CSS Reset & Variables */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --secondary: #64748b;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #06b6d4;
    --info-light: #ecfeff;
    
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #ffffff;
    
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 24px;
}

.brand-logo {
    max-width: 100%;
    height: auto;
    max-height: 48px;
    object-fit: contain;
}

.brand-badge {
    background: rgba(6, 182, 212, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-sidebar);
    font-size: 0.925rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.nav-item i {
    font-size: 1.1rem;
    width: 20px;
}

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

.nav-item.active {
    color: white;
    background-color: var(--primary);
}

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

/* Main Content */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 32px;
    max-width: 1400px;
}

/* Topbar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.header-title h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
}

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

.period-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: white;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    color: var(--text-muted);
}

.period-selector input[type="month"] {
    border: none;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    outline: none;
    background: transparent;
    cursor: pointer;
}

/* Buttons */
.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

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

.btn-secondary {
    background-color: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: #f1f5f9;
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-text:hover {
    text-decoration: underline;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background-color: #f8fafc;
    color: var(--text-main);
}

.btn-icon.btn-danger:hover {
    background-color: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
}

.btn-icon.btn-success:hover {
    background-color: var(--success-light);
    color: var(--success);
    border-color: var(--success);
}

.full-width {
    width: 100%;
}

.margin-top-xs { margin-top: 6px; }
.margin-top-md { margin-top: 16px; }

/* Tabs */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Cards */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.space-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.metric-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    margin-bottom: 0;
    border-left: 4px solid transparent;
}

.metric-card.border-warning { border-left-color: var(--warning); }
.metric-card.border-success { border-left-color: var(--success); }
.metric-card.border-danger { border-left-color: var(--danger); }
.metric-card.border-info { border-left-color: var(--info); }

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.bg-warning-light { background-color: var(--warning-light); }
.text-warning { color: var(--warning); }

.bg-success-light { background-color: var(--success-light); }
.text-success { color: var(--success); }

.bg-danger-light { background-color: var(--danger-light); }
.text-danger { color: var(--danger); }

.bg-info-light { background-color: var(--info-light); }
.text-info { color: var(--info); }

.metric-details .label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-details h3 {
    font-size: 1.45rem;
    font-weight: 700;
    margin: 2px 0;
}

.metric-details .sub-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.chart-card {
    margin-bottom: 0;
}

.chart-wrapper {
    position: relative;
    height: 280px;
    width: 100%;
}

/* Tables */
.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 260px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 9px 12px 9px 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: var(--primary);
}

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

.filter-group select {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    background-color: white;
    outline: none;
    color: var(--text-main);
}

.table-container {
    overflow-x: auto;
}

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

.data-table th {
    background-color: #f8fafc;
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.725rem;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

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

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background-color: var(--success-light);
    color: #047857;
}

.badge-warning {
    background-color: var(--warning-light);
    color: #b45309;
}

.badge-danger {
    background-color: var(--danger-light);
    color: #b91c1c;
}

.badge-info {
    background-color: var(--info-light);
    color: #0e7490;
}

.badge-secondary {
    background-color: #f1f5f9;
    color: var(--text-muted);
}

/* Category & Type Badges */
.tag-category {
    font-size: 0.8rem;
    background-color: #f1f5f9;
    color: #475569;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    margin-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-muted);
}

.totals-summary strong {
    font-size: 1.1rem;
    color: var(--text-main);
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-backdrop.active {
    display: flex;
    animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.modal {
    background-color: white;
    width: 100%;
    max-width: 600px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal form {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    background-color: #f8fafc;
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
    display: flex;
    gap: 16px;
}

.col-6 {
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background-color: #f8fafc;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
    z-index: 10;
}

/* Reports Grid */
.reports-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.report-summary-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.report-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border-color);
}

.report-row span {
    color: var(--text-muted);
    font-weight: 500;
}

.report-row strong {
    color: var(--text-main);
}

/* Action Buttons Container in Tables */
.action-buttons {
    display: flex;
    gap: 6px;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
        padding: 16px 8px;
    }
    .brand-text, .nav-item span, .sidebar-footer button span {
        display: none;
    }
    .brand {
        justify-content: center;
    }
    .nav-item {
        justify-content: center;
        padding: 12px;
    }
    .main-content {
        margin-left: 80px;
        padding: 20px;
    }
    .charts-grid, .reports-grid {
        grid-template-columns: 1fr;
    }
}

/* Login Screen Styles */
.login-screen-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.login-card {
    background: white;
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    padding: 36px 32px;
    text-align: center;
    animation: modalIn 0.3s ease;
}

.login-header {
    margin-bottom: 28px;
}

.login-logo {
    max-height: 52px;
    margin-bottom: 12px;
}

.login-header h2 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 2px;
}

.login-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.input-with-icon input,
.input-with-icon select {
    width: 100%;
    padding: 11px 14px 11px 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    outline: none;
    background-color: white;
}

.input-with-icon input:focus,
.input-with-icon select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.login-error {
    background-color: var(--danger-light);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.825rem;
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-login {
    padding: 12px;
    font-size: 0.95rem;
}

.login-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* User Badge in Topbar */
.user-badge-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-details {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}
