/* ---------------------------------------------------------------
   Design system — dark, high-contrast, fintech-app style.
--------------------------------------------------------------- */

:root {
  --bg: #000000;
  --bg-elevated: #121214;
  --bg-elevated-2: #1c1c1f;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text: #f5f5f7;
  --text-secondary: #8e8e93;
  --text-tertiary: #636366;

  --accent: #21e187;
  --accent-dim: rgba(33, 225, 135, 0.14);
  --accent-on: #04150c;

  --negative: #ff453a;
  --negative-dim: rgba(255, 69, 58, 0.14);

  --warning: #ffb340;
  --warning-dim: rgba(255, 179, 64, 0.16);

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-full: 999px;

  --nav-h: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------------------------------------------------------------
   Layout utilities (minimal subset, replaces Bootstrap grid/utils)
--------------------------------------------------------------- */

.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.gap-2 { gap: .5rem; }
.w-100 { width: 100%; }

.row { display: flex; flex-wrap: wrap; }
.row.g-2 { gap: .5rem; }
.col-6 { flex: 0 0 calc(50% - .25rem); max-width: calc(50% - .25rem); }
.col-12 { flex: 0 0 100%; max-width: 100%; }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-2 { margin-bottom: .5rem; margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.py-2 { padding-top: .5rem; padding-bottom: .5rem; }

.text-muted { color: var(--text-secondary); }
.small { font-size: .82rem; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.h4 { font-size: 1.3rem; }
.h5 { font-size: 1.1rem; }
.h6 {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ---------------------------------------------------------------
   Header + bottom tab bar
--------------------------------------------------------------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.1rem;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.app-header-title {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 1rem;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1030;
  display: flex;
  justify-content: space-around;
  background: rgba(10, 10, 11, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: .35rem .25rem calc(.35rem + var(--safe-bottom));
}

.bottom-nav-link {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  padding: .3rem 0;
  color: var(--text-tertiary);
  font-size: .68rem;
  font-weight: 600;
}

.bottom-nav-link i { font-size: 1.25rem; }

.bottom-nav-link.active { color: var(--accent); }

.app-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem 1.1rem 2rem;
  min-height: 100vh;
}

body.with-nav .app-main {
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 1.5rem);
}

/* ---------------------------------------------------------------
   Balance hero
--------------------------------------------------------------- */

.balance-hero {
  padding: 1.75rem 0 1.5rem;
  margin-bottom: .5rem;
}

.balance-hero .text-muted.small {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .72rem;
  font-weight: 600;
}

.balance-hero .amount {
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: .25rem;
}

/* ---------------------------------------------------------------
   Grouped list cards (accounts / movements / buckets / rules)
--------------------------------------------------------------- */

.list-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.list-card:empty {
  display: none;
}

.list-card > p {
  margin: 0;
  padding: 1rem 1.1rem;
}

.account-balance-row,
.movement-card {
  border-bottom: 1px solid var(--border);
  border-radius: 0 !important;
  margin: 0 !important;
  background: transparent !important;
}

.list-card > .account-balance-row:last-child,
.list-card > .movement-card:last-child {
  border-bottom: none;
}

.account-balance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .9rem 1.1rem;
  font-size: .95rem;
}

.movement-card {
  padding: .85rem 1.1rem;
}

.movement-card .amount.positive { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.movement-card .amount.negative { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.movement-card .meta {
  color: var(--text-secondary);
  font-size: .78rem;
  margin-top: .2rem;
}

.movement-card .bucket-select {
  margin-top: .55rem;
}

.bucket-chip {
  display: inline-block;
  padding: .18rem .6rem;
  border-radius: var(--radius-full);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: .72rem;
  font-weight: 600;
}

/* ---------------------------------------------------------------
   Badges / alerts
--------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: .35rem .75rem;
  border-radius: var(--radius-full);
  font-size: .78rem;
  font-weight: 600;
}

.text-bg-warning { background: var(--warning-dim); color: var(--warning); }
.text-bg-secondary { background: var(--bg-elevated-2); color: var(--text-secondary); }

.alert {
  padding: .9rem 1rem;
  border-radius: var(--radius-md);
  font-size: .88rem;
  line-height: 1.5;
}

.alert-success { background: var(--accent-dim); color: var(--accent); }
.alert-danger { background: var(--negative-dim); color: var(--negative); }
.alert div { margin-bottom: .2rem; }
.alert div:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------
   Forms
--------------------------------------------------------------- */

.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: .4rem;
}

.form-control,
.form-select {
  width: 100%;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: .7rem .85rem;
  font-size: .95rem;
  appearance: none;
  -webkit-appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238e8e93' stroke-width='1.6' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .9rem center;
  padding-right: 2.2rem;
}

.form-control::placeholder { color: var(--text-tertiary); }

.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-control-sm, .form-select-sm {
  padding: .5rem .7rem;
  font-size: .85rem;
}

input[type="file"].form-control {
  padding: .55rem .7rem;
  color: var(--text-secondary);
  font-size: .85rem;
}

input[type="file"].form-control::file-selector-button {
  background: var(--accent-dim);
  color: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: .5rem .8rem;
  margin-right: .8rem;
  font-weight: 700;
  font-size: .82rem;
  cursor: pointer;
}

/* ---------------------------------------------------------------
   Buttons
--------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .75rem 1.2rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  background: none;
  color: var(--text);
}

.btn-sm { padding: .5rem .9rem; font-size: .82rem; border-radius: var(--radius-sm); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-on);
}

.btn-outline-primary {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

.btn-outline-secondary {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.btn-outline-danger {
  background: transparent;
  border-color: rgba(255, 69, 58, 0.35);
  color: var(--negative);
}

/* ---------------------------------------------------------------
   Auth screens (login / setup)
--------------------------------------------------------------- */

.auth-card {
  max-width: 380px;
  margin: 4.5rem auto 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
}

@media (max-width: 480px) {
  .balance-hero .amount { font-size: 2.25rem; }
  .app-main { padding-left: .9rem; padding-right: .9rem; }
}
