:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --error: #ef4444;
    --warning: #f59e0b;
    --success: #10b981;
    --border: #e2e8f0;
    --radius: 8px;
    --sidebar-width: 260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Layout Structure */
.main-layout { display: flex; min-height: 100vh; width: 100%; }
.sidebar {
    width: var(--sidebar-width);
    background: #0f172a;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 50;
}
.sidebar nav {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding-top: 1rem;
}

.content-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
}

.topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 40;
}

.main-content { padding: 2.5rem; flex: 1; overflow-x: hidden; }

/* Auth Page (Login) */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    background-color: var(--bg);
    padding: 1.5rem;
}

.auth-card {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border);
}

.auth-card .btn {
    width: 100%;
    margin-top: 1rem;
}

/* Sidebar Links */
.nav-link {
    display: flex; align-items: center; gap: 0.85rem;
    padding: 1rem 1.5rem; color: #94a3b8;
    text-decoration: none; transition: all 0.2s;
    font-size: 0.95rem; font-weight: 500;
    width: 100%;
}
.nav-link:hover { background: #1e293b; color: white; }
.nav-link.active { background: var(--primary); color: white; }
.nav-link i, .nav-link svg { width: 20px; height: 20px; flex-shrink: 0; }

/* Forms */
.form-group { margin-bottom: 1.5rem; display: block; width: 100%; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.5rem; color: #334155; text-align: left; }
.form-control {
    display: block; width: 100%; padding: 0.75rem; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 0.95rem; outline: none;
    transition: border-color 0.2s; background: #fff; color: var(--text);
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
textarea.form-control { resize: vertical; min-height: 100px; }

/* Photo Upload - NEW NECESSARY ADDITION */
.photo-upload-container {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: #f8fafc;
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}

.photo-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #e2e8f0;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Stats Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    width: 100%;
}
.card {
    background: var(--surface); padding: 1.5rem; border-radius: var(--radius);
    border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    display: flex; flex-direction: column;
}
.card-interactive { cursor: pointer; transition: transform 0.2s; }
.card-interactive:hover { transform: translateY(-2px); border-color: var(--primary); }

.stat-label { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.stat-value { font-size: 1.5rem; font-weight: 800; color: #1e293b; }

/* Tables & Badges */
.data-table-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
table {
    width: 100%; border-collapse: collapse; text-align: left; font-size: 0.85rem;
}
th {
    background: #f8fafc; padding: 1rem 1.25rem; font-weight: 600; color: #64748b;
    border-bottom: 1px solid var(--border); text-transform: uppercase; font-size: 0.7rem;
}
td {
    padding: 1.25rem; border-bottom: 1px solid var(--border); color: #334155;
}

.badge {
    padding: 0.25rem 0.6rem; border-radius: 99px; font-size: 0.65rem;
    font-weight: 700; text-transform: uppercase;
}
.badge-unpaid { background: #fee2e2; color: #991b1b; }
.badge-partial { background: #fef3c7; color: #92400e; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-draft { background: #f1f5f9; color: #475569; }
.badge-published { background: #dcfce7; color: #166534; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-expense { background: #f1f5f9; color: #475569; border: 1px solid var(--border); }
.badge-success { background: #dcfce7; color: #166534; }

/* Modals */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; backdrop-filter: blur(2px); padding: 1rem;
}
.modal-content {
    background: var(--surface); padding: 2.5rem; border-radius: 12px;
    width: 100%; max-width: 550px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
    max-height: 90vh; overflow-y: auto;
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.75rem 1.5rem; border-radius: var(--radius); font-weight: 600;
    cursor: pointer; border: none; gap: 0.6rem; font-size: 0.9rem; transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: #475569; }
.btn-outline:hover { background: #f1f5f9; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.75rem; }

.spinner { width: 24px; height: 24px; border: 3px solid rgba(37, 99, 235, 0.1); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-msg { color: var(--error); font-size: 0.875rem; margin-top: 0.5rem; display: none; text-align: left; }

/* Specific to Wizard/Modals */
.dynamic-row, .schema-row {
    display: grid; grid-template-columns: 1fr 1fr auto; gap: 1rem; margin-bottom: 1rem;
    align-items: end; background: #fcfcfc; padding: 1rem; border-radius: var(--radius);
    border: 1px solid #f1f5f9;
}
.schema-row { grid-template-columns: 2fr 1.5fr 1fr 2fr auto; }

.checkbox-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem; background: #f8fafc; padding: 1rem; border-radius: var(--radius); border: 1px solid var(--border);
}
.checkbox-item {
    display: flex; align-items: center; gap: 0.6rem; font-size: 0.875rem; cursor: pointer; color: #475569;
}
.checkbox-item input { width: 16px; height: 16px; cursor: pointer; }

.deduction-row {
    display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.5rem; margin-bottom: 0.5rem;
    align-items: center;
}
.deduction-row input { padding: 0.5rem; font-size: 0.85rem; }
.deduction-row .remove-d { padding: 0.4rem 0.6rem; }

/* Alert Messages */
.alert {
    padding: 1rem; border-radius: var(--radius); margin-bottom: 1.5rem;
    display: flex; align-items: center; gap: 1rem; border: 1px solid transparent;
}
.alert-warning { background: #fffbeb; border-color: #fef3c7; color: #92400e; }
.alert i { width: 24px; height: 24px; }

/* PRINT STYLES */
@media print {
    .sidebar, .topbar, .btn, .alert, .reset-btn, #loading-bar, .modal-overlay:not(.printing-active) { display: none !important; }
    .content-area { margin-left: 0 !important; width: 100% !important; }
    .main-content { padding: 0 !important; }
    .card, .data-table-card { border: none !important; box-shadow: none !important; padding: 0 !important; margin-bottom: 2rem !important; }
    body { background: white !important; color: black !important; margin: 0 !important; padding: 0 !important; }
    table { width: 100% !important; border: 1px solid #eee !important; }
    th { background: #f9f9f9 !important; color: black !important; border-bottom: 2px solid #333 !important; }
    td { border-bottom: 1px solid #eee !important; }
    tr { page-break-inside: avoid !important; }
    .modal-overlay { position: static !important; background: none !important; padding: 0 !important; display: block !important; }
    .modal-content { box-shadow: none !important; border: none !important; width: 100% !important; max-width: 100% !important; padding: 0 !important; margin: 0 !important; }
    .stat-value, .badge, td { color: black !important; }
    .badge { border: 1px solid #ccc !important; background: transparent !important; }
}