:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273549;
  --border: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* LOGIN */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 24px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.4);
}
.brand-dot {
  width: 14px; height: 14px;
  background: var(--primary);
  border-radius: 50%;
  margin-bottom: 16px;
}
.login-card h1 { font-size: 1.4rem; margin-bottom: 4px; }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }

/* FORMULARIOS */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* BOTONES */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 16px;
  border: none;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
}
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-xs { padding: 4px 8px; font-size: 0.75rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #052e16; }
.btn-warning { background: var(--warning); color: #451a03; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

/* TOPBAR Y NAVEGACIÓN */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.brand-pill {
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}
.user-name { font-weight: 600; font-size: 0.95rem; }
.tc-badge {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 600;
}

.nav-tabs {
  display: flex;
  overflow-x: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  gap: 6px;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 12px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.badge-count {
  background: var(--danger);
  color: #fff;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}

/* LAYOUT Y TARJETAS */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.card-title { font-size: 1rem; font-weight: 700; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.stat-value { font-size: 1.55rem; font-weight: 800; margin-top: 4px; }
.stat-sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }

/* LISTAS MOBILE-FRIENDLY */
.item-list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; font-size: 0.95rem; word-break: break-word; }
.list-item-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 3px; }
.list-item-right { text-align: right; flex-shrink: 0; }
.item-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* BARRA DE PROGRESO (METAS) */
.progress-wrap {
  background: var(--bg);
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
  margin: 10px 0 6px;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  transition: width 0.3s ease;
}

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 0;
}
@media (min-width: 600px) {
  .modal-overlay { align-items: center; padding: 20px; }
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 480px;
  border-radius: 16px 16px 0 0;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
}
@media (min-width: 600px) {
  .modal-box { border-radius: 16px; }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.icon-btn {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.6rem; line-height: 1; cursor: pointer;
}

/* TOAST & ERROR */
.error-msg { color: var(--danger); font-size: 0.85rem; margin-top: 10px; text-align: center; }
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--primary);
  color: #fff;
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 100;
  box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
}
.pill-usd { background: rgba(16,185,129,0.15); color: var(--success); }
.pill-bob { background: rgba(59,130,246,0.15); color: var(--primary); }
.pill-warn { background: rgba(245,158,11,0.15); color: var(--warning); }
.pill-danger { background: rgba(239,68,68,0.15); color: var(--danger); }