/* ============================================================
   Sistema de diseño — Agencia (panel + web pública)
   ============================================================ */
:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev2: #1c2330;
  --card: #161b22;
  --border: #262d3a;
  --text: #e6edf3;
  --text-dim: #9aa7b5;
  --text-faint: #6b7684;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --green: #22c55e;
  --green-dim: #16351f;
  --red: #ef4444;
  --red-dim: #3a1a1c;
  --amber: #f59e0b;
  --amber-dim: #3a2c10;
  --purple: #a855f7;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { 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);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 1rem; }
img { max-width: 100%; display: block; }

/* ---------- Utilidades ---------- */
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.green { color: var(--green); }
.red { color: var(--red); }
.amber { color: var(--amber); }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.hidden { display: none !important; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: var(--radius-sm);
  background: var(--bg-elev2); color: var(--text);
  border: 1px solid var(--border); cursor: pointer;
  font-weight: 600; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); background: var(--red-dim); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 6px 10px; font-size: .85rem; }
.btn-block { width: 100%; }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card + .card { margin-top: 14px; }
.card-title { font-size: .95rem; font-weight: 700; margin-bottom: 12px; display:flex; gap:8px; align-items:center; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 70px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Chips / badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700;
  background: var(--bg-elev2); color: var(--text-dim); border: 1px solid var(--border);
}
.badge.green { background: var(--green-dim); color: #4ade80; border-color: transparent; }
.badge.red { background: var(--red-dim); color: #f87171; border-color: transparent; }
.badge.amber { background: var(--amber-dim); color: #fbbf24; border-color: transparent; }
.badge.blue { background: #14263f; color: #60a5fa; border-color: transparent; }
.badge.purple { background: #2a1740; color: #c084fc; border-color: transparent; }

/* ============================================================
   PANEL
   ============================================================ */
.app { min-height: 100vh; padding-bottom: 84px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: rgba(13,17,23,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.05rem; font-weight: 800; letter-spacing: -.02em; }
.topbar .logo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display:inline-block; margin-right: 8px; }
.container { max-width: 900px; margin: 0 auto; padding: 16px; }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.kpi {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.kpi .kpi-label { font-size: .78rem; color: var(--text-dim); font-weight: 600; display:flex; gap:6px; align-items:center; }
.kpi .kpi-value { font-size: 1.7rem; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.kpi .kpi-sub { font-size: .78rem; color: var(--text-faint); margin-top: 2px; }

/* Listas */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; }
.list-item .li-sub { font-size: .82rem; color: var(--text-dim); }
.list-item .li-amount { font-weight: 800; white-space: nowrap; }
.avatar {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; background: var(--bg-elev2); color: var(--accent);
}

.empty { text-align: center; padding: 34px 16px; color: var(--text-faint); }
.empty .emoji { font-size: 2rem; margin-bottom: 8px; }

.section-head { display:flex; align-items:center; justify-content:space-between; margin: 22px 4px 12px; }
.section-head h2 { font-size: 1.05rem; font-weight: 800; }

/* Navegación inferior */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: rgba(22,27,34,.95); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px; font-size: .68rem; color: var(--text-faint); font-weight: 600;
}
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a svg { width: 22px; height: 22px; }

/* FAB */
.fab {
  position: fixed; right: 18px; bottom: 82px; z-index: 25;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  font-size: 1.8rem; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(59,130,246,.45);
}

/* Modal / hoja inferior */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 560px; background: var(--bg-elev);
  border-radius: 20px 20px 0 0; border: 1px solid var(--border); border-bottom: none;
  padding: 20px; max-height: 92vh; overflow-y: auto;
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: .6 } to { transform: translateY(0); opacity: 1 } }
.sheet-head { display:flex; align-items:center; justify-content:space-between; margin-bottom: 16px; }
.sheet-head h3 { font-size: 1.15rem; font-weight: 800; }
.seg { display:flex; gap:6px; background: var(--bg); padding:5px; border-radius: 12px; margin-bottom: 16px; }
.seg button { flex:1; padding: 9px; border:none; background: transparent; color: var(--text-dim); border-radius: 8px; font-weight:700; cursor:pointer; }
.seg button.active { background: var(--accent); color:#fff; }

.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--green); color: #04210c; padding: 12px 20px; border-radius: 999px;
  font-weight: 700; z-index: 60; box-shadow: var(--shadow); animation: slideUp .2s;
}

@media (min-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .container { padding: 24px 16px; }
}

/* ---------- Pantalla de bloqueo ---------- */
.lock {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(120% 90% at 50% 0%, #1a2233 0%, var(--bg) 60%);
  transition: opacity .3s ease;
}
.lock.is-hidden { opacity: 0; pointer-events: none; }
.lock-card {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 26px; box-shadow: var(--shadow);
}
.lock-logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; margin-bottom: 20px; }
.lock-card h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 6px; }
.lock-card > p { margin-bottom: 20px; }
.lock-card form { display: flex; flex-direction: column; gap: 14px; }
.lock-card input[type=password], .lock-card input[type=email] {
  width: 100%; padding: 13px 14px; text-align: center; font-size: 1.05rem;
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); outline: none; -webkit-appearance: none;
}
.lock-card input[type=password]:focus, .lock-card input[type=email]:focus { border-color: var(--accent); }
.lock-card input::placeholder { color: var(--text-faint); }
.lock-remember {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  font-size: .85rem; color: var(--text-dim); cursor: pointer;
}
.lock-remember input { width: 16px; height: 16px; accent-color: var(--accent); }
.lock-error { color: var(--red); font-size: .88rem; min-height: 1.1em; font-weight: 600; }
.lock-card.shake { animation: shake .4s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-8px); }
  40%,80% { transform: translateX(8px); }
}
