:root {
    --primary: #1560BD;
    --primary-light: #e8f0f9;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --error: #f43f5e;
    --error-bg: #fff1f2;
    --warning: #f59e0b;
    --radius-sm: 6px;
    --radius: 12px;
    --radius-lg: 16px;
    --font-primary: 'Inter', system-ui, -apple-system, sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Light Theme Variables */
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --input-bg: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

[data-theme='dark'] {
    --bg-page: #020617;
    --bg-card: #0f172a;
    --bg-sidebar: #0f172a;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #1e293b;
    --input-bg: #1e293b;
    --primary-light: #1e293b;
    --success-bg: #064e3b;
    --error-bg: #4c0519;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --shadow: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
}

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

body {
    font-family: var(--font-primary);
    background-color: var(--bg-page);
    color: var(--text-main);
    transition: var(--transition);
    line-height: 1.5;
    overflow: hidden; /* Prevent body scroll */
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

/* HEADER */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo img {
    height: 40px;
    width: auto;
    border-radius: var(--radius-sm);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    font-size: 0.75rem;
    background: var(--primary-light);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.primary-icon {
    color: var(--primary);
}

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

.auth-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.login-inputs {
    display: flex;
    gap: 8px;
}

/* DASHBOARD GRID */
.dashboard-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 350px 1fr 300px;
    grid-template-rows: auto 1fr;
    grid-template-areas: 
        "stats stats stats"
        "list chart add";
    gap: 20px;
    overflow: hidden; /* Content will have its own scroll */
}

/* STATS */
.stats-section {
    grid-area: stats;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(16px);
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.income .stat-icon { 
    background: rgba(16, 185, 129, 0.2);
    color: var(--success); 
}
.expense .stat-icon { 
    background: rgba(244, 63, 94, 0.2);
    color: var(--error); 
}
.balance .stat-icon { 
    background: rgba(21, 96, 189, 0.2);
    color: var(--primary); 
}

.stat-info span {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.stat-info h2 {
    font-size: 1.75rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* CARDS COMMON */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

/* TRANSACTIONS SECTION */
.transactions-section {
    grid-area: list;
    min-height: 0;
}

.transactions-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.transaction-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.t-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.t-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.t-details h4 {
    font-size: 1rem;
    font-weight: 600;
}

.t-details p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.t-amount {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.t-value {
    font-weight: 700;
    font-size: 1rem;
}

.t-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: all 0.2s ease;
}

.transaction-item:hover .t-actions {
    opacity: 1;
    transform: translateY(-1px);
}

/* ANALYTICS */
.analytics-section {
    grid-area: chart;
}

.charts-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px;
    align-items: center;
}

.chart-box {
    height: 100%;
    position: relative;
    max-height: 300px;
}

/* ADD SECTION */
.add-section {
    grid-area: add;
}

.add-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

/* INPUTS & BUTTONS */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

input, select {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 0.875rem;
    transition: var(--transition);
}

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

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    min-height: 44px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.875rem;
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px 0 rgba(59, 130, 246, 0.6);
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.btn-secondary {
    background: transparent;
    color: var(--text-main);
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
}

.btn-danger {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    min-height: 44px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.875rem;
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 14px 0 rgba(239, 68, 68, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
}

.btn-danger:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 25px 0 rgba(239, 68, 68, 0.6);
    background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
}

.btn-danger:active {
    transform: translateY(0) scale(0.98);
}

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.action-icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 4px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    backdrop-filter: blur(8px);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.action-icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-main);
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}



/* UTILS */
.w-full { width: 100%; }

.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  padding: 16px 24px;
  border-radius: 16px;
  backdrop-filter: blur(20px);
  background: var(--toast-bg, rgba(255, 255, 255, 0.1));
  border: 1px solid var(--toast-border, rgba(255, 255, 255, 0.2));
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.875rem;
  box-shadow: var(--toast-shadow, 0 20px 40px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.2));
  z-index: 1000;
  display: none;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  animation: slideInToast 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.toast-icon, .toast-message {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.toast.success {
  --toast-bg: rgba(16, 185, 129, 0.15);
  --toast-border: rgba(16, 185, 129, 0.4);
  --toast-shadow: 0 20px 40px rgba(16, 185, 129, 0.25);
  color: var(--success);
}

.toast.error {
  --toast-bg: rgba(244, 63, 94, 0.15);
  --toast-border: rgba(244, 63, 94, 0.4);
  --toast-shadow: 0 20px 40px rgba(244, 63, 94, 0.25);
  color: var(--error);
}

.toast.warning {
  --toast-bg: rgba(245, 158, 11, 0.15);
  --toast-border: rgba(245, 158, 11, 0.4);
  --toast-shadow: 0 20px 40px rgba(245, 158, 11, 0.25);
  color: var(--warning);
}



.toast.error {
  --toast-bg: rgba(244, 63, 94, 0.15);
  --toast-border: rgba(244, 63, 94, 0.4);
  --toast-shadow: 0 20px 40px rgba(244, 63, 94, 0.25);
}

.toast.warning {
  --toast-bg: rgba(245, 158, 11, 0.15);
  --toast-border: rgba(245, 158, 11, 0.4);
  --toast-shadow: 0 20px 40px rgba(245, 158, 11, 0.25);
}

.toast-reload-hide {
  display: none !important;
}

@media (max-width: 768px) {
  .toast {
    top: 10px;
    right: 10px;
  }
}

@keyframes slideInToast {
  0% {
    transform: translateX(100%) scale(0.95);
    opacity: 0;
  }
  100% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
}

@keyframes slideInToast {
    from { transform: translateX(100%) scale(0.95); opacity: 0; }
    to { transform: translateX(0) scale(1); opacity: 1; }
}

.toast.hide-toast {
    animation: slideOutToast 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes slideOutToast {
    from { 
        transform: translateX(0) scale(1); 
        opacity: 1; 
    }
    to { 
        transform: translateX(100%) scale(0.95); 
        opacity: 0; 
    }
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
    text-align: center;
    gap: 12px;
}

.empty-state i {
    width: 48px;
    height: 48px;
    opacity: 0.3;
}

/* RESPONSIVE OVERRIDES */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-areas: 
            "stats stats"
            "list add"
            "chart chart";
        overflow-y: auto;
    }
    body { overflow: auto; }
}
