:root {
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --text-xs: 12px;
    --text-sm: 14px;
    --text-base: 16px;
    --text-lg: 18px;
    --text-xl: 24px;
    --text-2xl: 32px;
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --sidebar-width: 280px;
    --topbar-height: 80px;
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 32px;
    --radius-full: 9999px;
    --shadow-sm: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-md: 0 12px 32px rgba(0,0,0,0.25);
    --shadow-lg: 0 24px 48px rgba(0,0,0,0.4);
    --transition: 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    --dock-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dark-mode {
    --bg-base: #1A1714;
    --bg-surface: #26221E;
    --bg-elevated: #332E28;
    --text-primary: #F0EBE1;
    --text-secondary: #A69E93;
    --accent: #C47340;
    --accent-hover: #D98650;
    --success: #5C9665;
    --warning: #D4A84D;
    --orange: #D4804D;
    --danger: #C95F5F;
    --purple: #8A6B96;
    --border: #4A4138;
    --input-bg: #1A1714;
    --card-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.light-mode {
    --bg-base: #F5F2EE;
    --bg-surface: #FFFFFF;
    --bg-elevated: #EDE8E2;
    --text-primary: #2B2621;
    --text-secondary: #7A7369;
    --accent: #C47340;
    --accent-hover: #B36635;
    --success: #4A8A53;
    --warning: #C49A3D;
    --orange: #C4703D;
    --danger: #B84A4A;
    --purple: #7A5B86;
    --border: #DDD5CD;
    --input-bg: #F5F2EE;
    --card-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: var(--text-base);
    transition: background-color var(--transition), color var(--transition);
    overflow: hidden;
}

h1 { font-size: var(--text-2xl); font-weight: var(--weight-bold); letter-spacing: -0.5px; margin-bottom: var(--space-md); }
h2 { font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: -0.3px; margin-bottom: var(--space-md); }
h3 { font-size: var(--text-lg); font-weight: var(--weight-semibold); margin-bottom: var(--space-sm); }
h4 { font-size: var(--text-base); font-weight: var(--weight-medium); color: var(--text-secondary); }

/* ===== LOGIN SCREEN ===== */
.login-root {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-base);
    padding: 20px;
}

.loading-root {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-base);
}

.loading-spinner {
    font-size: 48px;
    color: var(--accent);
}

.login-container {
    width: 100%;
    max-width: 420px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 32px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
}

.login-brand i { font-size: 36px; }

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.login-tabs {
    display: inline-flex;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 4px;
    gap: 4px;
    margin-bottom: 24px;
}

.login-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px 28px;
    border-radius: calc(var(--radius-sm) - 4px);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
}

.login-tab.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.login-form { display: none; text-align: left; }
.login-form.active { display: block; }

.login-field {
    margin-bottom: 20px;
}

.login-field label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.login-field input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 15px;
    transition: var(--transition);
}

.login-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(196, 115, 64, 0.15);
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 16px;
    min-height: 20px;
}

.login-btn {
    width: 100%;
    justify-content: center;
    padding: 14px;
    font-size: 15px;
}

.login-footer {
    margin-top: 32px;
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.6;
}

/* ===== APP LAYOUT ===== */
.app-layout {
    display: flex;
    height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-base);
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 40px;
    padding-left: 12px;
}

.brand i { font-size: 28px; }

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

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-base);
    font-weight: var(--weight-medium);
    font-family: inherit;
    text-align: left;
    transition: var(--dock-transition);
    transform-origin: left center;
}

.nav-item i { font-size: 22px; transition: var(--dock-transition); }

.nav-item:hover {
    background-color: rgba(255,255,255,0.05);
    color: var(--text-primary);
    transform: scale(1.03);
}

.nav-item:hover i { transform: scale(1.1); }

.nav-item.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    box-shadow: 0 8px 20px rgba(196, 115, 64, 0.3);
    transform: scale(1.02);
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-email {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.sidebar-logout {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: var(--transition);
    flex-shrink: 0;
}

.sidebar-logout:hover {
    color: var(--danger);
    background: rgba(201, 95, 95, 0.1);
}

/* ===== MAIN ===== */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

.topbar {
    height: var(--topbar-height);
    background-color: var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-2xl);
    position: sticky;
    top: 0;
    z-index: 10;
}

.year-switcher {
    display: flex;
    align-items: center;
    gap: 16px;
}

.year-switcher button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
}

.year-switcher button:hover {
    color: var(--text-primary);
    background-color: var(--bg-elevated);
}

.year-switcher h2 {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}

.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    border: none;
    line-height: 1;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(196,115,64,0.3); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #4A8A53; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(92,150,101,0.3); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #B84A4A; transform: translateY(-1px); }

/* ===== TABS ===== */
.tab-container {
    display: inline-flex;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 4px;
    gap: 4px;
    margin-bottom: var(--space-lg);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: calc(var(--radius-sm) - 4px);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
}

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

.tab-btn.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ===== VIEW ===== */
.view-container {
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* ===== CARDS ===== */
.grid-cards {
    display: grid;
    gap: 20px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}

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

.card-title {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.card-value {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    letter-spacing: -1px;
}

/* ===== PROGRESS ===== */
.progress-container {
    margin-top: 16px;
    background: var(--bg-elevated);
    border-radius: 100px;
    height: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 100px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== TABLES ===== */
.table-wrapper {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }

th, td {
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td { font-size: 14px; }

tbody tr:hover { background: var(--bg-elevated); }

/* ===== BADGES ===== */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.2px;
    text-transform: uppercase;
}

/* ===== FORMS ===== */
.form-group { margin-bottom: var(--space-lg); }

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--text-base);
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(196, 115, 64, 0.15);
}

.inline-select {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.inline-select:hover, .inline-select:focus {
    background: var(--bg-elevated);
    border-color: var(--accent);
    outline: none;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateY(20px) scale(0.95);
    transition: var(--dock-transition);
}

.modal-overlay.active .modal { transform: translateY(0) scale(1); }

.modal-header {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { margin: 0; }

.modal-close {
    background: var(--bg-elevated);
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover { color: var(--text-primary); background: var(--border); transform: rotate(90deg); }

.modal-body { padding: var(--space-xl); }

.modal-footer {
    padding: var(--space-md) var(--space-xl);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
    background: rgba(0,0,0,0.05);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ===== TOASTS ===== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-size: 14px;
    font-weight: 500;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
    min-width: 280px;
}

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

.toast i { font-size: 20px; flex-shrink: 0; }
.toast-success i { color: var(--success); }
.toast-error i { color: var(--danger); }
.toast-info i { color: var(--accent); }

.toast span { flex: 1; }

/* ===== UTILITIES ===== */
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-accent { color: var(--accent) !important; }
.text-warning { color: var(--warning) !important; }
.text-orange { color: var(--orange) !important; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

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

.ph-spin { animation: spin 1s linear infinite; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
