:root {
  --bg-deep: #0d0d0d;
  --bg-mid: #141414;
  --bg-surface: #1c1c1c;
  --bg-glass: rgba(255, 255, 255, 0.05);
  --bg-glass-hover: rgba(255, 255, 255, 0.09);
  --border-glass: rgba(255, 255, 255, 0.1);
  --accent-blue: #3b82f6;
  --accent-violet: #8b5cf6;
  --accent-green: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;
  --accent-cyan: #06b6d4;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-glow-b: 0 0 24px rgba(59, 130, 246, 0.25);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 64px;
  background: rgba(20, 20, 20, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-name {
  font-size: 1.2rem;
  font-weight: 700;
  background: var(--accent-blue);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.month-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  letter-spacing: 0.02em;
}

.stats-band {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  padding: 1.5rem 2rem;
}

@media (max-width: 1024px) {
  .stats-band {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .stats-band {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.4rem;
  backdrop-filter: blur(12px);
  transition: var(--transition);
}

.stat-card:hover {
  background: var(--bg-glass-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.stat-icon--spent {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
}

.stat-icon--budget {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

.stat-icon--remaining {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.stat-icon--count {
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-violet);
}

.stat-body {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-top: 2px;
}

.main-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.25rem;
  padding: 0 2rem 2rem;
}

@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border-glass);
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.panel-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.filter-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.filter-input {
  background: var(--bg-mid);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem 0.4rem 2rem;
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
  font-family: var(--font);
}

.filter-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.filter-input::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

/* Primary CTA — Blueprint Blue, no gradient
   #2563eb sits one step below --accent-blue (#3b82f6) in luminosity,
   giving it intentional weight without relying on a gradient halo. */
.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: var(--font);
  /* Two-layer shadow: ambient depth + subtle colour echo */
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.1) inset,
    0 2px 8px rgba(0, 0, 0, 0.45);
}

.btn-add:hover {
  background: #1d4ed8; /* one stop darker — no brightness filter */
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.1) inset,
    0 4px 14px rgba(0, 0, 0, 0.5);
}

.btn-add:active {
  background: #1e40af; /* pressed: darkest stop */
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
}

.btn-add:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.6);
  outline-offset: 2px;
}

.table-wrap {
  overflow-x: auto;
}

#expensesTable {
  width: 100%;
  border-collapse: collapse;
}

#expensesTable thead tr {
  border-bottom: 1px solid var(--border-glass);
}

#expensesTable th {
  padding: 0.75rem 1.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

#expensesTable td {
  padding: 0.85rem 1.4rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s;
}

#expensesTable tbody tr:hover td {
  background: var(--bg-glass-hover);
}

#expensesTable tbody tr:last-child td {
  border-bottom: none;
}

#expensesTable td.text-end,
#expensesTable th.text-end {
  text-align: right;
}

.amount-cell {
  font-weight: 600;
  color: var(--accent-rose) !important;
}

.amount-cell.positive {
  color: var(--accent-green) !important;
}

.cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

/* Destructive tertiary — tinted rose ghost
   Low-fill tint keeps it contextually clear (danger) without
   screaming. No scale transform — scale-on-hover is distracting
   for destructive actions; a simple border intensify is enough. */
.btn-delete {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(244, 63, 94, 0.08);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.22);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
  font-weight: 500;
}

.btn-delete:hover {
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.4);
}

.btn-delete:active {
  background: rgba(244, 63, 94, 0.24);
  border-color: rgba(244, 63, 94, 0.55);
  transform: translateY(1px);
}

.btn-delete:focus-visible {
  outline: 2px solid rgba(244, 63, 94, 0.5);
  outline-offset: 2px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem 1rem;
  color: var(--text-muted);
  text-align: center;
}

.empty-state i {
  font-size: 2.5rem;
}

.empty-state p {
  font-size: 0.9rem;
  line-height: 1.6;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.budget-form {
  padding: 1.1rem 1.4rem 0;
}

.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.4rem;
}

.budget-input-row {
  display: flex;
  align-items: center;
  background: var(--bg-mid);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: var(--transition);
  padding-right: 0.5rem;
}

.budget-input-row:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.currency-symbol {
  padding: 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  border-right: 1px solid var(--border-glass);
}

.budget-field {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  outline: none;
  font-family: var(--font);
}

.budget-field::placeholder {
  color: var(--text-muted);
}

.btn-save {
  flex-shrink: 0;
  white-space: nowrap;
  background: var(--accent-violet);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.3125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
}

.btn-save:hover {
  background: #2563eb;
}

.progress-wrap {
  padding: 1rem 1.4rem 1.2rem;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.progress-pct {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.progress-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-violet));
  transition:
    width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.3s;
  min-width: 0;
}

.progress-fill.danger {
  background: linear-gradient(90deg, var(--accent-amber), var(--accent-rose));
}

.progress-detail {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

.chart-container {
  position: relative;
  padding: 1.25rem 1.4rem;
}

.chart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.chart-empty i {
  font-size: 2rem;
}

.app-modal {
  background: #161616;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg) !important;
  color: var(--text-primary);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

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

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.modal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-violet));
  border-radius: var(--radius-sm);
  font-size: 1rem;
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
}

.modal-close-btn:hover {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.3);
}

.app-modal-body {
  padding: 1.5rem;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 480px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

.field-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}

.field-group:last-child {
  margin-bottom: 0;
}

.app-input,
.app-select {
  background: var(--bg-mid);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition);
  font-family: var(--font);
  margin-top: 0.35rem;
}

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

.app-input:focus,
.app-select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.app-select option {
  background: #1a2236;
}

.app-input::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
  cursor: pointer;
}

.form-error {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: var(--radius-sm);
  color: var(--accent-rose);
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  margin-top: 0.75rem;
}

.app-modal-footer {
  border-top: 1px solid var(--border-glass);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Secondary — neutral ghost with crisper border
   Pure neutral palette: no hue, no fill, defined only by its border.
   Sits below primary and above nothing — dismissive, not invisible. */
.btn-cancel {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.1rem;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--text-primary);
}

.btn-cancel:active {
  background: rgba(255, 255, 255, 0.03);
  transform: translateY(1px);
}

.btn-cancel:focus-visible {
  outline: 2px solid rgba(148, 163, 184, 0.5);
  outline-offset: 2px;
}

/* Primary modal CTA — mirrors .btn-add, same solid Blueprint Blue
   Using the same hue token as .btn-add ensures systemic consistency;
   size/weight differences alone carry the semantic distinction. */
.btn-submit {
  display: inline-flex;
  align-items: center;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.3rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.1) inset,
    0 2px 8px rgba(0, 0, 0, 0.45);
}

.btn-submit:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.1) inset,
    0 4px 14px rgba(0, 0, 0, 0.5);
}

.btn-submit:active {
  background: #1e40af;
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
}

.btn-submit:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.6);
  outline-offset: 2px;
}

.app-toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  box-shadow: var(--shadow-card);
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 0.3s,
    transform 0.3s;
  pointer-events: none;
}

.app-toast.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.app-toast.success {
  border-left: 3px solid var(--accent-green);
}

.app-toast.error {
  border-left: 3px solid var(--accent-rose);
}

.overspent {
  border-left: 3px solid var(--accent-rose) !important;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

.modal-backdrop {
  background-color: rgba(0, 0, 0, 0.7) !important;
}
