/* ============================================================
   FinTrack – Global Stylesheet
   Minimal · Modern · Clean
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&family=DM+Mono:wght@400;500&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:         #0f0f11;
  --bg-2:       #18181c;
  --bg-3:       #222228;
  --border:     #2a2a32;
  --border-2:   #3a3a46;
  --text:       #f0f0f4;
  --text-2:     #9090a0;
  --text-3:     #5a5a6a;
  --accent:     #7c6fec;
  --accent-dim: #4a4580;
  --green:      #34c97a;
  --red:        #e05252;
  --amber:      #e0a040;
  --blue:       #4a9eff;
  --radius:     10px;
  --radius-lg:  16px;
  --nav-w:      240px;
  --topbar-h:   60px;
  --shadow:     0 4px 24px rgba(0,0,0,.4);
  --transition: 180ms cubic-bezier(.4,0,.2,1);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
input, textarea, select, button { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }

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

/* ── Navbar (sidebar) ───────────────────────────────────────── */
.navbar {
  width: var(--nav-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.navbar-brand-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.navbar-brand-icon svg { width: 18px; height: 18px; color: #fff; }
.navbar-brand-name {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -.01em;
}
.navbar-section {
  padding: 16px 12px 6px;
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.navbar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px;
}
.navbar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 400;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
}
.navbar-nav a:hover { background: var(--bg-3); color: var(--text); }
.navbar-nav a.active { background: rgba(124,111,236,.15); color: var(--accent); font-weight: 500; }
.navbar-nav a svg { width: 16px; height: 16px; flex-shrink: 0; }
.navbar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.navbar-footer a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
}
.navbar-footer a:hover { background: var(--bg-3); color: var(--text); }
.navbar-footer a svg { width: 16px; height: 16px; }

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--nav-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 90;
}
.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -.01em;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

/* ── Main Content ────────────────────────────────────────────── */
.main {
  margin-left: var(--nav-w);
  margin-top: var(--topbar-h);
  flex: 1;
  padding: 32px 28px;
  /* No max-width — let the grid columns control width via minmax(0,1fr) */
  min-width: 0;
  overflow-x: hidden;
  box-sizing: border-box;
  width: calc(100% - var(--nav-w));
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card + .card { margin-top: 16px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.card-title {
  font-size: .95rem;
  font-weight: 600;
}
.card-subtitle {
  font-size: .8rem;
  color: var(--text-2);
  margin-top: 2px;
}

/* ── Stat Cards ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.stat-label {
  font-size: .75rem;
  color: var(--text-2);
  font-weight: 500;
  letter-spacing: .02em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 600;
  font-family: 'DM Mono', monospace;
  letter-spacing: -.02em;
}
.stat-value.positive { color: var(--green); }
.stat-value.negative { color: var(--red); }
.stat-delta {
  font-size: .75rem;
  color: var(--text-3);
  margin-top: 4px;
}

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  background: var(--bg-3);
  padding: 12px 16px;
  text-align: left;
  font-size: .72rem;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-3); }
td {
  padding: 14px 16px;
  color: var(--text);
  vertical-align: middle;
}
td.mono {
  font-family: 'DM Mono', monospace;
  font-size: .85rem;
}
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
  font-size: .9rem;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #6a5fd8; }
.btn-secondary {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-danger {
  background: rgba(224,82,82,.1);
  color: var(--red);
  border: 1px solid rgba(224,82,82,.2);
}
.btn-danger:hover { background: rgba(224,82,82,.2); }
.btn-sm {
  padding: 6px 12px;
  font-size: .78rem;
}
.btn-icon {
  padding: 7px;
  border-radius: var(--radius);
}
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .02em;
}
.badge-green  { background: rgba(52,201,122,.12); color: var(--green); }
.badge-red    { background: rgba(224,82,82,.12);  color: var(--red); }
.badge-amber  { background: rgba(224,160,64,.12); color: var(--amber); }
.badge-blue   { background: rgba(74,158,255,.12); color: var(--blue); }
.badge-purple { background: rgba(124,111,236,.12);color: var(--accent); }
.badge-gray   { background: var(--bg-3); color: var(--text-2); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1/-1; }
label {
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: .02em;
}
input, select, textarea {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 13px;
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,111,236,.15);
}
textarea { resize: vertical; min-height: 90px; }
select option { background: var(--bg-2); }
.form-error {
  font-size: .75rem;
  color: var(--red);
  margin-top: 2px;
}
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -.02em;
}
.page-header p {
  font-size: .85rem;
  color: var(--text-2);
  margin-top: 3px;
}

/* ── Alert / Flash ───────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; }
.alert-success { background: rgba(52,201,122,.1); border: 1px solid rgba(52,201,122,.2); color: var(--green); }
.alert-danger   { background: rgba(224,82,82,.1);  border: 1px solid rgba(224,82,82,.2);  color: var(--red); }
.alert-info     { background: rgba(74,158,255,.1); border: 1px solid rgba(74,158,255,.2); color: var(--blue); }

/* ── Auth Pages ──────────────────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.auth-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}
.auth-logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.auth-logo-icon svg { width: 20px; height: 20px; color: #fff; }
.auth-logo-name { font-size: 1.1rem; font-weight: 600; }
.auth-title {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -.02em;
  margin-bottom: 6px;
}
.auth-subtitle {
  font-size: .85rem;
  color: var(--text-2);
  margin-bottom: 28px;
}
.auth-footer {
  margin-top: 20px;
  text-align: center;
  font-size: .82rem;
  color: var(--text-2);
}
.auth-footer a { color: var(--accent); }
.auth-footer a:hover { text-decoration: underline; }

/* ── Progress Bar ────────────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--bg-3);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .4s ease;
}

/* ── Color Dot ───────────────────────────────────────────────── */
.color-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ── Misc ────────────────────────────────────────────────────── */
.text-muted  { color: var(--text-2); }
.text-small  { font-size: .8rem; }
.mono        { font-family: 'DM Mono', monospace; }
.positive    { color: var(--green); }
.negative    { color: var(--red); }
.flex        { display: flex; }
.items-center{ align-items: center; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.mt-1        { margin-top: 6px; }
.mt-2        { margin-top: 12px; }
.mb-4        { margin-bottom: 16px; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --nav-w: 0px; }
  .navbar { transform: translateX(-240px); }
  .navbar.open { transform: translateX(0); --nav-w: 240px; }
  .topbar { left: 0; }
  .main { padding: 20px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}