:root {
  --fondo: #1e1f22;
  --panel: #2b2d31;
  --panel-alto: #313338;
  --borde: #3f4147;
  --texto: #dbdee1;
  --suave: #949ba4;
  --acento: #5865f2;
  --ok: #23a55a;
  --aviso: #f0b232;
  --peligro: #da373c;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--fondo);
  color: var(--texto);
  font: 15px/1.45 system-ui, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top, 0) 0 calc(env(safe-area-inset-bottom, 0) + 72px);
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

.cabecera {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--borde);
}
.marca { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.logo { font-size: 20px; }
html[data-tema="claro"] {
  --fondo: #f2f3f5; --panel: #ffffff; --panel-alto: #e3e5e8; --borde: #d4d7dc;
  --texto: #1e1f22; --suave: #5c6370; color-scheme: light;
}
.cabecera-acciones { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cabecera-acciones select { width: auto; padding: 6px 8px; font-size: 13px; }
.boton-icono { background: var(--panel-alto); border: 1px solid var(--borde); border-radius: 10px; min-width: 40px; min-height: 36px; font-size: 16px; cursor: pointer; }
.usuario { cursor: pointer; color: var(--suave); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.aviso-bot {
  margin: 12px 16px 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #3a2f12;
  border: 1px solid var(--aviso);
  color: #fde3a0;
  font-size: 14px;
}
.aviso-bot.caido { background: #3a1719; border-color: var(--peligro); color: #ffc3c5; }
.aviso-bot b { display: block; margin-bottom: 4px; }

main { padding: 16px; max-width: 720px; margin: 0 auto; }
h2 { font-size: 20px; margin: 4px 0 14px; }
h3 { font-size: 15px; margin: 18px 0 8px; color: var(--suave); text-transform: uppercase; letter-spacing: .04em; }

.tarjeta {
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.metrica { background: var(--panel-alto); border-radius: 10px; padding: 12px; min-width: 0; }
.metrica b { display: block; font-size: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metrica span { color: var(--suave); font-size: 12px; }

.lista { list-style: none; padding: 0; margin: 0; }
.lista li {
  padding: 10px 0;
  border-bottom: 1px solid var(--borde);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.fila-clic { cursor: pointer; }
.lista li:last-child { border-bottom: none; }
.lista .texto { min-width: 0; overflow-wrap: anywhere; }
.lista .fecha { color: var(--suave); font-size: 12px; white-space: nowrap; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: var(--panel-alto);
  border: 1px solid var(--borde);
  color: var(--texto);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.chip.activa { border-color: var(--acento); background: #3c4270; }
.chip img, .avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--borde); object-fit: cover; }

input, textarea, select {
  width: 100%;
  background: var(--fondo);
  color: var(--texto);
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  font-size: 16px;
}
input:focus { outline: 2px solid var(--acento); outline-offset: 0; }

button.boton {
  background: var(--panel-alto);
  color: var(--texto);
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 11px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}
button.boton.principal { background: var(--acento); border-color: var(--acento); color: #fff; }
button.boton.peligro { background: var(--peligro); border-color: var(--peligro); color: #fff; }
button.boton.ancho { width: 100%; }
button.boton:disabled { opacity: .5; }

.acciones { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.campo { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: 13px; color: var(--suave); }

.pestanas {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--panel);
  border-top: 1px solid var(--borde);
  padding: 6px 6px calc(env(safe-area-inset-bottom, 0) + 6px);
}
.pestanas button {
  background: none;
  border: none;
  color: var(--suave);
  font: inherit;
  font-size: 18px;
  padding: 6px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}
.pestanas button span { font-size: 11px; }
.pestanas button.activa { color: var(--texto); }

.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--panel-alto); color: var(--suave); white-space: nowrap; }
.badge.malo { background: #3a1719; color: #ffc3c5; }
.badge.ok { background: #1b3a26; color: #a6f0be; }

.transcripcion {
  background: #111214;
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 12px;
  max-height: 55vh;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12px/1.5 ui-monospace, Consolas, monospace;
}

.vacio { color: var(--suave); text-align: center; padding: 24px 8px; }
.login { text-align: center; padding: 48px 8px; }
.login p { color: var(--suave); }
.login .boton { max-width: 320px; margin: 16px auto 0; }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0) + 84px);
  z-index: 10;
  background: var(--panel-alto);
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 8px 24px #0008;
  max-width: 520px;
  margin: 0 auto;
}
.toast.error { border-color: var(--peligro); }

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