@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #08090c;
  --surface: #12141a;
  --surface-2: #1a1d26;
  --border: #262a35;
  --text: #eef1f6;
  --text-dim: #9aa3b2;
  --brand: #2f4be6;          /* azul TAPIT */
  --brand-bright: #3d5bff;
  --star: #f5b301;
  --wa: #25d366;
  --danger: #ff6b6b;
  --radius: 14px;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--text-dim); font-weight: 400; }
a { color: var(--brand-bright); }

/* ---------- Logo TAPIT (texto) ---------- */
.brand { display: inline-flex; flex-direction: column; line-height: 1; }
.brand-word {
  font-weight: 800; letter-spacing: -.02em; color: #fff;
}
.brand-accent { color: var(--brand-bright); }
.brand-by {
  font-weight: 400; color: var(--text-dim); letter-spacing: .02em;
  margin-top: .35em;
}
.brand-by b { color: var(--text); font-weight: 700; }
.brand-lg .brand-word { font-size: 72px; }
.brand-lg .brand-by  { font-size: 15px; }
.brand-md .brand-word { font-size: 42px; }
.brand-md .brand-by  { font-size: 11px; }
.brand-sm .brand-word { font-size: 24px; }

/* ---------- Splash ---------- */
.splash {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: var(--bg); overflow: hidden;
  transition: opacity .5s ease;
}
.splash.fade-out { opacity: 0; pointer-events: none; }
.splash::before, .splash::after {
  content: ""; position: absolute; border-radius: 50%;
  border: 22px solid transparent;
  border-top-color: var(--brand); border-right-color: var(--brand);
  opacity: .9;
}
.splash::before { width: 340px; height: 340px; top: -150px; left: -120px; transform: rotate(25deg); }
.splash::after  { width: 420px; height: 420px; bottom: -210px; right: -160px; transform: rotate(200deg); }
.splash-inner {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 38px;
  animation: pop .6s ease;
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.splash-bar { width: 220px; height: 4px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.splash-bar span {
  display: block; height: 100%; width: 40%;
  background: var(--brand-bright); border-radius: 999px;
  animation: load 1.5s ease-in-out infinite;
}
@keyframes load { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 34px 28px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-brand { align-self: center; margin-bottom: 4px; }
.login-card h1 { font-size: 20px; margin: 4px 0 0; text-align: center; font-weight: 700; }
.login-sub { margin: 0 0 10px; text-align: center; color: var(--text-dim); font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }

input, select, textarea {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px;
  color: var(--text); font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-bright); outline-offset: 0; }
textarea { resize: vertical; width: 100%; }

.login-card button, .btn {
  background: var(--brand); color: #fff; border: 0;
  border-radius: 10px; padding: 12px;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.login-card button:hover, .btn:hover { background: var(--brand-bright); }
.btn.danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn.danger:hover { background: rgba(255,107,107,.12); }
.login-error { color: var(--danger); font-size: 13px; margin: 0; text-align: center; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 14px 22px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.admin-tabs { display: flex; gap: 6px; }
.admin-tabs button {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 999px;
  padding: 8px 16px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.admin-tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

#search {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 9px 16px;
  color: var(--text); font-size: 13px; width: 260px; max-width: 52vw;
}
.btn-ghost {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); border-radius: 999px;
  padding: 9px 16px; cursor: pointer; font-size: 13px; font-family: inherit;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }

/* ---------- Content ---------- */
.content { max-width: 1100px; margin: 0 auto; padding: 26px 22px 60px; }
.content.wide { max-width: 1280px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 30px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-card .num { font-size: 26px; font-weight: 800; }
.stat-card .lbl { color: var(--text-dim); font-size: 12px; margin-top: 4px; }

/* ---------- Grupos / tablas ---------- */
.local { margin-bottom: 34px; }
.local-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 0 4px 12px; }
.local-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.local-head .meta { color: var(--text-dim); font-size: 13px; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-dim); font-weight: 600;
  padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.click-row { cursor: pointer; }
.cli-name { font-weight: 600; }
.stars { color: var(--star); letter-spacing: 2px; white-space: nowrap; }
.stars .off { color: var(--border); }
.empty { color: var(--text-dim); text-align: center; padding: 40px; }

.btn-wa {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--wa); color: #06301b; border: 0; border-radius: 999px;
  padding: 8px 14px; font-size: 12.5px; font-weight: 700;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn-wa:hover { filter: brightness(1.06); }
.btn-wa svg { width: 15px; height: 15px; }
.btn-wa.disabled {
  background: var(--surface-2); color: var(--text-dim);
  cursor: not-allowed; filter: none;
}
.stat-card.tope { border-color: var(--danger); }
.stat-card.tope .num { color: var(--danger); }
.tope-txt { color: var(--danger); }

.btn-sm {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 6px 12px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.btn-sm:hover { border-color: var(--text-dim); }
.btn-sm.danger { color: var(--danger); border-color: transparent; }
.btn-sm.danger:hover { border-color: var(--danger); }

/* ---------- Toolbars admin ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar h2 { margin: 0; font-size: 18px; font-weight: 700; }
.toolbar input[type="search"] { width: 280px; max-width: 60vw; border-radius: 999px; padding: 9px 16px; }
.toolbar .filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.toolbar .filtros label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 20px; }
.modal-box {
  position: relative; width: 100%; max-width: 640px; max-height: 86vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px;
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
}
.modal-box table { min-width: 0; }
.detalle-title { margin: 0 0 6px; }
.detalle-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--text-dim); font-size: 12.5px; margin-bottom: 16px; }
.detalle-tools { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.detalle-tools label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }

/* ---------- Config ---------- */
.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 700; }
.card label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-dim); margin-bottom: 10px; }
.card hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.card .btn { margin-top: 6px; }
.card code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.row-inline { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.row-inline input { flex: 1; }
.u-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.u-row input { flex: 1; min-width: 110px; }
.form-nueva { display: grid; gap: 0; }

@media (max-width: 560px) {
  #search, .toolbar input[type="search"] { width: 100%; max-width: none; }
  .topbar { gap: 10px; }
  .brand-lg .brand-word { font-size: 52px; }
}

/* ============================================================
   Página del NFC  (r.html)
   ============================================================ */
.nfc-wrap {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
  gap: 22px;
  padding: 40px 18px 30px;
}
.nfc-logo { margin-bottom: 4px; }
.nfc-foot { color: var(--text-dim); font-size: 11px; margin: auto 0 0; }
.nfc-foot b { color: var(--text); }

.nfc-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 22px;
  text-align: center;
}
.nfc-card h1 { font-size: 20px; margin: 0 0 4px; }
.nfc-sub { color: var(--text-dim); font-size: 13.5px; margin: 0 0 18px; }

.nfc-stars {
  display: flex; justify-content: center; gap: 6px;
  margin-bottom: 20px;
}
.nfc-stars button {
  background: none; border: 0; cursor: pointer;
  font-size: 38px; line-height: 1;
  color: var(--border);
  transition: transform .08s ease, color .1s ease;
  padding: 2px;
}
.nfc-stars button:hover { transform: scale(1.08); }
.nfc-stars button.on { color: var(--star); }

.nfc-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.nfc-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-dim); }
.nfc-form input, .nfc-form textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.nfc-form input:focus, .nfc-form textarea:focus { outline: 2px solid var(--brand); }
.nfc-err { color: var(--danger); font-size: 12.5px; margin: 0; }
.nfc-submit { margin-top: 4px; width: 100%; }

.btn-google {
  display: inline-block; width: 100%;
  background: #fff; color: #1a1a1a;
  border: 0; border-radius: 10px;
  padding: 13px 16px;
  font-size: 15px; font-weight: 700;
  text-decoration: none;
}
.btn-google:hover { filter: brightness(0.94); }

/* Sucursales / NFC en el panel admin */
.suc-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
}
.suc-row input { min-width: 0; }
.suc-row .nfc-link {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 7px 9px;
  overflow: hidden;
}
.suc-row .nfc-link code {
  flex: 1; overflow-x: auto; white-space: nowrap; font-size: 11px;
}
.suc-row .suc-meta { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; color: var(--text-dim); font-size: 12px; }

.nfc-link .nfc-tag {
  flex: 0 0 auto; font-size: 10px; font-weight: 700;
  background: var(--brand); color: #fff;
  padding: 2px 6px; border-radius: 5px;
}

/* ============================================================
   Panel de un local (modal Taps)
   ============================================================ */
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.panel-head h2 { margin: 0; font-size: 20px; }
.panel-head label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .4px; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
.kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.kpi-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); }
.kpi-num { font-size: 30px; font-weight: 800; margin: 4px 0 2px; }
.kpi-num.muted { color: var(--text-dim); font-weight: 700; }
.kpi-delta { font-size: 12px; color: var(--text-dim); }
.kpi-delta.up { color: #37d67a; }
.kpi-delta.down { color: var(--danger); }

.panel-sec { font-size: 13px; margin: 20px 0 10px; font-weight: 700; }
.chart-wrap { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.bar-chart { width: 100%; height: 120px; display: block; }
.bar-chart rect { fill: var(--brand-bright); }

.feed { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.feed-row { display: flex; gap: 12px; align-items: baseline; padding: 7px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.feed-row:last-child { border-bottom: 0; }
.feed-h { color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 78px; }

@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr; }
}
