@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ==============================
   TOKENS
   ============================== */
:root {
  --bg:          #0d1117;
  --bg-card:     #111827;
  --bg-card2:    #161f2e;
  --bg-input:    #0d1117;
  --border:      rgba(255,255,255,.07);
  --border-md:   rgba(255,255,255,.11);

  --text:        #e2e8f0;
  --text-muted:  #64748b;
  --text-faint:  #334155;

  --green:       #22c55e;
  --green-bg:    #052e16;
  --green-text:  #4ade80;
  --red:         #f87171;
  --red-bg:      #450a0a;
  --red-text:    #fca5a5;
  --yellow:      #f59e0b;
  --yellow-bg:   #431407;
  --yellow-text: #fbbf24;
  --blue:        #3b82f6;
  --blue-bg:     #0c1a2e;
  --blue-text:   #60a5fa;
  --purple:      #818cf8;
  --purple-bg:   #1e1b4b;
  --purple-text: #a5b4fc;

  --primary:       #6366f1;
  --primary-glow:  rgba(99,102,241,.35);
  --primary-dark:  #4f46e5;

  --radius:    14px;
  --radius-sm: 9px;
  --radius-lg: 18px;
  --nav-h:     64px;
  --header-h:  52px;

  --font:      'Plus Jakarta Sans', system-ui, sans-serif;
  --mono:      'DM Mono', 'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--purple); text-decoration: none; }

/* ==============================
   APP SHELL
   ============================== */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
}

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(13,17,23,.92);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
}

.header-left { display: flex; align-items: center; gap: 9px; }

.logo-icon-sm { font-size: 1.25rem; }

.app-title {
  font-size: 1rem; font-weight: 700; letter-spacing: -.025em;
  color: var(--text);
}
.app-title strong { color: var(--purple); font-weight: 700; }

.header-right { display: flex; align-items: center; gap: 10px; }

.user-name {
  font-size: 0.78rem; color: var(--text-muted);
  max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.btn-icon {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-muted); display: flex; align-items: center;
  justify-content: center; font-size: .9rem; transition: .2s;
  text-decoration: none;
}
.btn-icon:hover { background: var(--red-bg); color: var(--red); border-color: transparent; }

/* Main */
.app-main {
  flex: 1;
  padding: 16px 16px calc(var(--nav-h) + 20px);
}

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px;
  height: var(--nav-h);
  background: rgba(17,24,39,.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex; z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  color: var(--text-faint); font-size: .68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  text-decoration: none; transition: color .2s; padding: 8px 4px;
}

.nav-item.active { color: var(--purple); }

.nav-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; transition: .2s;
}

.nav-item.active .nav-icon { background: var(--purple-bg); color: var(--purple); }
.nav-item:not(.active):hover .nav-icon { background: var(--bg-card); color: var(--text-muted); }

/* ==============================
   AUTH
   ============================== */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; padding: 24px 16px;
  background: var(--bg);
}

.auth-card {
  width: 100%; max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.03), 0 32px 64px rgba(0,0,0,.6);
}

.auth-logo { text-align: center; margin-bottom: 32px; }

.logo-icon {
  font-size: 2.6rem; display: block; margin-bottom: 10px;
  filter: drop-shadow(0 0 20px rgba(99,102,241,.5));
}

.auth-logo h1 {
  font-size: 1.65rem; font-weight: 700; letter-spacing: -.035em;
  color: var(--text);
}

.auth-logo p { font-size: .84rem; color: var(--text-muted); margin-top: 5px; }

.auth-footer {
  text-align: center; margin-top: 22px;
  font-size: .82rem; color: var(--text-muted);
}

/* ==============================
   FORMS
   ============================== */
.form-group { margin-bottom: 15px; }

.form-group label {
  display: block; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); margin-bottom: 7px;
}

.form-control {
  width: 100%; padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font); font-size: .93rem;
  transition: border-color .18s, box-shadow .18s;
  -webkit-appearance: none; appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

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

select.form-control {
  cursor: pointer;
  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='%2364748b' stroke-width='1.5' stroke-linecap='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 36px;
}

input[type="date"].form-control { color-scheme: dark; }

.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-actions {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px;
}

.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.form-card.hidden { display: none; }

.form-title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--purple); margin-bottom: 16px;
}

/* ==============================
   BUTTONS
   ============================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: .88rem; font-weight: 600;
  cursor: pointer; border: none; transition: all .18s;
  white-space: nowrap; text-decoration: none; line-height: 1;
}

.btn-block { width: 100%; margin-top: 4px; }

.btn-primary {
  background: var(--primary); color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}
.btn-primary:hover {
  background: var(--primary-dark); color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-success { background: #14532d; color: var(--green-text); border: 1px solid #16a34a40; }
.btn-success:hover { background: #166534; color: var(--green-text); }

.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid #ef444430; }
.btn-danger:hover { background: #7f1d1d; color: var(--red-text); }

.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border-md);
}
.btn-ghost:hover { background: var(--bg-card); color: var(--text); }

.btn-sm { padding: 8px 13px; font-size: .8rem; }

.btn-xs {
  padding: 5px 10px; font-size: .73rem;
  border-radius: 7px; font-weight: 600;
}

/* ==============================
   ALERTS
   ============================== */
.alert {
  padding: 12px 15px; border-radius: var(--radius-sm);
  font-size: .86rem; margin-bottom: 14px; line-height: 1.45;
}

.alert-error   { background: var(--red-bg);    border: 1px solid #ef444433; color: var(--red-text); }
.alert-success { background: var(--green-bg);   border: 1px solid #22c55e33; color: var(--green-text); }
.alert-warning { background: var(--yellow-bg);  border: 1px solid #f59e0b33; color: var(--yellow-text); }
.alert-info    { background: var(--blue-bg);    border: 1px solid #3b82f633; color: var(--blue-text); }

.alert-banner {
  display: flex; align-items: flex-start; gap: 10px;
  border-radius: var(--radius); padding: 13px 15px;
  font-size: .87rem; font-weight: 500; margin-bottom: 16px;
  line-height: 1.45;
}

.alert-banner::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0; margin-top: 5px;
}
.alert-success.alert-banner::before { background: var(--green); }
.alert-warning.alert-banner::before { background: var(--yellow); }

.alert-toast {
  position: fixed;
  top: calc(var(--header-h) + 10px);
  left: 50%; transform: translateX(-50%);
  z-index: 300; min-width: 220px; max-width: calc(100vw - 32px);
  text-align: center;
  animation: toastIn .3s cubic-bezier(.34,1.4,.64,1), toastOut .3s ease 3.5s forwards;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  font-weight: 500;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px) scale(.95); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; pointer-events: none; }
}

/* ==============================
   PAGE LAYOUT
   ============================== */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}

.page-title { font-size: .95rem; font-weight: 700; }

.month-nav {
  display: flex; align-items: center; gap: 10px; flex: 1;
}

.month-btn {
  width: 32px; height: 32px; display: flex; align-items: center;
  justify-content: center; background: var(--bg-card);
  border: 1px solid var(--border-md); border-radius: 9px;
  color: var(--text-muted); font-size: 1rem; font-weight: 700;
  text-decoration: none; transition: .18s;
}
.month-btn:hover { background: var(--purple-bg); color: var(--purple); border-color: transparent; }

.month-label {
  font-size: .94rem; font-weight: 700; color: var(--text);
  flex: 1; text-align: center;
}

/* ==============================
   DASHBOARD CARDS
   ============================== */
.cards-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 9px; margin-bottom: 10px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  position: relative; overflow: hidden;
  transition: transform .18s;
}

.card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
}

.card-income::before    { background: var(--blue); }
.card-received::before  { background: var(--green); }
.card-bill::before      { background: var(--red); }
.card-paid::before      { background: var(--green); }
.card-pending::before   { background: var(--yellow); }
.card-balance::before,
.card-balance-real::before,
.card-diff::before      { background: var(--purple); }

.card-positive { border-color: rgba(34,197,94,.15); }
.card-negative { border-color: rgba(248,113,113,.15); }

.card-icon {
  width: 32px; height: 32px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem; margin-bottom: 10px;
}

.card-income   .card-icon { background: var(--blue-bg); }
.card-received .card-icon { background: var(--green-bg); }
.card-bill     .card-icon { background: var(--red-bg); }
.card-paid     .card-icon { background: var(--green-bg); }
.card-pending  .card-icon { background: var(--yellow-bg); }
.card-balance  .card-icon,
.card-balance-real .card-icon,
.card-diff     .card-icon { background: var(--purple-bg); }

.card-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); font-weight: 700; margin-bottom: 5px;
}

.card-value {
  font-family: var(--mono); font-size: .95rem; font-weight: 500;
  color: var(--text); word-break: break-all; line-height: 1.2;
}

.card-sub { font-size: .67rem; color: var(--text-faint); margin-top: 3px; }

/* Saldo wide card */
.card-wide {
  grid-column: span 2;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
}
.card-wide .card-value { font-size: 1.15rem; }

/* Quick actions */
.quick-actions {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 9px; margin: 10px 0 4px;
}

.quick-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 13px;
  border-radius: var(--radius); font-size: .86rem; font-weight: 600;
  text-decoration: none; transition: .18s; border: 1px solid transparent;
}

.quick-btn-income {
  background: var(--blue-bg); color: var(--blue-text);
  border-color: rgba(59,130,246,.15);
}
.quick-btn-income:hover { background: rgba(59,130,246,.2); color: var(--blue-text); }

.quick-btn-bill {
  background: var(--red-bg); color: var(--red-text);
  border-color: rgba(248,113,113,.15);
}
.quick-btn-bill:hover { background: rgba(248,113,113,.2); color: var(--red-text); }

/* ==============================
   SUMMARY BAR
   ============================== */
.summary-bar {
  display: flex; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 16px; overflow: hidden;
}

.summary-item {
  flex: 1; padding: 11px 8px; text-align: center;
  border-right: 1px solid var(--border);
}
.summary-item:last-child { border-right: none; }

.summary-label {
  display: block; font-size: .62rem; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted); font-weight: 700; margin-bottom: 5px;
}

.summary-value {
  display: block; font-family: var(--mono); font-size: .8rem; font-weight: 500;
}

/* ==============================
   ITEM LIST
   ============================== */
.list-section { margin-bottom: 16px; }

.list-title {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); margin-bottom: 10px; font-weight: 700;
}

.item-list { display: flex; flex-direction: column; gap: 7px; }

.list-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; overflow: hidden;
  transition: border-color .18s, transform .15s;
}

.list-item:hover { transform: translateX(2px); }
.list-item.item-success { border-color: rgba(34,197,94,.14); }
.list-item.item-danger  { border-color: rgba(248,113,113,.2); background: rgba(69,10,10,.3); }

.item-status-bar { width: 3px; flex-shrink: 0; }
.item-success .item-status-bar { background: var(--green); }
.item-danger  .item-status-bar { background: var(--red); }
.item-pending .item-status-bar { background: var(--yellow); }

.item-content { flex: 1; padding: 12px 14px; min-width: 0; }

.item-main {
  display: flex; justify-content: space-between;
  align-items: flex-start; gap: 8px; margin-bottom: 7px;
}

.item-desc { font-size: .9rem; font-weight: 600; color: var(--text); flex: 1; }

.item-value {
  font-family: var(--mono); font-size: .88rem; font-weight: 500;
  color: var(--text-muted); flex-shrink: 0;
}

.item-meta {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; margin-bottom: 9px;
}

.item-date { font-size: .72rem; color: var(--text-faint); }

.item-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 9px; border-radius: 99px;
  font-size: .68rem; font-weight: 700; letter-spacing: .02em;
}

.badge-success { background: var(--green-bg); color: var(--green-text); }
.badge-warning { background: var(--yellow-bg); color: var(--yellow-text); }
.badge-danger  { background: var(--red-bg);    color: var(--red-text); }

/* ==============================
   EMPTY STATE
   ============================== */
.empty-state {
  text-align: center; padding: 52px 20px; color: var(--text-muted);
}

.empty-icon { font-size: 2.8rem; margin-bottom: 12px; opacity: .35; display: block; }
.empty-state p { font-size: .9rem; margin-bottom: 20px; color: var(--text-muted); }

/* ==============================
   COLORS HELPERS
   ============================== */
.text-danger  { color: var(--red-text); }
.text-success { color: var(--green-text); }
.text-warning { color: var(--yellow-text); }
.text-income  { color: var(--blue-text); }
.text-bill    { color: var(--red-text); }

/* ==============================
   SCROLLBAR
   ============================== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 2px; }

/* ==============================
   ANIMATIONS
   ============================== */
.form-card:not(.hidden) { animation: formIn .22s cubic-bezier(.34,1.4,.64,1); }

@keyframes formIn {
  from { opacity: 0; transform: translateY(-10px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==============================
   RESPONSIVE
   ============================== */
@media (min-width: 560px) {
  .app-shell { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
