/* Kiozko Ya · Panel de administración
   Concepto: barra lateral negra con la marca amarilla; área de trabajo clara y sobria, tabla como pieza central. */
:root {
  --bg: #f5f5f2;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --ink: #141413;
  --muted: #64625b;
  --line: #e4e2dc;
  --accent: #ffb300;
  --accent-ink: #141413;
  --accent-soft: #fff4d6;
  --side: #0c0c0b;
  --side-ink: #f2f1ec;
  --side-muted: #8d8a80;
  --ok: #17804a;      --ok-soft: #e3f4ea;
  --warn: #b45309;    --warn-soft: #fdeedc;
  --bad: #b42318;     --bad-soft: #fde7e4;
  --off: #6b6a65;     --off-soft: #ecebe7;
  --shadow: 0 1px 2px rgba(20, 20, 19, .06), 0 8px 24px rgba(20, 20, 19, .06);
  --f-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-display: "Inter Tight", "Inter", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0e; --surface: #181817; --surface-2: #1d1d1b; --ink: #f2f1ec; --muted: #a29f95; --line: #2c2b28;
    --accent-soft: #3a2c05; --side: #050505; --side-ink: #f2f1ec; --side-muted: #85827a;
    --ok: #4ccf86; --ok-soft: #12301f; --warn: #f0a24b; --warn-soft: #3a2510; --bad: #ff8a7a; --bad-soft: #3d1813;
    --off: #a5a39c; --off-soft: #2a2a27; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f0e; --surface: #181817; --surface-2: #1d1d1b; --ink: #f2f1ec; --muted: #a29f95; --line: #2c2b28;
  --accent-soft: #3a2c05; --side: #050505; --side-ink: #f2f1ec; --side-muted: #85827a;
  --ok: #4ccf86; --ok-soft: #12301f; --warn: #f0a24b; --warn-soft: #3a2510; --bad: #ff8a7a; --bad-soft: #3d1813;
  --off: #a5a39c; --off-soft: #2a2a27; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--f-ui); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--f-display); letter-spacing: -0.01em; text-wrap: balance; margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--f-mono); }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Marca ---------- */
.marca { display: flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.marca-sello { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #141413; display: grid; place-items: center; font-size: 15px; font-weight: 800; flex: none; }
.marca small { display: block; font: 500 11px/1.2 var(--f-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted); }

/* ---------- Botones y campos ---------- */
.btn { color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s; text-decoration: none; }
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: default; transform: none; }
.btn-primario { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primario:hover { background: #ffc233; border-color: #ffc233; }
.btn-peligro { color: var(--bad); }
.btn-peligro:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-solido-peligro { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-solido-peligro:hover { background: var(--bad); filter: brightness(1.08); border-color: var(--bad); }
.btn-ok { color: var(--ok); }
.btn-ok:hover { background: var(--ok-soft); border-color: var(--ok); }
.btn-fantasma { border-color: transparent; background: transparent; }
.btn-fantasma:hover { background: var(--surface-2); border-color: var(--line); }
.btn-bloque { width: 100%; }
.icono { width: 16px; height: 16px; flex: none; }

.campo { display: grid; gap: 6px; }
.campo label { font-weight: 600; font-size: 13px; }
.campo .ayuda { font-size: 12px; color: var(--muted); }
.entrada { width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 15px; }
.entrada:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.entrada { min-height: 76px; resize: vertical; }
.error-form { color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 9px 12px; font-size: 13px; font-weight: 500; }

/* ---------- Utilidades de maquetación ---------- */
.pila { display: grid; gap: 18px; }
.sub { margin: 4px 0 0; }
.intro { margin: 0; max-width: 46ch; }
.pista { margin: 10px 0 0; }
.login-pie { color: var(--side-muted); font-size: 12px; }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.login-lado { background: var(--side); color: var(--side-ink); padding-block: 40px; padding-left: max(40px, env(safe-area-inset-left, 0px)); padding-right: 40px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; position: relative; overflow: hidden; }
.login-lado h1 { font-size: clamp(30px, 4vw, 46px); line-height: 1.05; font-weight: 800; max-width: 12ch; }
.login-lado h1 em { font-style: normal; color: var(--accent); }
.login-lado p { color: var(--side-muted); max-width: 40ch; margin: 14px 0 0; }
.login-ruta { position: absolute; right: -60px; bottom: -40px; width: 340px; opacity: .9; pointer-events: none; }
.login-form { display: grid; place-items: center; padding-block: 40px; padding-left: 24px; padding-right: max(24px, env(safe-area-inset-right, 0px)); }
.login-form form { width: 100%; max-width: 360px; display: grid; gap: 18px; }
.login-form h2 { font-size: 24px; }

/* ---------- Estructura ---------- */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100%; }
.lateral { background: var(--side); color: var(--side-ink); padding: 20px 14px; padding-left: max(14px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 26px; position: sticky; top: 0; height: 100vh; height: 100dvh; }
.nav { display: grid; gap: 2px; }
.nav-titulo { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--side-muted); padding: 0 10px 6px; font-weight: 600; }
.nav a, .nav span.prox { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-ink); text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .06); }
.nav a[aria-current="page"] { background: rgba(255, 179, 0, .14); color: var(--accent); }
.nav span.prox { color: var(--side-muted); cursor: default; justify-content: space-between; }
.nav span.prox i { font-style: normal; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; border: 1px solid #2f2e2a; border-radius: 99px; padding: 1px 7px; }
.lateral-pie { margin-top: auto; display: grid; gap: 10px; border-top: 1px solid #23221f; padding-top: 14px; }
.yo { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #262521; color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.yo div { min-width: 0; }
.yo strong { display: block; font-size: 13px; }
.yo div span { display: block; font-size: 12px; color: var(--side-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lateral .btn { background: transparent; border-color: #2f2e2a; color: var(--side-ink); }
.lateral .btn:hover { background: rgba(255, 255, 255, .06); }

.principal { min-width: 0; padding-block: 28px 48px; padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px)); display: grid; gap: 22px; align-content: start; max-width: 1180px; }
.encabezado { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.encabezado .migas { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.encabezado h1 { font-size: 28px; font-weight: 800; }

.aviso-demo { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--r); padding: 10px 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; font-size: 13px; }
.aviso-demo strong { font-weight: 700; }

/* ---------- Filtros por estado ---------- */
.filtros { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.filtro { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; cursor: pointer; display: grid; gap: 2px; transition: border-color .15s, box-shadow .15s; }
.filtro:hover { border-color: var(--muted); }
.filtro[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.filtro span { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.filtro strong { font: 700 24px/1.2 var(--f-display); font-variant-numeric: tabular-nums; }
.punto { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.punto.activo { background: var(--ok); } .punto.suspendido { background: var(--warn); } .punto.baja { background: var(--off); } .punto.todos { background: var(--ink); }

.barra { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.buscar { position: relative; flex: 1 1 260px; }
.buscar .icono { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.buscar .entrada { padding-left: 36px; }

/* ---------- Tabla ---------- */
.tarjeta { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.tabla-envoltura { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
th:first-child { border-top-left-radius: var(--r); } th:last-child { border-top-right-radius: var(--r); }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
.persona { display: flex; align-items: center; gap: 12px; min-width: 0; }
.persona .avatar { background: var(--accent-soft); color: var(--ink); }
.persona strong { display: block; font-weight: 600; }
.persona small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.vacio { padding: 48px 20px; text-align: center; color: var(--muted); display: grid; gap: 12px; justify-items: center; }
.vacio strong { color: var(--ink); font-size: 15px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.activo { color: var(--ok); background: var(--ok-soft); }
.chip.suspendido { color: var(--warn); background: var(--warn-soft); }
.chip.baja { color: var(--off); background: var(--off-soft); }
.chip.bloqueado { color: var(--bad); background: var(--bad-soft); }

/* Tarjetas en lugar de tabla en celular */
.lista-movil { display: none; }
.fila-movil { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; width: 100%; }
.fila-movil:last-child { border-bottom: 0; }
.fila-movil .meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- Panel de detalle ---------- */
.velo { position: fixed; inset: 0; background: rgba(12, 12, 11, .45); z-index: 40; animation: aparecer .15s ease-out; }
.cajon { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--surface); z-index: 41; display: flex; flex-direction: column; box-shadow: var(--shadow); animation: deslizar .2s cubic-bezier(.2, .8, .2, 1); padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-right: env(safe-area-inset-right, 0px); }
.cajon-cab { padding: 20px 22px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.cajon-cab .fila { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cajon-cab h2 { font-size: 22px; font-weight: 800; }
.cajon-cuerpo { padding: 18px 22px 28px; overflow-y: auto; display: grid; gap: 22px; align-content: start; }
.datos { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 18px; margin: 0; }
.datos dt { color: var(--muted); font-size: 13px; }
.datos dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.acciones { display: flex; flex-wrap: wrap; gap: 8px; }
.seccion-titulo { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.motivo { background: var(--warn-soft); color: var(--ink); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.motivo.baja { background: var(--off-soft); }
.linea-tiempo { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.linea-tiempo li { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 12px; padding-bottom: 14px; position: relative; }
.linea-tiempo li::before { content: ""; position: absolute; left: 6px; top: 14px; bottom: 0; width: 1px; background: var(--line); }
.linea-tiempo li:last-child::before { display: none; }
.linea-tiempo .marca-evento { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); background: var(--muted); margin-top: 4px; }
.linea-tiempo .marca-evento.ok { background: var(--ok); } .linea-tiempo .marca-evento.warn { background: var(--warn); }
.linea-tiempo .marca-evento.bad { background: var(--bad); } .linea-tiempo .marca-evento.acento { background: var(--accent); }
.linea-tiempo p { margin: 0; }
.linea-tiempo small { color: var(--muted); font-size: 12px; }

/* ---------- Diálogos ---------- */
.dialogo { position: fixed; z-index: 51; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(480px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow-y: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 24px; display: grid; gap: 18px; animation: subir .18s cubic-bezier(.2, .8, .2, 1); }
.dialogo h2 { font-size: 20px; font-weight: 800; }
.dialogo p { margin: 0; }
.dialogo .pie { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.velo.sobre { z-index: 50; }

.codigo-caja { background: var(--side); color: var(--side-ink); border-radius: 12px; padding: 20px; display: grid; gap: 6px; text-align: center; }
.codigo-caja small { color: var(--side-muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
.codigo-caja .codigo { font: 700 clamp(30px, 8vw, 40px)/1.1 var(--f-mono); letter-spacing: .06em; color: var(--accent); }
.codigo-caja .tel { color: var(--side-ink); font-weight: 500; }
.nota-aviso { font-size: 13px; color: var(--muted); display: flex; gap: 8px; }
.mensaje-wa { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 13px; white-space: pre-wrap; }

/* ---------- Zonas y WhatsApp ---------- */
.intro-ancha { margin: -8px 0 0; max-width: 72ch; }
.zonas { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 14px; align-items: start; }
.zona { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: grid; gap: 16px; }
.zona.on { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.zona-cab { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.zona-cab h3 { font-size: 17px; font-weight: 700; }
.zona-cab .muted { font-size: 13px; }
.zona-numero { display: flex; align-items: center; gap: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.zona-numero .icono { width: 22px; height: 22px; color: var(--ok); }
.zona-numero strong { display: block; font: 700 18px/1.2 var(--f-mono); letter-spacing: .02em; }
.zona-numero strong.muted { font: 600 14px/1.3 var(--f-ui); letter-spacing: 0; }
.zona-numero small { color: var(--muted); font-size: 12px; }
.zona-cobertura { margin: 0; font-size: 13px; }
.servicios { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.servicio { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-weight: 500; }
.servicio:last-child { border-bottom: 0; }
.etiqueta-dev { font-style: normal; font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; margin-left: 6px; white-space: nowrap; }
.interruptor { width: 44px; height: 26px; border-radius: 99px; border: 0; padding: 3px; background: var(--line); cursor: pointer; flex: none; transition: background .15s; }
.interruptor span { display: block; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .18s cubic-bezier(.2,.8,.2,1); }
.interruptor[aria-checked="true"] { background: var(--accent); }
.interruptor[aria-checked="true"] span { transform: translateX(18px); }
.interruptor[disabled] { cursor: not-allowed; opacity: .45; }
.zona-vacia { border-style: dashed; background: transparent; cursor: pointer; min-height: 200px; place-content: center; justify-items: center; gap: 6px; text-align: center; color: var(--ink); }
.zona-vacia:hover { border-color: var(--muted); background: var(--surface); }
.zona-vacia .icono { width: 22px; height: 22px; }

/* ---------- Bitácora ---------- */
.evento { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.evento:last-child { border-bottom: 0; }
.evento time { color: var(--muted); font-size: 13px; }
.evento p { margin: 0; }
.evento small { color: var(--muted); }

/* ---------- Simulador de app (solo vista previa) ---------- */
.telefono-sim { background: var(--side); border-radius: 26px; padding: 22px 18px; color: var(--side-ink); display: grid; gap: 14px; }
.telefono-sim .entrada { background: #1c1c1a; border-color: #34332f; color: var(--side-ink); }
.telefono-sim .res { border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.telefono-sim .res.ok { background: #12301f; color: #7ee2a8; }
.telefono-sim .res.mal { background: #3d1813; color: #ffb0a5; }

/* ---------- Aviso flotante ---------- */
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow); animation: subir .18s ease-out; max-width: calc(100% - 32px); }

@keyframes aparecer { from { opacity: 0; } }
@keyframes deslizar { from { transform: translateX(24px); opacity: 0; } }
@keyframes subir { from { opacity: 0; translate: 0 8px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Celular ---------- */
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-lado { padding-block: 28px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); gap: 18px; }
  .login-ruta { width: 200px; right: -40px; bottom: -50px; opacity: .5; }
  .app { grid-template-columns: 1fr; }
  .lateral { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .lateral .nav-titulo, .lateral .prox, .lateral .yo { display: none; }
  .lateral .nav { display: flex; gap: 4px; }
  .lateral-pie { margin-top: 0; border-top: 0; padding-top: 0; display: flex; }
  .lateral .grupo-prox { display: none; }
  .principal { padding-block: 20px 40px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .filtros { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabla-envoltura { display: none; }
  .lista-movil { display: block; }
  .evento { grid-template-columns: 1fr; gap: 4px; }
  .encabezado h1 { font-size: 24px; }
}
