/* ══════════════════════════════════════════════════════════════
   Zello 70 Plus — Dashboard
   Paleta pastel · Sora / Inter / Space Mono
   ══════════════════════════════════════════════════════════════ */

:root {
  /* Superficies */
  --bg:          #F5F3FB;
  --bg-2:        #EEEAF8;
  --surface:     #FFFFFF;
  --surface-2:   #FBFAFE;

  /* Tinta */
  --ink:         #2C2840;
  --ink-soft:    #625C7D;
  --muted:       #A29DBA;

  /* Acento principal (periwinkle) */
  --primary:     #7C6BD9;
  --primary-600: #6B59CE;
  --primary-soft:#B4A9EC;
  --primary-wash:#ECE8FB;

  /* Datos pastel */
  --mint:  #5FCFA6;  --mint-wash:  #E2F6EF;
  --peach: #F3A977;  --peach-wash: #FCEBDD;
  --sky:   #6FB8F2;  --sky-wash:   #E1F0FD;
  --rose:  #EE93BC;  --rose-wash:  #FBE6F0;
  --lilac: #A78BE6;  --lilac-wash: #EDE6FA;

  /* Estados */
  --ok:     #45C08B;
  --warn:   #E9A44B;
  --danger: #E5738A;

  /* Estructura */
  --line:   #E7E1F4;
  --line-2: #F0ECFA;
  --radius: 20px;
  --radius-sm: 13px;
  --shadow-sm: 0 1px 2px rgba(70,54,140,.05), 0 2px 8px rgba(70,54,140,.04);
  --shadow:    0 4px 14px rgba(70,54,140,.07), 0 10px 34px rgba(70,54,140,.06);
  --shadow-lg: 0 12px 40px rgba(70,54,140,.12);

  --font-display: "Sora", system-ui, sans-serif;
  --font-body:    "Inter", system-ui, sans-serif;
  --font-mono:    "Space Mono", ui-monospace, monospace;

  --sidebar-w: 258px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Blobs ambientales (riesgo estético, sutil) ── */
.ambient { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.ambient span {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: .45;
  animation: drift 26s ease-in-out infinite alternate;
}
.ambient .b1 { width: 420px; height: 420px; background: var(--lilac-wash);  top: -120px; left: -80px; }
.ambient .b2 { width: 380px; height: 380px; background: var(--sky-wash);    bottom: -140px; right: -60px; animation-delay: -8s; }
.ambient .b3 { width: 300px; height: 300px; background: var(--rose-wash);   top: 40%; right: 18%; animation-delay: -15s; }
@keyframes drift {
  0%   { transform: translate(0,0) scale(1); }
  100% { transform: translate(40px,-30px) scale(1.12); }
}

/* ══════════════════════════ PRELOADER ══════════════════════════ */
#preloader {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #F7F5FC 0%, #EDE7FA 55%, #F3E9F6 100%);
  transition: opacity .7s ease, visibility .7s ease;
}
#preloader.hidden { opacity: 0; visibility: hidden; }
.pre-brand {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(2rem, 7vw, 3.4rem);
  letter-spacing: -.02em;
  background: linear-gradient(100deg, var(--primary) 0%, var(--rose) 45%, var(--sky) 90%);
  background-size: 220% auto;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: shine 2.4s linear infinite;
}
@keyframes shine { to { background-position: 220% center; } }
.pre-track { margin-top: 22px; width: 148px; height: 4px; border-radius: 99px; background: #E4DBF5; overflow: hidden; }
.pre-track i { display: block; height: 100%; width: 40%; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--rose));
  animation: load 1.15s ease-in-out infinite; }
@keyframes load { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }
.pre-sub { margin-top: 16px; font-size: .74rem; letter-spacing: .28em; text-transform: uppercase; color: var(--muted); }

/* ══════════════════════════ LOGIN ══════════════════════════ */
.auth-wrap {
  position: relative; z-index: 1; min-height: 100vh;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 40px 34px;
  animation: rise .6s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.auth-logo {
  font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; letter-spacing: -.02em;
  text-align: center; color: var(--ink);
}
.auth-logo b {
  background: linear-gradient(100deg, var(--primary), var(--rose));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.auth-tag { text-align: center; color: var(--muted); font-size: .82rem; margin-top: 6px; margin-bottom: 28px; letter-spacing: .02em; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 7px; letter-spacing: .01em; }
.input {
  width: 100%; padding: 13px 15px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); font-family: var(--font-body); font-size: .95rem; color: var(--ink);
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.input:focus { outline: none; border-color: var(--primary-soft); background: #fff; box-shadow: 0 0 0 4px var(--primary-wash); }
.input.code { text-align: center; letter-spacing: .5em; font-family: var(--font-mono); font-size: 1.3rem; padding-left: .5em; }
.btn {
  width: 100%; padding: 13px 18px; border: none; border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--font-body); font-weight: 600; font-size: .95rem; color: #fff;
  background: linear-gradient(100deg, var(--primary), var(--primary-600));
  box-shadow: 0 6px 16px rgba(124,107,217,.32); transition: transform .15s, box-shadow .15s, filter .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(124,107,217,.4); filter: brightness(1.03); }
.btn:active { transform: translateY(0); }
.alert {
  background: var(--rose-wash); border: 1px solid #F4CBDD; color: #B4436A;
  padding: 11px 14px; border-radius: var(--radius-sm); font-size: .84rem; margin-bottom: 18px; text-align: center;
}
.auth-hint { text-align: center; font-size: .76rem; color: var(--muted); margin-top: 20px; }

/* ══════════════════════════ LAYOUT APP ══════════════════════════ */
.app { position: relative; z-index: 1; display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; padding: 26px 18px;
  display: flex; flex-direction: column; gap: 6px;
  background: rgba(255,255,255,.72); backdrop-filter: blur(14px);
  border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 22px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--rose));
  display: grid; place-items: center; color: #fff; font-family: var(--font-display);
  font-weight: 700; font-size: 1.05rem; box-shadow: 0 6px 14px rgba(124,107,217,.35);
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em; line-height: 1.15; }
.brand-name small { display: block; font-family: var(--font-body); font-weight: 500; font-size: .68rem; color: var(--muted); letter-spacing: .04em; }

.nav-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 12px;
  color: var(--ink-soft); text-decoration: none; font-size: .9rem; font-weight: 500;
  transition: background .16s, color .16s; cursor: pointer;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.nav-item:hover { background: var(--primary-wash); color: var(--primary-600); }
.nav-item.active { background: linear-gradient(100deg, var(--primary), var(--primary-600)); color: #fff; box-shadow: 0 6px 14px rgba(124,107,217,.28); }
.nav-item.active svg { opacity: 1; }
.nav-item.soon { opacity: .5; cursor: default; }
.nav-item.soon:hover { background: transparent; color: var(--ink-soft); }
.nav-badge { margin-left: auto; font-size: .6rem; text-transform: uppercase; letter-spacing: .08em; background: var(--bg-2); color: var(--muted); padding: 2px 7px; border-radius: 99px; }

.sidebar-foot { margin-top: auto; padding-top: 18px; }
.logout {
  display: flex; align-items: center; gap: 10px; padding: 11px 13px; border-radius: 12px;
  color: var(--ink-soft); text-decoration: none; font-size: .88rem; font-weight: 500; transition: background .16s, color .16s;
}
.logout:hover { background: var(--rose-wash); color: var(--danger); }
.logout svg { width: 18px; height: 18px; }

/* Contenido */
.main { flex: 1; min-width: 0; padding: 30px 34px 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; gap: 16px; flex-wrap: wrap; }
.page-title { font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; letter-spacing: -.02em; }
.page-title span { color: var(--muted); font-weight: 500; font-size: .95rem; display: block; font-family: var(--font-body); letter-spacing: 0; margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: .8rem; color: var(--ink-soft); box-shadow: var(--shadow-sm); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--mint-wash); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--rose-wash); }
.user-chip { display: inline-flex; align-items: center; gap: 9px; padding: 6px 8px 6px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); font-size: .84rem; font-weight: 500; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--lilac), var(--sky)); color: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 700; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  animation: rise .5s cubic-bezier(.2,.7,.2,1) both;
}
.kpi::after { content: ""; position: absolute; right: -20px; top: -20px; width: 80px; height: 80px; border-radius: 50%; opacity: .5; }
.kpi.i1::after { background: var(--primary-wash); }
.kpi.i2::after { background: var(--mint-wash); }
.kpi.i3::after { background: var(--peach-wash); }
.kpi.i4::after { background: var(--sky-wash); }
.kpi.i5::after { background: var(--rose-wash); }
.kpi.i6::after { background: var(--lilac-wash); }
.kpi-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 14px; position: relative; z-index: 1; }
.kpi-ico svg { width: 20px; height: 20px; }
.i1 .kpi-ico { background: var(--primary-wash); color: var(--primary); }
.i2 .kpi-ico { background: var(--mint-wash); color: #29a074; }
.i3 .kpi-ico { background: var(--peach-wash); color: #cd7a3d; }
.i4 .kpi-ico { background: var(--sky-wash); color: #3a86c9; }
.i5 .kpi-ico { background: var(--rose-wash); color: #c65689; }
.i6 .kpi-ico { background: var(--lilac-wash); color: #7d5fc0; }
.kpi-val { font-family: var(--font-display); font-weight: 700; font-size: 1.9rem; letter-spacing: -.03em; line-height: 1; position: relative; z-index: 1; }
.kpi-label { color: var(--ink-soft); font-size: .82rem; margin-top: 6px; position: relative; z-index: 1; }
.kpi-val.loading { color: var(--muted); }

/* Cards / paneles */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 22px; margin-bottom: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 14px; flex-wrap: wrap; }
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 1.08rem; letter-spacing: -.01em; }
.card-title small { display: block; font-family: var(--font-body); font-weight: 400; color: var(--muted); font-size: .78rem; margin-top: 2px; }

/* Segmented range */
.seg { display: inline-flex; background: var(--bg-2); border-radius: 99px; padding: 4px; gap: 2px; }
.seg button {
  border: none; background: transparent; padding: 7px 15px; border-radius: 99px; cursor: pointer;
  font-family: var(--font-body); font-size: .82rem; font-weight: 600; color: var(--ink-soft); transition: all .16s;
}
.seg button.active { background: var(--surface); color: var(--primary-600); box-shadow: var(--shadow-sm); }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 22px; align-items: start; }

#chart { width: 100%; height: 340px; }
#uniqueChart { width: 100%; height: 220px; }

/* Top usuarios */
.rank { display: flex; align-items: center; gap: 13px; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.rank:last-child { border-bottom: none; }
.rank-pos { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: .8rem; background: var(--bg-2); color: var(--ink-soft); flex-shrink: 0; }
.rank:nth-child(1) .rank-pos { background: linear-gradient(135deg,#F6C97A,#EFA94B); color:#fff; }
.rank:nth-child(2) .rank-pos { background: linear-gradient(135deg,#D5D8E2,#B4BAC9); color:#fff; }
.rank:nth-child(3) .rank-pos { background: linear-gradient(135deg,#E4B896,#D19A6E); color:#fff; }
.rank-info { min-width: 0; flex: 1; }
.rank-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-meta { font-size: .74rem; color: var(--muted); font-family: var(--font-mono); }
.rank-count { font-family: var(--font-display); font-weight: 700; font-size: 1rem; color: var(--primary-600); }
.rank-count small { font-family: var(--font-body); font-weight: 400; font-size: .68rem; color: var(--muted); display: block; text-align: right; }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: .88rem; }

/* Footer firma */
.signature { text-align: center; padding: 26px 0 6px; color: var(--muted); font-size: .82rem; letter-spacing: .02em; }
.signature b { color: var(--ink-soft); font-weight: 600; }
.heart { display: inline-block; color: var(--danger); animation: beat 1.3s ease-in-out infinite; }
@keyframes beat { 0%,100% { transform: scale(1); } 15% { transform: scale(1.28); } 30% { transform: scale(1); } 45% { transform: scale(1.18); } }

/* ── Mobile ── */
.menu-btn { display: none; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); }
.menu-btn svg { width: 20px; height: 20px; color: var(--ink); }
.scrim { display: none; position: fixed; inset: 0; background: rgba(44,40,64,.4); backdrop-filter: blur(2px); z-index: 40; }

@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.2,.7,.2,1); box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; }
  .menu-btn { display: inline-flex; }
  .main { padding: 20px 18px 34px; }
  .page-title { font-size: 1.35rem; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
  .kpi-val { font-size: 1.6rem; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .topbar-right .pill { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .ambient { display: none; }
}
