/* Estilos del panel de administracion: login, dashboard y tabla de usuarios. */
/* ==========================================================
   VITALIS · Panel de Administración
   Paleta VITALIS: salvia, beige cálido y gris oscuro
   ========================================================== */

:root {
  --blue: #343B36;
  --blue-700: #4d6a55;
  --blue-100: #F7F0E5;
  --green: #64866F;
  --green-700: #4d6a55;
  --green-100: #F7F0E5;
  --bg: #FFFCF7;
  --card: #FFFCF7;
  --text: #343B36;
  --muted: #6B6868;
  --line: #E6D6C5;
  --danger: #C23B3B;
  --danger-100: #FBE9E9;
  --amber: #B7791F;
  --amber-100: #FDF3DC;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(8, 56, 51, .04), 0 6px 20px rgba(8, 56, 51, .06);
  --sidebar-w: 264px;
  --font: "Poppins", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { width: 100%; min-width: 320px; scroll-behavior: smooth; }

body {
  width: 100%;
  min-width: 320px;
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* La ruta ya está protegida por Django. Mantén el panel visible si falla JS. */
body.is-loading { visibility: visible; }

h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 3px solid rgba(121, 164, 146, .45); outline-offset: 2px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 12px;
  padding: 11px 18px; font-weight: 600; font-size: 14.5px;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-700); }
.btn-primary[disabled] { opacity: .6; cursor: not-allowed; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--blue); }
.btn-ghost:hover { background: var(--blue-100); }
.btn-block { width: 100%; }

/* ==========================================================
   LOGIN
   ========================================================== */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

.login-brand {
  position: relative; overflow: hidden;
  background: linear-gradient(155deg, var(--green) 0%, #58765f 60%, var(--green-700) 100%);
  color: #fff;
  padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-brand .brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 22px; letter-spacing: .14em; }
.login-brand .brand img { width: 44px; height: 44px; }
.login-brand h2 { font-size: 34px; line-height: 1.2; font-weight: 800; max-width: 14em; }
.login-brand p { margin-top: 14px; color: rgba(255,255,255,.78); max-width: 30em; }
.login-brand .pulse { position: absolute; left: 0; right: 0; bottom: 90px; width: 100%; opacity: .22; pointer-events: none; }
.login-brand .brand-foot { font-size: 13px; color: rgba(255,255,255,.6); position: relative; }
.login-brand .brand-copy { position: relative; }

.login-panel { display: flex; align-items: center; justify-content: center; padding: 32px 24px; }

.login-card {
  width: 100%; max-width: 420px;
  background: var(--card); border-radius: 22px; padding: 40px 36px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.login-card .mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 20px; font-weight: 800; letter-spacing: .14em; color: var(--blue); }
.login-card .mobile-brand img { width: 36px; height: 36px; }
.login-card h1 { font-size: 26px; color: var(--blue); font-weight: 800; }
.login-card .subtitle { color: var(--muted); margin: 6px 0 26px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 7px; }
.input-wrap { position: relative; }
.input {
  width: 100%; padding: 12px 14px; border: 1px solid #D6DFDA; border-radius: 12px;
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 4px rgba(121,164,146,.2); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-wrap .input { padding-right: 76px; }
.toggle-pass {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--blue); font-weight: 600; font-size: 13px;
  padding: 6px 10px; border-radius: 8px;
}
.toggle-pass:hover { background: var(--blue-100); }
.field-error { color: var(--danger); font-size: 13px; margin-top: 6px; min-height: 0; }

.alert-box {
  display: none; margin-bottom: 18px; padding: 12px 14px; border-radius: 12px;
  background: var(--danger-100); color: var(--danger); font-weight: 600; font-size: 14px;
  border: 1px solid #f1c6c6;
}
.alert-box.show { display: block; }

.demo-note {
  margin-top: 22px; padding: 12px 14px; border-radius: 12px; font-size: 12.5px;
  background: var(--amber-100); color: #7a5413; border: 1px solid #f0dca8;
}

/* ==========================================================
   APP SHELL
   ========================================================== */
.app { display: flex; width: 100%; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--blue); color: #fff;
  display: flex; flex-direction: column; padding: 24px 16px;
  z-index: 40; transition: transform .25s ease;
}
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 26px; font-weight: 800; letter-spacing: .14em; font-size: 19px; }
.sidebar .brand img { width: 38px; height: 38px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a, .nav button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; border-radius: 12px; border: 0; background: transparent;
  color: rgba(255,255,255,.78); text-decoration: none; font-weight: 600; font-size: 14.5px; text-align: left;
  transition: background .15s, color .15s;
}
.nav a:hover, .nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(121,164,146,.2); color: #fff; box-shadow: inset 3px 0 0 var(--green); }
.nav .ico { width: 22px; text-align: center; font-size: 17px; }
.nav .spacer { flex: 1; }
.sidebar .side-foot { font-size: 12px; color: rgba(255,255,255,.5); padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.1); }

.scrim { display: none; position: fixed; inset: 0; background: rgba(9, 29, 45, .5); z-index: 30; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; max-width: none; padding: 28px 36px 56px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.topbar-left { display: flex; align-items: center; gap: 14px; }
.menu-btn {
  display: none; width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; font-size: 20px; color: var(--blue);
}
.topbar h1 { font-size: 26px; font-weight: 800; color: var(--blue); line-height: 1.2; }
.topbar .sub { color: var(--muted); font-size: 14px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.admin-chip {
  display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px 6px 6px; font-weight: 600; font-size: 14px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--green-100); color: var(--green-700);
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
}
.badge-demo {
  background: var(--amber-100); color: #7a5413; border: 1px solid #f0dca8;
  border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 700; white-space: nowrap;
}

/* ---------- Tarjetas ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 24px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin-bottom: 24px; }
.stat { display: flex; align-items: center; gap: 16px; }
.stat-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; flex: none; }
.stat-icon.blue { background: var(--blue-100); }
.stat-icon.green { background: var(--green-100); }
.stat-label { color: var(--muted); font-size: 13.5px; font-weight: 600; }
.stat-value { font-size: 32px; font-weight: 800; color: var(--blue); line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 12.5px; color: var(--muted); }

.charts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 24px; }
.charts-grid > .section-title { grid-column: 1 / -1; margin-bottom: -8px; color: var(--blue); font-size: 20px; font-weight: 800; }
.chart-card h2 { font-size: 17px; font-weight: 800; color: var(--blue); }
.chart-card .insight { color: var(--muted); font-size: 13.5px; margin: 2px 0 14px; min-height: 20px; }
.chart-card .insight strong { color: var(--green-700); }
.chart-box { position: relative; height: 270px; }

.mini-table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 13.5px; }
.mini-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.mini-table td { padding: 7px 4px; border-bottom: 1px solid #F0F1F0; }
.mini-table th.num, .mini-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }

/* ---------- Tabla de usuarios ---------- */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head h2 { font-size: 20px; font-weight: 800; color: var(--blue); }
.section-head p { color: var(--muted); font-size: 14px; }

.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr) 1.3fr; gap: 12px; margin-bottom: 18px; }
.filters .input { padding: 10px 12px; font-size: 14px; padding-right: 12px; }
.filters select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #53615B 50%), linear-gradient(135deg, #53615B 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.users { width: 100%; border-collapse: collapse; min-width: 640px; table-layout: fixed; }
table.users col.user-id-column { width: 19%; }
table.users col.user-age-column { width: 10%; }
table.users col.user-country-column { width: 16%; }
table.users col.user-gender-column { width: 16%; }
table.users col.user-bracelet-column { width: 19.5%; }
table.users col.user-camera-column { width: 19.5%; }
table.users th {
  text-align: left; padding: 13px 16px; background: #F7F9F7; color: var(--muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; white-space: nowrap;
}
table.users th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; }
table.users th button:focus-visible { outline: 3px solid rgba(121,164,146,.45); border-radius: 4px; }
table.users th button:hover { color: var(--blue); }
table.users td { padding: 13px 16px; border-top: 1px solid #E7EBE8; }
table.users tbody tr { cursor: pointer; transition: background .12s; }
table.users tbody tr:hover, table.users tbody tr:focus-visible { background: #F5F9F6; outline: none; }
table.users .name { font-weight: 700; color: var(--blue); }
table.users .center { text-align: center; }
.yes { color: var(--green-700); font-weight: 800; }
.no { color: #A0A8B4; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; font-size: 14px; color: var(--muted); }
.pager { display: flex; gap: 6px; align-items: center; }
.pager button {
  min-width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 600; color: var(--blue);
}
.pager button:hover:not([disabled]) { background: var(--blue-100); }
.pager button[disabled] { opacity: .4; cursor: not-allowed; }
.pager button[aria-current="page"] { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---------- Secciones secundarias ---------- */
.block { margin-bottom: 24px; scroll-margin-top: 20px; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.info-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; font-size: 14px; }
.info-list li { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid #E7EBE8; }
.info-list li span:first-child { color: var(--muted); }
.soon { color: var(--muted); margin-top: 8px; font-size: 14px; }
.h-flush { margin: 0; font-size: 20px; font-weight: 800; color: var(--blue); }

/* ---------- Modal ---------- */
dialog.profile {
  border: 0; border-radius: 20px; padding: 0; width: min(560px, calc(100vw - 32px));
  box-shadow: 0 24px 60px rgba(9, 29, 45, .3); color: var(--text);
}
dialog.profile::backdrop { background: rgba(9, 29, 45, .5); }
.profile-head { display: flex; align-items: center; gap: 16px; padding: 26px 28px 18px; background: linear-gradient(135deg, var(--blue-100), #fff); }
.profile-head .avatar { width: 56px; height: 56px; font-size: 20px; }
.profile-head h3 { font-size: 20px; color: var(--blue); font-weight: 800; }
.profile-head .id { color: var(--muted); font-size: 13px; }
.profile-close { margin-left: auto; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 18px; color: var(--blue); }
.profile-body { padding: 8px 28px 26px; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; margin: 16px 0; }
.profile-grid dt { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.profile-grid dd { margin: 2px 0 0; font-weight: 600; }
.profile-body h4 { margin: 18px 0 0; font-size: 13px; color: var(--blue); text-transform: uppercase; letter-spacing: .06em; }
.privacy-note { margin-top: 16px; font-size: 12.5px; color: var(--muted); background: #F7F9F7; border-radius: 10px; padding: 10px 12px; }

.pill { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 700; }
.pill.ok { background: var(--green-100); color: var(--green-700); }
.pill.warn { background: var(--amber-100); color: #7a5413; }
.pill.off { background: #F0F1F0; color: var(--muted); }
.pill.bad { background: var(--danger-100); color: var(--danger); }

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  .filters .f-search { grid-column: 1 / -1; }
}

@media (max-width: 960px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-card .mobile-brand { display: flex; }

  .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; }
  .main { margin-left: 0; padding: 20px 18px 48px; }
  .menu-btn { display: grid; place-items: center; }
  .charts-grid, .info-grid { grid-template-columns: 1fr; }
  .admin-chip .who { display: none; }
  .admin-chip { padding: 6px; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .topbar h1 { font-size: 21px; }
  .badge-demo { display: none; }
  .profile-grid { grid-template-columns: 1fr; }
  .login-card { padding: 30px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Acabado profesional del panel ---------- */
:root {
  --blue: #343b36;
  --blue-700: #4d6a55;
  --blue-100: #f7f0e5;
  --green: #64866f;
  --green-700: #4d6a55;
  --green-100: #f7f0e5;
  --bg: #fffcf7;
  --card: #fffcf7;
  --text: #343b36;
  --muted: #6b6868;
  --line: #e6d6c5;
  --shadow: 0 2px 5px rgba(52, 59, 54, .035), 0 12px 30px rgba(52, 59, 54, .055);
}

body { background: var(--bg); }
.sidebar {
  background: linear-gradient(180deg, #64866f 0%, #58765f 58%, #4d6a55 100%);
  padding: 28px 18px 20px;
}
.sidebar .brand {
  gap: 13px;
  padding: 4px 12px 34px;
  font-size: 18px;
  letter-spacing: .16em;
}
.sidebar .brand img { width: 40px; height: 40px; }
.nav { gap: 7px; }
.nav a,.nav button {
  min-height: 48px;
  gap: 13px;
  padding: 11px 13px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: rgba(255,255,255,.76);
  font-size: 13.5px;
  font-weight: 600;
}
.nav a:hover,.nav button:hover { background: rgba(255,255,255,.075); }
.nav a.active {
  border-color: rgba(255,255,255,.1);
  background: rgba(255,255,255,.105);
  box-shadow: inset 3px 0 0 #dfa080;
  color: #fff;
}
.nav .ico { width: 20px; height: 20px; display:grid; place-items:center; color: #d2e4dc; }
.nav .ico svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.nav a.active .ico { color:#a5c9b6; }
.sidebar .side-foot { margin-top:14px; color:rgba(255,255,255,.55); }
.main { padding:30px clamp(22px,3vw,48px) 64px; }
.topbar {
  position:relative;
  align-items:flex-start;
  margin-bottom:30px;
  padding-bottom:22px;
  border-bottom:1px solid var(--line);
}
.topbar h1 { font-size:25px; letter-spacing:-.035em; }
.topbar .sub { margin-top:5px; text-transform:capitalize; }
.admin-chip { box-shadow:0 2px 6px rgba(8,56,51,.04); }
.badge-demo { padding:6px 12px; }
.dashboard-heading {
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:18px;
  margin:0 0 17px;
}
.dashboard-heading h2 { color:var(--blue); font-size:20px; font-weight:800; letter-spacing:-.025em; }
.dashboard-heading p:last-child { margin-top:4px; color:var(--muted); font-size:13.5px; }
.section-kicker { margin-bottom:5px; color:var(--green-700); font-size:10px; font-weight:800; letter-spacing:.14em; }
.updated-label {
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:7px 10px;
  border:1px solid #e2e8e4;
  border-radius:999px;
  background:#f5f9f6;
  color:#53615b;
  font-size:11px;
  font-weight:700;
  white-space:nowrap;
}
.updated-label span { width:7px; height:7px; border-radius:50%; background:#64866f; }
.stats-grid { gap:15px; margin-bottom:24px; }
.card { border-radius:14px; box-shadow:var(--shadow); border-color:#e7ebe8; padding:21px; }
.stat { min-height:120px; gap:14px; }
.stat-icon { width:46px; height:46px; border-radius:13px; }
.stat-icon svg { width:22px; height:22px; fill:none; stroke:var(--blue); stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.stat-icon.green svg { stroke:var(--green-700); }
.stat-label { font-size:12.5px; line-height:1.4; }
.stat-value { margin-top:2px; font-size:30px; letter-spacing:-.04em; }
.stat-hint { margin-top:2px; font-size:11.5px; }
.section-head { align-items:center; }
.section-head h2,.h-flush { font-size:19px; letter-spacing:-.02em; }
.section-head p { margin-top:5px; font-size:13px; line-height:1.5; }
.btn { border-radius:10px; font-size:13px; }
.btn-ghost { border-color:#d9e0dc; }
.filters { gap:10px; margin-top:17px; }
.filters .input { min-height:43px; border-color:#d9e0dc; border-radius:10px; background-color:#fff; }
.filters .input:focus { border-color:var(--green); }
.table-wrap { border-color:#e2e8e4; border-radius:11px; }
table.users th { background:#f7f9f7; font-size:10.5px; letter-spacing:.06em; }
table.users td { padding-top:12px; padding-bottom:12px; font-size:13px; }
table.users tbody tr:hover,table.users tbody tr:focus-visible { background:#f5f9f6; }
.pagination { font-size:12px; }
.charts-grid { gap:15px; }
.charts-grid > .section-title { margin:0 0 1px; font-size:20px; letter-spacing:-.025em; }
.chart-card h2 { font-size:15px; }
.chart-box { height:250px; }
.mini-table { font-size:12px; }
.mini-table th { font-size:10px; }
.info-list { font-size:13px; }
.block { scroll-margin-top:24px; }

@media (max-width:1200px) {
  .stats-grid { gap:13px; }
}
@media (max-width:960px) {
  .main { padding:20px 22px 48px; }
  .topbar { margin-bottom:24px; }
  .charts-grid,.info-grid { grid-template-columns:minmax(0,1fr); }
  .charts-grid > * { min-width:0; }
}
@media (max-width:600px) {
  .main { padding:16px 14px 40px; }
  .topbar { align-items:center; gap:10px; padding-bottom:16px; }
  .topbar-left { gap:10px; min-width:0; }
  .topbar h1 { font-size:18px; }
  .topbar .sub { font-size:12px; }
  .topbar-right { flex:0 0 auto; }
  .dashboard-heading { align-items:flex-start; flex-direction:column; gap:10px; }
  .updated-label { align-self:flex-start; }
  .card { padding:17px; }
  .stat { min-height:98px; }
  .section-head { align-items:flex-start; }
  .charts-grid { grid-template-columns:minmax(0,1fr); }
  .chart-card,.chart-box { min-width:0; }
}
