:root {
    /* Base Variables (Theme Independent) */
    --primary-color: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.3);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --danger: #f43f5e;
    --danger-glow: rgba(244, 63, 94, 0.2);
    --warning: #f59e0b;
    --info: #0ea5e9;
    --accent: #f59e0b;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Outfit', var(--font-sans);
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Default Dark Mode Variables */
    --bg-color: #020617;
    --surface-color: rgba(15, 23, 42, 0.6);
    --surface-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --glass-blur: 16px;
    --bg-gradient-1: rgba(99, 102, 241, 0.05);
    --bg-gradient-2: rgba(14, 165, 233, 0.05);
}

body.light-mode {
    /* Light Mode Variables */
    --bg-color: #f8fafc;
    --surface-color: rgba(255, 255, 255, 0.8);
    --surface-border: rgba(15, 23, 42, 0.08);
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #64748b;
    --glass-blur: 20px;
    --primary-glow: rgba(99, 102, 241, 0.1);
    --bg-gradient-1: rgba(99, 102, 241, 0.03);
    --bg-gradient-2: rgba(14, 165, 233, 0.03);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.04), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 0% 0%, var(--bg-gradient-1) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, var(--bg-gradient-2) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Glassmorphism */
.glass {
    background: var(--surface-color);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--surface-border);
    box-shadow: var(--shadow-lg);
}

.glass-hover:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    transition: var(--transition);
}

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

.sidebar {
    width: 280px;
    padding: 2.5rem 1.5rem;
    border-right: 1px solid var(--surface-border);
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    padding: 2.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Navigation */
.nav-brand {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 3.5rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.02em;
}

.nav-brand svg {
    color: var(--primary-color);
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.nav-links {
    list-style: none;
    flex-grow: 1;
}

.nav-item {
    margin-bottom: 0.4rem;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    transition: var(--transition);
    font-weight: 500;
}

.nav-link svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-link.active {
    background: var(--primary-glow);
    color: var(--primary-light);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.nav-link.active svg {
    opacity: 1;
}

.nav-separator {
    padding: 1.5rem 1rem 0.75rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-dim);
    letter-spacing: 0.15em;
    font-weight: 700;
}

/* Components */
.card {
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 2rem;
    transition: var(--transition);
}

.card-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 2rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-family: var(--font-sans);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    text-decoration: none;
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 14px 0 var(--primary-glow);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px 0 var(--primary-glow);
}

.btn-outline {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--surface-border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}

input, select, textarea {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--surface-border);
    color: white;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
    width: 100%;
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    text-align: left;
    color: var(--text-dim);
    font-weight: 600;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--surface-border);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--surface-border);
    font-size: 0.95rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.amount-positive { color: var(--success); font-weight: 600; }
.amount-negative { color: var(--danger); font-weight: 600; }

/* Dashboard Widgets */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.kpi-card {
    padding: 1.75rem;
}

.kpi-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.kpi-value {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.kpi-trend {
    font-size: 0.8rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Mobile adjustments */
@media (max-width: 1024px) {
    .sidebar { width: 240px; }
}

@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 1rem;
        border-right: none;
        border-bottom: 1px solid var(--surface-border);
    }
    .nav-brand { margin-bottom: 1.5rem; }
    .nav-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }
    .nav-separator { display: none; }
    .tenant-switcher { display: none; }
}
