* {
  box-sizing: border-box;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  background: #f4f6f8;
  margin: 0;
  color: #222;
}

/* --- Pantallas centradas (login, 2FA) --- */
body.center-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

.login-box {
  background: #fff;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  width: 340px;
  text-align: center;
}

.login-box.ancho {
  width: 380px;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  color: #1a3c6e;
}

.subtitle {
  color: #666;
  margin-top: 0;
  margin-bottom: 1.5rem;
}

label {
  display: block;
  text-align: left;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: #333;
}

input, select, textarea {
  width: 100%;
  padding: 0.7rem;
  margin-top: 0.3rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  box-sizing: border-box;
}

textarea {
  resize: vertical;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.checkbox-line input {
  width: auto;
  margin-top: 0;
}

.checkbox-line label {
  margin: 0;
}

button, .btn {
  display: inline-block;
  padding: 0.8rem 1.4rem;
  background: #1a6ee8;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1.05rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

button.full, .btn.full {
  width: 100%;
  margin-top: 1.5rem;
}

button:hover, .btn:hover {
  background: #1558b8;
}

.btn-secundario {
  background: #e6e9ee;
  color: #333;
}

.btn-secundario:hover {
  background: #d5d9e0;
}

.btn-peligro {
  background: #c0392b;
}

.btn-peligro:hover {
  background: #a5301f;
}

.btn-pequeno {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.error {
  color: #c0392b;
  font-size: 0.9rem;
  background: #fdecea;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
}

.button-link {
  display: inline-block;
  margin-top: 1.5rem;
  padding: 0.7rem 1.2rem;
  background: #1a6ee8;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
}

/* --- Layout de la aplicación --- */
.topbar {
  background: #1a3c6e;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.topbar-brand {
  font-weight: bold;
  font-size: 1.1rem;
}

.topbar-nav {
  display: flex;
  gap: 1.2rem;
}

.topbar-nav a {
  color: #dce6f7;
  text-decoration: none;
  font-size: 0.95rem;
}

.topbar-nav a:hover {
  color: #fff;
  text-decoration: underline;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.logout-link {
  color: #dce6f7;
  text-decoration: underline;
}

.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.5rem;
}

.form-grid .full-width {
  grid-column: 1 / -1;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #eee;
  font-size: 0.92rem;
}

th {
  background: #f0f2f5;
  color: #444;
  font-weight: 600;
}

tr:hover td {
  background: #f8fafc;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-verde {
  background: #e3f6e8;
  color: #1e7e34;
}

.badge-gris {
  background: #eceff1;
  color: #607d8b;
}

.badge-azul {
  background: #e3ecfb;
  color: #1a3c6e;
}

.filtros {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
  align-items: flex-end;
}

.filtros label {
  margin-top: 0;
}

.filtros > div {
  min-width: 160px;
}

.filtros button {
  margin-top: 0.3rem;
}

.ficha-seccion {
  margin-bottom: 1.5rem;
}

.ficha-seccion h3 {
  color: #1a3c6e;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.acciones {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.qr-box {
  text-align: center;
  margin: 1rem 0;
}

.qr-box img {
  border: 1px solid #eee;
  border-radius: 8px;
}

.secreto-manual {
  font-family: monospace;
  background: #f0f2f5;
  padding: 0.5rem;
  border-radius: 6px;
  word-break: break-all;
  font-size: 0.85rem;
}

.badge-naranja {
  background: #fdf0e0;
  color: #b5651d;
}

/* --- Bandeja de WhatsApp --- */
.split-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 800px) {
  .split-layout {
    grid-template-columns: 1fr;
  }
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.5rem;
}

.chat-bubble {
  max-width: 75%;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  font-size: 0.92rem;
  white-space: pre-wrap;
}

.chat-bubble.entrante {
  align-self: flex-start;
  background: #eceff1;
  color: #222;
  border-bottom-left-radius: 2px;
}

.chat-bubble.saliente {
  align-self: flex-end;
  background: #dcf0e0;
  color: #1e3a24;
  border-bottom-right-radius: 2px;
}

.chat-bubble .chat-meta {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.72rem;
  color: #667;
  opacity: 0.75;
}

/* --- Tablero de direccion --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-tile {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  padding: 1.2rem 1.4rem;
  border-left: 4px solid #1a6ee8;
}

.stat-tile.stat-alerta {
  border-left-color: #b5651d;
}

.stat-tile .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1a3c6e;
  line-height: 1.1;
}

.stat-tile .stat-label {
  color: #666;
  font-size: 0.85rem;
  margin-top: 0.3rem;
}

.stat-tile a {
  color: inherit;
  text-decoration: none;
  display: block;
}

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 3rem;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.bar-track {
  background: #eceff1;
  border-radius: 6px;
  height: 14px;
  overflow: hidden;
}

.bar-fill {
  background: #1a6ee8;
  height: 100%;
  border-radius: 6px;
}

.lista-alertas {
  list-style: none;
  padding: 0;
  margin: 0;
}

.lista-alertas li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
}

.lista-alertas li:last-child {
  border-bottom: none;
}

.lista-alertas a {
  color: #1a3c6e;
  text-decoration: none;
}

.lista-alertas a:hover {
  text-decoration: underline;
}
