/* ============================================================
   Votame — Design System  (v1, refinable con spec UX/UI)
   Seguimiento del voto · Tamaulipas
   ============================================================ */

/* ---- Tokens ---- */
:root {
  /* Marca */
  --ink:        #0B1020;
  --ink-2:      #141a2e;
  --brand:      #4F46E5;
  --brand-600:  #4338CA;
  --brand-700:  #3730A3;
  --brand-tint: #EEF0FE;
  --accent:     #F5A524;   /* energía cívica / marca de voto */
  --accent-600: #D98A12;

  /* Semánticos */
  --ok:    #16A34A;
  --ok-tint:#E7F6EC;
  --warn:  #D97706;
  --err:   #DC2626;
  --err-tint:#FCEBEB;

  /* Neutros */
  --bg:       #F6F7FB;
  --surface:  #FFFFFF;
  --surface-2:#FBFBFE;
  --border:   #E6E8EF;
  --border-2: #D7DAE4;
  --muted:    #6B7280;
  --muted-2:  #9AA1AE;
  --text:     #1B2030;

  /* Tipografía */
  --font-ui: "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-brand: "Sora", var(--font-ui);

  /* Escala / radios / sombras */
  --r-sm: 8px; --r: 12px; --r-lg: 18px; --r-pill: 999px;
  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:24px; --sp-6:32px; --sp-7:48px;
  --sh-1: 0 1px 2px rgba(16,22,40,.06), 0 1px 3px rgba(16,22,40,.04);
  --sh-2: 0 4px 14px rgba(16,22,40,.08);
  --sh-3: 0 18px 50px rgba(16,22,40,.18);
  --t: 160ms cubic-bezier(.2,.6,.2,1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }

/* ---- Wordmark ---- */
.wordmark {
  font-family: var(--font-brand);
  font-weight: 800;
  letter-spacing: -.02em;
  display: inline-flex;
  align-items: center;
  gap: .12em;
  line-height: 1;
  color: var(--ink);
}
.wordmark .vt-a { color: var(--brand); }
.wordmark .vt-mark {
  width: .62em; height: .62em;
  border-radius: 5px;
  background: var(--accent);
  display: inline-grid;
  place-items: center;
  transform: rotate(-8deg);
  box-shadow: 0 2px 6px rgba(245,165,36,.45);
}
.wordmark .vt-mark::after {
  content: "";
  width: .30em; height: .16em;
  border-left: .07em solid #fff;
  border-bottom: .07em solid #fff;
  transform: rotate(-45deg) translateY(-.02em);
}
.wordmark.on-dark { color: #fff; }
.wordmark.on-dark .vt-a { color: #C7C9FF; }

/* ============================================================
   LOGIN  (split screen)
   ============================================================ */
.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
}

/* Panel de marca */
.auth__brand {
  position: relative;
  overflow: hidden;
  color: #fff;
  padding: clamp(28px, 5vw, 64px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(79,70,229,.55), transparent 60%),
    radial-gradient(900px 700px at 110% 120%, rgba(245,165,36,.20), transparent 55%),
    linear-gradient(160deg, var(--ink) 0%, var(--ink-2) 60%, #1c2547 100%);
}
/* patrón cartográfico sutil: malla de secciones */
.auth__brand::before {
  content:"";
  position:absolute; inset:0;
  background-image:
    radial-gradient(rgba(255,255,255,.10) 1.3px, transparent 1.4px),
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 26px 26px, 78px 78px, 78px 78px;
  background-position: 0 0, 0 0, 0 0;
  mask-image: radial-gradient(120% 120% at 30% 20%, #000 40%, transparent 90%);
  pointer-events:none;
}
.auth__brand > * { position: relative; z-index: 1; }
.auth__brand .wordmark { font-size: clamp(30px, 4vw, 44px); }
.brand-hero h1 {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: clamp(28px, 3.4vw, 44px);
  line-height: 1.08;
  letter-spacing: -.02em;
  margin: 0 0 14px;
}
.brand-hero p { color: #C3C8DA; font-size: 17px; max-width: 42ch; margin: 0; }
.brand-tag {
  display:inline-flex; align-items:center; gap:8px;
  font-size: 13px; font-weight: 600; letter-spacing:.02em;
  color:#fff; background: rgba(255,255,255,.10);
  border:1px solid rgba(255,255,255,.16);
  padding: 6px 12px; border-radius: var(--r-pill);
  margin-bottom: 22px;
}
.brand-tag .dot { width:7px; height:7px; border-radius:50%; background: var(--accent); }
.brand-feats { list-style:none; margin: 26px 0 0; padding:0; display:grid; gap:14px; }
.brand-feats li { display:flex; gap:12px; align-items:flex-start; color:#D7DBEA; font-size:15px; }
.brand-feats .ic {
  flex: 0 0 auto; width:26px; height:26px; border-radius:8px;
  background: rgba(255,255,255,.10); display:grid; place-items:center;
  color: var(--accent);
}
.brand-foot { color:#8A90A6; font-size:13px; }

/* Panel de formulario */
.auth__form {
  display:flex; align-items:center; justify-content:center;
  padding: clamp(24px, 5vw, 48px);
  background: var(--surface);
}
.form-card { width:100%; max-width: 400px; }
.form-card h2 {
  font-family: var(--font-brand);
  font-size: 28px; font-weight: 700; letter-spacing:-.02em;
  margin: 0 0 6px;
}
.form-card .sub { color: var(--muted); margin: 0 0 28px; font-size: 15px; }

.field { margin-bottom: 18px; }
.field label { display:block; font-size:13px; font-weight:600; color:#3a4152; margin-bottom:7px; }
.input-wrap { position: relative; }
.input {
  width:100%; height:48px; padding: 0 14px;
  font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border-2);
  border-radius: var(--r-sm);
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
.input::placeholder { color: var(--muted-2); }
.input:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 4px var(--brand-tint);
}
.input.has-toggle { padding-right: 46px; }
.toggle-pw {
  position:absolute; right:6px; top:50%; transform:translateY(-50%);
  width:36px; height:36px; border:0; background:transparent; cursor:pointer;
  color: var(--muted); border-radius:8px; display:grid; place-items:center;
}
.toggle-pw:hover { background: var(--bg); color: var(--text); }

.row-between { display:flex; align-items:center; justify-content:space-between; margin: 4px 0 24px; }
.check { display:inline-flex; align-items:center; gap:8px; font-size:14px; color:#3a4152; cursor:pointer; user-select:none; }
.check input { width:17px; height:17px; accent-color: var(--brand); }

.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  height:48px; padding: 0 20px; width:100%;
  font: inherit; font-weight:700; font-size:15px;
  color:#fff; background: var(--brand);
  border:0; border-radius: var(--r-sm); cursor:pointer;
  transition: background var(--t), transform var(--t), box-shadow var(--t);
  box-shadow: var(--sh-1);
}
.btn:hover { background: var(--brand-600); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity:.7; cursor:progress; }
.btn .spin { width:16px; height:16px; border:2px solid rgba(255,255,255,.4); border-top-color:#fff; border-radius:50%; animation: spin .7s linear infinite; display:none; }
.btn.loading .spin { display:inline-block; }
.btn.loading .label { opacity:.85; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-ghost {
  background: transparent; color: var(--text);
  border: 1.5px solid var(--border-2); box-shadow:none;
}
.btn-ghost:hover { background: var(--bg); }

.form-foot { margin-top: 26px; font-size: 13px; color: var(--muted); text-align:center; }
.alert {
  display:none; align-items:center; gap:10px;
  background: var(--err-tint); color:#9b1c1c;
  border:1px solid #f3c7c7; border-radius: var(--r-sm);
  padding:10px 14px; font-size:14px; margin-bottom:18px;
}
.alert.show { display:flex; }

@media (max-width: 920px) {
  .auth { grid-template-columns: 1fr; }
  .auth__brand {
    min-height: auto;
    padding: 28px 24px 32px;
    flex-direction: column; gap: 18px;
  }
  .brand-hero h1 { font-size: 24px; }
  .brand-feats, .brand-foot { display:none; }
  .auth__form { padding: 32px 22px 48px; }
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app { min-height: 100dvh; display: grid; grid-template-columns: 256px 1fr; grid-template-rows: 60px 1fr; }
.app.collapsed { grid-template-columns: 72px 1fr; }

.topbar {
  grid-column: 1 / -1;
  display:flex; align-items:center; gap:14px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top:0; z-index: 30;
}
.topbar .wordmark { font-size: 22px; }
.icon-btn {
  width:40px; height:40px; border:0; background:transparent; cursor:pointer;
  color: var(--muted); border-radius:10px; display:grid; place-items:center;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.topbar .search {
  margin-left: 8px; flex: 1 1 auto; max-width: 420px;
  height:40px; display:flex; align-items:center; gap:8px;
  padding: 0 12px; background: var(--bg);
  border:1px solid var(--border); border-radius: var(--r-pill);
  color: var(--muted);
}
.topbar .search input { border:0; background:transparent; font:inherit; font-size:14px; width:100%; outline:none; color:var(--text); }
.topbar .spacer { flex:1 1 auto; }
.avatar {
  width:38px; height:38px; border-radius:50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-700));
  color:#fff; display:grid; place-items:center; font-weight:700; font-size:14px;
  cursor:pointer; border:2px solid #fff; box-shadow: var(--sh-1);
}

.sidebar {
  background: var(--ink);
  border-right: 1px solid rgba(255,255,255,.06);
  padding: 14px 12px;
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.nav { list-style:none; margin:0; padding:0; display:grid; gap:3px; }
.nav a {
  position: relative;
  display:flex; align-items:center; gap:12px;
  padding: 11px 12px; border-radius: 10px;
  color: rgba(255,255,255,.66); font-weight:600; font-size:14.5px;
  transition: background var(--t), color var(--t);
  white-space: nowrap; overflow: hidden;
}
.nav a:hover { background: rgba(255,255,255,.08); text-decoration:none; color:#fff; }
.nav a.active { background: rgba(79,70,229,.28); color:#fff; }
.nav a.active::before {
  content:""; position:absolute; left:-12px; top:50%; transform:translateY(-50%);
  width:3px; height:20px; background:var(--accent); border-radius:0 99px 99px 0;
}
.nav a .ic { flex:0 0 auto; width:22px; height:22px; display:grid; place-items:center; opacity:.85; }
.nav .group-label { font-size:11px; font-weight:700; letter-spacing:.1em; text-transform:uppercase; color: rgba(255,255,255,.32); padding: 16px 12px 6px; }
.app.collapsed .nav a .txt, .app.collapsed .nav .group-label, .app.collapsed .sb-foot { display:none; }
.app.collapsed .nav a { justify-content:center; padding:11px 0; }
.app.collapsed .nav a.active::before { left:0; }
.sb-foot { margin-top:auto; padding:12px; border-top:1px solid rgba(255,255,255,.08); }
.sb-user { display:flex; align-items:center; gap:10px; }
.sb-user .av { width:34px;height:34px;border-radius:50%; background:rgba(255,255,255,.12); color:#fff; display:grid;place-items:center; font-weight:700; font-size:13px; flex:0 0 auto; }
.sb-user .nm { font-size:13.5px; font-weight:700; color:rgba(255,255,255,.92); line-height:1.2; }
.sb-user .rl { font-size:11.5px; color:rgba(255,255,255,.45); }

/* bottom-nav móvil */
.bottom-nav { display:none; }
@media (max-width: 860px){
  .bottom-nav {
    display:flex; position:fixed; left:0; right:0; bottom:0; height:62px; z-index:35;
    background:var(--surface); border-top:1px solid var(--border);
    box-shadow:0 -4px 16px rgba(11,16,32,.06);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a {
    flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
    color:var(--muted); font-size:10.5px; font-weight:700; letter-spacing:.02em; text-decoration:none; min-height:44px;
  }
  .bottom-nav a.active { color:var(--brand); }
  .main { padding-bottom: 80px; }
}

.main { padding: clamp(18px, 3vw, 30px); overflow-y:auto; }
.page-head { display:flex; align-items:flex-end; justify-content:space-between; gap:16px; margin-bottom: 22px; flex-wrap:wrap; }
.page-head h1 { font-family: var(--font-brand); font-size: 26px; font-weight:700; letter-spacing:-.02em; margin:0 0 4px; }
.page-head .crumb { color: var(--muted); font-size:14px; }

/* métricas */
.grid-cards { display:grid; grid-template-columns: repeat(4, 1fr); gap:16px; }
.card {
  background: var(--surface); border:1px solid var(--border);
  border-radius: var(--r); padding: 18px; box-shadow: var(--sh-1);
}
.metric .top { display:flex; align-items:center; justify-content:space-between; }
.metric .ic { width:38px; height:38px; border-radius:10px; display:grid; place-items:center; background: var(--brand-tint); color: var(--brand-600); }
.metric .ic.amber { background:#FEF3DD; color: var(--accent-600); }
.metric .ic.green { background: var(--ok-tint); color: var(--ok); }
.metric .ic.violet { background:#F0E9FE; color:#7C3AED; }
.metric .val { font-family: var(--font-brand); font-size: 30px; font-weight:700; letter-spacing:-.02em; margin: 12px 0 2px; }
.metric .lbl { color: var(--muted); font-size: 13.5px; }
.metric .delta { font-size:12.5px; font-weight:700; margin-top:8px; display:inline-flex; gap:5px; align-items:center; }
.delta.up { color: var(--ok); }
.delta.flat { color: var(--muted); }

.cols { display:grid; grid-template-columns: 1.4fr 1fr; gap:16px; margin-top:16px; }
.card h3 { margin:0 0 14px; font-size:15px; font-weight:700; }
.card .card-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.card .card-head h3 { margin:0; }

/* barras avance por sección */
.bars { display:grid; gap:14px; }
.bar-row .bar-top { display:flex; justify-content:space-between; font-size:13.5px; margin-bottom:6px; }
.bar-row .bar-top b { font-weight:700; }
.bar-row .track { height:9px; background: var(--bg); border-radius:99px; overflow:hidden; }
.bar-row .fill { height:100%; border-radius:99px; background: linear-gradient(90deg, var(--brand), #7C75F2); }
.bar-row .fill.amber { background: linear-gradient(90deg, var(--accent), #FFC55C); }
.bar-row .fill.green { background: linear-gradient(90deg, var(--ok), #4ADE80); }

/* mapa placeholder */
.map-card { position:relative; min-height: 300px; padding:0; overflow:hidden; }
.map-ph {
  position:absolute; inset:0;
  background:
    radial-gradient(rgba(79,70,229,.10) 1.5px, transparent 1.6px),
    linear-gradient(rgba(11,16,32,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11,16,32,.05) 1px, transparent 1px),
    linear-gradient(160deg,#fff, #F1F3FB);
  background-size: 22px 22px, 64px 64px, 64px 64px, 100% 100%;
  display:grid; place-items:center; text-align:center;
}
.map-ph .pin { width:42px;height:42px;border-radius:50% 50% 50% 0; background:var(--accent); transform:rotate(-45deg); box-shadow:var(--sh-2); margin:0 auto 14px; position:relative; }
.map-ph .pin::after{content:"";position:absolute;inset:11px;background:#fff;border-radius:50%;}
.map-ph .t { font-family:var(--font-brand); font-weight:700; font-size:16px; }
.map-ph .s { color:var(--muted); font-size:13.5px; margin-top:4px; max-width:34ch; }

/* tabla */
.tbl { width:100%; border-collapse: collapse; font-size:14px; }
.tbl th { text-align:left; color:var(--muted); font-weight:600; font-size:12px; text-transform:uppercase; letter-spacing:.04em; padding:8px 10px; border-bottom:1px solid var(--border); }
.tbl td { padding:11px 10px; border-bottom:1px solid var(--border); }
.tbl tr:last-child td { border-bottom:0; }
.tbl .who { display:flex; align-items:center; gap:10px; font-weight:600; }
.tbl .mini-av { width:30px;height:30px;border-radius:50%; background:var(--brand-tint); color:var(--brand-700); display:grid; place-items:center; font-size:12px; font-weight:700; }
.badge { display:inline-flex; align-items:center; gap:6px; font-size:12px; font-weight:700; padding:4px 10px; border-radius:99px; }
.badge.ok { background:var(--ok-tint); color:#15803d; }
.badge.warn { background:#FEF3DD; color:#b45309; }
.badge.dur { background:var(--brand-tint); color:var(--brand-700); }

/* overlay móvil */
.scrim { display:none; position:fixed; inset:0; background:rgba(11,16,32,.5); z-index:40; }
.scrim.show { display:block; }

@media (max-width: 1100px){ .grid-cards{grid-template-columns:repeat(2,1fr);} .cols{grid-template-columns:1fr;} }
@media (max-width: 860px){
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top:0; left:0; bottom:0; width: 264px; z-index: 50;
    transform: translateX(-100%); transition: transform var(--t); box-shadow: var(--sh-3);
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .topbar .search { display:none; }
  .main { grid-column: 1 / -1; }
}
@media (max-width: 460px){ .grid-cards{grid-template-columns:1fr;} }
