/* KM43 admin — mismo sistema visual que la app y la landing:
   fondo casi negro, crema, gradiente ember, Blauer + Space Mono. */

@font-face { font-family: 'Blauer'; src: url('../fonts/BlauerNue-Regular.otf') format('opentype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Blauer'; src: url('../fonts/BlauerNue-Medium.otf')  format('opentype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Blauer'; src: url('../fonts/BlauerNue-Bold.otf')    format('opentype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Blauer'; src: url('../fonts/BlauerNue-Heavy.otf')   format('opentype'); font-weight: 900; font-display: swap; }
@font-face { font-family: 'SpaceMono'; src: url('../fonts/SpaceMono-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'SpaceMono'; src: url('../fonts/SpaceMono-Bold.ttf')    format('truetype'); font-weight: 700; font-display: swap; }

:root {
  --ink: #000;
  --ink-2: #070605;
  --surface: #0b0908;
  --surface-2: #100c0a;
  --cream: #efe2cc;
  --white: #fff;
  --orange: #d75b2d;
  --orange-b: #e85015;
  --ember: #b60a01;
  --ember-deep: #521711;
  --warm-gray: #97907f;
  --line: rgba(239, 226, 204, 0.16);
  --line-soft: rgba(239, 226, 204, 0.08);
  --grad: linear-gradient(100deg, #521711 0%, #b60a01 30%, #e85015 62%, #efe2cc 100%);
  --grad-cta: linear-gradient(100deg, #521711 0%, #b60a01 38%, #e85015 100%);
  --display: 'Blauer', system-ui, sans-serif;
  --mono: 'SpaceMono', ui-monospace, monospace;
  --sidebar: 236px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--ink-2);
  color: var(--cream);
  font-family: var(--display);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* halo ember arriba, como el hero de la app */
body::before {
  content: '';
  position: fixed;
  inset: 0 0 auto 0;
  height: 420px;
  background: radial-gradient(70% 100% at 78% 0%, rgba(182, 10, 1, 0.22), transparent 62%);
  pointer-events: none;
  z-index: 0;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
::placeholder { color: rgba(151, 144, 127, 0.6); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(239, 226, 204, 0.12); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(239, 226, 204, 0.2); }

/* ---------------- tipografía utilitaria ---------------- */

.label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: var(--warm-gray);
}
.label--ember { color: var(--orange-b); }
.mono { font-family: var(--mono); font-size: 11px; color: var(--warm-gray); }
.muted { color: var(--warm-gray); }

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

.login {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login__card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 34px 28px 28px;
  overflow: hidden;
  position: relative;
}
.login__rule { position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--grad); }
.login__logo { display: block; width: 116px; margin: 0 auto 26px; }
.login__title { font-weight: 900; font-size: 24px; text-align: center; letter-spacing: -0.3px; }
.login__sub { text-align: center; margin: 8px 0 26px; }

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

.shell { position: relative; z-index: 1; display: flex; min-height: 100vh; }

.side {
  width: var(--sidebar);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 26px 0 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side__logo { width: 104px; margin: 0 22px 30px; }
.side__group { padding: 0 14px; margin-bottom: 22px; }
.side__group > .label { padding: 0 10px; margin-bottom: 9px; display: block; }

.nav {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--warm-gray);
  transition: background 0.15s, color 0.15s;
}
.nav:hover { background: rgba(239, 226, 204, 0.04); color: var(--cream); }
.nav--on { background: rgba(232, 80, 21, 0.11); color: var(--cream); }
.nav--on .nav__dot { background: var(--orange-b); box-shadow: 0 0 10px 0 rgba(232, 80, 21, 0.8); }
.nav__dot { width: 6px; height: 6px; border-radius: 999px; background: rgba(239, 226, 204, 0.22); flex: none; }
.nav__count { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--warm-gray); }

.side__foot { margin-top: auto; padding: 0 24px; }
.side__user { font-size: 12.5px; font-weight: 500; margin-bottom: 3px; }

.main { flex: 1; min-width: 0; padding: 34px 40px 80px; max-width: 1180px; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.head__title { font-weight: 900; font-size: 32px; letter-spacing: -0.6px; line-height: 1.05; }
.head__sub { margin-top: 7px; }
.head__actions { display: flex; gap: 10px; flex: none; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.card + .card { margin-top: 16px; }
.card__rule { position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--grad-cta); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.card__title { font-weight: 700; font-size: 17px; }
.card__hint { margin-top: 4px; font-family: var(--mono); font-size: 10.5px; color: var(--warm-gray); line-height: 1.55; }

.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: 1fr 1fr; }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--stats { grid-template-columns: repeat(4, 1fr); }

/* ---------------- stats ---------------- */

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.stat__n { font-weight: 900; font-size: 34px; line-height: 1; margin-top: 10px; letter-spacing: -1px; }
.stat__n--sm { font-size: 23px; letter-spacing: -0.5px; }
/* gradiente propio: arranca encendido para que un solo dígito no salga apagado */
.stat__n--ember {
  background: linear-gradient(100deg, #e85015 0%, #f0813f 55%, var(--cream) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------------- formularios ---------------- */

.field { display: block; }
.field > .label { display: block; margin-bottom: 7px; }

.input, .select, .textarea {
  width: 100%;
  background: rgba(239, 226, 204, 0.04);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--cream);
  font-size: 14px;
  font-weight: 500;
  padding: 0 13px;
  height: 46px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { height: auto; padding: 12px 13px; line-height: 1.6; resize: vertical; min-height: 104px; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--orange-b);
  box-shadow: 0 0 0 1px var(--orange-b), 0 0 34px -14px var(--orange-b);
}
.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--warm-gray) 50%), linear-gradient(135deg, var(--warm-gray) 50%, transparent 50%);
  background-position: calc(100% - 17px) 21px, calc(100% - 12px) 21px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
.select option { background: var(--surface); color: var(--cream); }
.field__hint { font-family: var(--mono); font-size: 9.5px; color: var(--warm-gray); margin-top: 6px; line-height: 1.5; }

/* toggle */
.toggle { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; user-select: none; }
.toggle__track {
  width: 44px; height: 25px; border-radius: 999px; flex: none;
  background: rgba(239, 226, 204, 0.1);
  border: 1px solid var(--line);
  position: relative;
  transition: background 0.18s;
}
.toggle__knob {
  position: absolute; top: 2px; left: 2px;
  width: 19px; height: 19px; border-radius: 999px;
  background: var(--warm-gray);
  transition: transform 0.18s, background 0.18s;
}
.toggle input { display: none; }
.toggle input:checked + .toggle__track { background: var(--grad-cta); border-color: transparent; }
.toggle input:checked + .toggle__track .toggle__knob { transform: translateX(19px); background: var(--white); }
.toggle__text { font-size: 13.5px; font-weight: 500; }

/* ---------------- botones ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border-radius: 999px;
  font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn--primary { background: var(--grad-cta); color: var(--white); }
.btn--primary:hover:not(:disabled) { opacity: 0.9; }
.btn--ghost { border: 1px solid var(--line); color: var(--cream); }
.btn--ghost:hover:not(:disabled) { border-color: rgba(239, 226, 204, 0.35); background: rgba(239, 226, 204, 0.03); }
.btn--danger { border: 1px solid rgba(182, 10, 1, 0.5); color: #e8776a; }
.btn--danger:hover:not(:disabled) { background: rgba(182, 10, 1, 0.14); }
.btn--sm { height: 36px; padding: 0 15px; font-size: 13px; }
.btn--full { width: 100%; }

/* ---------------- listas / filas ---------------- */

.rows { border-top: 1px solid var(--line-soft); }
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line-soft);
  transition: background 0.12s;
}
.row--link { cursor: pointer; }
.row--link:hover { background: rgba(239, 226, 204, 0.03); }
.row__main { flex: 1; min-width: 0; }
.row__title { font-size: 14.5px; font-weight: 500; }
.row__sub { font-family: var(--mono); font-size: 10px; color: var(--warm-gray); margin-top: 4px; }
.row__arrow { font-family: var(--mono); font-size: 13px; color: var(--orange-b); flex: none; }
.row__actions { display: flex; gap: 8px; flex: none; }

.thumb {
  width: 54px; height: 54px; border-radius: 12px; flex: none;
  background: var(--surface-2) center/cover no-repeat;
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-weight: 900; font-size: 18px; color: var(--warm-gray);
}
.thumb--round { border-radius: 999px; }

.pill {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 1.4px; text-transform: uppercase;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--warm-gray);
  flex: none; white-space: nowrap;
}
.pill--on { color: var(--orange-b); border-color: rgba(232, 80, 21, 0.45); }
.pill--off { color: var(--warm-gray); opacity: 0.7; }
.pill--live { color: #7bd88f; border-color: rgba(123, 216, 143, 0.4); }

.empty {
  text-align: center; padding: 46px 20px;
  font-family: var(--mono); font-size: 11px; color: var(--warm-gray); line-height: 1.7;
}

/* ---------------- uploader ---------------- */

.up { display: flex; gap: 14px; align-items: flex-start; }
.up__preview {
  width: 148px; height: 96px; border-radius: 14px; flex: none;
  border: 1px dashed var(--line);
  background: var(--surface-2) center/cover no-repeat;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 9px; letter-spacing: 1.5px; color: var(--warm-gray);
  text-align: center; padding: 8px; cursor: pointer;
  transition: border-color 0.15s;
}
.up__preview:hover { border-color: var(--orange-b); }
.up__preview--logo { width: 96px; height: 96px; border-radius: 999px; }
.up__side { flex: 1; min-width: 0; }
.up input[type='file'] { display: none; }

/* ---------------- modal ---------------- */

.modal-bg {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(3, 2, 2, 0.72);
  backdrop-filter: blur(7px);
  display: grid; place-items: center;
  padding: 24px;
  animation: fade 0.16s ease;
}
.modal {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 26px; position: relative;
  animation: pop 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.modal__close {
  position: absolute; top: 18px; right: 18px;
  width: 34px; height: 34px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--cream);
  display: grid; place-items: center; font-size: 15px;
}
.modal__close:hover { border-color: rgba(239, 226, 204, 0.4); }
.modal__title { font-weight: 900; font-size: 22px; letter-spacing: -0.3px; padding-right: 44px; }
.modal__sub { margin: 7px 0 20px; }
.modal__foot { display: flex; gap: 10px; margin-top: 22px; }
.modal__foot .btn { flex: 1; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

/* ---------------- toast ---------------- */

.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--orange-b);
  border-radius: 12px; padding: 13px 17px; font-size: 13.5px; font-weight: 500;
  max-width: 340px; animation: slide 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
  box-shadow: 0 18px 40px -22px #000;
}
.toast--bad { border-left-color: var(--ember); }
.toast--ok { border-left-color: #7bd88f; }
@keyframes slide { from { opacity: 0; transform: translateX(24px); } }

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

.back {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--warm-gray); margin-bottom: 16px;
}
.back:hover { color: var(--cream); }

.search {
  height: 44px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(239, 226, 204, 0.04); color: var(--cream);
  padding: 0 18px; font-size: 14px; outline: none; min-width: 260px;
}
.search:focus { border-color: var(--orange-b); }

.split { display: flex; gap: 16px; align-items: center; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.map-preview {
  width: 100%; height: 132px; border-radius: 12px; margin-top: 12px;
  border: 1px solid var(--line); background: var(--surface-2) center/cover no-repeat;
}

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; padding: 14px; gap: 10px; }
  .side__logo, .side__foot { display: none; }
  .side__group { margin: 0; display: flex; gap: 8px; }
  .side__group > .label { display: none; }
  .main { padding: 22px 18px 60px; }
  .grid--2, .grid--3 { grid-template-columns: 1fr; }
  .head { flex-direction: column; align-items: stretch; }
}

/* ---------------- analítica ---------------- */

/* filtros: una sola fila arriba, mandan sobre todo lo de abajo */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.filters .label { display: block; margin-bottom: 8px; }

.seg { display: flex; gap: 6px; }
.seg--wrap { flex-wrap: wrap; }
.seg__b {
  height: 36px;
  padding: 0 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--warm-gray);
  font-size: 13px;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.seg__b:hover { color: var(--cream); border-color: rgba(239, 226, 204, 0.32); }
.seg__b--on {
  background: rgba(232, 80, 21, 0.14);
  border-color: var(--orange-b);
  color: var(--cream);
}

.plot { position: relative; margin-top: 4px; }
.plot svg { display: block; width: 100%; }

/* tooltip: el valor manda, la fecha acompaña */
.tip {
  position: absolute;
  transform: translateX(-50%);
  background: rgba(7, 6, 5, 0.94);
  border: 1px solid var(--line);
  border-left: 2px solid var(--orange-b);
  border-radius: 10px;
  padding: 8px 12px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 14px 34px -18px #000;
}
.tip__v { font-size: 15px; font-weight: 700; color: var(--cream); }
.tip__d { font-family: var(--mono); font-size: 9.5px; color: var(--warm-gray); margin-top: 3px; }

.tabledata { margin-top: 6px; max-height: 380px; overflow-y: auto; }

/* ranking con barra proporcional dentro de la fila */
.rank { border-top: 1px solid var(--line-soft); }
.rank__head,
.rank__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px 88px 66px 62px;
  gap: 10px;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line-soft);
}
.rank__head {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--warm-gray);
  border-bottom-color: var(--line);
}
.rank__head span:not(:first-child),
.rank__n { text-align: right; }
a.rank__row { transition: background 0.12s; }
a.rank__row:hover { background: rgba(239, 226, 204, 0.03); }
.rank__name { min-width: 0; font-size: 14.5px; font-weight: 500; }
.rank__sub {
  display: block;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--warm-gray);
  margin-top: 3px;
}
.rank__n { font-family: var(--mono); font-size: 12px; color: var(--warm-gray); }
.rank__n--strong { color: var(--cream); font-size: 13px; }

.bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(239, 226, 204, 0.07);
  overflow: hidden;
  margin-top: 8px;
}
.bar__fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #b60a01, #e85015);
}

@media (max-width: 760px) {
  .rank__head { display: none; }
  .rank__row { grid-template-columns: minmax(0, 1fr) 60px 56px; }
  .rank__row > span:nth-child(4),
  .rank__row > span:nth-child(5) { display: none; }
}
