@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-alt: #f7f8fc;
  --border: #edeff5;
  --border-strong: #dfe2ec;
  --text: #3d4465;
  --text-secondary: #7e7e8a;
  --text-faint: #a9adbb;
  --accent: #fe634e;
  --accent-hover: #ff7b68;
  --accent-soft: #ffe4e0;
  --danger: #d92d3f;
  --danger-soft: #fde2e5;
  --success: #16a673;
  --success-soft: #dff6ec;
  --amber: #c98a00;
  --amber-soft: #fff3da;
  --indigo: #5b6fd8;
  --indigo-soft: #eceffd;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --shadow: 0 12px 32px -16px rgba(61, 68, 101, 0.18), 0 2px 6px rgba(61, 68, 101, 0.05);
  --space-1: 0.4rem;
  --space-2: 0.7rem;
  --space-3: 1.1rem;
  --space-4: 1.7rem;
  --space-5: 2.4rem;
  --font: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "IBM Plex Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1600px; margin: 0 auto; padding: var(--space-5) var(--space-4) 4rem; }

/* ---------- App shell (sidebar + content) ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  padding: 1.4rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}
.sidebar-brand { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 1.4rem; padding: 0 0.4rem; }
.sidebar-mark {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 12px;
  background: linear-gradient(155deg, var(--accent), #ff9478);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.15rem;
  box-shadow: 0 10px 22px -8px rgba(254, 99, 78, 0.55);
}
.sidebar-brand-text { font-weight: 650; color: var(--text); font-size: 0.95rem; letter-spacing: -0.01em; }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; }
.sidebar-link {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-faint);
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-icon { font-size: 1.15rem; flex: none; line-height: 1; }
.sidebar-label { white-space: nowrap; }
.sidebar-link:hover { background: var(--surface-alt); color: var(--text); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-logout { margin: 0; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.8rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 1.15rem; margin: 0; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.topbar .sub { font-size: 0.78rem; color: var(--text-faint); display: block; margin-top: 0.1rem; }
.topbar form { margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: var(--space-3); flex-wrap: wrap; }
.panel h2 { margin: 0; font-size: 1.05rem; font-weight: 600; color: var(--text); letter-spacing: -0.005em; }
.panel .count { color: var(--text-faint); font-weight: 500; font-size: 0.85rem; }

/* ---------- Estadísticas (donas SVG) ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.stat-card-title { margin: 0; font-size: 0.85rem; font-weight: 650; color: var(--text); text-align: center; }
.donut-wrap { position: relative; display: inline-flex; }
.donut-svg circle { transition: stroke-dasharray 0.3s ease; }
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.donut-center-value { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1; }
.donut-center-label { font-size: 0.68rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.donut-legend { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 0.35rem; }
.donut-legend li { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.legend-label { color: var(--text-secondary); flex: 1; }
.legend-value { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Forms ---------- */
.form-grid { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-3); align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 140px; }
.field label { font-size: 0.78rem; color: var(--text-secondary); font-weight: 600; }
input, select, textarea {
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  font-family: var(--font);
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
button {
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
  white-space: nowrap;
}
button:hover { background: var(--accent-hover); }
button:active { transform: translateY(1px); }
button.secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border-strong); }
button.secondary:hover { background: var(--border); }

.button-link {
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.button-link:hover { background: var(--accent-hover); }
.button-link.secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border-strong); }
.button-link.secondary:hover { background: var(--border); }
.button-link.disabled { opacity: 0.4; pointer-events: none; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: var(--space-3); }
.pagination-status { font-size: 0.82rem; color: var(--text-secondary); }
button.danger { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(217, 45, 63, 0.25); }
button.danger:hover { background: #fbd2d6; }

/* ---------- Table ---------- */
.table-scroll { overflow-x: auto; overflow-y: hidden; }
table { width: 100%; min-width: 900px; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 0.75rem 0.7rem; vertical-align: top; }
thead th {
  color: var(--text-faint);
  font-weight: 650;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-strong);
  background: var(--surface);
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--surface-alt); }
tbody tr:last-child { border-bottom: none; }
td .primary { font-weight: 600; color: var(--text); }
td .stack { display: flex; flex-direction: column; gap: 0.15rem; }
td .stack-label { font-size: 0.7rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.03em; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-active { background: var(--success-soft); color: var(--success); }
.badge-revoked { background: var(--danger-soft); color: var(--danger); }
.badge-annual { background: var(--indigo-soft); color: var(--indigo); }
.badge-perpetual { background: var(--amber-soft); color: var(--amber); }

.hint { color: var(--text-secondary); font-size: 0.8rem; }
.error { color: var(--danger); font-size: 0.85rem; background: var(--danger-soft); border-radius: var(--radius-sm); padding: 0.6rem 0.9rem; }
.success-msg { color: var(--success); font-size: 0.85rem; background: var(--success-soft); border-radius: var(--radius-sm); padding: 0.6rem 0.9rem; }

.license-key { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: -0.01em; color: var(--text); }

.whatsapp-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #e6f8ee;
  font-size: 0.95rem;
  text-decoration: none;
  flex: none;
  transition: background 0.15s ease, transform 0.05s ease;
}
.whatsapp-link:hover { background: #cdf2de; }
.whatsapp-link:active { transform: translateY(1px); }

td.actions, th:last-child { min-width: 320px; }
.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.actions form { margin: 0; }
.actions button, .actions .button-link { padding: 0.4rem 0.9rem; font-size: 0.76rem; }

.empty-row { text-align: center; padding: var(--space-5) 0; color: var(--text-faint); }

/* ---------- Login ---------- */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: var(--bg); }
.login-wrap { width: 100%; max-width: 380px; }
.login-mark {
  width: 48px; height: 48px;
  border-radius: 14px;
  background: linear-gradient(155deg, var(--accent), #ff9478);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.3rem;
  margin: 0 auto 1.1rem;
  box-shadow: 0 10px 22px -8px rgba(254, 99, 78, 0.55);
}
.login-wrap .panel { text-align: center; }
.login-wrap h2 { margin-bottom: 0.3rem; color: var(--text); }
.login-wrap .hint { margin: 0 0 1.3rem; }
.login-wrap .form-grid { text-align: left; }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    position: static;
    padding: 0.6rem 0.8rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-brand { margin: 0 1rem 0 0; }
  .sidebar-brand-text { display: none; }
  .sidebar-nav { flex-direction: row; flex: none; flex-wrap: wrap; justify-content: center; }
  .sidebar-link { width: auto; padding: 0.5rem 0.75rem; }
  .sidebar-label { font-size: 0.82rem; }
  .sidebar-logout { margin-left: 0.3rem; }
}

@media (max-width: 720px) {
  .wrap { padding: var(--space-4) 1rem 3rem; }
  .panel { padding: var(--space-3); }
  .topbar { padding: 0.8rem 1rem; }
}

/* ---------- Encabezado y pie de reporte (seller_sales.php) ---------- */
.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.report-logo { height: 34px; width: auto; display: block; }

.thanks-note {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 0.9rem 1.2rem;
  margin-bottom: var(--space-4);
}
.thanks-note p { margin: 0; color: var(--text); font-weight: 500; font-size: 0.9rem; }

.report-footer {
  text-align: center;
  padding: var(--space-4) 0 var(--space-3);
  margin-top: var(--space-2);
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 0.8rem;
}
.report-footer p { margin: 0.25rem 0; }
.report-footer a { color: var(--text-faint); }

/* ---------- Comprobante de licencia (license_pdf.php) ---------- */
.license-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  text-align: center;
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 1.2rem 1rem;
  margin: 0.5rem 0 1.5rem;
}
.license-hero-label { font-size: 0.75rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); }
.license-hero-key { font-family: var(--font-mono); font-size: 1.3rem; font-weight: 600; color: var(--text); letter-spacing: 0.02em; word-break: break-all; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 1.1rem 1.5rem;
}
.detail-item { display: flex; flex-direction: column; gap: 0.25rem; }
.detail-label { font-size: 0.72rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); }
.detail-value { font-size: 0.95rem; color: var(--text); font-weight: 500; }

@media (max-width: 560px) {
  .detail-grid { grid-template-columns: 1fr; }
}

/* ---------- Impresión / exportar a PDF ----------
   El botón "Exportar a PDF" solo llama a window.print() — sin librería ni
   generación en el servidor. Esto oculta todo lo que no debe salir en el
   PDF (sidebar, topbar, filtros, botones) y deja los paneles como un
   reporte limpio para "Guardar como PDF" desde el diálogo de impresión. */
@media print {
  .sidebar, .no-print { display: none !important; }
  body { background: #fff; }
  .app-shell { display: block; }
  .app-main { display: block; }
  .topbar { position: static; border-bottom: none; padding: 0 0 1rem; }
  .wrap { max-width: none; padding: 0; }
  .panel { box-shadow: none; border: 1px solid #ddd; border-radius: 0; break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
