* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

body {
  margin: 0;
  background: #f4f6f9;
  color: #222;
}

/* LOGIN */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0d6efd, #6610f2);
}

.login-box {
  background: #fff;
  padding: 40px;
  border-radius: 14px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-header h1 {
  margin: 0 0 4px;
  color: #0d6efd;
}

.login-header p {
  margin: 0;
  color: #666;
  font-size: 14px;
}

.login-box form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-box label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: #444;
  gap: 4px;
}

.login-box input {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
}

.login-box button {
  padding: 11px;
  background: #0d6efd;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}

.login-box button:hover {
  background: #0b5ed7;
}

.login-hint {
  text-align: center;
  font-size: 12px;
  color: #888;
  margin-top: 16px;
}

/* LAYOUT */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: #1f2937;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 20px;
  font-weight: 700;
  font-size: 16px;
  border-bottom: 1px solid #374151;
}

.sidebar-brand img {
  max-height: 80px;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 0;
}

.sidebar-nav a {
  padding: 11px 20px;
  color: #d1d5db;
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: #111827;
  color: #fff;
}

.sidebar-nav a.active {
  background: #111827;
  color: #fff;
  border-left-color: #0d6efd;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid #374151;
  font-size: 13px;
}

.sidebar-footer .user-info {
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-logout {
  display: block;
  text-align: center;
  padding: 8px;
  background: #dc3545;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-size: 13px;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: #fff;
  padding: 16px 28px;
  border-bottom: 1px solid #e5e7eb;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
}

.content {
  padding: 24px 28px;
  flex: 1;
}

/* CARDS */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

.card h3 {
  margin: 0 0 14px;
  font-size: 16px;
  color: #111;
}

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi-card {
  padding: 18px;
  border-radius: 10px;
  color: #fff;
  position: relative;
}

.kpi-label {
  display: block;
  font-size: 12px;
  opacity: .9;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
}

.kpi-link {
  position: absolute;
  bottom: 10px;
  right: 14px;
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  opacity: .85;
}

.kpi-blue {
  background: #0d6efd;
}

.kpi-green {
  background: #198754;
}

.kpi-yellow {
  background: #fd7e14;
}

.kpi-red {
  background: #dc3545;
}

.kpi-purple {
  background: #6f42c1;
}

.kpi-cyan {
  background: #0dcaf0;
  color: #083344;
}

/* ROWS */
.row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.col-half {
  flex: 1 1 calc(50% - 10px);
  min-width: 320px;
}

.col-third {
  flex: 1 1 30%;
  min-width: 260px;
}

.col-2thirds {
  flex: 1 1 65%;
  min-width: 320px;
}

/* TABLES */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
  vertical-align: top;
}

.table thead th {
  background: #f8f9fa;
  font-size: 12px;
  text-transform: uppercase;
  color: #555;
}

.table tbody tr:hover {
  background: #f8f9ff;
}

/* FORMS */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
}

form label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: #444;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  align-items: center;
}

.form-actions.sticky {
  position: sticky;
  bottom: 0;
  background: #fff;
  padding: 14px 0;
  border-top: 1px solid #eee;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* BUTTONS */
.btn,
.btn-primary,
.btn-ghost,
.btn-danger,
.btn-small {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  border: none;
}

.btn {
  background: #e5e7eb;
  color: #111;
}

.btn-primary {
  background: #0d6efd;
  color: #fff;
}

.btn-primary:hover {
  background: #0b5ed7;
}

.btn-ghost {
  background: transparent;
  border: 1px solid #ccc;
  color: #555;
}

.btn-danger {
  background: #dc3545;
  color: #fff;
}

.btn-small {
  padding: 5px 10px;
  font-size: 12px;
  background: #e5e7eb;
  color: #111;
}

.btn-small.btn-primary {
  background: #0d6efd;
  color: #fff;
}

.btn-small.btn-danger {
  background: #dc3545;
  color: #fff;
}

/* ALERTS */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-ok {
  background: #d1e7dd;
  color: #0f5132;
}

.alert-error {
  background: #f8d7da;
  color: #842029;
}

/* BADGES */
.badge {
  background: #e5e7eb;
  color: #111;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.badge-warn {
  background: #fff3cd;
  color: #664d03;
}

.badge-learn {
  background: #d1ecf1;
  color: #055160;
}

.role-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.role-superadmin {
  background: #6f42c1;
  color: #fff;
}

.role-editor {
  background: #0d6efd;
  color: #fff;
}

.role-consulta {
  background: #e5e7eb;
  color: #111;
}

.status {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.status-activa {
  background: #d1e7dd;
  color: #0f5132;
}

.status-finalizada {
  background: #e2e3e5;
  color: #41464b;
}

.status-redirigida {
  background: #fff3cd;
  color: #664d03;
}

.status-expirada {
  background: #f8d7da;
  color: #842029;
}

/* TOOLBAR */
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  padding: 12px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filters input,
.filters select {
  width: auto;
  min-width: 160px;
}

.toolbar .actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* TABS */
.tabs {
  display: flex;
  gap: 4px;
}

.tabs a {
  padding: 8px 14px;
  background: #e5e7eb;
  border-radius: 8px;
  text-decoration: none;
  color: #333;
  font-size: 13px;
}

.tabs a.active {
  background: #0d6efd;
  color: #fff;
}

/* SIMPLE LIST */
.simple-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.simple-list li {
  padding: 10px 0;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.simple-list li:last-child {
  border-bottom: none;
}

/* INFO LIST */
.info-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  font-size: 14px;
}

.info-list li {
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
}

/* CHAT PREVIEW */
.chat-preview {
  max-height: 600px;
  overflow-y: auto;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #eee;
}

.chat-msg {
  margin: 6px 0;
  display: flex;
}

.chat-usuario {
  justify-content: flex-end;
}

.chat-bot {
  justify-content: flex-start;
}

.chat-bubble {
  background: #e9ecef;
  padding: 8px 12px;
  border-radius: 10px;
  max-width: 70%;
  font-size: 14px;
}

.chat-usuario .chat-bubble {
  background: #0d6efd;
  color: #fff;
}

.chat-meta {
  font-size: 10px;
  opacity: .7;
  margin-top: 4px;
}

/* PAGINATION */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
}

.pagination a {
  padding: 6px 12px;
  background: #e5e7eb;
  border-radius: 6px;
  text-decoration: none;
  color: #333;
  font-size: 13px;
}

.pagination a.active {
  background: #0d6efd;
  color: #fff;
}

/* MISC */
.muted {
  color: #888;
  font-size: 13px;
}

.center {
  text-align: center;
}

.quote {
  background: #f8f9fa;
  padding: 14px 18px;
  border-left: 4px solid #0d6efd;
  margin: 0 0 14px;
  font-style: italic;
  border-radius: 4px;
}

.actions {
  display: flex;
  gap: 6px;
}

/* NOTIFICACIONES */
.notif-badge {
  background: #dc3545;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
  }

  .sidebar-nav a {
    white-space: nowrap;
  }

  .col-half,
  .col-third,
  .col-2thirds {
    flex: 1 1 100%;
  }
}

/* LOGO EN LOGIN */
.login-logo {
  text-align: center;
  margin-bottom: 0px;
}

.login-logo img {
  max-width: 280px;
  max-height: 280px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

/* IMPORTAR */
.info-box { background: #f8f9fa; border-left: 4px solid #0d6efd; padding: 16px 20px; border-radius: 6px; margin: 16px 0; }
.info-box h4 { margin: 0 0 10px; font-size: 15px; color: #0d6efd; }
.info-box p { margin: 0 0 10px; font-size: 13px; color: #555; }
.table-format { margin: 10px 0; font-size: 13px; }
.table-format code { background: #e9ecef; padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.badge-required { background: #dc3545; color: #fff; }
.badge-optional { background: #6c757d; color: #fff; }
.rules-list { margin: 10px 0; padding-left: 20px; font-size: 13px; color: #555; }
.rules-list li { margin: 6px 0; }
.rules-list code { background: #e9ecef; padding: 1px 5px; border-radius: 3px; font-size: 12px; }

.actions-row { display: flex; gap: 10px; margin: 16px 0; flex-wrap: wrap; }

.import-options { display: flex; flex-direction: column; gap: 10px; background: #f8f9fa; padding: 14px; border-radius: 8px; margin: 14px 0; }
.import-options .check { font-size: 13px; }

/* PREVIEW */
.preview-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.preview-card { padding: 14px; border-radius: 8px; color: #fff; text-align: center; }
.preview-card-label { display: block; font-size: 12px; opacity: .9; }
.preview-card-value { display: block; font-size: 24px; font-weight: 700; margin-top: 4px; }
.card-blue   { background: #0d6efd; }
.card-green  { background: #198754; }
.card-yellow { background: #fd7e14; }
.card-red    { background: #dc3545; }

.preview-table { font-size: 12px; }
.preview-table td { max-width: 320px; word-wrap: break-word; }
.preview-table tbody tr:hover { background: #f8f9ff; }

.preview-resumen { margin-bottom: 16px; }