/* PesoTrack Theme - Derived from provided green palette */
:root {
  /* Primary Palette from image */
  --green-50:  #f0f7f0;
  --green-100: #e0efe0;
  --green-200: #c8e0c8;
  --green-300: #a5d0a5;
  --green-400: #7cbc7c;
  --green-500: #5a9f5a;
  --green-600: #3d7a3d;
  --green-700: #2d5c2d;
  --green-800: #1e3f1e;
  --green-900: #0f220f;

  /* Exact-ish matches to the 4 bands */
  --palette-lightest: #e8f5e9;
  --palette-light:    #a5d6a7;
  --palette-medium:   #66bb6a;
  --palette-dark:     #1b5e20;

  /* Semantic */
  --primary:        var(--palette-medium);
  --primary-hover:  #4caf50;
  --primary-dark:   var(--palette-dark);
  --primary-light:  var(--palette-light);
  --primary-bg:     var(--palette-lightest);

  --success: #2e7d32;
  --warning: #f9a825;
  --danger:  #c62828;
  --info:    #0277bd;

  --bg-body:       #f7faf7;
  --bg-card:       #ffffff;
  --bg-sidebar:    #1b5e20;
  --bg-sidebar-hover: #2e7d32;
  --text-primary:  #1a2e1a;
  --text-secondary:#4a5e4a;
  --text-muted:    #6b7c6b;
  --border:        #d4e4d4;
  --border-light:  #e8f0e8;

  --shadow-sm: 0 1px 2px rgba(27, 94, 32, 0.06);
  --shadow:    0 1px 3px rgba(27, 94, 32, 0.08), 0 1px 2px rgba(27, 94, 32, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(27, 94, 32, 0.08), 0 2px 4px -1px rgba(27, 94, 32, 0.04);
  --radius: 6px;
  --radius-lg: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
  --bg-body:       #0f1a0f;
  --bg-card:       #162416;
  --bg-sidebar:    #0a140a;
  --bg-sidebar-hover: #1b3a1b;
  --text-primary:  #e8f5e9;
  --text-secondary:#a5d6a7;
  --text-muted:    #7cbc7c;
  --border:        #2d4a2d;
  --border-light:  #1e3f1e;
  --primary-bg:    #1b3a1b;
}

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

body {
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

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

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  color: #e8f5e9;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  padding: 1.25rem 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-brand span {
  font-weight: 400;
  font-size: 0.75rem;
  opacity: 0.7;
  display: block;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}

.nav-section {
  padding: 0.5rem 1.25rem 0.25rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.5;
  margin-top: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.5rem;
  color: rgba(232,245,233,0.85);
  font-size: 0.875rem;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-left-color: var(--palette-light);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  opacity: 0.9;
}

.main-content {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

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

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
}

.card-body {
  padding: 1.25rem;
}

/* Summary cards */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.summary-card .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.35rem;
}

.summary-card .value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.summary-card .sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.summary-card.positive .value { color: var(--success); }
.summary-card.negative .value { color: var(--danger); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.25;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--primary-bg);
  border-color: var(--primary-light);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #b71c1c; }

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8125rem;
}

.btn-icon {
  padding: 0.45rem;
  width: 36px;
  height: 36px;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102, 187, 106, 0.2);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234a5e4a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table.data-table th {
  text-align: left;
  padding: 0.7rem 1rem;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--primary-bg);
}

table.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

table.data-table tr:hover td {
  background: rgba(102, 187, 106, 0.04);
}

.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.amount.expense { color: var(--danger); }
.amount.income { color: var(--success); }
.amount.transfer { color: var(--info); }

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-expense { background: #ffebee; color: #c62828; }
.badge-income { background: #e8f5e9; color: #2e7d32; }
.badge-transfer { background: #e3f2fd; color: #1565c0; }
.badge-paid { background: #e8f5e9; color: #2e7d32; }
.badge-overdue { background: #ffebee; color: #c62828; }
.badge-upcoming { background: #fff8e1; color: #f57f17; }

[data-theme="dark"] .badge-expense { background: #3e1a1a; }
[data-theme="dark"] .badge-income { background: #1b3a1b; }
[data-theme="dark"] .badge-transfer { background: #1a2a3e; }

/* Progress bars */
.progress {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* Auth pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--palette-dark) 0%, #2e7d32 50%, var(--palette-medium) 100%);
  padding: 1.5rem;
}

.auth-card {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 400px;
  padding: 2rem;
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--palette-dark);
}

.auth-logo p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Toast */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  box-shadow: var(--shadow-md);
  min-width: 280px;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: slideIn 0.25s ease;
}

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

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }

/* Mobile */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.4rem;
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .sidebar-toggle {
    display: flex;
  }
  .overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 35;
  }
  .overlay.show { display: block; }
}

/* Utilities */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.w-full { width: 100%; }
.hidden { display: none !important; }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.4;
}

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

/* Notification panel */
.notif-panel {
  position: absolute;
  top: 100%;
  right: 0;
  width: 360px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: none;
  z-index: 50;
}

.notif-panel.open { display: block; }

.notif-item {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}

.notif-item:hover { background: var(--primary-bg); }
.notif-item.unread { background: rgba(102,187,106,0.08); }

.notif-item .title { font-weight: 500; font-size: 0.875rem; }
.notif-item .time { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }
