/* ============================================
   GastoSmart - Design System
   Dark Navy + Glassmorphism
   ============================================ */

:root {
  --bg-deep:      #050c1a;
  --bg-dark:      #0a1628;
  --bg-card:      rgba(255,255,255,0.04);
  --bg-card-hover:rgba(255,255,255,0.07);
  --bg-input:     rgba(255,255,255,0.06);
  --border:       rgba(255,255,255,0.08);
  --border-focus: rgba(79,172,254,0.5);

  --primary:      #4facfe;
  --primary-dark: #2e8fe8;
  --secondary:    #00f2fe;
  --accent:       #a78bfa;
  --success:      #10d9a0;
  --warning:      #fbbf24;
  --danger:       #f87171;
  --danger-dark:  #dc2626;

  --grad-primary: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --grad-purple:  linear-gradient(135deg, #a78bfa 0%, #7c3aed 100%);
  --grad-success: linear-gradient(135deg, #10d9a0 0%, #059669 100%);
  --grad-danger:  linear-gradient(135deg, #f87171 0%, #dc2626 100%);
  --grad-warm:    linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  --grad-bg:      linear-gradient(160deg, #0a1628 0%, #050c1a 50%, #0d1a35 100%);

  --text:         #e8ecf4;
  --text-muted:   #8892a4;
  --text-faint:   #4a5568;

  --sidebar-w:    260px;
  --radius:       12px;
  --radius-lg:    18px;
  --radius-xl:    24px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow:  0 0 30px rgba(79,172,254,0.15);
  --transition:   all 0.2s ease;
}

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Fundo 3D animado ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(17,58,122,0.55) 0%, transparent 70%),
    radial-gradient(ellipse 60% 50% at 80% 100%, rgba(10,40,100,0.4) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 60% 40%, rgba(79,172,254,0.06) 0%, transparent 60%),
    linear-gradient(180deg, #060d1f 0%, #08122a 50%, #050c1a 100%);
  pointer-events: none;
}

/* Grade 3D em perspectiva */
body::after {
  content: '';
  position: fixed;
  bottom: 0;
  left: -20%;
  width: 140%;
  height: 55%;
  z-index: -1;
  background-image:
    linear-gradient(rgba(79,172,254,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79,172,254,0.07) 1px, transparent 1px);
  background-size: 60px 60px;
  transform: perspective(600px) rotateX(55deg);
  transform-origin: 50% 100%;
  animation: gridScroll 12s linear infinite;
  mask-image: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 100%);
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 100%);
  pointer-events: none;
}

@keyframes gridScroll {
  from { background-position: 0 0; }
  to   { background-position: 0 60px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ========== AUTH PAGES ========== */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.auth-bg .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  animation: float 9s ease-in-out infinite;
}
.auth-bg .orb-1 { width: 600px; height: 600px; background: radial-gradient(circle, #1a5abf 0%, #0a2a6e 60%, transparent 100%); opacity: 0.45; top: -20%; left: -15%; animation-delay: 0s; }
.auth-bg .orb-2 { width: 500px; height: 500px; background: radial-gradient(circle, #0d3a8c 0%, #061a50 60%, transparent 100%); opacity: 0.4; bottom: -15%; right: -10%; animation-delay: 3.5s; }
.auth-bg .orb-3 { width: 350px; height: 350px; background: radial-gradient(circle, rgba(79,172,254,0.25) 0%, transparent 70%); opacity: 1; top: 35%; left: 50%; animation-delay: 6s; }
.auth-bg .orb-4 { width: 200px; height: 200px; background: radial-gradient(circle, rgba(167,139,250,0.2) 0%, transparent 70%); opacity: 1; top: 15%; right: 20%; animation-delay: 2s; }

@keyframes float {
  0%,100% { transform: translateY(0) scale(1); }
  33%      { transform: translateY(-25px) scale(1.04) rotate(3deg); }
  66%      { transform: translateY(15px) scale(0.97) rotate(-2deg); }
}

/* Estrelas no fundo auth */
.auth-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 15%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 75%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 85% 30%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 20% 85%, rgba(79,172,254,0.6) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 65% 50%, rgba(79,172,254,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 55%, rgba(255,255,255,0.35) 0%, transparent 100%),
    radial-gradient(1px 1px at 45% 90%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(2px 2px at 5% 45%, rgba(79,172,254,0.4) 0%, transparent 100%);
  pointer-events: none;
  animation: starTwinkle 6s ease-in-out infinite alternate;
}

@keyframes starTwinkle {
  from { opacity: 0.6; }
  to   { opacity: 1; }
}

.auth-card {
  position: relative;
  z-index: 1;
  background: rgba(8,18,38,0.88);
  backdrop-filter: blur(40px);
  border: 1px solid rgba(79,172,254,0.15);
  border-radius: var(--radius-xl);
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04), var(--shadow-glow);
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo .logo-icon {
  font-size: 44px;
  display: block;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 16px rgba(79,172,254,0.6));
}
.auth-logo h1 {
  font-size: 26px;
  font-weight: 800;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.auth-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 28px;
}
.auth-tabs button {
  flex: 1;
  padding: 9px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.auth-tabs button.active {
  background: var(--grad-primary);
  color: #fff;
  font-weight: 600;
}

/* ========== APP LAYOUT ========== */
#app-screen { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: rgba(4,10,22,0.97);
  backdrop-filter: blur(30px);
  border-right: 1px solid rgba(79,172,254,0.08);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-text {
  font-size: 20px;
  font-weight: 800;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-logo .logo-sub { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.nav-section { margin-bottom: 6px; }
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 10px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  position: relative;
}
.nav-item:hover { background: var(--bg-card-hover); color: var(--text); }
.nav-item.active {
  background: rgba(79,172,254,0.12);
  color: var(--primary);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 3px;
  background: var(--grad-primary);
  border-radius: 0 3px 3px 0;
}
.nav-item .nav-icon { font-size: 18px; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}
.user-chip:hover { background: var(--bg-card-hover); }
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--grad-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-info { flex: 1; min-width: 0; }
.user-info .user-name { font-size: 13px; font-weight: 600; color: var(--text); truncate: ellipsis; white-space: nowrap; overflow: hidden; }
.user-info .user-role { font-size: 11px; color: var(--text-faint); }

/* Main content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(6,13,31,0.9);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
}

#topbar-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 1px; white-space: nowrap; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.page-content { padding: 24px; flex: 1; max-width: 1400px; width: 100%; }

/* Hamburger for mobile */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

/* ========== COMPONENTS ========== */

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: var(--transition);
}
.card:hover { border-color: rgba(79,172,254,0.2); }
.card-glass {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(12px);
}

/* Stat Cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}
.stat-card.primary::before { background: var(--grad-primary); }
.stat-card.success::before { background: var(--grad-success); }
.stat-card.warning::before { background: var(--grad-warm); }
.stat-card.danger::before  { background: var(--grad-danger); }
.stat-card.purple::before  { background: var(--grad-purple); }

.stat-icon { font-size: 28px; margin-bottom: 12px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); }
.stat-value.primary { color: var(--primary); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger  { color: var(--danger); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-sub   { font-size: 12px; color: var(--text-faint); margin-top: 8px; }

/* Progress bar */
.progress-wrap { margin-top: 12px; }
.progress-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.progress-bar { height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; }
.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--grad-primary);
  transition: width 0.5s ease;
}
.progress-fill.warning { background: var(--grad-warm); }
.progress-fill.danger  { background: var(--grad-danger); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 4px 20px rgba(79,172,254,0.3);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 28px rgba(79,172,254,0.45); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-card-hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.1); }
.btn-danger { background: var(--grad-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { box-shadow: 0 4px 20px rgba(248,113,113,0.3); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-card); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 13px 28px; font-size: 15px; border-radius: 14px; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: var(--radius); }
.btn-full { width: 100%; justify-content: center; }

/* Form Elements */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 7px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-faint); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 0 3px rgba(79,172,254,0.1);
}
.form-select { cursor: pointer; }
.form-select option { background: #0a1628; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 5px; }
.form-input.error { border-color: var(--danger); }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-primary   { background: rgba(79,172,254,0.15); color: var(--primary); }
.badge-success   { background: rgba(16,217,160,0.15); color: var(--success); }
.badge-warning   { background: rgba(251,191,36,0.15); color: var(--warning); }
.badge-danger    { background: rgba(248,113,113,0.15); color: var(--danger); }
.badge-purple    { background: rgba(167,139,250,0.15); color: var(--accent); }
.badge-muted     { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* Table */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
.td-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* Expense Item Row */
.item-row { transition: var(--transition); }
.item-row.purchased td { opacity: 0.55; }
.item-row.purchased .item-name { text-decoration: line-through; }
.item-name { font-weight: 500; }
.item-details { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.item-total { font-weight: 700; color: var(--primary); }
.item-priority-star { color: var(--warning); font-size: 14px; }

/* Inline edit */
.editable {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition);
}
.editable:hover { background: rgba(255,255,255,0.07); }
.inline-input {
  background: var(--bg-input);
  border: 1px solid var(--border-focus);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 4px 8px;
  outline: none;
  font-family: inherit;
}

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.section-icon { font-size: 18px; }
.section-name { font-size: 15px; font-weight: 700; flex: 1; }
.section-totals { font-size: 13px; color: var(--text-muted); }
.section-actions { display: flex; gap: 4px; }
.section-collapse-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 2px 6px;
  transition: var(--transition);
}
.section-collapse-btn:hover { color: var(--text); }

/* Quick add row */
.quick-add-row td { padding: 8px 16px; background: rgba(79,172,254,0.04); }

/* Modal */
.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;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: #0d1a35;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  transform: scale(0.95);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-title { font-size: 18px; font-weight: 700; flex: 1; }
.modal-body { padding: 22px 24px; }
.modal-footer { padding: 18px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: var(--transition);
}
.modal-close:hover { background: var(--bg-card-hover); color: var(--text); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab-btn {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Toast notifications */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: rgba(13,26,53,0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  min-width: 280px;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  pointer-events: all;
  animation: toastIn 0.3s ease;
}
.toast.removing { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn  { from { opacity:0; transform: translateX(100%); } to { opacity:1; transform: translateX(0); } }
@keyframes toastOut { to   { opacity:0; transform: translateX(100%); } }
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--primary); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast-icon    { font-size: 18px; }
.toast-msg     { flex: 1; color: var(--text); }

/* Loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  color: var(--text-muted);
}
.loading-screen .spinner { width: 40px; height: 40px; border-width: 3px; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 14px; opacity: 0.5; }
.empty-state h3 { font-size: 16px; color: var(--text); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; color: var(--text-muted); max-width: 300px; margin-bottom: 20px; }

/* Dashboard specific */
.dashboard-grid { display: grid; grid-template-columns: 1fr 380px; gap: 20px; margin-top: 20px; }
.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.project-card:hover { border-color: rgba(79,172,254,0.3); transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.project-card .project-icon { font-size: 26px; margin-bottom: 10px; }
.project-card .project-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.project-card .project-type { font-size: 12px; color: var(--text-faint); margin-bottom: 12px; }
.project-card .fav-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.5;
  transition: var(--transition);
}
.project-card .fav-btn:hover, .project-card .fav-btn.active { opacity: 1; }
.project-card .role-badge { position: absolute; top: 14px; right: 42px; }
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* AI Suggestions */
.ai-suggestions { display: flex; flex-direction: column; gap: 8px; }
.suggestion-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
}
.suggestion-item:hover { background: var(--bg-card-hover); border-color: rgba(79,172,254,0.3); }
.suggestion-item.selected { background: rgba(79,172,254,0.1); border-color: var(--primary); }
.suggestion-check { width: 18px; height: 18px; border: 2px solid var(--border); border-radius: 4px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; transition: var(--transition); }
.suggestion-item.selected .suggestion-check { background: var(--primary); border-color: var(--primary); color: #fff; }
.suggestion-name { font-size: 14px; font-weight: 500; }
.suggestion-items { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* Logs */
.log-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.log-item:last-child { border-bottom: none; }
.log-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--grad-primary); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; overflow: hidden; }
.log-avatar img { width: 100%; height: 100%; object-fit: cover; }
.log-desc { font-size: 13px; color: var(--text); line-height: 1.5; }
.log-meta { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.log-undo { background: none; border: 1px solid var(--border); color: var(--text-muted); font-size: 11px; padding: 2px 8px; border-radius: 6px; cursor: pointer; margin-left: auto; flex-shrink: 0; transition: var(--transition); }
.log-undo:hover { border-color: var(--primary); color: var(--primary); }
.log-undone { text-decoration: line-through; opacity: 0.5; }

/* Members */
.member-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.member-item:last-child { border-bottom: none; }
.member-name { font-size: 14px; font-weight: 500; }
.member-email { font-size: 12px; color: var(--text-faint); }
.member-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* Profile */
.avatar-upload { text-align: center; margin-bottom: 24px; }
.avatar-large {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--grad-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  color: #fff;
  margin: 0 auto 12px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 3px solid rgba(79,172,254,0.3);
  transition: var(--transition);
}
.avatar-large:hover .avatar-overlay { opacity: 1; }
.avatar-large img { width: 100%; height: 100%; object-fit: cover; }
.avatar-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  opacity: 0;
  transition: var(--transition);
}

/* Divider */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-faint);
  font-size: 12px;
  margin: 16px 0;
}
.divider-text::before, .divider-text::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Chip group */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  background: none;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: rgba(79,172,254,0.12); border-color: var(--primary); color: var(--primary); }

/* Role selector */
.role-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 8px;
}
.role-option:hover { background: var(--bg-card-hover); }
.role-option input { margin-top: 3px; }
.role-option .role-info h4 { font-size: 14px; font-weight: 600; }
.role-option .role-info p  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Danger zone */
.danger-zone { border: 1px solid rgba(248,113,113,0.3); border-radius: var(--radius-lg); padding: 20px; }
.danger-zone h3 { color: var(--danger); font-size: 15px; margin-bottom: 12px; }

/* Scrollable panel */
.scroll-panel { max-height: 400px; overflow-y: auto; padding-right: 4px; }

/* Tooltip */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13,26,53,0.98);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 100;
}
[data-tip]:hover::after { opacity: 1; }

/* Currency input */
.currency-input { position: relative; }
.currency-input .prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}
.currency-input .form-input { padding-left: 34px; }

/* ========== RESPONSIVE ========== */
@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0,0,0,0.5);
  }
  .sidebar-overlay.open { display: block; }
  .sidebar-toggle { display: flex; }

  .main-content { margin-left: 0; }
  .page-content  { padding: 16px; }
  .topbar        { padding: 0 16px; }

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

  .table-wrap { font-size: 13px; }
  th, td { padding: 10px 12px; }

  .modal { max-width: 100%; border-radius: 16px 16px 0 0; max-height: 90vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }

  .auth-card { padding: 32px 24px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .projects-grid { grid-template-columns: 1fr; }
}
