/* ── Reset + Variables ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0a0a0f;
  --panel:    #111118;
  --border:   rgba(255,255,255,0.07);
  --text:     #e8e8f0;
  --muted:    #9a9ab0;
  --accent:   #0996d4;
  --positive: #34d399;
  --negative: #f87171;
  --warn:     #fbbf24;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
}

/* ── Header ──────────────────────────────────────────────────── */
header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  gap: 1rem;
}
header h1 { font-size: 1.2rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
.logo-header { height: 28px; width: auto; display: block; }
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.email-badge  { font-size: 0.75rem; color: var(--muted); }
.beta-badge   { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.08em; color: #fff; background: #f59e0b; padding: 0.15rem 0.45rem; border-radius: 4px; vertical-align: middle; display: none; }
#btn-logout {
  background: none; border: 1px solid var(--border); color: var(--muted);
  padding: 0.3rem 0.7rem; border-radius: 4px; cursor: pointer; font-size: 0.75rem;
}
#btn-logout:hover { color: var(--negative); border-color: var(--negative); }

/* ── Tabla ───────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.45rem 0.6rem; white-space: nowrap; }
th {
  background: var(--panel); color: var(--muted); font-weight: 600;
  font-size: 0.75rem; text-transform: uppercase; border-bottom: 1px solid var(--border);
  position: sticky; top: 57px; cursor: pointer; user-select: none;
}
th:hover { color: var(--text); }
td { border-bottom: 1px solid var(--border); }
tr:hover td { background: rgba(124,131,253,.06); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--positive); }
.neg { color: var(--negative); }
.overflow-x { overflow-x: auto; }

/* ── Chips de tipo ───────────────────────────────────────────── */
.chip {
  display: inline-block; padding: 0.1rem 0.4rem; border-radius: 3px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: .3px;
}
.chip-accion  { background: #1e3a5f; color: #60a5fa; }
.chip-etf     { background: #1f3a29; color: #4ade80; }
.chip-fondo   { background: #3a2a1a; color: #fb923c; }
.chip-cartera { background: #2a1a3a; color: #c084fc; }

/* ── Action buttons (tabla) ──────────────────────────────────── */
.action-btn {
  background: none; border: none; cursor: pointer; padding: 0.2rem 0.3rem;
  color: var(--muted); border-radius: 3px; font-size: 0.8rem;
}
.action-btn:hover { color: var(--text); background: var(--border); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge-active   { background: #1f3a29; color: #4ade80; padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.72rem; }
.badge-inactive { background: #3a1a1a; color: #f87171; padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.72rem; }

/* ── Modales ─────────────────────────────────────────────────── */
.modal-bg {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.7); align-items: flex-start; justify-content: center;
  padding: 2rem 1rem; overflow-y: auto;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  width: 100%; max-width: 560px; padding: 1.5rem;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.modal-header h2 { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 1.25rem; cursor: pointer; }
.modal-close:hover { color: var(--negative); }
.modal-footer { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* ── Formularios ─────────────────────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-group { margin-bottom: 0.75rem; }
.form-group label { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 0.25rem; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 5px; color: var(--text); padding: 0.45rem 0.6rem;
  font-size: 0.875rem; outline: none; font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 60px; }
.form-group select option { background: var(--panel); }

/* ── Botones ─────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent); color: #fff; border: none;
  padding: 0.5rem 1.2rem; border-radius: 5px; cursor: pointer; font-weight: 600;
}
.btn-primary:hover { background: #077fb8; }

.btn-secondary {
  background: var(--border); color: var(--muted); border: none;
  padding: 0.5rem 1rem; border-radius: 5px; cursor: pointer;
}

.btn-danger {
  background: #7f1d1d; color: #fca5a5; border: none;
  padding: 0.5rem 1rem; border-radius: 5px; cursor: pointer;
}
.btn-danger:hover { background: #991b1b; }

.btn-cancel {
  background: var(--border); color: var(--muted); border: none;
  border-radius: 5px; padding: 0.5rem 1rem; cursor: pointer;
}

.btn-sm {
  background: var(--accent); color: #fff; border: none;
  border-radius: 4px; padding: 0.35rem 0.8rem; font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.btn-sm:hover { background: #077fb8; }

.btn-sm-danger {
  background: #7f1d1d; color: #fca5a5; border: none;
  border-radius: 4px; padding: 0.35rem 0.8rem; font-size: 0.8rem; cursor: pointer;
}
.btn-sm-danger:hover { background: #991b1b; }

/* ── Toast ───────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 999;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.6rem 1rem; font-size: 0.85rem; pointer-events: none;
  transform: translateY(4rem); opacity: 0; transition: all .3s;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.err  { border-color: var(--negative); color: var(--negative); }

/* ── Loading ─────────────────────────────────────────────────── */
#loading {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(15,17,23,.8);
  display: none; align-items: center; justify-content: center;
}
#loading.active { display: flex; }
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  header h1 { font-size: 1rem; }
  .logo-header { height: 22px; }
}
