
:root {
  /* Marca */
  --primary: #23854b;
  --primary-dark: #1b6a3b;
  --primary-rgb: 35, 133, 75;
  --primary-soft: #e8f4ed;      /* fondos tintados de verde */
  --accent: #23854b;
  --secondary: #1f2a24;

  /* Neutros con un ligero sesgo verde */
  --background: #e8eeea;
  --surface: #fbfcfb;
  --surface-light: #f1f5f2;
  --border: #d5dfd9;
  --border-strong: #c1cec6;
  --text: #17201b;
  --text-muted: #66726b;

  /* Estados */
  --success: #23854b;
  --error: #d64545;
  --error-soft: #fdecec;

  /* Espaciado */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Radios */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Sombras suaves */
  --shadow-sm: 0 1px 2px rgba(23, 32, 27, 0.05);
  --shadow-md: 0 1px 2px rgba(23, 32, 27, 0.04), 0 4px 12px rgba(23, 32, 27, 0.06);
  --shadow-lg: 0 2px 4px rgba(23, 32, 27, 0.04), 0 16px 40px rgba(23, 32, 27, 0.10);
  --ring: 0 0 0 3px rgba(35, 133, 75, 0.18);
  --shadow-glow: var(--ring);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--background);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input {
  font: inherit;
}

::selection {
  background: rgba(var(--primary-rgb), 0.18);
}

h1, h2, h3, h4 {
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

/* Antes era un vidrio oscuro; ahora tarjeta blanca limpia */
.card-glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.625rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn:disabled {
  opacity: 0.65;
  cursor: progress;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(23, 32, 27, 0.12);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--surface-light);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--error);
  color: #fff;
}
.btn-danger:hover {
  background: #bd3a3a;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8125rem;
  font-weight: 500;
}

/* ---------- Formularios ---------- */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.input-group label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.input {
  width: 100%;
  padding: 0.75rem 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.9375rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:hover {
  border-color: #b9c4bd;
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
.input::placeholder {
  color: #9aa49e;
}

/* ---------- Tablas ---------- */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--surface);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
tr:hover {
  background: var(--surface-light);
}

/* ---------- Stats (no usado en dashboard, se conserva) ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.stat-label {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: var(--space-xs);
}

/* ---------- Header ---------- */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--space-md) 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

/* ---------- Utilidades ---------- */
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error   { color: var(--error); }
.text-center  { text-align: center; }
.text-sm      { font-size: 0.875rem; }

.flex            { display: flex; }
.flex-col        { flex-direction: column; }
.items-center    { align-items: center; }
.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.w-full { width: 100%; }

/* ---------- Animaciones ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in {
  animation: fadeIn 0.3s ease forwards;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 1rem 0.75rem 0.875rem;
  border-radius: var(--radius-md);
  background: var(--secondary);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4cc47f;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast-success { background: var(--secondary); color: #fff; }
.toast-error   { background: var(--secondary); color: #fff; }
.toast-error::before { background: #ff6b6b; }

/* El JS asigna display:block; mantenemos flex para alinear el punto */
.toast[style*="display: block"],
.toast[style*="display:block"] {
  display: flex !important;
}

/* ---------- Link corto ---------- */
.short-link {
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--primary-soft);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--primary-dark);
  word-break: break-all;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}
.copy-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}
.copy-btn:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

/* ---------- Interacción de botones (login y general) ---------- */
.btn-primary {
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.30);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(23, 32, 27, 0.12);
}
.btn-secondary:active {
  transform: translateY(1px);
}