:root {
  --bg: #eef1f6;
  --bg-2: #e4e8f1;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --ink: #161b2c;
  --muted: #6b7280;
  --border: #e2e5ec;

  --man: #2f5fde;
  --man-soft: #e8edfc;
  --woman: #b33f76;
  --woman-soft: #fbe9f1;
  --savings: #12866f;
  --savings-soft: #e1f3ee;

  --nav: #12162a;
  --danger: #c0392b;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 14px 34px -16px rgba(18, 22, 42, 0.28);
  --shadow-sm: 0 4px 14px -8px rgba(18, 22, 42, 0.2);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, .display { font-family: 'Fraunces', Georgia, serif; }
.num { font-variant-numeric: tabular-nums; }
.screen { min-height: 100vh; }

/* ============ LOGIN ============ */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  padding: 24px; min-height: 100vh;
  background:
    radial-gradient(60% 50% at 15% 10%, rgba(47,95,222,0.35), transparent 60%),
    radial-gradient(55% 45% at 90% 15%, rgba(179,63,118,0.32), transparent 60%),
    radial-gradient(70% 60% at 50% 100%, rgba(18,134,111,0.28), transparent 60%),
    var(--nav);
}
.login-card {
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(20px);
  padding: 44px 36px 36px;
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 70px -20px rgba(0,0,0,0.5);
  width: 100%; max-width: 380px; text-align: center;
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .login-card { animation: none; } }

.venn { width: 76px; height: 56px; margin: 0 auto 18px; }
.login-card h1 { margin: 0 0 6px; font-size: 26px; font-weight: 600; letter-spacing: -.2px; }
.login-card .muted { margin-bottom: 26px; }
.field-wrap { position: relative; margin-bottom: 14px; }
.field-wrap input {
  width: 100%; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: 12px;
  font-size: 16px; font-family: inherit; background: var(--surface-2);
  transition: border-color .15s, background .15s;
}
.field-wrap input:focus { outline: none; border-color: var(--man); background: white; }
.btn-unlock {
  width: 100%; border: none; padding: 14px; border-radius: 12px; font-size: 15px; font-weight: 700;
  color: white; cursor: pointer; letter-spacing: .2px;
  background: linear-gradient(100deg, var(--man), var(--woman) 60%, var(--savings));
  background-size: 160% 100%;
  box-shadow: 0 10px 24px -10px rgba(47,95,222,0.55);
  transition: background-position .3s, transform .1s;
}
.btn-unlock:hover { background-position: 100% 0; }
.btn-unlock:active { transform: scale(.98); }
.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); font-size: 13.5px; min-height: 18px; margin-top: 12px; font-weight: 500; }

/* ============ TOPBAR ============ */
.topbar {
  background: var(--nav); color: white; padding: 14px 20px;
  position: sticky; top: 0; z-index: 20;
  box-shadow: 0 2px 20px rgba(0,0,0,0.15);
}
.topbar-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16.5px; white-space: nowrap; letter-spacing: -.2px; }
.brand .venn-sm { width: 30px; height: 22px; flex: none; }

.burger-btn {
  display: none; background: rgba(255,255,255,0.08); border: none; color: white;
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  align-items: center; justify-content: center; flex: none;
}
.burger-btn svg { width: 20px; height: 20px; }
.burger-btn:hover { background: rgba(255,255,255,0.16); }

.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-top: 12px; }
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.85); border: 1px solid transparent;
  padding: 8px 15px; border-radius: 30px; font-size: 13.5px; white-space: nowrap; cursor: pointer;
  font-family: inherit; font-weight: 500; transition: background .15s, color .15s;
}
.tab-btn:hover { background: rgba(255,255,255,0.16); }
.tab-btn.active { background: white; color: var(--ink); font-weight: 700; }
.tab-btn svg { width: 15px; height: 15px; flex: none; }

/* Burger / collapsible nav on phones and narrow tablets */
@media (max-width: 720px) {
  .burger-btn { display: flex; }
  .tabs {
    display: none; flex-direction: column; align-items: stretch;
    gap: 8px; margin-top: 14px; padding-bottom: 4px;
  }
  .tabs.open { display: flex; }
  .tab-btn { width: 100%; padding: 12px 16px; border-radius: 12px; justify-content: flex-start; }
}

main#content { padding: 20px 16px 70px; max-width: 920px; margin: 0 auto; }

/* ============ CARDS ============ */
.card {
  background: var(--surface); border-radius: var(--radius-lg); padding: 22px;
  margin-bottom: 18px; box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.card.accent::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 5px;
  background: var(--accent, var(--man));
}
.card-clickable { cursor: pointer; transition: transform .12s, box-shadow .12s; }
.card-clickable:hover { box-shadow: 0 18px 40px -18px rgba(18,22,42,0.32); transform: translateY(-2px); }
.card-clickable:active { transform: translateY(0) scale(.995); }
.card-clickable:focus-visible { outline: 2px solid var(--accent, var(--man)); outline-offset: 2px; }
.card h2, .card h3 { margin-top: 0; font-weight: 600; }
.card h3 { font-size: 15.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 16px; }

.hero-card {
  background: linear-gradient(120deg, var(--nav) 0%, #1c2444 100%);
  color: white; border: none;
}
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.hero-top h2 { color: white; margin: 0; font-size: 20px; }
.hero-balance { font-size: 42px; font-weight: 600; margin: 6px 0 2px; }
.hero-sub { color: rgba(255,255,255,0.55); font-size: 13.5px; margin-bottom: 18px; }
.hero-seam {
  height: 6px; border-radius: 6px; margin-top: 6px;
  background: linear-gradient(90deg, var(--man), var(--woman) 50%, var(--savings));
}

.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; margin-bottom: 18px; }
.stat-pill {
  background: rgba(255,255,255,0.06); border-radius: var(--radius-md); padding: 16px;
  border: 1px solid rgba(255,255,255,0.1);
}
.stat-pill .label { font-size: 12.5px; color: rgba(255,255,255,0.6); text-transform: uppercase; letter-spacing: .4px; }
.stat-pill .value { font-size: 21px; font-weight: 600; margin-top: 4px; }
.stat-pill.income .value { color: #6fe0b8; }
.stat-pill.expense .value { color: #ff9f8f; }

.acc-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.acc-name-badge { display: flex; align-items: center; gap: 10px; }
.acc-dot { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 14px; flex: none; }
.acc-card-head h3 { margin: 0; text-transform: none; letter-spacing: 0; font-size: 18px; color: var(--ink); font-family: 'Fraunces', serif; }
.acc-balance { font-size: 24px; font-weight: 600; }

.summary-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.summary-row:last-of-type { border-bottom: none; }
.amt-income { color: #0f9d63; font-weight: 700; }
.amt-expense { color: var(--danger); font-weight: 700; }

.cat-over { color: var(--danger); font-weight: 700; }

.txn-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.txn-item:last-child { border-bottom: none; }
.txn-icon { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 14px; margin-right: 12px; flex: none; }
.txn-left { display: flex; align-items: center; min-width: 0; flex: 1 1 auto; }
.txn-left > div { min-width: 0; }
.txn-desc { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.txn-amount { font-weight: 700; white-space: nowrap; }
.txn-amount.income { color: #0f9d63; }
.txn-amount.expense { color: var(--danger); }
.txn-actions { flex: none; display: flex; }
.txn-actions button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; margin-left: 6px; padding: 6px; opacity: .6; transition: opacity .15s; display: flex; align-items: center; }
.txn-actions button svg { width: 16px; height: 16px; }
.txn-actions button:hover { opacity: 1; }
.txn-edit-row { display: block; padding: 14px 0; }
.txn-edit-row .form-grid { gap: 10px; }
.txn-edit-row .form-row button { flex: 1; }

.form-grid { display: grid; gap: 11px; }
.form-grid input, .form-grid select {
  padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 11px; font-size: 14.5px;
  width: 100%; font-family: inherit; background: var(--surface-2); transition: border-color .15s, background .15s;
}
.form-grid input:focus, .form-grid select:focus { outline: none; border-color: var(--man); background: white; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row > * { flex: 1 1 130px; min-width: 0; }
.form-row select, .form-row input { max-width: 100%; }
.type-toggle { display: flex; gap: 8px; margin-bottom: 2px; }
.type-toggle button, .type-btn {
  flex: 1; padding: 11px; border-radius: 11px; border: 1.5px solid var(--border);
  background: var(--surface-2); cursor: pointer; font-weight: 600; font-family: inherit; font-size: 14px;
  transition: all .15s;
}
.type-toggle button.active.income, .type-btn.active.income { background: #e3f9ef; border-color: #0f9d63; color: #0f9d63; }
.type-toggle button.active.expense, .type-btn.active.expense { background: #fdeae7; border-color: var(--danger); color: var(--danger); }
.type-toggle button.active:not(.income):not(.expense) { background: var(--man-soft); border-color: var(--man); color: var(--man); }
.form-grid label.muted { display: block; margin-bottom: 4px; font-size: 12.5px; }

.btn {
  border: none; padding: 12px 20px; border-radius: 11px; font-size: 14.5px; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: white; width: 100%; }
.btn-primary:hover { opacity: .9; }
.btn-ghost { background: transparent; color: white; border: 1px solid rgba(255,255,255,0.4); }
.btn-outline { background: transparent; color: var(--man); border: 1.5px solid var(--man); }
.btn-sm { padding: 8px 13px; font-size: 12.5px; }
.btn-danger { background: #fdeae7; color: var(--danger); }
.btn-block { width: 100%; margin-top: 10px; }
.btn svg { width: 15px; height: 15px; vertical-align: -3px; flex: none; }

.settings-section { margin-bottom: 20px; }
.rename-row { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; flex-wrap: wrap; }
.reorder-btns { display: flex; flex-direction: column; gap: 3px; }
.reorder-btns .btn { padding: 3px 8px; }
.rename-row > input[type="text"], .rename-row > input[type="number"] { min-width: 90px; }
.color-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; margin-right: 6px; flex: none; }

.file-input-label {
  display: block; padding: 13px 16px; border: 1.5px dashed var(--man); border-radius: 11px;
  color: var(--man); cursor: pointer; font-size: 14px; text-align: center; font-weight: 600;
  transition: background .15s;
}
.file-input-label:hover { background: var(--man-soft); }
.file-input-label input { display: none; }

.empty-state { text-align: center; color: var(--muted); padding: 34px 10px; font-size: 14px; }

@media (max-width: 560px) {
  .hero-balance { font-size: 32px; }
  .card { padding: 18px; }
}
