/* ==========================================================================
   Plataforma Canje Royal Condor · Sistema de diseño
   Paleta y tipografía tomadas del brand system "La Gran Recompensa 2026"
   ========================================================================== */

:root {
  --rc-red: #E6212A;
  --rc-red-deep: #B81820;
  --rc-red-dark: #8A1319;
  --rc-gold: #F5B800;
  --rc-gold-soft: #FFCB3D;
  --rc-gold-deep: #D49E00;
  --rc-cream: #FFF8E7;
  --rc-bone: #FDF7EA;
  --rc-earth: #1A1A1A;
  --rc-earth-soft: #4D4D4D;
  --rc-ink: #0F0F0F;
  --rc-paper: #FFFFFF;
  --rc-line: #ECE4D0;
  --rc-green: #5C6B3E;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Manrope', -apple-system, 'Segoe UI', sans-serif;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(15, 15, 15, .06), 0 6px 24px rgba(15, 15, 15, .05);
  --shadow-lg: 0 8px 40px rgba(15, 15, 15, .16);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--rc-earth);
  background: var(--rc-bone);
  min-height: 100vh;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 500; margin: 0 0 .5rem; color: var(--rc-ink); }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 .75rem; }

.muted { color: var(--rc-earth-soft); font-size: .85rem; }

.eyebrow {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--rc-red);
  margin-bottom: .35rem;
}

/* ---------- Layout ---------- */

.container { max-width: 1180px; margin: 0 auto; padding: 1.25rem; }
.container.narrow { max-width: 560px; }

.topbar {
  background: var(--rc-earth);
  color: var(--rc-cream);
  padding: .7rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar .brand { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.topbar .brand img { height: 34px; width: auto; display: block; }
.topbar .brand .title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-style: italic;
  color: var(--rc-gold-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar .user { display: flex; align-items: center; gap: .75rem; font-size: .82rem; }
.topbar .user span { opacity: .85; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Tarjetas ---------- */

.card {
  background: var(--rc-paper);
  border: 1px solid var(--rc-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* ---------- Formularios ---------- */

.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--rc-earth-soft);
  margin-bottom: .35rem;
}

input[type="text"], input[type="tel"], input[type="date"], input[type="password"],
input[type="number"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--rc-earth);
  background: var(--rc-paper);
  border: 1.5px solid var(--rc-line);
  border-radius: var(--radius-sm);
  padding: .8rem .9rem;
  min-height: 50px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--rc-red);
  box-shadow: 0 0 0 3px rgba(230, 33, 42, .12);
}
input.invalid, select.invalid { border-color: var(--rc-red); background: #fff5f5; }

.hint { font-size: .75rem; color: var(--rc-earth-soft); margin-top: .25rem; }

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font: inherit;
  font-weight: 700;
  font-size: .95rem;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  padding: .7rem 1.2rem;
  min-height: 48px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--rc-red); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--rc-red-deep); }

.btn-dark { background: var(--rc-earth); color: var(--rc-cream); }
.btn-dark:hover:not(:disabled) { background: var(--rc-ink); }

.btn-outline { background: var(--rc-paper); color: var(--rc-earth); border-color: var(--rc-line); }
.btn-outline:hover:not(:disabled) { border-color: var(--rc-earth-soft); }

.btn-gold { background: var(--rc-gold); color: var(--rc-ink); }
.btn-gold:hover:not(:disabled) { background: var(--rc-gold-deep); }

.btn-xl { width: 100%; min-height: 58px; font-size: 1.05rem; }
.btn-sm { min-height: 36px; padding: .35rem .7rem; font-size: .8rem; }
.btn-link {
  background: none; border: none; color: var(--rc-red);
  font-weight: 700; cursor: pointer; font-size: .82rem; padding: .25rem;
}

/* ---------- Captura de foto ---------- */

.photo-box {
  border: 2px dashed var(--rc-gold-deep);
  background: var(--rc-cream);
  border-radius: var(--radius);
  padding: 1.4rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.photo-box:hover { border-color: var(--rc-red); }
.photo-box .icon { font-size: 2rem; display: block; margin-bottom: .3rem; }
.photo-box strong { color: var(--rc-earth); }
.photo-box.has-photo { border-style: solid; border-color: var(--rc-green); background: #f4f7ee; }

.photo-preview {
  margin-top: .75rem;
  display: none;
  position: relative;
}
.photo-preview img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
}
.photo-preview .retake {
  position: absolute; bottom: .6rem; right: .6rem;
}

/* ---------- Stats / Dashboard ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .8rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: var(--rc-paper);
  border: 1px solid var(--rc-line);
  border-top: 3px solid var(--rc-gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}
.stat-card.primary { border-top-color: var(--rc-red); }
.stat-card .label {
  font-size: .68rem; font-weight: 700; letter-spacing: .18em;
  text-transform: uppercase; color: var(--rc-earth-soft);
}
.stat-card .value {
  font-family: var(--font-display);
  font-size: 2rem; font-weight: 600; color: var(--rc-ink); line-height: 1.15;
}

.bar-list { display: flex; flex-direction: column; gap: .55rem; }
.bar-item .bar-label {
  display: flex; justify-content: space-between; gap: .5rem;
  font-size: .82rem; margin-bottom: .2rem;
}
.bar-item .bar-label b { font-variant-numeric: tabular-nums; }
.bar-track { background: var(--rc-cream); border-radius: 99px; height: 10px; overflow: hidden; }
.bar-fill { background: var(--rc-red); height: 100%; border-radius: 99px; min-width: 4px; }
.bar-fill.gold { background: var(--rc-gold); }

/* ---------- Tablas ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--rc-line); border-radius: var(--radius); background: var(--rc-paper); }
table { width: 100%; border-collapse: collapse; font-size: .85rem; min-width: 720px; }
thead th {
  text-align: left;
  font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--rc-earth-soft);
  background: var(--rc-cream);
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--rc-line);
  white-space: nowrap;
}
tbody td { padding: .6rem .8rem; border-bottom: 1px solid var(--rc-line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--rc-bone); }

.thumb {
  width: 44px; height: 44px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--rc-line); display: block;
  background: var(--rc-cream);
}

.badge {
  display: inline-block; font-size: .7rem; font-weight: 700;
  padding: .15rem .55rem; border-radius: 99px;
}
.badge.ok { background: #eef3e4; color: var(--rc-green); }
.badge.off { background: #fdeaea; color: var(--rc-red-deep); }
.badge.admin { background: var(--rc-cream); color: var(--rc-gold-deep); }

/* ---------- Tabs (admin) ---------- */

.tabs { display: flex; gap: .25rem; margin-bottom: 1.1rem; overflow-x: auto; }
.tab-btn {
  font: inherit; font-weight: 700; font-size: .85rem;
  background: none; border: none; cursor: pointer;
  color: var(--rc-earth-soft);
  padding: .55rem .9rem;
  border-radius: 99px;
  white-space: nowrap;
}
.tab-btn.active { background: var(--rc-earth); color: var(--rc-cream); }

/* ---------- Filtros ---------- */

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: .6rem;
  margin-bottom: .9rem;
}
.filters input, .filters select { min-height: 44px; padding: .5rem .7rem; font-size: .9rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .9rem; }
.toolbar .spacer { flex: 1; }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 15, 15, .55);
  display: none; align-items: flex-start; justify-content: center;
  padding: 2rem 1rem; z-index: 100; overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--rc-paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 640px;
  padding: 1.4rem;
}
.modal .modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal .close-x {
  background: none; border: none; font-size: 1.4rem; cursor: pointer;
  color: var(--rc-earth-soft); line-height: 1; padding: .25rem .5rem;
}
.modal img.foto-full {
  width: 100%; max-height: 380px; object-fit: contain;
  background: var(--rc-cream); border-radius: var(--radius-sm); margin-bottom: 1rem;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Toast ---------- */

#toast {
  position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%);
  background: var(--rc-earth); color: var(--rc-cream);
  padding: .7rem 1.2rem; border-radius: 99px;
  font-size: .88rem; font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
  z-index: 200; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--rc-red-deep); color: #fff; }

/* ---------- Login ---------- */

.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, var(--rc-red-dark), var(--rc-red-deep) 55%, var(--rc-red));
}
.login-card {
  background: var(--rc-paper);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 2.2rem 1.8rem;
  width: 100%; max-width: 400px;
  text-align: center;
}
.login-card .logo-wrap {
  display: inline-block;
  background: var(--rc-earth);
  border-radius: 12px;
  padding: .7rem 1.1rem;
  margin-bottom: .9rem;
}
.login-card img.logo { height: 48px; display: block; }
.login-card h1 { font-size: 1.45rem; font-style: italic; }
.login-card form { text-align: left; margin-top: 1.4rem; }
.login-error {
  display: none;
  background: #fdeaea; color: var(--rc-red-deep);
  border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 600;
  padding: .6rem .8rem; margin-bottom: .9rem;
}

/* ---------- Éxito (captura) ---------- */

.success-panel { text-align: center; padding: 2.2rem 1rem; }
.success-panel .check {
  width: 74px; height: 74px; border-radius: 50%;
  background: var(--rc-green); color: #fff;
  font-size: 2.3rem; line-height: 74px;
  margin: 0 auto 1rem;
}

.list-mini { list-style: none; margin: 0; padding: 0; }
.list-mini li {
  display: flex; justify-content: space-between; gap: .75rem;
  padding: .55rem 0; border-bottom: 1px solid var(--rc-line);
  font-size: .85rem;
}
.list-mini li:last-child { border-bottom: none; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .8rem; }

@media (max-width: 640px) {
  .container { padding: .9rem; }
  h1 { font-size: 1.4rem; }
}
