/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --bg:        #0d0d14;
  --surface:   #141420;
  --surface2:  #1b1b2c;
  --surface3:  #22223a;
  --border:    #252538;
  --border2:   #30304a;
  --text:      #e4e4f0;
  --muted:     #7878a0;
  --dim:       #454565;
  --accent:    #6c63ff;
  --accent2:   #7b73ff;
  --green:     #4ade80;
  --yellow:    #fbbf24;
  --red:       #f87171;
  --r:         12px;
  --rsm:       8px;
  --rlg:       18px;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 15px;
}
button { font-family: inherit; }
input, select { font-family: inherit; }

/* ── Container ────────────────────────────────────────────────────────────── */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13,13,20,.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-icon { width: 22px; height: 22px; color: var(--accent); }
.brand-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.4px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.month-badge {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--rsm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  border: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent2);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(108,99,255,.35);
}
.btn-primary:active { transform: translateY(0); }
.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border2);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--surface2);
}
.btn-icon {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: all .15s;
}
.btn-icon:hover { color: var(--text); background: var(--surface2); }
.btn-icon.danger:hover { color: var(--red); background: rgba(248,113,113,.08); }

/* ── Main ─────────────────────────────────────────────────────────────────── */
.main { padding: 28px 0 130px; }
.section { margin-top: 32px; }
.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
}

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.hero-section { margin-top: 8px; }
.hero-card {
  background: linear-gradient(145deg, #191930 0%, #131325 100%);
  border: 1px solid var(--border);
  border-radius: var(--rlg);
  padding: 32px 36px;
  position: relative;
  overflow: hidden;
}
.hero-card::after {
  content: '';
  position: absolute;
  top: -80px; right: -80px;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(108,99,255,.13) 0%, transparent 65%);
  pointer-events: none;
}
.hero-eyebrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 10px;
}
.hero-amount-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.hero-amount {
  font-size: clamp(44px, 9vw, 68px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -3px;
  color: var(--text);
}
.hero-badge {
  padding: 5px 14px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 700;
  background: rgba(74,222,128,.12);
  color: var(--green);
  border: 1px solid rgba(74,222,128,.25);
  transition: all .3s;
}
.hero-badge.warn  { background: rgba(251,191,36,.12); color: var(--yellow); border-color: rgba(251,191,36,.25); }
.hero-badge.danger{ background: rgba(248,113,113,.12); color: var(--red);    border-color: rgba(248,113,113,.25); }
.hero-track {
  height: 7px;
  background: rgba(255,255,255,.07);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 14px;
}
.hero-fill {
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  transition: width .7s cubic-bezier(.4,0,.2,1), background-color .3s;
  width: 0%;
}
.hero-fill.warn   { background: var(--yellow); }
.hero-fill.danger { background: var(--red); }
.hero-footer {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}

/* ── Category Grid ────────────────────────────────────────────────────────── */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}
.cat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  transition: border-color .2s, box-shadow .2s;
}
.cat-card:hover {
  border-color: var(--border2);
  box-shadow: 0 2px 12px rgba(0,0,0,.2);
}
.cat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cat-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
}
.cat-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cat-name {
  font-size: 13px;
  font-weight: 600;
}
.cat-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface2);
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .3px;
}
.cat-remaining {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.5px;
  margin-bottom: 2px;
  line-height: 1.15;
}
.cat-remaining.over { color: var(--red); }
.cat-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 10px;
}
.cat-bar {
  height: 3px;
  background: rgba(255,255,255,.06);
  border-radius: 2px;
  overflow: hidden;
}
.cat-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width .5s ease;
}

/* ── Net Card ─────────────────────────────────────────────────────────────── */
.net-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}
.net-item { display: flex; flex-direction: column; gap: 3px; }
.net-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .7px;
}
.net-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.5px;
}
.net-value.pos { color: var(--green); }
.net-value.neg { color: var(--red); }
.net-sep {
  width: 1px;
  height: 44px;
  background: var(--border);
}

/* ── Chart ────────────────────────────────────────────────────────────────── */
.chart-layout {
  display: flex;
  align-items: flex-start;
  gap: 36px;
}
.chart-wrap {
  position: relative;
  width: 240px;
  height: 240px;
  flex-shrink: 0;
}
#spendingChart {
  width: 100% !important;
  height: 100% !important;
}
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
  background: var(--surface);
  border-radius: 50%;
}
.chart-empty-sub { font-size: 11px; opacity: .6; }
.chart-controls { flex: 1; min-width: 0; }
.chart-controls-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  margin-bottom: 12px;
}
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  cursor: pointer;
  border-radius: 6px;
  transition: background .1s;
}
.toggle-row:hover { background: var(--surface2); padding-left: 6px; }
.toggle-checkbox { display: none; }
.toggle-box {
  width: 17px; height: 17px;
  border-radius: 5px;
  border: 2px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .15s;
}
.toggle-checkbox:checked + .toggle-box {
  border-color: transparent;
}
.toggle-check { display: none; }
.toggle-checkbox:checked + .toggle-box .toggle-check { display: block; }
.toggle-dot2 { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.toggle-name { font-size: 13.5px; flex: 1; }
.toggle-fixed-badge {
  font-size: 9px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .3px;
}
.toggle-spent { font-size: 12px; color: var(--muted); margin-left: auto; padding-right: 4px; }

/* ── FAB ──────────────────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 100px;
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 24px rgba(108,99,255,.45), 0 2px 8px rgba(0,0,0,.4);
  transition: all .2s ease;
  white-space: nowrap;
}
.fab:hover {
  background: var(--accent2);
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 6px 30px rgba(108,99,255,.55);
}
.fab:active { transform: translateX(-50%) scale(.97); }

/* ── Modal Overlay ────────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.overlay.open {
  opacity: 1;
  pointer-events: all;
}
@media (min-width: 600px) {
  .overlay { align-items: center; padding: 24px; }
}

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rlg) var(--rlg) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(24px);
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.overlay.open .modal { transform: translateY(0); }
@media (min-width: 600px) { .modal { border-radius: var(--rlg); } }
.modal-wide { max-width: 620px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 18px; font-weight: 800; }
.close-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 5px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  transition: all .15s;
}
.close-btn:hover { color: var(--text); background: var(--surface2); }
.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  flex-shrink: 0;
}
.tab-btn {
  padding: 11px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel.hidden { display: none; }

/* ── Form ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.flex1 { flex: 1; min-width: 140px; }
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--rsm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  appearance: none;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--dim); }
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237878a0' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
  cursor: pointer;
}
.form-control.error { border-color: var(--red); }

/* ── Amount input ─────────────────────────────────────────────────────────── */
.amt-wrap {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--rsm);
  overflow: hidden;
  transition: border-color .15s;
}
.amt-wrap:focus-within { border-color: var(--accent); }
.amt-prefix {
  padding: 0 12px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
  background: var(--surface3);
  align-self: stretch;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--border);
}
.amt-input {
  border: none !important;
  border-radius: 0 !important;
  background: transparent;
  flex: 1;
}

/* ── Autocomplete ─────────────────────────────────────────────────────────── */
.ac-wrap { position: relative; }
.ac-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--rsm);
  z-index: 400;
  max-height: 180px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.ac-list.show { display: block; }
.ac-item {
  padding: 10px 13px;
  font-size: 13.5px;
  cursor: pointer;
  transition: background .1s;
}
.ac-item:hover { background: var(--surface3); }

/* ── Manage categories list ───────────────────────────────────────────────── */
.cat-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  margin-top: 22px;
}
.cat-group-label:first-child { margin-top: 0; }
.manage-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,.03);
}
.manage-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.manage-name { flex: 1; font-size: 13.5px; font-weight: 500; }
.manage-budget { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.manage-actions { display: flex; gap: 2px; }
.inline-input {
  background: var(--bg);
  border: 1.5px solid var(--accent);
  border-radius: 5px;
  color: var(--text);
  padding: 4px 8px;
  font-size: 13px;
  width: 100%;
}

/* ── Add category form ────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 24px 0 20px; }
.panel-subheading { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 14px; }

/* ── Color Picker ─────────────────────────────────────────────────────────── */
.color-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 0;
}
.swatch {
  width: 22px; height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: 2.5px solid transparent;
  transition: transform .15s, border-color .15s;
  flex-shrink: 0;
}
.swatch:hover { transform: scale(1.18); }
.swatch.sel { border-color: #fff; transform: scale(1.15); }

/* ── Entries list ─────────────────────────────────────────────────────────── */
.entry-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.entry-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.entry-info { flex: 1; min-width: 0; }
.entry-desc { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-meta { font-size: 11.5px; color: var(--muted); }
.entry-amount { font-size: 14px; font-weight: 700; white-space: nowrap; }
.entry-amount.inc { color: var(--green); }
.entry-amount.exp { color: var(--text); }

/* ── Empty states ─────────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  font-size: 13.5px;
}
.empty-icon { font-size: 28px; margin-bottom: 8px; }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444466; }

/* ── Shake animation ──────────────────────────────────────────────────────── */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
.shake { animation: shake .3s ease; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .hero-card { padding: 24px 20px; }
  .hero-amount { letter-spacing: -2px; }
  .chart-layout { flex-direction: column; align-items: stretch; }
  .chart-wrap { width: 220px; height: 220px; margin: 0 auto; }
  .net-card { flex-direction: column; align-items: flex-start; }
  .net-sep { display: none; }
  .header-brand .brand-name { font-size: 15px; }
  .month-badge { display: none; }
}
@media (max-width: 400px) {
  .container { padding: 0 14px; }
  .btn-outline span { display: none; }
}
