/* FinanceApp - Main CSS */
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;0,700;1,400&family=Roboto+Mono:wght@400;500&display=swap');

/* ==============================
   CSS VARIABLES - DARK THEME
   ============================== */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #0f1525;
  --bg-card: #131929;
  --bg-card-hover: #1a2235;
  --bg-input: #0f1525;
  --bg-sidebar: #080c17;
  --bg-topbar: rgba(8, 12, 23, 0.95);
  
  --border: #1e2d45;
  --border-light: #253450;
  
  --text-primary: #e8edf5;
  --text-secondary: #8494a8;
  --text-muted: #536273;
  
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: rgba(99, 102, 241, 0.15);
  --accent-glow: rgba(99, 102, 241, 0.3);
  
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.15);
  --info: #06b6d4;
  --info-light: rgba(6, 182, 212, 0.15);
  --purple: #8b5cf6;
  --purple-light: rgba(139, 92, 246, 0.15);
  
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;
  
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 30px var(--accent-glow);
  
  --transition: 0.2s ease;
  --font-main: 'Roboto', sans-serif;
  --font-mono: 'Roboto Mono', monospace;
}

/* LIGHT THEME */
[data-theme="light"] {
  --bg-primary: #f0f4f8;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f8fafc;
  --bg-sidebar: #1e293b;
  --bg-topbar: rgba(255, 255, 255, 0.95);
  
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* ==============================
   RESET & BASE
   ============================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; }

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

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 12px var(--accent-glow);
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  line-height: 1.2;
}
.logo-text span { 
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 12px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 20px;
  color: var(--text-secondary);
  border-radius: 0;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  font-size: 0.875rem;
  font-weight: 400;
  text-decoration: none;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--accent-light);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-item svg { 
  width: 17px; height: 17px; 
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-item.active svg, .nav-item:hover svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.user-mini {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-info { flex: 1; overflow: hidden; }
.user-info strong { 
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-info span { 
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* TOPBAR */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-topbar);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 99;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-btn {
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
  position: relative;
}
.topbar-btn:hover { color: var(--text-primary); border-color: var(--accent); }
.topbar-btn svg { width: 16px; height: 16px; }

.alert-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-topbar);
}

/* MAIN CONTENT */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  min-height: calc(100vh - var(--topbar-height));
  padding: 28px 28px 40px;
  flex: 1;
}

/* ==============================
   CARDS
   ============================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 20px;
  transition: var(--transition);
}

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

.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.card-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.card-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.card-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-icon svg { width: 20px; height: 20px; }

/* Summary Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.stat-info { flex: 1; }
.stat-label { 
  font-size: 0.72rem; 
  font-weight: 600;
  color: var(--text-muted); 
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 6px;
}
.stat-value { 
  font-size: 1.35rem; 
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-sub {
  font-size: 0.72rem;
  margin-top: 4px;
  font-weight: 500;
}

/* ==============================
   TABLES
   ============================== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-card-hover); }

tbody td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

.text-right { text-align: right; }
.text-center { text-align: center; }

/* ==============================
   BUTTONS
   ============================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn svg { width: 15px; height: 15px; }

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

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { opacity: 0.9; color: white; }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { opacity: 0.9; color: white; }

.btn-warning {
  background: var(--warning);
  color: white;
}
.btn-warning:hover { opacity: 0.9; color: white; }

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

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

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }
.btn-icon svg { width: 16px; height: 16px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ==============================
   FORMS
   ============================== */
.form-group {
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-sm);
  padding: 10px 14px;
  font-family: var(--font-main);
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: var(--transition);
  outline: none;
  appearance: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }

textarea.form-control { 
  resize: vertical; 
  min-height: 90px;
  line-height: 1.5;
}

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

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.input-group {
  position: relative;
}

.input-prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.875rem;
  pointer-events: none;
}

.input-group .form-control { padding-left: 36px; }

/* ==============================
   BADGES
   ============================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-primary { background: var(--accent-light); color: var(--accent); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-secondary { background: rgba(100,116,139,0.15); color: var(--text-secondary); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-purple { background: var(--purple-light); color: var(--purple); }

/* ==============================
   PROGRESS BARS
   ============================== */
.progress {
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
}

.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* ==============================
   MODALS
   ============================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.2s ease;
}

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

.modal-lg { max-width: 760px; }

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

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.modal-close:hover { color: var(--text-primary); border-color: var(--border-light); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body {
  padding: 20px 24px;
}

.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ==============================
   ALERTS / FLASH
   ============================== */
.alert {
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
}

.alert svg { width: 16px; height: 16px; flex-shrink: 0; }

.alert-success { background: var(--success-light); color: var(--success); border-color: rgba(16,185,129,0.3); }
.alert-danger { background: var(--danger-light); color: var(--danger); border-color: rgba(239,68,68,0.3); }
.alert-warning { background: var(--warning-light); color: var(--warning); border-color: rgba(245,158,11,0.3); }
.alert-info { background: var(--info-light); color: var(--info); border-color: rgba(6,182,212,0.3); }

/* ==============================
   PAGE HEADER
   ============================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

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

/* ==============================
   CHARTS CONTAINER
   ============================== */
.chart-container {
  position: relative;
  width: 100%;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* ==============================
   FILTERS BAR
   ============================== */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
}

.filters-bar .form-control {
  padding: 8px 12px;
  font-size: 0.82rem;
}

/* ==============================
   EMPTY STATE
   ============================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 52px; height: 52px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.875rem;
  line-height: 1.6;
  max-width: 300px;
  margin: 0 auto 20px;
}

/* ==============================
   ACCOUNT PILL
   ============================== */
.account-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.account-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ==============================
   DIVIDERS
   ============================== */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ==============================
   UTILITIES
   ============================== */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-accent { color: var(--accent) !important; }
.text-mono { font-family: var(--font-mono) !important; }

.bg-success-light { background: var(--success-light) !important; }
.bg-danger-light { background: var(--danger-light) !important; }
.bg-warning-light { background: var(--warning-light) !important; }
.bg-accent-light { background: var(--accent-light) !important; }

.fw-500 { font-weight: 500 !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }

.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-4 { margin-bottom: 4px !important; }
.mb-8 { margin-bottom: 8px !important; }
.mb-12 { margin-bottom: 12px !important; }
.mb-16 { margin-bottom: 16px !important; }
.mb-20 { margin-bottom: 20px !important; }
.mb-24 { margin-bottom: 24px !important; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-1 { flex: 1; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ==============================
   NOTIFICATIONS DROPDOWN
   ============================== */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all 0.2s ease;
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.dropdown-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.dropdown-item {
  padding: 11px 16px;
  font-size: 0.82rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--bg-card-hover); }

.dropdown-item-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

/* ==============================
   HAMBURGER MENU
   ============================== */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--border-radius-sm);
  background: transparent;
  color: var(--text-secondary);
}
.menu-toggle span {
  display: block;
  width: 18px; height: 2px;
  background: currentColor;
  transition: var(--transition);
}

/* ==============================
   SCROLLBAR GLOBAL
   ============================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ==============================
   LOGIN PAGE
   ============================== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.06) 0%, transparent 50%);
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-lg);
  padding: 40px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .logo-icon {
  width: 52px; height: 52px;
  margin: 0 auto 12px;
  font-size: 24px;
}

.login-logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.login-logo p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==============================
   PATRIMONY CARDS
   ============================== */
.patrimony-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 20px;
  text-align: center;
}

.patrimony-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 8px 0 4px;
}

/* ==============================
   RESPONSIVE
   ============================== */
@media (max-width: 1024px) {
  .charts-grid { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 260px; }
  
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.4);
  }
  
  .topbar { left: 0; }
  .menu-toggle { display: flex; }
  
  .main-content { margin-left: 0; padding: 20px 16px 32px; }
  
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  
  .page-header { flex-direction: column; align-items: flex-start; }
  
  .mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    display: none;
  }
  .mobile-overlay.active { display: block; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; }
}

/* ==============================
   ANIMATIONS
   ============================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.fade-in { animation: fadeIn 0.3s ease forwards; }
.loading-spin { animation: spin 0.8s linear infinite; }

/* ==============================
   TOOLTIP
   ============================== */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.72rem;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 500;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ==============================
   GOAL CARD
   ============================== */
.goal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 18px;
  transition: var(--transition);
}
.goal-card:hover { border-color: var(--border-light); }

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

.goal-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.goal-percent {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
}

.goal-values {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ==============================
   COLOR SWATCH
   ============================== */
.color-swatch {
  width: 14px; height: 14px;
  border-radius: 4px;
  display: inline-block;
  flex-shrink: 0;
}

/* ==============================
   TOPBAR CLOCK (Fortaleza BRT)
   ============================== */
.topbar-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-sm);
  min-width: 80px;
}

.clock-time {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 1px;
  line-height: 1.2;
}

.clock-label {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

@media (max-width: 600px) {
  .topbar-clock { display: none; }
}

/* ==============================
   PWA INSTALL BANNER
   ============================== */
.pwa-install-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--border-radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 999;
  box-shadow: var(--shadow), 0 0 20px var(--accent-glow);
  animation: slideUp 0.3s ease;
  min-width: 300px;
  max-width: 90vw;
}

@keyframes slideUp {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.pwa-install-banner .pwa-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.pwa-install-banner .pwa-text strong {
  display: block;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.pwa-install-banner .pwa-text span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==============================
   IMPROVED CHART CONTAINERS
   ============================== */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.chart-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  border-radius: var(--border-radius) var(--border-radius) 0 0;
}

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

.chart-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

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

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Stat card trend indicator */
.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 20px;
  margin-top: 4px;
}

.stat-trend.up { background: var(--success-light); color: var(--success); }
.stat-trend.down { background: var(--danger-light); color: var(--danger); }

/* Improved stat cards */
.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0; right: 0;
  width: 60px; height: 60px;
  background: currentColor;
  opacity: 0.03;
  border-radius: 50%;
  transform: translate(15px, 15px);
}

/* ==============================
   KPI CARDS (Dashboard)
   ============================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 16px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.kpi-card.kpi-accent {
  border-color: rgba(99,102,241,0.3);
  background: linear-gradient(135deg, rgba(99,102,241,0.06) 0%, var(--bg-card) 60%);
}

.kpi-card.kpi-danger { border-left: 3px solid var(--danger); }

.kpi-icon {
  width: 42px; height: 42px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-body { flex: 1; overflow: hidden; }

.kpi-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-sub {
  font-size: 0.7rem;
  margin-top: 5px;
  font-weight: 500;
  color: var(--text-muted);
}

/* KPI mini cards (patrimony breakdown) */
.kpi-mini {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 16px 18px;
  transition: var(--transition);
}

.kpi-mini:hover { border-color: var(--border-light); transform: translateY(-1px); }

.kpi-mini-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 8px;
}

.kpi-mini-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-bottom: 4px;
}

.kpi-mini-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==============================
   PROJECTION SUMMARY CARDS
   ============================== */
.proj-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-sm);
  padding: 14px 16px;
  transition: var(--transition);
}

.proj-card:hover { border-color: var(--border-light); }

.proj-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 6px;
}

.proj-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  line-height: 1.1;
}

.proj-note {
  font-size: 0.67rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Responsive for kpi-grid */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 1.1rem; }
}
