/* ============================================================
   FINCONTROL PRO v5.0 — DESIGN PROFISSIONAL
   Desenvolvido por FELIPE ANDRADE DEV
   ============================================================ */

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

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

:root {
  /* Brand Colors */
  --blue-900: #0f1e45;
  --blue-800: #1e3a8a;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-400: #60a5fa;
  --blue-100: #dbeafe;

  --green-700: #15803d;
  --green-600: #16a34a;
  --green-500: #22c55e;
  --green-400: #4ade80;
  --green-100: #dcfce7;

  --red-600:  #dc2626;
  --red-500:  #ef4444;
  --red-100:  #fee2e2;

  --amber-500: #f59e0b;
  --amber-100: #fef3c7;

  /* Neutrals */
  --white:    #ffffff;
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Semantic */
  --bg:           var(--gray-50);
  --surface:      var(--white);
  --surface-alt:  var(--gray-100);
  --border:       var(--gray-200);
  --text:         var(--gray-900);
  --text-muted:   var(--gray-500);
  --text-faint:   var(--gray-400);

  --income:  var(--green-500);
  --expense: var(--red-500);
  --balance: var(--blue-600);

  /* Gradients */
  --grad-brand:   linear-gradient(135deg, var(--blue-800) 0%, var(--blue-600) 100%);
  --grad-income:  linear-gradient(135deg, var(--green-600) 0%, var(--green-400) 100%);
  --grad-expense: linear-gradient(135deg, var(--red-600) 0%, var(--red-500) 100%);
  --grad-balance: linear-gradient(135deg, var(--blue-800) 0%, var(--blue-700) 100%);

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(15,23,42,.04);
  --shadow-sm:  0 2px 8px rgba(15,23,42,.06);
  --shadow-md:  0 4px 16px rgba(15,23,42,.08);
  --shadow-lg:  0 8px 32px rgba(15,23,42,.12);
  --shadow-xl:  0 16px 48px rgba(15,23,42,.16);

  /* Layout */
  --nav-w: 260px;
  --nav-w-collapsed: 72px;
  --topbar-h: 64px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Type */
  --font: 'Sora', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-size-xs:  11px;
  --font-size-sm:  13px;
  --font-size-base: 14px;
  --font-size-md:  15px;
  --font-size-lg:  17px;
  --font-size-xl:  20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 30px;

  /* Motion */
  --ease: cubic-bezier(.4,0,.2,1);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --dur-fast:  120ms;
  --dur-base:  200ms;
  --dur-slow:  360ms;
}

/* Dark theme */
html.dark-theme, body.dark-theme {
  --bg:          var(--gray-900);
  --surface:     var(--gray-800);
  --surface-alt: var(--gray-700);
  --border:      var(--gray-700);
  --text:        #f1f5f9;
  --text-muted:  var(--gray-400);
  --text-faint:  var(--gray-500);
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background var(--dur-slow) var(--ease),
              color var(--dur-slow) var(--ease);
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ============================================================
   LOADING SCREEN
   ============================================================ */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: var(--grad-brand);
}

#loading-screen p {
  color: rgba(255,255,255,.8);
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  animation: blink 1.6s ease-in-out infinite;
}

@keyframes blink { 0%,100%{opacity:.6} 50%{opacity:1} }

.loader {
  width: 44px; height: 44px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

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

/* ============================================================
   AUTH LAYOUT
   ============================================================ */
.page-container {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.auth-background {
  position: absolute;
  inset: 0;
  background: var(--grad-brand);
  z-index: 0;
}

.auth-background.register-bg {
  background: linear-gradient(135deg, var(--green-700) 0%, var(--blue-800) 100%);
}

.background-decoration,
.background-decoration-2 {
  position: absolute;
  border-radius: 50%;
  opacity: .12;
}

.background-decoration {
  width: 560px; height: 560px;
  background: white;
  top: -160px; right: -160px;
  animation: floatA 18s ease-in-out infinite;
}

.background-decoration-2 {
  width: 400px; height: 400px;
  background: white;
  bottom: -100px; left: -100px;
  animation: floatA 24s ease-in-out infinite reverse;
}

@keyframes floatA {
  0%,100%{ transform: translate(0,0) rotate(0deg) }
  33%    { transform: translate(20px,-30px) rotate(8deg) }
  66%    { transform: translate(-15px,20px) rotate(-5deg) }
}

.auth-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 48px 44px;
  width: 100%;
  max-width: 460px;
  animation: slideUp var(--dur-slow) var(--ease-spring);
}

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

.auth-header {
  text-align: center;
  margin-bottom: 36px;
}

.app-icon {
  width: 88px; height: 88px;
  margin: 0 auto 20px;
  background: var(--grad-brand);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 32px rgba(30,58,138,.3);
}

.app-icon img {
  width: 100%; height: 100%;
  object-fit: contain;
  border-radius: 22px;
}

.app-title {
  font-size: var(--font-size-3xl);
  font-weight: 800;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -.5px;
  margin-bottom: 6px;
}

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

/* ============================================================
   FORMS
   ============================================================ */
.auth-form { display: flex; flex-direction: column; gap: 18px; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: var(--font-size-base);
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--dur-base) var(--ease),
              box-shadow var(--dur-base) var(--ease);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper input {
  flex: 1;
  padding-right: 42px;
}

.toggle-password {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  transition: color var(--dur-base);
}
.toggle-password:hover { color: var(--blue-600); }

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--blue-600);
}

.checkbox-label a {
  color: var(--blue-600);
  text-decoration: none;
  font-weight: 600;
}

/* Password strength */
.password-strength { margin-top: 6px; }
.strength-bar {
  height: 4px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.strength-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--dur-base) var(--ease);
  width: 0%;
}
.strength-bar-fill.weak   { width: 30%; background: var(--red-500); }
.strength-bar-fill.medium { width: 65%; background: var(--amber-500); }
.strength-bar-fill.strong { width: 100%; background: var(--green-500); }
.strength-text {
  font-size: var(--font-size-xs);
  font-weight: 600;
  margin-top: 4px;
}
.strength-text.weak   { color: var(--red-500); }
.strength-text.medium { color: var(--amber-500); }
.strength-text.strong { color: var(--green-500); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: var(--font);
  font-size: var(--font-size-sm);
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--dur-base) var(--ease);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.btn:active { transform: scale(.97) !important; }

.btn-primary {
  background: var(--grad-brand);
  color: white;
  box-shadow: 0 2px 8px rgba(30,58,138,.25);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px rgba(30,58,138,.35);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--grad-income);
  color: white;
  box-shadow: 0 2px 8px rgba(22,163,74,.25);
}
.btn-success:hover {
  box-shadow: 0 4px 16px rgba(22,163,74,.35);
  transform: translateY(-1px);
}

.btn-ghost {
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover {
  background: var(--border);
  color: var(--text);
}

.btn-danger {
  background: var(--grad-expense);
  color: white;
}

.btn-full { width: 100%; }

.btn-mark-paid {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--green-100);
  color: var(--green-700);
  border: 1.5px solid var(--green-400);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: var(--font-size-xs);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--dur-base) var(--ease);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.btn-mark-paid:hover {
  background: var(--green-500);
  color: white;
  border-color: var(--green-500);
  transform: translateY(-1px);
}

.link-button {
  background: none;
  border: none;
  color: var(--blue-600);
  font-family: var(--font);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: color var(--dur-fast);
  padding: 0;
}
.link-button:hover { color: var(--blue-800); text-decoration: underline; }

.link-btn {
  background: none;
  border: none;
  color: var(--blue-600);
  font-family: var(--font);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color var(--dur-fast);
  padding: 0;
}
.link-btn:hover { color: var(--blue-800); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: var(--font-size-sm);
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-left: 3px solid transparent;
  animation: slideDown var(--dur-base) var(--ease);
}

@keyframes slideDown {
  from { opacity:0; transform: translateY(-8px) }
  to   { opacity:1; transform: translateY(0) }
}

.alert-error {
  background: var(--red-100);
  color: var(--red-600);
  border-left-color: var(--red-500);
}
.alert-success {
  background: var(--green-100);
  color: var(--green-700);
  border-left-color: var(--green-500);
}
.alert-warning {
  background: var(--amber-100);
  color: #92400e;
  border-left-color: var(--amber-500);
}
.alert-info {
  background: var(--blue-100);
  color: var(--blue-800);
  border-left-color: var(--blue-600);
}

/* ============================================================
   AUTH FOOTER
   ============================================================ */
.auth-footer {
  text-align: center;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.auth-footer p {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  margin-bottom: 8px;
}
.auth-security {
  margin-top: 20px;
  padding: 10px 14px;
  background: var(--green-100);
  border-radius: var(--radius);
  font-size: var(--font-size-xs);
  color: var(--green-700);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ============================================================
   APP SHELL — SIDEBAR LAYOUT
   ============================================================ */
#main-app {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR NAVBAR
   ============================================================ */
.navbar {
  position: fixed;
  top: 0; left: 0;
  width: var(--nav-w);
  height: 100vh;
  background: var(--blue-900);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--dur-slow) var(--ease),
              width var(--dur-slow) var(--ease);
  overflow: hidden;
}

.nav-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
}

/* Brand */
.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.brand-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: rgba(255,255,255,.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-icon img {
  width: 100%; height: 100%;
  object-fit: contain;
}

.brand-name {
  font-size: var(--font-size-md);
  font-weight: 800;
  color: white !important;
  white-space: nowrap;
  -webkit-text-fill-color: white !important;
  letter-spacing: -.2px;
}

.brand-name-mobile { display: none; }

/* Nav Menu */
.nav-menu {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: none;
}
.nav-menu::-webkit-scrollbar { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: rgba(255,255,255,.65);
  font-family: var(--font);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-base) var(--ease);
  white-space: nowrap;
  width: 100%;
  text-align: left;
}

.nav-item i {
  width: 18px;
  font-size: 15px;
  flex-shrink: 0;
  text-align: center;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: white;
}

.nav-item.active {
  background: rgba(255,255,255,.14);
  color: white;
  font-weight: 600;
}

.nav-item.active i { color: var(--blue-400); }

/* Logout special */
.logout-btn {
  margin: 8px 10px;
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: 12px !important;
  color: rgba(255,255,255,.45) !important;
}
.logout-btn:hover {
  background: rgba(239,68,68,.15) !important;
  color: #fca5a5 !important;
}

/* Theme toggle in nav */
#theme-toggle {
  margin: 4px 10px;
}

/* Divider in nav */
.nav-divider {
  height: 1px;
  background: rgba(255,255,255,.06);
  margin: 6px 10px;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  position: fixed;
  top: 0;
  left: var(--nav-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 100;
  transition: left var(--dur-slow) var(--ease);
}

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

.topbar-greeting {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--text);
}

.topbar-date {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: 500;
}

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

.topbar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--grad-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: var(--font-size-sm);
  font-weight: 700;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--nav-w);
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
  padding: 28px 32px 48px;
  transition: margin-left var(--dur-slow) var(--ease);
}

.content-page {
  animation: fadeUp var(--dur-slow) var(--ease);
}

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

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

.page-title {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title i { color: var(--blue-600); font-size: 22px; }

.page-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 400;
}

.select-filter {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: border-color var(--dur-base);
}
.select-filter:focus { border-color: var(--blue-600); }

/* ============================================================
   SUMMARY CARDS
   ============================================================ */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.summary-card {
  border-radius: var(--radius-lg);
  padding: 24px 22px;
  color: white;
  position: relative;
  overflow: hidden;
  transition: transform var(--dur-base) var(--ease-spring),
              box-shadow var(--dur-base) var(--ease);
}

.summary-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-xl);
}

.summary-card::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 160%;
  height: 160%;
  background: radial-gradient(circle, rgba(255,255,255,.12) 0%, transparent 60%);
  pointer-events: none;
}

.income-card  { background: var(--grad-income); }
.expense-card { background: var(--grad-expense); }
.balance-card { background: var(--grad-balance); }
.balance-card.negative { background: linear-gradient(135deg,#9a3412,#ea580c); }

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

.card-header span {
  font-size: var(--font-size-sm);
  font-weight: 600;
  opacity: .9;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.card-icon {
  width: 40px; height: 40px;
  background: rgba(255,255,255,.2);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.card-amount {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: -.5px;
  line-height: 1;
  margin-bottom: 6px;
}

.card-info {
  font-size: var(--font-size-xs);
  opacity: .8;
  font-weight: 500;
}

/* ============================================================
   CARD COMPONENT
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-base) var(--ease);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-title {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-title i { color: var(--blue-600); font-size: 16px; }

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

.card-header-flex .card-title {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* ============================================================
   CHARTS
   ============================================================ */
.chart-container {
  position: relative;
  height: 280px;
}

/* ============================================================
   FORM GRID
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.form-full { grid-column: 1 / -1; }

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

/* ============================================================
   TRANSACTION / BILL ITEMS
   ============================================================ */
.transaction-item,
.bill-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all var(--dur-base) var(--ease);
  margin-bottom: 8px;
}

.transaction-item:hover,
.bill-item:hover {
  border-color: var(--blue-400);
  box-shadow: var(--shadow-sm);
  transform: translateX(2px);
}

.transaction-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.transaction-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.transaction-icon.income  { background: var(--green-100); color: var(--green-600); }
.transaction-icon.expense { background: var(--red-100);   color: var(--red-600); }

.transaction-details {
  min-width: 0;
}

.transaction-details h4 {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transaction-details p {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transaction-details small {
  font-size: var(--font-size-xs);
  color: var(--text-faint);
}

.transaction-amount {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  font-weight: 700;
  white-space: nowrap;
}

.transaction-amount.income  { color: var(--green-600); }
.transaction-amount.expense { color: var(--red-600); }

/* ============================================================
   PROGRESS BARS
   ============================================================ */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width .6s var(--ease);
}

.progress-fill.success { background: var(--grad-income); }
.progress-fill.warning { background: linear-gradient(90deg,var(--amber-500),#d97706); }
.progress-fill.danger  { background: var(--grad-expense); }

/* ============================================================
   BUDGET / GOAL / INVESTMENT / BILL ITEMS
   ============================================================ */
.budget-item,
.goal-item,
.investment-item,
.bill-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  transition: box-shadow var(--dur-base) var(--ease),
              border-color var(--dur-base) var(--ease);
}

.budget-item:hover,
.goal-item:hover,
.investment-item:hover { border-color: var(--blue-400); box-shadow: var(--shadow-sm); }

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

.budget-name,
.goal-name,
.investment-name {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text);
}

.budget-percentage {
  font-size: var(--font-size-xs);
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-full);
}

.budget-percentage.success { background: var(--green-100); color: var(--green-700); }
.budget-percentage.warning { background: var(--amber-100); color: #92400e; }
.budget-percentage.danger  { background: var(--red-100);   color: var(--red-600); }

.budget-info,
.goal-progress {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 6px;
}

.goal-percentage {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--blue-600);
}

.goal-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.goal-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.goal-stat span:first-child {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: 500;
}

.goal-stat span:last-child {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
}

.goal-stat.deadline span:last-child { color: var(--amber-500); }

.investment-type {
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 3px 9px;
  background: var(--blue-100);
  color: var(--blue-800);
  border-radius: var(--radius-full);
}

.investment-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.investment-detail {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.investment-detail-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: 500;
}

.investment-detail-value {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
}

/* Bill Status */
.bill-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--font-size-xs);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: .3px;
}

.bill-status.success { background: var(--green-100); color: var(--green-700); }
.bill-status.info    { background: var(--blue-100);  color: var(--blue-800); }
.bill-status.warning { background: var(--amber-100); color: #92400e; }
.bill-status.danger  { background: var(--red-100);   color: var(--red-600); }

/* ============================================================
   INVESTMENT SUMMARY
   ============================================================ */
.investment-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.summary-item {
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 14px 16px;
  border: 1px solid var(--border);
}

.summary-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  display: block;
  margin-bottom: 4px;
}

.summary-value {
  font-family: var(--font-mono);
  font-size: var(--font-size-md);
  font-weight: 800;
  color: var(--text);
  display: block;
}

.summary-value.success { color: var(--green-600); }
.summary-value.danger  { color: var(--red-600); }

/* ============================================================
   CALENDAR BILLS
   ============================================================ */
.calendar-day-item {
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}

.calendar-day-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.calendar-day-number {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text);
}

.calendar-day-total {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--red-600);
}

.calendar-day-bills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.calendar-bill-tag {
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.calendar-bill-tag.success { background: var(--green-100); color: var(--green-700); }
.calendar-bill-tag.info    { background: var(--blue-100);  color: var(--blue-800); }
.calendar-bill-tag.warning { background: var(--amber-100); color: #92400e; }
.calendar-bill-tag.danger  { background: var(--red-100);   color: var(--red-600); }

/* ============================================================
   CATEGORIES
   ============================================================ */
.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 8px;
  transition: border-color var(--dur-base);
}

.category-item:hover { border-color: var(--blue-400); }

.category-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-badge {
  font-size: var(--font-size-xs);
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.category-badge.income  { background: var(--green-100); color: var(--green-700); }
.category-badge.expense { background: var(--red-100);   color: var(--red-600); }

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-section { display: flex; flex-direction: column; gap: 10px; }

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background: var(--surface-alt);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.settings-item h4 {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}

.settings-item p {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* Theme selector */
.theme-selector {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 20px;
  background: var(--surface-alt);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--dur-base) var(--ease);
}

.theme-option i { font-size: 20px; }
.theme-option:hover { border-color: var(--blue-600); color: var(--blue-600); }
.theme-option.active {
  border-color: var(--blue-600);
  background: var(--blue-100);
  color: var(--blue-800);
}

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

.empty-state i {
  font-size: 48px;
  color: var(--gray-300);
  display: block;
  margin-bottom: 14px;
}

.empty-state p {
  font-size: var(--font-size-sm);
  font-weight: 500;
}

/* ============================================================
   NOTIFICATIONS
   ============================================================ */
.notification-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
  width: calc(100% - 40px);
}

.notification {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--blue-600);
  animation: slideInRight var(--dur-base) var(--ease-spring);
  transition: opacity var(--dur-base), transform var(--dur-base);
}

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

.notification.success { border-left-color: var(--green-500); }
.notification.error   { border-left-color: var(--red-500); }
.notification.warning { border-left-color: var(--amber-500); }
.notification.info    { border-left-color: var(--blue-600); }

/* ============================================================
   DYNAMIC ALERTS (DASHBOARD)
   ============================================================ */
.dynamic-alerts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  margin-left: var(--nav-w);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 36px 32px 24px;
  transition: margin-left var(--dur-slow) var(--ease);
}

.footer-container {
  display: grid;
  grid-template-columns: 2fr auto;
  gap: 40px;
  max-width: 900px;
  margin-bottom: 28px;
  align-items: start;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.footer-description {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 440px;
  margin-bottom: 16px;
}

.footer-security {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.security-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: var(--green-100);
  color: var(--green-700);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.security-badge i { font-size: 11px; }

.footer-links { display: flex; gap: 32px; }

.footer-column h4 {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.footer-column ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.footer-column ul li a {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color var(--dur-fast);
}

.footer-column ul li a:hover { color: var(--blue-600); }

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 8px;
}

.footer-dev strong { color: var(--blue-600); }

/* ============================================================
   MOBILE MENU TOGGLE
   ============================================================ */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 16px;
  z-index: 300;
  width: 40px; height: 40px;
  border-radius: var(--radius);
  background: var(--blue-800);
  color: white;
  border: none;
  font-size: 16px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: background var(--dur-base);
}
.mobile-menu-toggle:hover { background: var(--blue-700); }

/* Sidebar overlay on mobile */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
  backdrop-filter: blur(2px);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 24px;
  animation: fadeIn var(--dur-base) var(--ease);
}

@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 500px;
  width: 100%;
  overflow: hidden;
  animation: slideUp var(--dur-slow) var(--ease-spring);
}

.modal-header {
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--text);
}

.modal-body {
  padding: 24px 28px;
  max-height: 55vh;
  overflow-y: auto;
}

.modal-body h3 {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text);
  margin: 16px 0 6px;
}

.modal-body h3:first-child { margin-top: 0; }

.modal-body p {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.modal-footer {
  padding: 16px 28px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* ============================================================
   REPORTS — STATS ROW
   ============================================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-card .stat-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: block;
}

.stat-card .stat-value {
  font-family: var(--font-mono);
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--text);
}

/* ============================================================
   RESPONSIVE — TABLET
   ============================================================ */
@media (max-width: 1024px) {
  :root { --nav-w: 220px; }

  .main-content { padding: 20px 20px 40px; }
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 768px) {
  :root {
    --nav-w: 260px;
  }

  /* Sidebar hidden off-screen by default */
  .navbar {
    transform: translateX(-100%);
  }

  .navbar.menu-open {
    transform: translateX(0);
  }

  .nav-overlay.visible {
    display: block;
  }

  /* Topbar full width on mobile */
  .topbar {
    left: 0;
    padding: 0 16px 0 64px;
  }

  .main-content {
    margin-left: 0;
    padding: 16px 14px 40px;
  }

  .footer {
    margin-left: 0;
    padding: 28px 16px 20px;
  }

  .mobile-menu-toggle {
    display: flex;
  }

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

  /* Summary cards single col */
  .summary-cards {
    grid-template-columns: 1fr;
  }

  /* Grid 2 single col */
  .grid-2 {
    grid-template-columns: 1fr;
  }

  /* Form grid single col */
  .form-grid {
    grid-template-columns: 1fr;
  }

  /* Transaction item stack */
  .transaction-item,
  .bill-item {
    flex-wrap: wrap;
  }

  .investment-summary {
    grid-template-columns: 1fr;
  }

  .investment-details {
    grid-template-columns: 1fr 1fr;
  }

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

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

  .card-amount {
    font-size: var(--font-size-xl);
  }

  .footer-container {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .footer-links {
    flex-direction: column;
    gap: 20px;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }

  .notification-container {
    top: 70px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: 100%;
  }

  .theme-selector { flex-direction: column; }
  .theme-option { flex-direction: row; justify-content: flex-start; }
}

@media (max-width: 480px) {
  .summary-card { padding: 18px 16px; }
  .card { padding: 16px; }
  .goal-stats { grid-template-columns: 1fr; }
}

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

/* ============================================================
   SELECTION
   ============================================================ */
::selection {
  background: rgba(37,99,235,.15);
  color: var(--blue-800);
}

/* ============================================================
   DARK THEME REFINEMENTS
   ============================================================ */
html.dark-theme .transaction-item:hover,
body.dark-theme  .transaction-item:hover {
  background: var(--gray-700);
}

html.dark-theme .notification,
body.dark-theme  .notification {
  background: var(--gray-800);
  border-color: var(--gray-700);
}
