/* =============================================
   Fina.ai Dashboard — App Styles v2 (Redesign)
   Modern glassmorphism + refined dark theme
   ============================================= */

/* ── Design Tokens ──────────────────────────── */
:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #0f0f23;
  --bg-card: #141428;
  --bg-card-hover: #181834;
  --text-primary: #f0f0ff;
  --text-secondary: #a0a0c0;
  --text-muted: #6a6a8a;
  --accent: #6C5CE7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.15);
  --cyan: #00D2FF;
  --success: #00E676;
  --danger: #FF6B6B;
  --warning: #FDCB6E;
  --glass-bg: rgba(15, 15, 35, 0.85);
  --glass-border: rgba(108, 92, 231, 0.1);
  --glass-blur: blur(20px);
  --border-subtle: rgba(108, 92, 231, 0.08);
  --border-light: rgba(108, 92, 231, 0.12);
  --border-medium: rgba(108, 92, 231, 0.2);
  --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  --card-hover-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --transition-fast: 0.15s ease;
  --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
}

/* ── Layout ─────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg-primary);
}

/* ── Sidebar ────────────────────────────────── */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--glass-border);
  position: fixed;
  top: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: width var(--transition-smooth), transform 0.3s ease;
}

/* Scrollbar styling */
.app-sidebar::-webkit-scrollbar { width: 4px; }
.app-sidebar::-webkit-scrollbar-track { background: transparent; }
.app-sidebar::-webkit-scrollbar-thumb {
  background: rgba(108, 92, 231, 0.15);
  border-radius: 4px;
}

/* Collapsed sidebar */
.app-sidebar.collapsed { width: var(--sidebar-collapsed); }
.app-sidebar.collapsed .sidebar-logo-text,
.app-sidebar.collapsed .sidebar-section-label,
.app-sidebar.collapsed .sidebar-link span,
.app-sidebar.collapsed .sidebar-user-info,
.app-sidebar.collapsed .team-banner span,
.app-sidebar.collapsed .team-banner .role-badge {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.15s ease, width 0.15s ease;
}
.app-sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 12px;
}
.app-sidebar.collapsed .sidebar-link .icon {
  font-size: 1.25rem;
}
.app-sidebar.collapsed .sidebar-header { padding: 20px 16px; justify-content: center; }
.app-sidebar.collapsed .sidebar-user { justify-content: center; padding: 10px; }
.app-sidebar.collapsed .sidebar-collapse-btn { justify-content: center; }
.app-sidebar.collapsed .sidebar-collapse-btn .collapse-text { display: none; }

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  transition: opacity var(--transition-smooth), width var(--transition-smooth);
}

.sidebar-logo-dot {
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 20px 12px 8px;
  transition: opacity var(--transition-smooth);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  position: relative;
  border-left: 3px solid transparent;
  margin-left: -3px;
}

.sidebar-link:hover {
  background: rgba(108, 92, 231, 0.08);
  color: var(--text-primary);
  transform: translateX(2px);
}

.sidebar-link.active {
  background: rgba(108, 92, 231, 0.1);
  color: var(--accent-light);
  border-left-color: var(--accent);
  font-weight: 600;
}

.sidebar-link .icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

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

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: rgba(108, 92, 231, 0.05);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 8px;
}

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: default;
  transition: background var(--transition-fast);
}

.sidebar-user:hover {
  background: rgba(108, 92, 231, 0.05);
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}

.sidebar-avatar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--bg-secondary);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
  transition: opacity var(--transition-smooth);
}

.sidebar-user-name {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Main Content ───────────────────────────── */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 28px 32px;
  min-height: 100vh;
  transition: margin-left var(--transition-smooth);
}

.app-sidebar.collapsed ~ .app-main {
  margin-left: var(--sidebar-collapsed);
}

/* ── Topbar ──────────────────────────────────── */
.app-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-left h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.topbar-left p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: 4px 0 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.topbar-btn:hover {
  background: rgba(108, 92, 231, 0.1);
  border-color: var(--border-medium);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.topbar-btn .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: badge-pulse 2s ease infinite;
}

@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(255, 107, 107, 0); }
}

/* ── Stat Cards Grid ─────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  opacity: 0;
  transition: opacity var(--transition-smooth);
}

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

.stat-card:hover::before {
  opacity: 1;
}

.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.stat-card-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  transition: transform var(--transition-fast);
}

.stat-card:hover .stat-card-icon {
  transform: scale(1.1);
}

/* Icon color variants */
.stat-icon-income { background: rgba(0, 230, 118, 0.1); }
.stat-icon-expense { background: rgba(255, 107, 107, 0.1); }
.stat-icon-balance { background: rgba(108, 92, 231, 0.1); }
.stat-icon-pending { background: rgba(253, 203, 110, 0.1); }
.stat-icon-accounts { background: rgba(0, 210, 255, 0.1); }
.stat-icon-default { background: rgba(108, 92, 231, 0.1); }

.stat-card-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  font-feature-settings: 'tnum';
  letter-spacing: -0.02em;
}

.stat-card-change {
  font-size: 0.8rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stat-card-change.positive { color: var(--success); }
.stat-card-change.negative { color: var(--danger); }
.stat-card-change.neutral  { color: var(--text-muted); }

/* ── Content Cards ───────────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition-smooth);
}

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

.content-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(108, 92, 231, 0.02);
}

.content-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.content-card-body {
  padding: 20px 24px;
}

/* ── Data Table ──────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
  transition: color var(--transition-fast);
}

.data-table thead th:hover {
  color: var(--text-secondary);
}

.data-table tbody tr {
  border-bottom: 1px solid rgba(108, 92, 231, 0.03);
  transition: all var(--transition-fast);
  position: relative;
}

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

.data-table tbody td {
  padding: 14px 16px;
  font-size: 0.86rem;
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table .amount-income {
  color: var(--success);
  font-weight: 600;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.84rem;
}

.data-table .amount-expense {
  color: var(--danger);
  font-weight: 600;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.84rem;
}

/* Row action buttons — reveal on hover */
.data-table .actions-cell {
  opacity: 0.3;
  transition: opacity var(--transition-fast);
}
.data-table tbody tr:hover .actions-cell {
  opacity: 1;
}

/* Transaction icon containers */
.icon-income {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(0, 230, 118, 0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.icon-expense {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255, 107, 107, 0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.icon-transfer {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(0, 210, 255, 0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}

/* ── Unified Badge System ───────────────────── */
.data-table .category-badge,
.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 500;
  background: rgba(108, 92, 231, 0.08);
  color: var(--text-secondary);
}

.data-table .status-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-completed { background: rgba(0, 230, 118, 0.1); color: var(--success); }
.status-pending   { background: rgba(253, 203, 110, 0.1); color: var(--warning); }
.status-scheduled { background: rgba(108, 92, 231, 0.1); color: var(--accent-light); }
.status-cancelled { background: rgba(255, 107, 107, 0.1); color: var(--danger); }

/* Recurrence Badge */
.recurrence-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  background: rgba(0, 210, 255, 0.08);
  color: var(--cyan);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* Role Badge */
.role-badge {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Buttons ─────────────────────────────────── */
.btn-app {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all var(--transition-smooth);
  border: none;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn-app-primary {
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  color: #fff;
  box-shadow: 0 2px 12px rgba(108, 92, 231, 0.2);
}

.btn-app-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.35);
}

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

.btn-app-ghost {
  background: rgba(108, 92, 231, 0.06);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.btn-app-ghost:hover {
  background: rgba(108, 92, 231, 0.12);
  color: var(--text-primary);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.btn-app-danger {
  background: rgba(255, 107, 107, 0.08);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.15);
}

.btn-app-danger:hover {
  background: rgba(255, 107, 107, 0.15);
  border-color: rgba(255, 107, 107, 0.3);
  transform: translateY(-1px);
}

.btn-app-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* Period button group */
.period-btn-group {
  display: flex;
  gap: 4px;
  background: rgba(108, 92, 231, 0.05);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.period-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.period-btn.active {
  background: rgba(108, 92, 231, 0.15);
  color: var(--accent-light);
  font-weight: 600;
}

/* ── Forms ────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  transition: all var(--transition-fast);
  outline: none;
  box-sizing: border-box;
}

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

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

.form-select {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236a6a8a' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
  box-sizing: border-box;
  transition: all var(--transition-fast);
}

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

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

.form-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 6px;
}

/* ── Empty State ─────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
  filter: grayscale(30%);
}

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

.empty-state-desc {
  font-size: 0.88rem;
  margin-bottom: 24px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

/* ── Filters Bar ─────────────────────────────── */
.filters-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filters-bar .form-input,
.filters-bar .form-select {
  width: auto;
  min-width: 160px;
  padding: 9px 14px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

/* ── Chart Area ──────────────────────────────── */
.chart-container {
  width: 100%;
  height: 260px;
  position: relative;
}

.chart-container svg {
  width: 100%;
  height: 100%;
}

/* ── Pagination ──────────────────────────────── */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(108, 92, 231, 0.02);
}

.pagination-info {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.pagination-btns {
  display: flex;
  gap: 4px;
}

.pagination-btns button {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pagination-btns button:hover:not(:disabled) {
  background: rgba(108, 92, 231, 0.1);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.pagination-btns button.active {
  background: rgba(108, 92, 231, 0.15);
  border-color: var(--accent);
  color: var(--accent-light);
  font-weight: 600;
}

.pagination-btns button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── Loading Skeleton ────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    rgba(108, 92, 231, 0.04) 25%,
    rgba(108, 92, 231, 0.08) 50%,
    rgba(108, 92, 231, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.8s ease infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Modal System ────────────────────────────── */
.modal-overlay {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: modal-fade-in 0.2s ease;
}

.modal-body {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
  animation: modal-scale-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-scale-in {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Mobile Toggle ───────────────────────────── */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
  background: rgba(108, 92, 231, 0.15);
  color: var(--text-primary);
}

/* Mobile backdrop overlay */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 140;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.visible {
  display: block;
  opacity: 1;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar-toggle { display: flex; }

  .app-sidebar {
    transform: translateX(-100%);
    z-index: 150;
    width: var(--sidebar-width);
  }

  .app-sidebar.collapsed { width: var(--sidebar-width); }

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

  .app-main {
    margin-left: 0 !important;
    padding: 20px 16px;
    padding-top: 68px;
  }

  .stats-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .filters-bar .form-input,
  .filters-bar .form-select { width: 100%; min-width: unset; }

  .topbar-left h1 { font-size: 1.3rem; }
  .app-topbar { padding-bottom: 16px; margin-bottom: 20px; }

  /* PWA standalone safe areas */
  .app-main {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  /* Touch-friendly buttons */
  .btn-app, .login-btn {
    min-height: 44px;
  }

  /* Table horizontal scroll */
  .data-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
  }

  /* Modal full-width on mobile */
  .modal-body {
    width: 95vw;
    max-width: 95vw;
    max-height: 85vh;
    margin: 8px;
    border-radius: var(--radius-lg);
  }

  /* Insights compact on mobile */
  .insight-severity { display: none; }

  /* Charts row stack */
  .charts-row { grid-template-columns: 1fr; }

  /* Stat cards compact */
  .stat-card { padding: 18px; }
  .stat-card-value { font-size: 1.5rem; }

  /* Sidebar collapse button hidden on mobile */
  .sidebar-collapse-btn { display: none; }

  /* Content card body compact */
  .content-card-body { padding: 16px; }
  .content-card-header { padding: 16px; }
}

/* ── Login Page ──────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

/* Subtle background pattern */
.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 20%, rgba(108, 92, 231, 0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(0, 210, 255, 0.04) 0%, transparent 50%);
  animation: login-bg-drift 20s ease infinite alternate;
}

@keyframes login-bg-drift {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(-3%, 3%) rotate(2deg); }
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 40px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  position: relative;
  z-index: 1;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 32px;
}

.login-logo-text {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}

.login-title {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-subtitle {
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.login-toggle {
  text-align: center;
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.login-toggle a {
  color: var(--accent-light);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.login-toggle a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.login-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all var(--transition-smooth);
  margin-top: 8px;
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.25);
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(108, 92, 231, 0.35);
}

.login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* ── AI Insights ─────────────────────────────── */
.insights-card {
  margin-bottom: 0;
}

.insight-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--accent);
  background: rgba(108, 92, 231, 0.03);
  margin-bottom: 8px;
  transition: all var(--transition-fast);
}

.insight-item:hover {
  background: rgba(108, 92, 231, 0.06);
  transform: translateX(3px);
}

.insight-item:last-child {
  margin-bottom: 0;
}

.insight-ai {
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.05), rgba(0, 210, 255, 0.03));
  border-left-color: var(--cyan);
}

.insight-icon {
  font-size: 1.15rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.insight-body {
  flex: 1;
  min-width: 0;
}

.insight-title {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.insight-message {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.insight-severity {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ── Team / Multi-User ──────────────────────── */
.team-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.08), rgba(0, 210, 255, 0.04));
  border: 1px solid var(--border-light);
  font-size: 0.78rem;
  transition: all var(--transition-smooth);
}

/* ── Utility Classes ─────────────────────────── */
.text-income { color: var(--success) !important; }
.text-expense { color: var(--danger) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-accent { color: var(--accent-light) !important; }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace !important; }

/* ── Animations ──────────────────────────────── */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* Staggered animation for cards */
.stats-grid .stat-card:nth-child(1) { animation-delay: 0s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 0.05s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.1s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.15s; }

/* ── Print ───────────────────────────────────── */
@media print {
  .app-sidebar, .sidebar-toggle, .topbar-right { display: none !important; }
  .app-main { margin-left: 0 !important; padding: 0 !important; }
  .stat-card, .content-card { break-inside: avoid; border: 1px solid #ddd; }
}
