:root {
  --bg: #f2f4f8;
  --bg-2: #e9ecf3;
  --card: #ffffff;
  --card-strong: #ffffff;
  --border: #e6e8f0;
  --border-strong: #d8dbe6;
  --text: #1c2130;
  --muted: #6b7280;
  --muted-2: #98a0b3;
  --indigo: #6366f1;
  --violet: #8b5cf6;
  --cyan: #0891b2;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --gray: #9ca3af;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  --grad-soft: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.08));
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 28px -12px rgba(16, 24, 40, 0.14);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --glow: 0 0 0 4px rgba(99, 102, 241, 0.14);
  --radius: 16px;
  --radius-sm: 11px;
  --sidebar-w: 248px;
  --font: "Inter", system-ui, sans-serif;
  --font-display: "Space Grotesk", "Inter", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

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

::selection { background: rgba(99, 102, 241, 0.25); color: #1c2130; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.14); border-radius: 20px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.24); }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ---------- Fondo / login oscuro ---------- */
.bg-scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; display: none; }
body.login-page-body .bg-scene { display: block; }
#bg3d { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.55; }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5; animation: drift 22s ease-in-out infinite alternate; }
.blob-1 { width: 520px; height: 520px; background: radial-gradient(circle, rgba(99,102,241,.55), transparent 70%); top: -160px; left: -120px; }
.blob-2 { width: 460px; height: 460px; background: radial-gradient(circle, rgba(34,211,238,.4), transparent 70%); bottom: -140px; right: -100px; animation-delay: -8s; }
.blob-3 { width: 380px; height: 380px; background: radial-gradient(circle, rgba(139,92,246,.45), transparent 70%); top: 55%; left: 38%; animation-delay: -16s; }
@keyframes drift { 0% { transform: translate3d(0,0,0) scale(1); } 100% { transform: translate3d(40px,-30px,0) scale(1.12); } }

/* ---------- Login (tema oscuro dedicado) ---------- */
body.login-page-body {
  --bg: #05070f;
  --card: rgba(255,255,255,.045);
  --border: rgba(255,255,255,.09);
  --border-strong: rgba(255,255,255,.16);
  --text: #eef2ff;
  --muted: #94a0c4;
  --muted-2: #6d769c;
  --shadow: 0 24px 60px rgba(2,4,12,.6);
  background: var(--bg);
  color: var(--text);
}
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; position: relative; z-index: 1; }
.login-wrap { display: flex; flex-direction: column; align-items: center; gap: 28px; width: 100%; max-width: 420px; }
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand img { width: 52px; height: 52px; border-radius: 14px; filter: drop-shadow(0 10px 30px rgba(99,102,241,.5)); }
.login-brand h1 { font-family: var(--font-display); font-size: 20px; line-height: 1.15; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 700; }
.login-brand span { display: block; font-family: var(--font); font-size: 13px; color: var(--muted); background: none; -webkit-background-clip: initial; background-clip: initial; }

.login-card {
  width: 100%;
  background: linear-gradient(160deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 34px 30px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  animation: cardIn .7s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(22px) scale(.97); } to { opacity: 1; transform: none; } }
.login-card h2 { font-family: var(--font-display); font-size: 22px; margin-bottom: 4px; }
.login-card > p { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 7px; letter-spacing: .3px; text-transform: uppercase; }
.input-shell { position: relative; }
.input-shell svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted-2); }
.input {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  color: var(--text);
  padding: 11px 14px;
  font-size: 14.5px;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
body.login-page-body .input { background: rgba(255,255,255,.05); padding-left: 42px; }
.input:focus { border-color: var(--indigo); box-shadow: var(--glow); }
.input::placeholder { color: var(--muted-2); }

.login-error {
  display: flex; align-items: center; gap: 10px;
  background: rgba(248,113,113,.12); border: 1px solid rgba(248,113,113,.35); color: #fecaca;
  padding: 11px 14px; border-radius: 12px; font-size: 13.5px; margin-bottom: 16px;
}
.login-error svg { width: 18px; height: 18px; flex: none; }
.login-note { text-align: center; color: var(--muted-2); font-size: 12.5px; margin-top: 4px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--radius-sm);
  padding: 11px 18px; font-size: 14px; font-weight: 600;
  color: #fff; background: var(--grad); background-size: 160% 160%;
  transition: background-position .3s, transform .15s, box-shadow .2s, opacity .2s;
  box-shadow: 0 8px 20px -8px rgba(99,102,241,.5);
  white-space: nowrap;
}
.btn:hover { background-position: 100% 50%; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn svg { width: 17px; height: 17px; }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 9px; }
.btn-ghost { background: #fff; color: var(--text); box-shadow: none; border: 1px solid var(--border-strong); }
.btn-ghost:hover { background: var(--bg-2); }
.btn-card { background: #fff; border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm); color: var(--text); }
.btn-card:hover { background: var(--bg-2); }
.btn-ok, .btn-success { background: linear-gradient(135deg, #10b981, #34d399); box-shadow: 0 8px 20px -8px rgba(16,185,129,.5); }
.btn-warn { background: linear-gradient(135deg, #f59e0b, #fbbf24); color: #201400; box-shadow: 0 8px 20px -8px rgba(245,158,11,.5); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #f87171); box-shadow: 0 8px 20px -8px rgba(239,68,68,.5); }
.btn-primary { background: var(--grad); }
.btn-export { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 8px 20px -8px rgba(16,185,129,.5); }

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

.sidebar {
  position: fixed; inset: 12px auto 12px 12px; width: var(--sidebar-w);
  background: #fff; border: 1px solid var(--border); border-radius: 20px;
  display: flex; flex-direction: column; padding: 16px 12px;
  box-shadow: var(--shadow); z-index: 60;
  transition: transform .32s cubic-bezier(.2,.8,.2,1);
}
.sidebar__brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 16px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.sidebar__brand img { width: 38px; height: 38px; border-radius: 11px; }
.sidebar__brand b { font-family: var(--font-display); font-size: 14.5px; display: block; line-height: 1.1; color: var(--text); }
.sidebar__brand span { font-size: 11px; color: var(--muted); }

.sidebar__nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px;
  color: var(--muted); font-size: 13.5px; font-weight: 500; transition: all .2s; position: relative;
}
.nav-link svg { width: 18px; height: 18px; flex: none; }
.nav-link:hover { color: var(--text); background: var(--bg-2); }
.nav-link.active { color: var(--indigo); background: rgba(99,102,241,.1); font-weight: 700; }
.nav-section { font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted-2); padding: 12px 10px 4px; font-weight: 700; }

.sidebar__user {
  margin-top: 12px; padding: 10px; border-radius: 13px; background: var(--bg-2);
  border: 1px solid var(--border); display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff;
  background: var(--grad); box-shadow: 0 4px 12px -3px rgba(99,102,241,.6);
}
.sidebar__user .who { min-width: 0; }
.sidebar__user .who b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.sidebar__user .who span { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.sidebar__user .logout { margin-left: auto; color: var(--muted); width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; transition: all .2s; }
.sidebar__user .logout:hover { color: var(--red); background: rgba(239,68,68,.1); }
.sidebar__user .logout svg { width: 16px; height: 16px; }

.main { flex: 1; margin-left: calc(var(--sidebar-w) + 12px); padding: 20px 26px 40px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 4px 0; }
.topbar h2 { font-family: var(--font-display); font-size: 21px; font-weight: 700; }
.topbar p.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.burger { display: none; width: 40px; height: 40px; border-radius: 11px; background: #fff; border: 1px solid var(--border-strong); color: var(--text); place-items: center; flex: none; }
.burger svg { width: 19px; height: 19px; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.sync-chip {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--green);
  background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.25); padding: 7px 13px; border-radius: 30px;
}
.sync-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); animation: pulse 2.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .5; transform: scale(.8);} }

.backlink { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.backlink:hover { color: var(--text); }
.backlink svg { width: 16px; height: 16px; }

/* ---------- Cards ---------- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.tilt { transition: box-shadow .25s ease; }
.tilt:hover { box-shadow: var(--shadow); }

.stat { display: flex; flex-direction: column; gap: 10px; }
.stat__head { display: flex; align-items: center; justify-content: space-between; }
.stat__label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase; }
.stat__icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; }
.stat__icon svg { width: 19px; height: 19px; }
.stat__icon.i1 { background: linear-gradient(135deg,#6366f1,#8b5cf6); }
.stat__icon.i2 { background: linear-gradient(135deg,#8b5cf6,#d946ef); }
.stat__icon.i3 { background: linear-gradient(135deg,#06b6d4,#3b82f6); }
.stat__icon.i4 { background: linear-gradient(135deg,#10b981,#059669); }
.stat__icon.i5 { background: linear-gradient(135deg,#f59e0b,#d97706); }
.stat__value { font-family: var(--font-display); font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: -.5px; }
.stat__value small { font-size: 15px; color: var(--muted); font-weight: 600; }
.stat__foot { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.stat__foot svg { width: 13px; height: 13px; }
.stat__foot.up { color: var(--green); }
.stat__foot.warn { color: var(--amber); }

/* ---------- Progress ---------- */
.progress { height: 9px; border-radius: 20px; background: var(--bg-2); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 20px; background: linear-gradient(90deg, #10b981, #34d399); transition: width .6s cubic-bezier(.2,.8,.2,1); }

.ring { position: relative; width: 110px; height: 110px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-track { fill: none; stroke: var(--bg-2); stroke-width: 10; }
.ring .ring-bar { fill: none; stroke: url(#ringGrad); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .8s cubic-bezier(.2,.8,.2,1); }
.ring .ring-num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 22px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; padding: 5px 11px; border-radius: 30px; letter-spacing: .2px; }
.badge svg { width: 12px; height: 12px; }
.badge-admin { background: rgba(139,92,246,.1); color: #7c3aed; border: 1px solid rgba(139,92,246,.3); }
.badge-digitador { background: rgba(6,182,212,.1); color: #0e7490; border: 1px solid rgba(6,182,212,.3); }
.badge-on { background: rgba(16,185,129,.1); color: #047857; border: 1px solid rgba(16,185,129,.3); }
.badge-off { background: rgba(107,114,128,.1); color: #4b5563; border: 1px solid rgba(107,114,128,.25); }
.badge-urbana { background: rgba(59,130,246,.1); color: #1d4ed8; border: 1px solid rgba(59,130,246,.3); }
.badge-rural { background: rgba(16,185,129,.1); color: #047857; border: 1px solid rgba(16,185,129,.3); }
.badge-danger { background: rgba(239,68,68,.1); color: #b91c1c; border: 1px solid rgba(239,68,68,.3); }
.badge-chip { background: var(--bg-2); border: 1px solid var(--border-strong); color: var(--text); }

/* ---------- Panel / headers ---------- */
.panel { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.panel-info { flex: 1; min-width: 240px; }
.panel-info h3 { font-family: var(--font-display); font-size: 18px; margin-bottom: 4px; }
.panel-info .addr { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.panel-info .addr svg { width: 14px; height: 14px; }
.panel-chips { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.chip-stat { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 9px 14px; min-width: 92px; }
.chip-stat b { font-family: var(--font-display); font-size: 17px; display: block; }
.chip-stat span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* ---------- Toolbar / filtros ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 380px; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted-2); }
.search input { padding-left: 38px; }
.seg { display: inline-flex; gap: 3px; padding: 4px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 11px; }
.seg button, .seg a { border: none; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 7px 13px; border-radius: 8px; transition: all .2s; display: inline-block; }
.seg button:hover, .seg a:hover { color: var(--text); }
.seg button.on, .seg a.on { color: var(--indigo); background: #fff; box-shadow: var(--shadow-sm); }

.input-select { width: auto; min-width: 140px; padding-left: 14px; }
.input-sm { padding: 7px 12px; font-size: 12.5px; }
select.input { color: var(--text); background: #fff; }
textarea.input { padding: 11px 14px; min-height: 90px; resize: vertical; }

/* ---------- Estado (4 estados del checklist) ---------- */
.st-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .2px; padding: 5px 11px; border-radius: 30px; white-space: nowrap; }
.st-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.st-pendiente { background: rgba(156,163,175,.14); color: #4b5563; border: 1px solid rgba(156,163,175,.35); }
.st-foto-recibida { background: rgba(245,158,11,.13); color: #b45309; border: 1px solid rgba(245,158,11,.35); }
.st-observada { background: rgba(239,68,68,.12); color: #b91c1c; border: 1px solid rgba(239,68,68,.35); }
.st-procesada { background: rgba(16,185,129,.13); color: #047857; border: 1px solid rgba(16,185,129,.35); }

/* Select de estado, editable en línea */
.estado-select {
  appearance: none; -webkit-appearance: none;
  font-size: 12.5px; font-weight: 700; letter-spacing: .2px;
  padding: 7px 30px 7px 14px; border-radius: 30px; cursor: pointer;
  border: 1.5px solid var(--border-strong); background-color: #fff; color: var(--text);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.4' stroke-linecap='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 13px;
  transition: box-shadow .2s, border-color .2s;
}
.estado-select:focus { outline: none; box-shadow: var(--glow); }
.estado-select:disabled { cursor: not-allowed; opacity: .75; background-image: none; padding-right: 14px; }
.estado-select.es-pendiente { border-color: rgba(156,163,175,.5); color: #4b5563; background-color: rgba(156,163,175,.1); }
.estado-select.es-foto-recibida { border-color: rgba(245,158,11,.5); color: #b45309; background-color: rgba(245,158,11,.1); }
.estado-select.es-observada { border-color: rgba(239,68,68,.5); color: #b91c1c; background-color: rgba(239,68,68,.1); }
.estado-select.es-procesada { border-color: rgba(16,185,129,.5); color: #047857; background-color: rgba(16,185,129,.1); }

.lock-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #047857; background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); padding: 7px 13px; border-radius: 30px; }
.lock-chip svg { width: 13px; height: 13px; }

/* ---------- Grid de locales / mesas ---------- */
.local-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.mesa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }

.local-card { display: flex; flex-direction: column; gap: 12px; }
.local-card__top { display: flex; align-items: flex-start; gap: 12px; }
.local-card__top .avatar-lg { width: 44px; height: 44px; border-radius: 13px; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; background: var(--grad); }
.local-card__top h4 { font-family: var(--font-display); font-size: 15px; line-height: 1.25; }
.local-card__top p { color: var(--muted); font-size: 12px; margin-top: 2px; }
.local-card__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.local-card__stats div { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px; text-align: center; }
.local-card__stats b { font-size: 15px; display: block; }
.local-card__stats span { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.local-card__foot { display: flex; align-items: center; gap: 12px; }
.local-card__foot .progress { flex: 1; }
.local-card__foot .pct { font-family: var(--font-display); font-weight: 700; font-size: 13px; }

.mesa-card {
  display: flex; flex-direction: column; gap: 11px; padding: 16px; border-radius: 15px;
  background: #fff; border: 1px solid var(--border); position: relative; overflow: hidden; transition: all .2s;
}
.mesa-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.mesa-card::after { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--gray); }
.mesa-card.m-pendiente::after { background: var(--gray); }
.mesa-card.m-foto-recibida::after { background: var(--amber); }
.mesa-card.m-observada::after { background: var(--red); }
.mesa-card.m-procesada::after { background: var(--green); }

.mesa-card__head { display: flex; align-items: center; gap: 10px; }
.mesa-num { font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.mesa-card__head .badge, .mesa-card__head .st-chip { margin-left: auto; }
.mesa-card__meta { display: flex; gap: 12px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.mesa-card__meta span { display: inline-flex; gap: 5px; align-items: center; }
.mesa-card__meta svg { width: 13px; height: 13px; }
.mesa-card__obs { font-size: 12.5px; color: #b91c1c; background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.22); padding: 8px 11px; border-radius: 10px; }
.mesa-actions { display: flex; gap: 7px; margin-top: auto; flex-wrap: wrap; }
.mesa-actions .btn { flex: 1; font-size: 12px; padding: 8px 6px; }

.empty { grid-column: 1 / -1; text-align: center; padding: 50px 20px; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty svg { width: 38px; height: 38px; margin-bottom: 10px; opacity: .45; }

/* ---------- Chart cards ---------- */
.chart-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; }
.chart-card h3 { font-family: var(--font-display); font-size: 15px; margin-bottom: 4px; }
.chart-card > p { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }

/* ---------- Tabla ---------- */
.table-wrap { overflow-x: auto; border-radius: 13px; border: 1px solid var(--border); }
table.tbl { width: 100%; border-collapse: collapse; min-width: 640px; }
.tbl thead { background: var(--bg-2); }
.tbl th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted-2); font-weight: 700; padding: 11px 14px; }
.tbl td { padding: 12px 14px; border-top: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
.tbl tbody tr:hover td { background: var(--bg-2); }
.tbl .actions-cell { display: flex; gap: 8px; justify-content: flex-end; }
.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user .avatar { width: 32px; height: 32px; font-size: 11px; }
.cell-user b { display: block; font-size: 13px; }
.cell-user span { font-size: 11.5px; color: var(--muted); }
.cell-mesa b { display: block; font-size: 13.5px; }
.cell-mesa span { font-size: 12px; color: var(--muted); }
.cell-obs { color: var(--muted); font-size: 12.5px; max-width: 260px; }
.cell-obs.is-obs { color: #b91c1c; }
.cell-time { font-family: var(--font-display); font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.switch { position: relative; width: 42px; height: 23px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; border-radius: 30px; background: var(--border-strong); transition: all .25s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: all .25s; }
.switch input:checked + .track { background: rgba(16,185,129,.5); }
.switch input:checked + .track::after { transform: translateX(19px); background: var(--green); }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(28,33,48,.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity .25s; }
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal { width: 100%; max-width: 460px; background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 26px; box-shadow: 0 30px 70px -20px rgba(16,24,40,.35); transform: translateY(18px) scale(.97); transition: transform .28s cubic-bezier(.2,.8,.2,1); max-height: 90vh; overflow-y: auto; }
.modal-overlay.open .modal { transform: none; }
.modal h3 { font-family: var(--font-display); font-size: 18px; margin-bottom: 4px; }
.modal > p { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.modal__close { position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--bg-2); color: var(--muted); display: grid; place-items: center; }
.modal__close:hover { color: var(--text); }
.modal__close svg { width: 16px; height: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.modal-lg { max-width: 620px; }

/* ---------- Toast ---------- */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; align-items: center; gap: 11px; background: #1c2130; color: #fff; border-radius: 13px; padding: 12px 16px; box-shadow: 0 20px 45px -14px rgba(16,24,40,.5); animation: toastIn .35s cubic-bezier(.2,.8,.2,1) both; font-size: 13.5px; font-weight: 500; max-width: 360px; }
.toast.out { animation: toastOut .3s ease both; }
.toast.success .toast__ic { color: #34d399; }
.toast.error .toast__ic { color: #f87171; }
.toast__ic { flex: none; display: grid; place-items: center; }
.toast__ic svg { width: 19px; height: 19px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.95);} to { opacity: 1; transform: none;} }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.95);} }

.flash-zone { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Errores ---------- */
.error-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; position: relative; z-index: 1; text-align: center; }
.error-card { max-width: 460px; padding: 44px 34px; }
.error-card .code { font-family: var(--font-display); font-size: 70px; font-weight: 700; line-height: 1; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.error-card h2 { font-family: var(--font-display); font-size: 20px; margin: 10px 0 8px; }
.error-card p { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .main { margin-left: 0; padding: 16px 16px 36px; }
  .sidebar { transform: translateX(calc(-100% - 24px)); top: 8px; bottom: 8px; left: 8px; }
  .sidebar.open { transform: none; }
  .burger { display: grid; }
  .topbar { flex-wrap: wrap; }
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .cards-grid { grid-template-columns: 1fr 1fr; }
  .stat__value { font-size: 24px; }
  .toolbar { align-items: stretch; }
  .search { max-width: none; }
}
@media (max-width: 420px) {
  .cards-grid { grid-template-columns: 1fr; }
  .login-card { padding: 26px 20px; }
}

/* ---------- Utilidades ---------- */
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.mt-4 { margin-top: 16px; }
.mt-3 { margin-top: 12px; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.flex-1 { flex: 1; min-width: 0; }
.mono { font-family: "Space Grotesk", monospace; letter-spacing: .3px; }
.hide { display: none !important; }
[data-filter-group] .is-hidden, [data-search-group] .is-hidden { display: none !important; }
.fade-up { animation: fadeUp .5s cubic-bezier(.2,.8,.2,1) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ============================================================
   BANDEJA · Tarjetas de estado (checklist de 4 estados)
   ============================================================ */
.status-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; color: #047857; background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); padding: 7px 14px; border-radius: 30px; }
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); animation: pulse 2.4s infinite; }

.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat-tile { background: #fff; border: 1px solid var(--border); border-radius: 15px; padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat-tile__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stat-tile__label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat-tile__dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.stat-tile__dot.gray { background: var(--gray); }
.stat-tile__dot.amber { background: var(--amber); }
.stat-tile__dot.red { background: var(--red); }
.stat-tile__dot.green { background: var(--green); }
.stat-tile__value { font-family: var(--font-display); font-size: 30px; font-weight: 700; line-height: 1; }

.progress-card { display: flex; flex-direction: column; gap: 10px; }
.progress-card__head { display: flex; align-items: center; justify-content: space-between; }
.progress-card__head b { font-size: 14px; font-weight: 700; }
.progress-card__head span { font-size: 13px; font-weight: 700; color: var(--green); }

.digitador-select { display: flex; align-items: center; gap: 10px; }
.digitador-select label { font-size: 12.5px; font-weight: 600; color: var(--muted); }

/* ---------- Tarjeta de digitador (dashboard admin) ---------- */
.dig-row { display: flex; align-items: center; gap: 14px; padding: 13px 14px; border-radius: 13px; border: 1px solid var(--border); background: #fff; }
.dig-row + .dig-row { margin-top: 8px; }
.dig-row .avatar { width: 38px; height: 38px; font-size: 13px; }
.dig-row__info { flex: 1; min-width: 0; }
.dig-row__info b { display: block; font-size: 13.5px; }
.dig-row__info span { font-size: 11.5px; color: var(--muted); }
.dig-row__progress { width: 140px; flex: none; }
.dig-row__progress .progress { margin-bottom: 4px; }
.dig-row__progress span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.dig-row__pct { font-family: var(--font-display); font-weight: 700; font-size: 15px; width: 46px; text-align: right; flex: none; }

.note { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); padding: 12px 14px; border-radius: 12px; background: rgba(99,102,241,.06); border: 1px solid rgba(99,102,241,.18); }
.note svg { width: 16px; height: 16px; flex: none; color: var(--violet); }

.empty-small { padding: 16px; color: var(--muted); font-size: 13px; border: 1px dashed var(--border-strong); border-radius: 12px; text-align: center; margin-top: 8px; }

/* ---------- Trazabilidad ---------- */
.sec-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted-2); font-weight: 700; margin: 18px 0 10px; }
.timeline { display: flex; flex-direction: column; gap: 0; max-height: 300px; overflow-y: auto; padding-right: 6px; }
.tl-item { display: flex; gap: 12px; position: relative; padding-bottom: 16px; }
.tl-item::before { content: ""; position: absolute; left: 5px; top: 16px; bottom: 2px; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; margin-top: 4px; background: var(--grad); box-shadow: 0 0 8px rgba(99,102,241,.4); }
.tl-body p { font-size: 13.5px; line-height: 1.4; }
.tl-body span { font-size: 11.5px; color: var(--muted-2); }
.t-line-loading, .tl-empty { color: var(--muted); font-size: 13px; padding: 10px 0; }

.obs-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--bg-2); }
.obs-card + .obs-card { margin-top: 8px; }
.obs-card p { font-size: 13.5px; margin-top: 8px; }
.obs-card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.obs-card.resuelta { border-color: rgba(16,185,129,.35); background: rgba(16,185,129,.05); }

.asignar-bar { display: flex; gap: 8px; align-items: center; }
.ck { width: 17px; height: 17px; accent-color: #6366f1; flex: none; cursor: pointer; }
.ck-wrap { display: grid; place-items: center; }

/* ============================================================
   AVANCE POR LOCAL · gráfica de barras apiladas (dashboard)
   ============================================================ */
.local-summary__line { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.local-summary__line b { font-family: var(--font-display); font-size: 16px; }

.legend-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.legend-row span { display: inline-flex; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; flex: none; }
.dot.procesada, .local-bar__seg.procesada { background: var(--green); }
.dot.foto, .local-bar__seg.foto { background: var(--amber); }
.dot.observada, .local-bar__seg.observada { background: var(--red); }
.dot.pendiente, .local-bar__seg.pendiente { background: var(--gray); }

.local-avance-list { display: flex; flex-direction: column; }
.local-avance-row {
  display: block; padding: 12px 6px; border-bottom: 1px solid var(--border);
  color: inherit; transition: background .15s; border-radius: 10px;
}
.local-avance-row:hover { background: var(--bg-2); }
.local-avance-row:last-child { border-bottom: none; }
.local-avance-row.is-hidden { display: none; }
.local-avance-row__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.local-avance-row__head b { font-size: 13.5px; display: block; line-height: 1.3; }
.local-avance-row__pct { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--green); flex: none; }
.local-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--bg-2); }
.local-bar__seg { height: 100%; }
.local-avance-row__counts { display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); margin-top: 7px; flex-wrap: wrap; }
