.admin-page {
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  background: #f5f5f7;
  color: #1d1d1f;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.admin-main {
  display: grid;
  width: 100%;
  max-width: 1200px;
  flex: 1;
  place-items: center;
  margin: 0 auto;
  padding: 80px 24px 60px;
}

/* Formulario de Login */
.admin-login {
  width: min(100%, 440px);
  padding: 44px 36px;
  border: 1px solid #d2d2d7;
  border-radius: 28px;
  background: #ffffff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.07);
  text-align: center;
}
.admin-lock { width: 54px; height: 54px; margin-bottom: 16px; color: #1d1d1f; }
.admin-eyebrow {
  margin-bottom: 8px;
  color: #86868b;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.admin-login h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #1d1d1f;
}
.admin-intro {
  margin-top: 8px;
  color: #86868b;
  font-size: 15px;
  line-height: 1.4;
}
.admin-form { margin-top: 26px; text-align: left; }
.admin-field + .admin-field { margin-top: 18px; }
.admin-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #1d1d1f;
}
.admin-field input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid #d2d2d7;
  border-radius: 12px;
  outline: 0;
  color: #1d1d1f;
  background: #ffffff;
  font: inherit;
  font-size: 15px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.admin-field input:focus {
  border-color: #0071e3;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15);
}
.admin-password-wrap { position: relative; }
.admin-password-wrap input { padding-right: 80px; }
.admin-password-wrap button {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 68px;
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  color: #0071e3;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.admin-password-wrap button:hover { background: #f5f5f7; }
.admin-error {
  margin-top: 14px;
  color: #e30000;
  font-size: 13px;
  line-height: 1.4;
}
.admin-submit,
.admin-logout {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 24px;
  border: 0;
  border-radius: 980px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background-color 140ms ease;
}
.admin-submit {
  width: 100%;
  margin-top: 24px;
  color: #ffffff;
  background: #0071e3;
}
.admin-submit:hover { background: #0077ed; }
.admin-logout {
  color: #1d1d1f;
  background: #e8e8ed;
  font-size: 14px;
}
.admin-logout:hover { background: #dcdce2; }

/* Dashboard Principal */
.admin-dashboard {
  width: 100%;
  text-align: left;
}
.dashboard-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.dashboard-heading h1 {
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: #1d1d1f;
}
.dashboard-heading p {
  color: #86868b;
  font-size: 15px;
  margin-top: 4px;
}
.dashboard-actions-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid #d2d2d7;
  border-radius: 980px;
  color: #1d1d1f;
  background: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.admin-action-btn:hover { background: #f5f5f7; border-color: #86868b; }
.admin-action-btn:active { transform: scale(0.98); }

/* Estadísticas KPIs */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.admin-stat {
  padding: 24px;
  border: 1px solid #e5e5ea;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}
.admin-status,
.admin-stat-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #86868b;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status-pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #34c759;
  box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.7);
  animation: pulse-green 2s infinite;
}
@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(52, 199, 89, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 199, 89, 0); }
}
.admin-stat h2 {
  margin-top: 14px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: #1d1d1f;
}
.admin-stat p {
  margin-top: 4px;
  color: #86868b;
  font-size: 13px;
}

/* Switch de Auto-recarga */
.auto-refresh-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
.auto-refresh-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}
.auto-refresh-toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #e5e5ea;
  border-radius: 34px;
  transition: background-color 200ms ease;
}
.toggle-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.auto-refresh-toggle input:checked + .toggle-slider { background-color: #34c759; }
.auto-refresh-toggle input:checked + .toggle-slider:before { transform: translateX(20px); }
.toggle-text { font-size: 14px; font-weight: 600; color: #1d1d1f; }

/* Barra de herramientas */
.records-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.search-box {
  position: relative;
  flex: 1;
  max-width: 460px;
}
.search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #86868b;
  pointer-events: none;
}
.search-box input {
  width: 100%;
  min-height: 44px;
  padding: 10px 38px 10px 42px;
  border: 1px solid #d2d2d7;
  border-radius: 12px;
  background: #ffffff;
  font-size: 14px;
  outline: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.search-box input:focus {
  border-color: #0071e3;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}
.search-box button {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: #86868b;
  color: white;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.toolbar-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-btn-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid #d2d2d7;
  border-radius: 12px;
  color: #0071e3;
  background: #ffffff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 140ms ease;
}
.admin-btn-action:hover { background: #f0f7ff; border-color: #0071e3; }
.admin-btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid #ff3b30;
  border-radius: 12px;
  color: #ff3b30;
  background: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease;
}
.admin-btn-danger:hover { background: #fff2f2; }

/* Tabla de Notas */
.table-container {
  overflow-x: auto;
  border: 1px solid #e5e5ea;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}
.notes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
}
.notes-table th {
  padding: 14px 18px;
  background: #fafafa;
  color: #86868b;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #e5e5ea;
}
.notes-table td {
  padding: 16px 18px;
  border-bottom: 1px solid #f2f2f7;
  vertical-align: middle;
  color: #1d1d1f;
}
.notes-table tbody tr:hover { background: #fbfbfd; }
.notes-table tbody tr:last-child td { border-bottom: 0; }

/* Celdas específicas */
.cell-index {
  color: #86868b;
  font-weight: 600;
  font-size: 13px;
}
.cell-time {
  font-family: ui-monospace, "SF Pro Text", Consolas, monospace;
  font-size: 13px;
  white-space: nowrap;
}
.cell-ip {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  color: #86868b;
  background: #f5f5f7;
  padding: 3px 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.cell-copyable {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  font-weight: 500;
}
.copy-btn {
  border: 0;
  background: transparent;
  color: #86868b;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  transition: color 120ms ease, background-color 120ms ease;
}
.copy-btn:hover { color: #0071e3; background: #eef6ff; }
.reveal-btn {
  border: 0;
  background: #f0f0f5;
  color: #1d1d1f;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.reveal-btn:hover { background: #e5e5ea; }
.pin-badge {
  display: inline-block;
  padding: 4px 10px;
  background: #eef6ff;
  color: #0071e3;
  border: 1px solid #bce0fd;
  border-radius: 8px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
}
.del-btn {
  border: 0;
  background: transparent;
  color: #86868b;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  transition: color 140ms ease, background-color 140ms ease;
}
.del-btn:hover { color: #ff3b30; background: #fff0ef; }

/* Estado vacío */
.empty-state {
  padding: 60px 20px;
  text-align: center;
}
.empty-state h3 {
  margin-top: 14px;
  font-size: 18px;
  font-weight: 600;
  color: #1d1d1f;
}
.empty-state p {
  margin-top: 6px;
  color: #86868b;
  font-size: 14px;
}

/* Toast de Notificaciones */
.admin-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(29, 29, 31, 0.92);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  backdrop-filter: blur(10px);
  z-index: 1000;
  animation: slide-up 200ms ease-out;
}
@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Enlaces del Dashboard */
.admin-links {
  overflow: hidden;
  margin-top: 24px;
  border: 1px solid #e5e5ea;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}
.admin-link-row {
  display: flex;
  min-height: 80px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 24px;
  text-decoration: none;
  color: inherit;
  transition: background-color 160ms ease-out;
}
.admin-link-row + .admin-link-row { border-top: 1px solid #e5e5ea; }
.admin-link-row:hover { background: #fafafa; }
.admin-link-row strong { display: block; font-size: 16px; font-weight: 600; color: #1d1d1f; }
.admin-link-row small { display: block; margin-top: 3px; color: #86868b; font-size: 13px; }
.admin-link-row > span:last-child { flex-shrink: 0; font-size: 18px; color: #86868b; }
.admin-footer { padding: 24px; color: #86868b; font-size: 12px; text-align: center; }

/* Sección Generador de Enlaces */
.token-generator-section {
  margin-bottom: 28px;
}
.section-card {
  padding: 28px;
  border: 1px solid #e5e5ea;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}
.section-card-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #1d1d1f;
  margin: 4px 0 6px;
}
.section-card-header p {
  color: #86868b;
  font-size: 14px;
}
.token-gen-form {
  margin-top: 20px;
}
.token-form-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}
.token-field {
  display: flex;
  flex-direction: column;
}
.token-field.flex-2 { flex: 2; min-width: 200px; }
.token-field.flex-1 { flex: 1; min-width: 150px; }
.token-field.btn-field { flex-shrink: 0; }
.token-field label {
  font-size: 13px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 6px;
}
.token-field input,
.token-field select {
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid #d2d2d7;
  border-radius: 12px;
  background: #ffffff;
  font: inherit;
  font-size: 14px;
  color: #1d1d1f;
  outline: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.token-field input:focus,
.token-field select:focus {
  border-color: #0071e3;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}
.token-gen-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 12px;
  background: #0071e3;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease, transform 140ms ease;
}
.token-gen-btn:hover { background: #0077ed; }
.token-gen-btn:active { transform: scale(0.98); }

/* Lista de tokens */
.active-tokens-wrap {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid #f2f2f7;
}
.tokens-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.tokens-list-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #1d1d1f;
}
.tokens-list-header span {
  font-size: 13px;
  font-weight: 600;
  color: #86868b;
}
.tokens-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.token-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border: 1px solid #e5e5ea;
  border-radius: 14px;
  background: #fafafc;
  transition: background-color 140ms ease, border-color 140ms ease;
}
.token-item.expired {
  opacity: 0.65;
  background: #fdf2f2;
  border-color: #ffd6d6;
}
.token-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.token-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.token-status-dot.active { background: #34c759; box-shadow: 0 0 6px rgba(52, 199, 89, 0.6); }
.token-status-dot.expired { background: #ff3b30; }
.token-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.token-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.token-title {
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
}
.token-badge-target {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: #eef6ff;
  color: #0071e3;
  font-weight: 600;
}
.token-sub {
  font-size: 12px;
  color: #86868b;
  margin-top: 2px;
}
.token-link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 440px;
}
.token-url-input {
  width: 100%;
  min-height: 36px;
  padding: 6px 12px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: #ffffff;
  color: #1d1d1f;
  outline: 0;
}
.token-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.token-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #0071e3;
  border-radius: 8px;
  background: #0071e3;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 140ms ease;
}
.token-copy-btn:hover { background: #0077ed; }
.token-revoke-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  background: #ffffff;
  color: #ff3b30;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}
.token-revoke-btn:hover { background: #fff2f2; border-color: #ff3b30; }

@media (max-width: 860px) {
  .admin-stats { grid-template-columns: 1fr; }
  .token-form-row { flex-direction: column; align-items: stretch; }
  .token-field.btn-field { margin-top: 6px; }
  .token-gen-btn { width: 100%; justify-content: center; }
  .token-item { flex-direction: column; align-items: stretch; }
  .token-link-box { max-width: 100%; }
  .token-actions { justify-content: flex-end; }
  .records-toolbar { flex-direction: column; align-items: stretch; }
  .search-box { max-width: 100%; }
  .toolbar-buttons { justify-content: flex-end; }
  .dashboard-heading { flex-direction: column; align-items: stretch; }
  .dashboard-actions-top { justify-content: space-between; }
}
