/* Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: Inter, Arial, sans-serif;
}

:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #4f46e5;
  --success: #10b981;
  --danger: #ef4444;
  --balance-color: #2563eb;
  /* blue */
  --shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] {
  --bg: #08090c;
  --card: #0f1115;
  --text: #e6eef8;
  --muted: #9aa4b2;
  --accent: #7c5cff;
  --success: #10b981;
  --danger: #f87171;
  --balance-color: #60a5fa;
  --shadow: 0 8px 30px rgba(2, 6, 23, 0.6);
}

/* Page */
html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

.container {
  width: 100%;
  max-width: 1200px;
  padding: 12px;
  margin: 0 auto;
}

/* Header */
/* Fixed navbar with background */
/* Fixed navbar with background */
.site-header {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 64px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), var(--card));
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  z-index: 999;
  display: flex;
  align-items: center;
}

[data-theme="dark"] .site-header {
  background: var(--card);
  /* Solid dark background for dark mode */
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  /* Slight separation */
}

.header-inner {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 12px;
}

/* ensure main page content is not hidden under fixed header */
body {
  padding-top: 72px;
}

/* Left header (title + mobile hamburger) */
.left-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

/* Hamburger for mobile */
.hamburger {
  display: none;
  width: 40px;
  height: 36px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  align-items: center;
  justify-content: center;
}

.hamburger span {
  display: block;
  height: 3px;
  width: 22px;
  background: var(--text);
  margin: 3px 0;
  border-radius: 3px;
  transition: transform .18s ease, opacity .18s ease;
}

.hamburger[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.hamburger[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Center nav (desktop) */
.main-nav {
  display: flex;
  gap: 18px;
  align-items: center;
}

.main-nav .nav-link {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  padding-bottom: 6px;
  position: relative;
  cursor: pointer;
  background: transparent;
  border: none;
}

.main-nav .nav-link:hover {
  color: var(--text);
}

.main-nav .nav-link.active {
  color: var(--accent);
}

.main-nav .nav-link.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  bottom: -2px;
  background: linear-gradient(90deg, var(--accent), var(--accent));
  border-radius: 4px;
}

/* Right header (theme + auth) */
.header-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: nowrap;
}

/* small link style for theme button in nav */
.btn-link {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 4px;
  font-weight: 600;
}

/* Mobile menu slider overlay */
.mobile-menu {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 960;
  background: rgba(2, 6, 23, 0.35);
}

.mobile-menu-inner {
  background: var(--card);
  width: 320px;
  max-width: 92%;
  height: 100%;
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(.22, .9, .25, 1);
  position: absolute;
  right: 0;
  top: 0;
  padding: 18px;
  overflow-y: auto;
}

.mobile-menu.open {
  display: block;
}

.mobile-menu.open .mobile-menu-inner {
  transform: translateX(0);
}

.mobile-close {
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--muted);
  float: right;
  cursor: pointer;
  margin-bottom: 8px;
}

/* Mobile nav links */
.mobile-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.mobile-nav-link {
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  background: transparent;
  display: block;
}

.mobile-nav-link:hover {
  background: rgba(0, 0, 0, 0.03);
}

/* Auth inside mobile menu */
.mobile-auth {
  margin-top: 8px;
}

/* Auth / Theme styling kept from original */
.user-info {
  display: flex;
  gap: 8px;
  align-items: center;
}

.user-pic {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--shadow);
}

.user-name {
  font-weight: 600;
  color: var(--muted);
}

/* Theme switch */
.theme-switch {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.theme-switch input {
  display: none;
}

.theme-switch .slider {
  width: 44px;
  height: 24px;
  background: #e6e6e6;
  border-radius: 12px;
  position: relative;
}

.theme-switch .slider::after {
  content: "";
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  position: absolute;
  left: 3px;
  top: 3px;
  transition: transform .18s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.theme-switch input:checked+.slider {
  background: var(--accent);
}

.theme-switch input:checked+.slider::after {
  transform: translateX(20px);
}

/* Buttons */
.btn {
  padding: 8px 12px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
}

.btn.primary {
  background: var(--accent);
  color: white;
}

.btn:active {
  transform: translateY(1px);
}

/* Layout */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 18px;
  margin-top: 16px;
}

@media (max-width: 980px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

/* Card */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}

/* SUMMARY SECTION */
.summary {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin-bottom: 12px;
  overflow-x: auto;
}

.summary-card {
  flex: 1;
  min-width: 0;
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
  text-align: center;
}

.summary-card h2 {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 6px;
}

.summary-card p {
  font-size: 20px;
  font-weight: 700;
}

/* Summary Amount Colors */
.balance-amount {
  color: var(--balance-color) !important;
}

.income-amount {
  color: var(--success) !important;
}

.expense-amount {
  color: var(--danger) !important;
}

/* LEFT / RIGHT columns */
.left-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.right-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

/* Add Transaction */
.transaction-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-title {
  font-size: 16px;
  margin-bottom: 6px;
  color: var(--muted);
}

.transaction-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.transaction-form .full-width {
  grid-column: 1 / -1;
}

@media (max-width:640px) {
  .transaction-form {
    grid-template-columns: 1fr;
  }
}

/* Input group */
.input-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-label {
  font-size: 13px;
  color: var(--muted);
}

.input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: transparent;
}

.input-group .icon {
  font-size: 16px;
  color: var(--muted);
}

.input-group input,
.input-group select,
.input-group textarea {
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  width: 100%;
  color: var(--text);
}

/* Filter row */
.filters {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  width: 100%;
  padding-bottom: 6px;
}

.filters select {
  min-width: 120px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: var(--card);
  color: var(--text);
}

/* Dark theme dropdown fix */
select,
option {
  background: var(--card) !important;
  color: var(--text) !important;
}

/* Charts */
.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.chart-container {
  background: var(--card);
  padding: 12px;
  border-radius: 12px;
  min-height: 250px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow);
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

@media (max-width:780px) {
  .charts {
    grid-template-columns: 1fr;
  }
}

/* Monthly summary table */
.monthly-summary .table-wrap {
  overflow-x: auto;
  width: 100%;
  margin-top: 8px;
}

#monthly-summary-table th,
#monthly-summary-table td {
  padding: 10px 8px;
  white-space: nowrap;
}

#monthly-summary-table td.income {
  color: var(--success) !important;
}

#monthly-summary-table td.expense {
  color: var(--danger) !important;
}

#monthly-summary-table td.balance {
  color: var(--balance-color) !important;
}

/* Transaction history */
.table-wrap {
  overflow-x: auto;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

td.income {
  color: var(--success);
  font-weight: 600;
}

td.expense {
  color: var(--danger);
  font-weight: 600;
}

tr:hover {
  background: rgba(79, 70, 229, 0.03);
}

.delete-btn {
  padding: 6px 8px;
  background: var(--danger);
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  justify-content: center;
  align-items: center;
  z-index: 50;
}

.modal-content {
  background: var(--card);
  padding: 18px;
  border-radius: 12px;
  max-width: 420px;
  width: 90%;
}

.close {
  position: absolute;
  right: 12px;
  top: 10px;
  cursor: pointer;
  color: var(--muted);
}

/* Insights & contact */
.insights-controls {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.contact-form .input-row {
  margin-bottom: 10px;
}

.contact-form textarea {
  resize: vertical;
}



/* Small Screens */
@media (max-width:980px) {
  .main-nav {
    display: none;
  }

  .hamburger {
    display: flex;
  }

  /* keep header inline: title left, controls right on same line */
  .header-inner {
    flex-wrap: nowrap;
  }

  .left-header {
    flex: 0 0 auto;
  }

  .header-controls {
    flex: 0 0 auto;
  }
}

@media (max-width:520px) {
  .header-inner {
    align-items: center;
  }

  .summary-card {
    padding: 10px;
  }

  .mobile-menu {
    display: none;
  }

  /* shown via JS */
}

/* small accessibility / focus */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(79, 70, 229, 0.18);
  outline-offset: 2px;
}

/* Utility */
.muted {
  color: var(--muted);
  font-size: 13px;
}

/* Mobile menu-specific (keep right-slide) */
.mobile-menu {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 960;
  background: rgba(2, 6, 23, 0.35);
  right: 0;
  left: 0;
  top: 0;
  bottom: 0;
}

.mobile-menu-inner {
  background: var(--card);
  width: 320px;
  max-width: 92%;
  height: 100%;
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(.22, .9, .25, 1);
  position: absolute;
  right: 0;
  top: 0;
  padding: 18px;
  overflow-y: auto;
}

.mobile-menu.open {
  display: block;
}

.mobile-menu.open .mobile-menu-inner {
  transform: translateX(0);
}

/* Insights summary cards styling + colored values */

/* -------------------------------------------------------
   INSIGHTS — SAME UI AS MONTHLY SUMMARY
-------------------------------------------------------- */

/* Insights container */
.insights {
  background: var(--card-bg);
  padding: 18px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  margin-top: 20px;

  transition: background 0.25s ease, box-shadow 0.25s ease,
    transform 0.25s ease, opacity 0.25s ease;
}

.insights:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.12);
}

/* Title */
.insights .card-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

/* Subtitle */
.insights p.muted {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 14px;
}

/* -------------------------------------------------------
   FILTER ROW — EXACTLY LIKE MONTHLY SUMMARY
-------------------------------------------------------- */

.insights-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  white-space: nowrap;
  padding: 8px 0;
  scroll-behavior: smooth;

  margin-bottom: 18px;

  transition: background 0.25s ease, transform 0.25s ease;
}

.insights-controls label {
  font-size: 14px;
  color: var(--muted);
  flex-shrink: 0;
}

.insights-controls select {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);

  transition: border-color 0.25s ease,
    background 0.25s ease,
    transform 0.18s ease;
}

.insights-controls select:focus {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* -------------------------------------------------------
   SUMMARY ROW — EXACT MATCH TO MONTHLY SUMMARY
-------------------------------------------------------- */

.insights-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  overflow-x: auto;
  white-space: nowrap;
  padding: 8px 0;

  transition: opacity 0.3s ease, transform 0.3s ease;
}

.insight-card {
  background: rgba(255, 255, 255, 0.06);
  padding: 14px;
  border-radius: 12px;
  min-width: 160px;
  flex: 1;

  display: flex;
  flex-direction: column;
  gap: 4px;

  box-shadow: var(--shadow);

  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.insight-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.insight-card h4 {
  font-size: 14px;
  color: var(--muted);
}

.insight-card p {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

/* Colors */
.insight-card p.income {
  color: var(--success);
}

.insight-card p.expense {
  color: var(--danger);
}

.insight-card p.balance {
  color: var(--balance-color);
}

/* -------------------------------------------------------
   MOBILE FIXES
-------------------------------------------------------- */

@media (max-width: 480px) {
  .insights {
    padding: 14px;
  }

  .insights-controls {
    gap: 10px;
    padding-bottom: 10px;
  }

  .insight-card {
    min-width: 140px;
    padding: 12px;
  }
}



.insights-summary {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.insight-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  padding: 12px;
  border-radius: 10px;
  min-width: 160px;
  flex: 1;
  box-shadow: var(--shadow);
}

.insight-card h4 {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.insight-card p {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.insight-card p.income {
  color: var(--success);
}

.insight-card p.expense {
  color: var(--danger);
}

.insight-card p.balance {
  color: var(--balance-color);
}

/* Contact section styling improvements + socials */
.contact-section {
  padding: 80px 20px;
  text-align: center;
}

/* Titles */
.section-title {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.section-subtitle {
  font-size: 1rem;
  opacity: 0.7;
  margin-bottom: 50px;
}

/* Layout */
.contact-container {
  max-width: 900px;
  margin: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: center;
}

/* Social Icons */
.contact-icons {
  display: flex;
  justify-content: center;
  gap: 25px;
}

.icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border: 2px solid currentColor;
  transition: 0.3s ease;
}

.icon:hover {
  transform: translateY(-8px) scale(1.05);
}

.linkedin {
  color: #0077b5;
}

.github {
  color: gray;
}

.instagram {
  color: #e1306c;
}

/* Form */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.contact-form input,
.contact-form textarea {
  padding: 14px;
  border-radius: 8px;
  border: 1px solid #ccc;
  outline: none;
  font-size: 1rem;
  background: transparent;
  color: var(--text);
  /* Fix for dark mode visibility */
}

/* ... existing styles ... */

/* Responsive */
@media (max-width: 768px) {
  .contact-section {
    padding: 40px 16px;
    /* Reduced padding for mobile */
  }

  .contact-container {
    grid-template-columns: 1fr;
  }

  .contact-icons {
    margin-bottom: 20px;
  }
}

#form-success {
  font-size: 0.95rem;
  text-align: center;
  transition: opacity 0.4s ease;
}

#form-success.show {
  display: block;
  opacity: 1;
}