/* ============================================================
   EVOLUTION CAIXAS — Design System
   Premium Dark Theme with Glassmorphism
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── CSS Custom Properties ─────────────────────────────── */
:root {
  /* Brand Colors */
  --primary: #6C5CE7;
  --primary-light: #A29BFE;
  --primary-dark: #4834D4;
  --primary-glow: rgba(108, 92, 231, 0.3);

  /* Accent */
  --accent-green: #00B894;
  --accent-green-light: #55EFC4;
  --accent-red: #E17055;
  --accent-red-light: #FAB1A0;
  --accent-orange: #FDCB6E;
  --accent-blue: #74B9FF;
  --accent-pink: #FD79A8;

  /* Surfaces */
  --bg-base: #0A0A1A;
  --bg-surface: #12122A;
  --bg-card: rgba(25, 25, 55, 0.7);
  --bg-card-hover: rgba(35, 35, 75, 0.8);
  --bg-input: rgba(20, 20, 50, 0.6);
  --bg-modal: rgba(10, 10, 26, 0.95);
  --bg-sidebar: rgba(15, 15, 35, 0.95);

  /* Glass */
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);

  /* Text */
  --text-primary: #E8E8F0;
  --text-secondary: #9090B0;
  --text-muted: #606080;
  --text-inverse: #0A0A1A;

  /* Borders */
  --border-color: rgba(255, 255, 255, 0.06);
  --border-focus: var(--primary);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-xs: 0.7rem;
  --font-sm: 0.8rem;
  --font-base: 0.9rem;
  --font-md: 1rem;
  --font-lg: 1.2rem;
  --font-xl: 1.5rem;
  --font-2xl: 2rem;
  --font-3xl: 2.5rem;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Sidebar */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --header-height: 64px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px var(--primary-glow);
}

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Animated background gradient */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(108, 92, 231, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(0, 184, 148, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(253, 203, 110, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--primary-light);
  text-decoration: none;
}

/* ── Layout ────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: var(--space-lg);
  padding-top: calc(var(--header-height) + var(--space-lg));
  transition: margin-left var(--transition-base);
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: width var(--transition-base), transform var(--transition-base);
  overflow: hidden;
}

.sidebar-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-height: var(--header-height);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--accent-green));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-lg);
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
}

.sidebar-brand h1 {
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.sidebar-brand span {
  font-size: var(--font-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md);
  overflow-y: auto;
}

.nav-section-title {
  font-size: var(--font-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: var(--space-md) var(--space-md) var(--space-sm);
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  font-size: var(--font-sm);
  font-weight: 500;
  position: relative;
  user-select: none;
}

.nav-item:hover {
  background: rgba(108, 92, 231, 0.1);
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.2), rgba(108, 92, 231, 0.1));
  color: var(--primary-light);
  font-weight: 600;
}

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

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: var(--font-md);
}

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

/* ── Header ────────────────────────────────────────────── */
.header {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--header-height);
  background: rgba(10, 10, 26, 0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  transition: left var(--transition-base);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
}

.header-title {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-subtitle {
  font-size: var(--font-sm);
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
  flex: 1;
  justify-content: flex-end;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: var(--font-lg);
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
}

.menu-toggle:hover {
  background: var(--glass-bg);
}

/* ── Month Selector ────────────────────────────────────── */
.month-selector {
  display: flex;
  gap: var(--space-xs);
  background: var(--bg-card);
  padding: var(--space-xs);
  border-radius: var(--radius-full);
  border: 1px solid var(--glass-border);
  max-width: min(64vw, 900px);
  overflow-x: auto;
  scrollbar-width: thin;
}

.period-control {
  min-width: 0;
}

.period-select {
  display: none;
  min-width: 150px;
  background-color: var(--bg-surface);
}

.month-btn {
  padding: var(--space-xs) var(--space-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: var(--font-xs);
  font-weight: 500;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.month-btn:hover {
  color: var(--text-primary);
  background: rgba(108, 92, 231, 0.1);
}

.month-btn.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-base);
}

.card:hover {
  border-color: rgba(108, 92, 231, 0.15);
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.card-title {
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: var(--font-sm);
  color: var(--text-muted);
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

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

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card.green::after { background: linear-gradient(90deg, var(--accent-green), var(--accent-green-light)); }
.kpi-card.red::after { background: linear-gradient(90deg, var(--accent-red), var(--accent-red-light)); }
.kpi-card.purple::after { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.kpi-card.orange::after { background: linear-gradient(90deg, var(--accent-orange), #F9CA24); }
.kpi-card.blue::after { background: linear-gradient(90deg, var(--accent-blue), #0984E3); }
.kpi-card.pink::after { background: linear-gradient(90deg, var(--accent-pink), #E84393); }

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-xl);
  margin-bottom: var(--space-md);
}

.kpi-card.green .kpi-icon { background: rgba(0, 184, 148, 0.15); }
.kpi-card.red .kpi-icon { background: rgba(225, 112, 85, 0.15); }
.kpi-card.purple .kpi-icon { background: rgba(108, 92, 231, 0.15); }
.kpi-card.orange .kpi-icon { background: rgba(253, 203, 110, 0.15); }
.kpi-card.blue .kpi-icon { background: rgba(116, 185, 255, 0.15); }
.kpi-card.pink .kpi-icon { background: rgba(253, 121, 168, 0.15); }

.kpi-label {
  font-size: var(--font-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.kpi-value {
  font-size: var(--font-xl);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.kpi-value.positive { color: var(--accent-green); }
.kpi-value.negative { color: var(--accent-red); }

.kpi-change {
  font-size: var(--font-xs);
  margin-top: var(--space-sm);
  font-weight: 500;
}

.kpi-change.up { color: var(--accent-green); }
.kpi-change.down { color: var(--accent-red); }

/* ── Tables ────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-sm);
}

.data-table thead {
  background: rgba(108, 92, 231, 0.08);
}

.data-table th {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: var(--font-xs);
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  white-space: nowrap;
}

.data-table th:first-child,
.data-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: rgba(18, 18, 42, 0.96);
}

.data-table th:first-child {
  z-index: 2;
  background: rgba(35, 30, 72, 0.98);
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(108, 92, 231, 0.05);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.table-empty {
  text-align: center;
  padding: var(--space-2xl) !important;
  color: var(--text-muted) !important;
}

.table-empty-icon {
  font-size: var(--font-3xl);
  margin-bottom: var(--space-md);
  opacity: 0.3;
}

/* Table totals row */
.data-table tfoot {
  background: rgba(108, 92, 231, 0.05);
}

.data-table tfoot td {
  padding: var(--space-sm) var(--space-md);
  font-weight: 700;
  color: var(--primary-light);
  border-top: 2px solid var(--primary-glow);
  border-bottom: none;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 2px 8px var(--primary-glow);
}

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

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

.btn-success {
  background: linear-gradient(135deg, var(--accent-green), #00A885);
  color: white;
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 184, 148, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, var(--accent-red), #D63031);
  color: white;
}

.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(225, 112, 85, 0.3);
}

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

.btn-ghost:hover {
  background: var(--glass-bg);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  font-size: var(--font-md);
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-xs);
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-base);
}

/* Action buttons in table */
.action-btns {
  display: flex;
  gap: var(--space-xs);
}

.btn-edit {
  background: rgba(116, 185, 255, 0.15);
  color: var(--accent-blue);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-sm);
  transition: all var(--transition-fast);
}

.btn-edit:hover {
  background: rgba(116, 185, 255, 0.3);
}

.btn-delete {
  background: rgba(225, 112, 85, 0.15);
  color: var(--accent-red);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-sm);
  transition: all var(--transition-fast);
}

.btn-delete:hover {
  background: rgba(225, 112, 85, 0.3);
}

/* ── Forms ─────────────────────────────────────────────── */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-xs);
}

.form-input,
.form-select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--font-sm);
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

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

.form-input[type="date"] {
  color-scheme: dark;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-md);
}

.form-computed {
  background: rgba(108, 92, 231, 0.1);
  border-color: rgba(108, 92, 231, 0.2);
  color: var(--primary-light);
  font-weight: 600;
  cursor: not-allowed;
}

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

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

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

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

.modal-title {
  font-size: var(--font-lg);
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--font-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: rgba(225, 112, 85, 0.15);
  color: var(--accent-red);
}

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

.modal-footer {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
  padding: var(--space-lg);
  border-top: 1px solid var(--border-color);
}

/* ── Toast Notifications ───────────────────────────────── */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  min-width: 300px;
  max-width: 420px;
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }
.toast.info { border-left: 3px solid var(--accent-blue); }
.toast.warning { border-left: 3px solid var(--accent-orange); }

.toast-icon {
  font-size: var(--font-lg);
  flex-shrink: 0;
}

.toast-message {
  font-size: var(--font-sm);
  color: var(--text-primary);
  font-weight: 500;
}

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

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

/* ── Status Badges ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: 600;
  gap: 4px;
}

.badge-paid {
  background: rgba(0, 184, 148, 0.15);
  color: var(--accent-green);
}

.badge-pending {
  background: rgba(253, 203, 110, 0.15);
  color: var(--accent-orange);
}

.badge-overdue {
  background: rgba(225, 112, 85, 0.15);
  color: var(--accent-red);
}

/* ── Page Sections ─────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.page-title {
  font-size: var(--font-xl);
  font-weight: 800;
  color: var(--text-primary);
}

.page-description {
  font-size: var(--font-sm);
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.page-actions {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

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

.section-grid.two-col {
  grid-template-columns: repeat(2, 1fr);
}

/* ── Charts (Canvas) ───────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
  height: 300px;
  padding: var(--space-md);
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ── Expenses Grid ─────────────────────────────────────── */
.expense-grid {
  display: grid;
  grid-template-columns: 180px repeat(7, 1fr);
  gap: 1px;
  background: var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

.expense-cell {
  background: var(--bg-card);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-sm);
  display: flex;
  align-items: center;
}

.expense-cell.header {
  background: rgba(108, 92, 231, 0.08);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: var(--font-xs);
  letter-spacing: 0.5px;
}

.expense-cell.label {
  font-weight: 500;
  color: var(--text-secondary);
}

.expense-cell.total {
  background: rgba(108, 92, 231, 0.05);
  font-weight: 700;
  color: var(--primary-light);
}

.expense-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--font-sm);
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  text-align: right;
}

.expense-input:focus {
  background: var(--bg-input);
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* ── Stock Indicator ───────────────────────────────────── */
.stock-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
}

.stock-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
}

.stock-value {
  font-size: var(--font-2xl);
  font-weight: 800;
  margin: var(--space-sm) 0;
}

.stock-label {
  font-size: var(--font-sm);
  color: var(--text-muted);
}

/* ── Confirm Dialog ────────────────────────────────────── */
.confirm-dialog {
  text-align: center;
}

.confirm-dialog-icon {
  font-size: var(--font-3xl);
  margin-bottom: var(--space-md);
}

.confirm-dialog-text {
  font-size: var(--font-base);
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ── Empty State ───────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
}

.empty-state-icon {
  font-size: 4rem;
  opacity: 0.2;
  margin-bottom: var(--space-md);
}

.empty-state-text {
  font-size: var(--font-base);
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

/* ── Page View Containers ──────────────────────────────── */
.view-container {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view-container.active {
  display: block;
}

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

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 1024px) {
  .section-grid.two-col {
    grid-template-columns: 1fr;
  }

  .month-selector {
    max-width: 58vw;
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .expense-grid {
    font-size: var(--font-xs);
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: var(--space-md);
    padding-top: calc(var(--header-height) + var(--space-md));
    padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom));
  }

  .header {
    left: 0;
    padding: 0 var(--space-md);
    gap: var(--space-sm);
  }

  .menu-toggle {
    display: flex;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .month-selector {
    display: none;
  }

  .period-select {
    display: block;
  }

  .header-title {
    max-width: 42vw;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .expense-grid {
    grid-template-columns: 120px repeat(7, 1fr);
    font-size: 0.65rem;
  }

  .card,
  .kpi-card {
    padding: var(--space-md);
  }

  .chart-container {
    height: 240px;
    padding: var(--space-sm);
  }

  .modal-overlay {
    align-items: flex-end;
    padding: var(--space-sm);
  }

  .modal {
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: var(--space-md);
  }
}

@media (max-width: 480px) {
  :root {
    --header-height: 60px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .header-title {
    max-width: 34vw;
    font-size: var(--font-md);
  }

  .period-select {
    min-width: 132px;
    font-size: var(--font-xs);
    padding: var(--space-xs) var(--space-sm);
  }

  .page-title {
    font-size: var(--font-lg);
  }

  .page-actions,
  .page-actions .btn {
    width: 100%;
  }

  .data-table th,
  .data-table td {
    padding: var(--space-xs) var(--space-sm);
  }

  .toast-container {
    left: var(--space-sm);
    right: var(--space-sm);
    top: auto;
    bottom: calc(var(--space-sm) + env(safe-area-inset-bottom));
  }

  .toast {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  .modal {
    margin: var(--space-md);
    max-height: 95vh;
  }
}

/* ── Utility Classes ───────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-green { color: var(--accent-green); }
.text-red { color: var(--accent-red); }
.text-muted { color: var(--text-muted); }
.text-bold { font-weight: 700; }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.hidden { display: none !important; }
