/* ─── FinWise · dark minimal dashboard theme ─────────────────────────────────
   Palette & gradients inspired by a modern emerald/teal dashboard: near-black
   background, rich gradient cards, thin progress bars, soft shadows.
--------------------------------------------------------------------------------- */

:root {
  --bg: #0e1116;
  --bg-soft: #171c22;        /* elevated surfaces / modal */
  --panel: rgba(255, 255, 255, 0.03);
  --panel-2: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.06);
  --text: #eef1f4;
  --muted: rgba(255, 255, 255, 0.44);
  --muted-2: rgba(255, 255, 255, 0.3);
  --primary: #2dd4a0;        /* emerald-teal */
  --primary-2: #12866a;
  --emerald: #2dd4a0;
  --red: #f87171;
  --blue: #4f83f7;
  --amber: #f6a63b;
  --radius: 20px;
  --radius-sm: 14px;
  --sidebar-w: 216px;

  --grad-emerald: linear-gradient(140deg, #2fd8a4 0%, #127e60 100%);
  --grad-blue:    linear-gradient(140deg, #4f83f7 0%, #1b3a9e 100%);
  --grad-red:     linear-gradient(140deg, #f0604a 0%, #8f2a1c 100%);
  --grad-amber:   linear-gradient(140deg, #f7a63b 0%, #b4600a 100%);
  --grad-slate:   linear-gradient(140deg, #3a4250 0%, #22272f 100%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

/* Ambient glow, echoing the reference's teal highlight */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(700px 480px at 88% -8%, rgba(45, 212, 160, 0.12), transparent 60%),
    radial-gradient(600px 420px at 0% 108%, rgba(79, 131, 247, 0.08), transparent 60%);
}

h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; position: relative; overflow: hidden; z-index: 1; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 12px;
  padding: 12px 16px; font-size: 14px; font-weight: 600; color: #fff;
  background: rgba(255, 255, 255, 0.06); transition: transform .12s ease, opacity .15s, box-shadow .15s;
}
.btn:hover { opacity: .95; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn { min-width: 0; }
.flex-1 { min-width: 0; }
.btn-primary { background: var(--grad-emerald); color: #05231a; box-shadow: 0 6px 20px rgba(45, 212, 160, 0.3); }
.btn-emerald { background: var(--grad-emerald); color: #05231a; box-shadow: 0 6px 20px rgba(45, 212, 160, 0.3); }
.btn-ghost { background: rgba(255, 255, 255, 0.05); border-color: var(--card-border); color: var(--text); }
.btn-danger { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.25); color: var(--red); }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 13px; font-size: 13px; border-radius: 11px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04); color: var(--muted); font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center; transition: background .15s, color .15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

/* ─── Inputs ──────────────────────────────────────────────────────────────── */
.field { display: block; }
.field-label { display: block; font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.62); margin-bottom: 7px; }
.input, .select {
  width: 100%; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05); color: #fff; font-size: 14px;
  padding: 12px 14px; transition: border .15s, box-shadow .15s, background .15s;
}
.input::placeholder { color: rgba(255, 255, 255, 0.3); }
.input:focus, .select:focus { outline: none; border-color: transparent; background: rgba(255,255,255,0.07); box-shadow: 0 0 0 2px rgba(45, 212, 160, 0.55); }
.select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px; }

.stack > * + * { margin-top: 16px; }

/* ─── Cards / glass ───────────────────────────────────────────────────────── */
.card {
  position: relative; z-index: 1;
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--card-border); border-radius: var(--radius);
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.42);
}
.card-pad { padding: 18px; }

.alert { border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.alert-error { color: #fca5a5; background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248, 113, 113, 0.2); }

/* ─── Auth pages ──────────────────────────────────────────────────────────── */
.auth-glow { position: absolute; top: -160px; left: 50%; transform: translateX(-50%); width: 560px; height: 560px; border-radius: 50%; filter: blur(90px); background: radial-gradient(circle, rgba(45, 212, 160, 0.28), transparent 70%); pointer-events: none; }
.auth-card {
  position: relative; z-index: 1; width: 100%; max-width: 390px; padding: 32px;
  background: rgba(255, 255, 255, 0.04); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.09); border-radius: 26px; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}
.auth-title { font-size: 23px; font-weight: 700; }
.auth-sub { color: var(--muted); font-size: 14px; margin: 6px 0 24px; }
.auth-alt { text-align: center; color: var(--muted); font-size: 14px; margin-top: 22px; }
.auth-alt a { color: var(--primary); font-weight: 600; }
.setup-list { list-style: none; padding: 0; margin: 0 0 18px; color: var(--emerald); font-size: 14px; }
.setup-list li { padding: 4px 0; }

/* ─── Brand ───────────────────────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 11px; margin-bottom: 24px; }
.brand-badge { width: 38px; height: 38px; border-radius: 12px; background: var(--grad-emerald); color: #05231a; font-weight: 900; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(45, 212, 160, 0.45); }
.brand-name { font-weight: 700; line-height: 1; }
.brand-tag { font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--primary); margin-top: 3px; }

/* ─── App layout ──────────────────────────────────────────────────────────── */
.app { min-height: 100vh; display: flex; position: relative; z-index: 1; }
.sidebar {
  position: fixed; left: 0; top: 0; height: 100vh; width: var(--sidebar-w); z-index: 30;
  display: flex; flex-direction: column;
  background: rgba(13, 16, 21, 0.86); backdrop-filter: blur(26px); -webkit-backdrop-filter: blur(26px);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.sidebar-head { padding: 22px 20px 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.sidebar-head .brand { margin-bottom: 12px; }
.sidebar-email { font-size: 12px; color: var(--muted-2); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 5px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border: none; border-radius: 14px; font-size: 14px; font-weight: 500;
  background: transparent; color: var(--muted); transition: all .15s;
}
.nav-item span { font-size: 15px; }
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: rgba(255, 255, 255, 0.85); }
.nav-item.active { background: var(--grad-emerald); color: #05231a; font-weight: 700; box-shadow: 0 8px 22px rgba(45, 212, 160, 0.32); }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, 0.05); display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 11px 14px; border: none; border-radius: 12px; font-size: 13px;
  background: transparent; color: var(--muted); transition: all .15s;
}
.side-link:hover { background: rgba(255, 255, 255, 0.06); color: rgba(255,255,255,0.85); }
.side-link.danger { color: rgba(248, 113, 113, 0.72); }
.side-link.danger:hover { color: var(--red); background: rgba(248, 113, 113, 0.1); }

.sidebar-scrim { display: none; }

.main { flex: 1; margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 18px 28px; }
.topbar-greeting { flex: 1; }
.topbar-hi { font-size: 19px; font-weight: 700; margin-top: 2px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--grad-emerald); color: #05231a; font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(45,212,160,0.35); }

.content { flex: 1; overflow: auto; padding: 8px 28px 32px; }
.container { max-width: 920px; margin: 0 auto; }
.module-header { margin-bottom: 20px; }
.module-header h2 { font-size: 21px; font-weight: 700; }
.module-header p { margin-top: 3px; }

.only-mobile { display: none; }

/* ─── Generic module bits ─────────────────────────────────────────────────── */
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.row { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mb-3 { margin-bottom: 12px; }
.flex-1 { flex: 1; }

/* Gradient stat cards (like the reference project cards) */
.stat {
  position: relative; overflow: hidden; border-radius: var(--radius); padding: 18px 18px 16px;
  color: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.stat::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,0.08), transparent 40%); pointer-events: none; }
.stat .stat-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.13em; color: rgba(255,255,255,0.72); }
.stat .stat-value { font-size: 27px; font-weight: 900; line-height: 1; margin: 8px 0 4px; }
.stat .stat-cur { font-size: 11px; color: rgba(255,255,255,0.55); }
.stat .stat-note { font-size: 11px; color: rgba(255,255,255,0.72); margin-top: 10px; }
.stat-emerald { background: var(--grad-emerald); }
.stat-blue { background: var(--grad-blue); }
.stat-red { background: var(--grad-red); }
.stat-amber { background: var(--grad-amber); }
.stat-slate { background: var(--grad-slate); }

/* Thin rounded progress bar */
.progress { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.22); overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: rgba(255, 255, 255, 0.92); transition: width .4s ease; }

/* Mini stat tiles (monthly overview) */
.mini-grid { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 768px) { .mini-grid { grid-template-columns: repeat(2, 1fr); } }
.mini { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--card-border); border-radius: 14px; padding: 13px 14px; }
.mini-top { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.mini-ico { font-size: 14px; }
.mini-label { font-size: 10px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.mini-val { font-size: 19px; font-weight: 800; color: var(--text); line-height: 1; }
.mini-val.blue { color: var(--blue); }
.mini-val.amber { color: var(--amber); }
.mini-cur { font-size: 10px; color: var(--muted-2); margin-left: 4px; font-weight: 600; }

/* Category breakdown bars */
.cat-row { margin-bottom: 13px; }
.cat-row:last-child { margin-bottom: 0; }
.cat-bar { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.cat-bar > span { display: block; height: 100%; border-radius: 999px; transition: width .4s ease; }

.section-title { font-weight: 700; font-size: 14px; }
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; border: 1px solid rgba(255,255,255,0.05); border-radius: var(--radius-sm); background: rgba(255,255,255,0.02); transition: background .15s; }
.list-row:hover { background: rgba(255,255,255,0.045); }
.list-row + .list-row { margin-top: 9px; }
.pill { font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.pill-in { background: rgba(45,212,160,0.18); color: #6ee7c2; }
.pill-out { background: rgba(248,113,113,0.18); color: #fca5a5; }

.tile { padding: 16px; text-align: left; border: 1px solid rgba(255,255,255,0.07); border-radius: var(--radius-sm); background: rgba(255,255,255,0.025); transition: background .15s, transform .12s; }
.tile:hover { background: rgba(255,255,255,0.06); transform: translateY(-1px); }
.pos { color: var(--emerald); } .neg { color: var(--red); } .zero { color: var(--muted); }

.empty { padding: 44px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.icon-x { background: none; border: none; color: var(--muted); font-size: 15px; padding: 6px; border-radius: 8px; transition: color .15s, background .15s; }
.icon-x:hover { color: var(--red); background: rgba(248,113,113,0.1); }
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.month-nav h3 { font-size: 18px; font-weight: 700; }
.chip { padding: 10px 12px; border-radius: 12px; font-size: 12px; font-weight: 600; border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.04); color: var(--muted); transition: all .15s; }
.chip.active { color: #05231a; border-color: transparent; background: var(--grad-emerald); }

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.72); backdrop-filter: blur(5px); z-index: 40; }
.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: calc(100% - 32px); max-width: 430px; max-height: 90vh; overflow-y: auto; z-index: 50;
  background: var(--bg-soft); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 24px; padding: 24px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.72);
}
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.modal .modal-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

/* ─── Toasts ──────────────────────────────────────────────────────────────── */
.toast-host { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--bg-soft); border: 1px solid rgba(255,255,255,0.1); color: #fff;
  padding: 12px 16px; border-radius: 12px; font-size: 13px; font-weight: 500;
  box-shadow: 0 14px 44px rgba(0,0,0,0.55); animation: toast-in .2s ease;
}
.toast.ok { border-color: rgba(45,212,160,0.45); }
.toast.err { border-color: rgba(248,113,113,0.45); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .container { max-width: 100%; }
}
@media (max-width: 768px) {
  .only-mobile { display: inline-flex; }
  .sidebar { transform: translateX(-100%); width: 250px; box-shadow: 0 0 60px rgba(0,0,0,0.6); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 25; backdrop-filter: blur(2px); }
  .main { margin-left: 0; }
  .content { padding: 4px 16px 28px; }
  .topbar { padding: 14px 16px; }
  .topbar-hi { font-size: 17px; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .stat .stat-value { font-size: 24px; }
}
@media (max-width: 520px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stat-span-2 { grid-column: auto; }
  .module-header h2 { font-size: 19px; }
}
