/* ==========================================================================
   VecinGo — sistema de diseño
   Sin framework: tokens + componentes. Todo el color vive aquí.
   ========================================================================== */

:root {
  --brand-50:  #ecfdf6;
  --brand-100: #d1fae7;
  --brand-200: #a7f3d4;
  --brand-400: #34d399;
  --brand-500: #10b981;
  --brand-600: #059669;
  --brand-700: #047857;
  --brand-900: #064e3b;

  --ink-900: #0b1220;
  --ink-800: #111a2b;
  --ink-700: #1c2740;
  --ink-500: #47546b;
  --ink-400: #6b7a91;
  --ink-300: #97a3b6;
  --ink-200: #d5dce6;
  --ink-100: #eef2f7;
  --ink-50:  #f7f9fc;

  --ok:    #059669;
  --warn:  #d97706;
  --bad:   #dc2626;
  --info:  #2563eb;
  --grape: #7c3aed;

  --bg:        var(--ink-50);
  --surface:   #ffffff;
  --surface-2: var(--ink-100);
  --border:    var(--ink-200);
  --text:      var(--ink-900);
  --text-soft: var(--ink-500);
  --text-mute: var(--ink-400);

  --radius:    14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(11,18,32,.06), 0 1px 3px rgba(11,18,32,.05);
  --shadow-md: 0 4px 6px -1px rgba(11,18,32,.07), 0 10px 24px -6px rgba(11,18,32,.12);
  --shadow-lg: 0 24px 60px -12px rgba(11,18,32,.25);

  --sans: "Segoe UI", Inter, system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #070b13;
    --surface:   #0e1524;
    --surface-2: #16203300;
    --surface-2: #141d2f;
    --border:    #223049;
    --text:      #e8eef7;
    --text-soft: #a4b2c7;
    --text-mute: #7d8ca3;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.45), 0 12px 28px -8px rgba(0,0,0,.6);
    --shadow-lg: 0 24px 60px -12px rgba(0,0,0,.7);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.015em; font-weight: 650; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.18rem; }
h3 { font-size: 1rem; }
p  { margin: 0; }

/* ---------------------------------------------------------------- layout */

.app { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(140deg, var(--brand-400), var(--brand-700));
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 1rem; letter-spacing: -.03em;
  box-shadow: 0 4px 12px -2px rgba(5,150,105,.5);
}
.brand-name { font-weight: 750; font-size: 1.12rem; letter-spacing: -.02em; }
.brand-sub  { font-size: .72rem; color: var(--text-mute); margin-top: -3px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-mute); font-weight: 700; padding: 12px 10px 5px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--text-soft); font-weight: 500; font-size: .9rem;
  text-decoration: none; transition: background .13s, color .13s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--brand-600); color: #fff; font-weight: 600; }
.nav a.active .ico { opacity: 1; }
.ico { width: 18px; text-align: center; opacity: .8; font-size: .95rem; }
.nav .badge-nav {
  margin-left: auto; background: var(--bad); color: #fff;
  font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: 999px;
}
.nav a.active .badge-nav { background: rgba(255,255,255,.25); }

.who {
  margin-top: auto; padding: 12px; border-radius: var(--radius);
  background: var(--surface-2); font-size: .82rem;
}
.who-name { font-weight: 650; }
.who-role { color: var(--text-mute); font-size: .75rem; }

.main { padding: 26px 32px 64px; max-width: 1240px; width: 100%; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.page-head .sub { color: var(--text-soft); font-size: .9rem; margin-top: 3px; }

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }
.card-head {
  padding: 15px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h2 { font-size: 1rem; }

.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }

.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 17px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--accent, var(--brand-500));
}
.stat-label {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-mute); font-weight: 700;
}
.stat-value { font-size: 1.85rem; font-weight: 720; letter-spacing: -.03em; margin-top: 4px; }
.stat-foot  { font-size: .78rem; color: var(--text-soft); margin-top: 2px; }

/* --------------------------------------------------------------- pills */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 650; white-space: nowrap;
  background: var(--surface-2); color: var(--text-soft);
  border: 1px solid var(--border);
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pill.ok    { background: color-mix(in srgb, var(--ok) 13%, transparent);    color: var(--ok);    border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.pill.warn  { background: color-mix(in srgb, var(--warn) 15%, transparent);  color: var(--warn);  border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.pill.bad   { background: color-mix(in srgb, var(--bad) 13%, transparent);   color: var(--bad);   border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.pill.info  { background: color-mix(in srgb, var(--info) 13%, transparent);  color: var(--info);  border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.pill.grape { background: color-mix(in srgb, var(--grape) 13%, transparent); color: var(--grape); border-color: color-mix(in srgb, var(--grape) 30%, transparent); }

/* --------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .885rem; }
thead th {
  text-align: left; font-size: .71rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-mute); font-weight: 700;
  padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .84em; }

/* -------------------------------------------------------------- controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--brand-600); color: #fff;
  font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer;
  transition: background .13s, transform .06s, opacity .13s;
  white-space: nowrap;
}
.btn:hover  { background: var(--brand-700); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text-soft); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #b91c1c; }
.btn.sm { padding: 5px 11px; font-size: .8rem; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field label { font-size: .8rem; font-weight: 620; color: var(--text-soft); }
.field .hint { font-size: .74rem; color: var(--text-mute); }
input, select, textarea {
  font: inherit; font-size: .89rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px; width: 100%;
  transition: border-color .13s, box-shadow .13s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 20%, transparent);
}
textarea { resize: vertical; min-height: 82px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
@media (max-width: 620px) { .row-2 { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------- alerts */

.alert {
  padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: .87rem; margin-bottom: 14px; border: 1px solid;
  display: flex; gap: 9px; align-items: flex-start;
}
.alert.err  { background: color-mix(in srgb, var(--bad) 9%, transparent);  color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 28%, transparent); }
.alert.ok   { background: color-mix(in srgb, var(--ok) 10%, transparent);  color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.alert.info { background: color-mix(in srgb, var(--info) 9%, transparent); color: var(--info); border-color: color-mix(in srgb, var(--info) 28%, transparent); }

.empty { padding: 42px 20px; text-align: center; color: var(--text-mute); }
.empty .big { font-size: 2rem; opacity: .35; margin-bottom: 6px; }

/* ---------------------------------------------------------------- meter */

.meter { height: 9px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--brand-500); transition: width .4s ease; }
.meter.is-ok  > span { background: var(--ok); }
.meter.is-bad > span { background: var(--bad); }

.quorum-num { font-size: 2.4rem; font-weight: 730; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- login */

.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1100px 520px at 12% -10%, color-mix(in srgb, var(--brand-500) 17%, transparent), transparent 60%),
    radial-gradient(900px 480px at 92% 108%, color-mix(in srgb, var(--info) 15%, transparent), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 404px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 32px 30px; box-shadow: var(--shadow-lg);
}
.login-card .brand { justify-content: center; margin-bottom: 6px; padding: 0; }
.login-title { text-align: center; margin-bottom: 3px; }
.login-sub { text-align: center; color: var(--text-soft); font-size: .87rem; margin-bottom: 22px; }

/* --------------------------------------------------------------- misc */

.toolbar { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 15px; }
.toolbar .grow { flex: 1; min-width: 170px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.inline { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-mute); }
.soft  { color: var(--text-soft); }
.tiny  { font-size: .78rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.modal-back {
  position: fixed; inset: 0; background: rgba(6,10,18,.55);
  display: grid; place-items: center; padding: 22px; z-index: 60;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 540px; max-height: 88vh; overflow-y: auto;
}
.modal .card-head { position: sticky; top: 0; background: var(--surface); border-radius: 18px 18px 0 0; }

.spinner {
  width: 17px; height: 17px; border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor; border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading { padding: 46px; text-align: center; color: var(--text-mute); }

.login-foot { text-align: center; margin-top: 18px; font-size: .78rem; color: var(--text-mute); }
.who .btn { margin-top: 9px; }

/* toasts */
.toast-box {
  position: fixed; right: 18px; bottom: 18px; z-index: 90;
  display: flex; flex-direction: column; gap: 9px;
  max-width: min(400px, calc(100vw - 36px));
}
.toast {
  margin: 0; box-shadow: var(--shadow-md);
  background: var(--surface); animation: toast-in .22s ease;
}
.toast.ok  { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.toast.err { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* checkbox inline */
.field input[type="checkbox"] { width: auto; margin-right: 7px; vertical-align: middle; }

.gate-input {
  font-size: 1.5rem; font-family: var(--mono); text-align: center;
  letter-spacing: .06em; padding: 15px;
}

.vote-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.vote-btn {
  padding: 16px 10px; border-radius: var(--radius); border: 2px solid var(--border);
  background: var(--surface); cursor: pointer; font: inherit; font-weight: 680;
  font-size: .95rem; transition: all .14s; color: var(--text);
}
.vote-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.vote-btn.si  { border-color: color-mix(in srgb, var(--ok) 45%, transparent);  color: var(--ok); }
.vote-btn.no  { border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad); }
.vote-btn.abs { border-color: var(--border); color: var(--text-soft); }
.vote-btn.si:hover  { background: color-mix(in srgb, var(--ok) 11%, transparent); }
.vote-btn.no:hover  { background: color-mix(in srgb, var(--bad) 11%, transparent); }
.vote-btn.abs:hover { background: var(--surface-2); }

.topbar-mobile { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0; width: 256px;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .topbar-mobile {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 15px; border-bottom: 1px solid var(--border);
    background: var(--surface); position: sticky; top: 0; z-index: 40;
  }
  .main { padding: 18px 15px 60px; }
  .grid-stats { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); }
}
