* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Auth - Sin scroll, contenido compacto */
.auth-screen {
  min-height: 100vh;
  max-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow: hidden;
  background: #f8fafc;
}

.auth-box {
  background: white;
  padding: 1.25rem 1.75rem;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  width: 100%;
  max-width: 420px;
  margin: auto;
  max-height: calc(100vh - 2rem);
  overflow: hidden;
}

.auth-box h1 {
  text-align: center;
  margin-bottom: 0.25rem;
  color: #1e293b;
  font-size: 1.35rem;
  font-weight: 700;
}

.auth-subtitle {
  text-align: center;
  color: #64748b;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid #e2e8f0;
}

.auth-tab {
  flex: 1;
  padding: 0.6rem 1rem;
  border: none;
  background: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.2s;
}

.auth-tab:hover { color: #64748b; }

.auth-tab.active {
  color: #7c3aed;
  font-weight: 600;
  border-bottom: 2px solid #7c3aed;
  margin-bottom: -2px;
}

.auth-form-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.75rem;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.label-row label { margin-bottom: 0; }

.forgot-link {
  font-size: 0.85rem;
  color: #7c3aed;
  text-decoration: none;
}

.forgot-link:hover { text-decoration: underline; }

.auth-form .pwd-wrap {
  position: relative;
}

.auth-form .pwd-wrap input { padding-right: 2.75rem; }

.auth-form .pwd-toggle {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: #64748b;
  font-size: 1.1rem;
}

.auth-form .pwd-toggle:hover { color: #7c3aed; }

.auth-footer-link {
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #64748b;
}

.auth-footer-link a {
  color: #7c3aed;
  font-weight: 600;
  text-decoration: none;
}

.auth-footer-link a:hover { text-decoration: underline; }

.auth-form .form-group {
  margin-bottom: 0.7rem;
}

.auth-form label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: #475569;
  margin-bottom: 0.5rem;
}

.auth-form input {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.auth-form input:focus {
  outline: none;
  border-color: #7c3aed;
}

.auth-footer {
  text-align: center;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: #64748b;
}

.auth-footer a {
  color: #7c3aed;
  font-weight: 600;
  text-decoration: none;
}

.auth-footer a:hover { text-decoration: underline; }

.auth-box .btn-block {
  width: 100%;
  padding: 0.6rem 1rem;
  margin-top: 0.35rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: #7c3aed;
  color: white;
  transition: background 0.2s;
}

.auth-box .btn-block:hover { background: #6d28d9; }

.btn-admin {
  font-size: 0.85rem;
  color: var(--primary);
  text-decoration: none;
}

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --sidebar-bg: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%);
  --card-shadow: 0 1px 3px rgba(0,0,0,0.1);
  --radius: 8px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  line-height: 1.5;
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: white;
  padding: 1.5rem 1rem;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 2rem;
}

.logo-icon {
  font-size: 1.5rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  transition: background 0.2s;
}

.nav-item:hover {
  background: rgba(255,255,255,0.15);
}

.nav-item.active {
  background: rgba(255,255,255,0.25);
  color: white;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.header {
  background: white;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-name {
  font-size: 0.9rem;
  color: #64748b;
}

.btn-logout {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  border: 1px solid #e2e8f0;
  background: white;
  border-radius: var(--radius);
  cursor: pointer;
  color: #64748b;
}

.btn-logout:hover {
  background: #f1f5f9;
}

#content {
  flex: 1;
  padding: 1.5rem;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.card {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: #475569;
}

.status-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94a3b8;
}

.status-dot.api,
.status-dot.db {
  background: var(--success);
}

.status-dot.connected {
  background: var(--success);
}

.status-dot.disconnected,
.status-dot.logged_out {
  background: var(--danger);
}

.status-dot.qr {
  background: var(--warning);
}

.token-box {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.token-box code {
  flex: 1;
  font-size: 0.75rem;
  background: #f1f5f9;
  padding: 0.5rem;
  border-radius: 4px;
  word-break: break-all;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.btn-copy {
  background: #e2e8f0;
  color: #475569;
  flex-shrink: 0;
}

.btn-copy:hover {
  background: #cbd5e1;
}

.btn-doc {
  display: inline-block;
  background: var(--primary);
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.btn-doc:hover {
  background: var(--primary-dark);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-secondary {
  background: #e2e8f0;
  color: #475569;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-danger {
  background: #dc2626;
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-upgrade {
  background: var(--warning);
  color: white;
  width: 100%;
  margin-top: 0.5rem;
}

.subscription .note {
  font-size: 0.8rem;
  color: #94a3b8;
  margin: 0.5rem 0;
}

.progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.progress {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s;
}

.toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.table-container {
  background: white;
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: visible;
  box-shadow: var(--card-shadow);
  -webkit-overflow-scrolling: touch;
}

.table-container .table {
  min-width: 720px;
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.table th {
  background: #f8fafc;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.btn-icon {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  margin: 0 0.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon.orange { background: #fed7aa; color: #9a3412; }
.btn-icon.blue { background: #bfdbfe; color: #1e40af; }
.btn-icon.red { background: #fecaca; color: #991b1b; }

.btn-icon:hover {
  opacity: 0.9;
}

.instance-id {
  font-family: monospace;
  font-size: 0.8rem;
}

.btn-qr {
  margin-top: 0.35rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  background: var(--success);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.send-form {
  max-width: 600px;
  background: white;
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.phone-input {
  display: flex;
  gap: 0.5rem;
}

.phone-input select {
  width: 120px;
}

.btn-attach {
  background: #f1f5f9;
  color: #475569;
  border: 1px dashed #cbd5e1;
  padding: 0.5rem 1rem;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

#file-name {
  font-size: 0.85rem;
  color: #64748b;
}

.btn-send {
  width: 100%;
  padding: 0.75rem;
  background: var(--primary);
  color: white;
  font-size: 1rem;
  margin-top: 0.5rem;
}

.btn-send:hover {
  background: var(--primary-dark);
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  padding: 1.5rem;
  border-radius: var(--radius);
  max-width: 400px;
  width: 90%;
}

.modal-content h3 {
  margin-bottom: 1rem;
}

.modal-success-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 1rem;
  background: var(--success);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
}

.modal-content p {
  color: #64748b;
  margin-bottom: 1rem;
  text-align: center;
}

/* Modal éxito - contenido centrado */
#modal-register-success .modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#modal-register-success .modal-content h3 {
  text-align: center;
}

#modal-register-success #btn-go-login {
  width: auto;
  padding: 0.6rem 1.5rem;
  margin-top: 0.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* Modal de confirmación */
.modal-confirm .modal-confirm-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 380px;
}

.modal-confirm-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  background: #fef3c7;
  color: #d97706;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.modal-confirm-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.modal-confirm-message {
  color: #64748b;
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.modal-confirm-actions {
  width: 100%;
  justify-content: center;
}

#qr-container {
  padding: 1rem;
  background: white;
  display: flex;
  justify-content: center;
  margin: 1rem 0;
}

#qr-container img {
  max-width: 256px;
  height: auto;
}

.qr-hint {
  color: #64748b;
  font-size: 0.9rem;
}

.error {
  color: var(--danger);
  padding: 1rem;
}

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 0.75rem 1.25rem;
  background: #1e293b;
  color: white;
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 200;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
