/* ============================================
   Licencias CRM Iguana70 — Design System
   Fondo blanco, profesional, con carácter
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

/* === TOKENS === */
:root {
  --brand:        #0ea36b;   /* verde iguana — color principal */
  --brand-dark:   #0b8558;
  --brand-light:  #e8f8f1;
  --brand-glow:   rgba(14, 163, 107, .15);

  --ink:          #0f1923;   /* texto principal */
  --ink-2:        #3d5166;   /* texto secundario */
  --ink-3:        #8fa3b4;   /* placeholders, muted */

  --surface:      #ffffff;
  --surface-2:    #f5f8fa;
  --surface-3:    #eef2f6;

  --border:       #dde4ec;
  --border-focus: #0ea36b;

  --danger:       #e03535;
  --warning:      #f59e0b;
  --success:      #0ea36b;

  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    16px;

  --shadow-sm:    0 1px 3px rgba(15, 25, 35, .06), 0 1px 2px rgba(15, 25, 35, .04);
  --shadow:       0 4px 16px rgba(15, 25, 35, .08), 0 1px 4px rgba(15, 25, 35, .04);
  --shadow-brand: 0 4px 20px rgba(14, 163, 107, .25);

  --font:         'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', monospace;
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--surface-2);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; transition: color .15s; }
a:hover { color: var(--brand-dark); }

/* === TOPBAR === */
.topbar {
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  letter-spacing: -.02em;
}

/* Ícono de iguana SVG inline — simple y memorable */
.topbar-brand::before {
  content: '';
  display: inline-block;
  width: 30px;
  height: 30px;
  background: var(--brand);
  border-radius: 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z'/%3E%3Cpath d='M8 12h8M12 8v8'/%3E%3C/svg%3E");
  background-size: 16px;
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0;
}

.topbar strong {
  color: var(--brand);
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar nav a {
  color: var(--ink-2);
  font-size: .875rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
}

.topbar nav a:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.topbar nav a.active {
  background: var(--brand-light);
  color: var(--brand-dark);
}

/* Botón "Nuevo cliente" en topbar */
.topbar nav a:last-child {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  margin-left: 6px;
}
.topbar nav a:last-child:hover {
  background: var(--brand-dark);
  color: #fff;
}

/* === LAYOUT === */
.container {
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 24px;
}

/* === PÁGINA: TÍTULO === */
.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--ink);
}
.page-header p {
  color: var(--ink-2);
  font-size: .9rem;
  margin-top: 2px;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.03em;
  margin-bottom: 20px;
}

h2 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -.01em;
  margin-bottom: 16px;
  color: var(--ink);
}

/* === STAT GRID === */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}

.stat:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

/* Acento de color en el borde superior */
.stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--brand);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat:nth-child(2)::before { background: #3b82f6; }
.stat:nth-child(3)::before { background: var(--warning); }
.stat:nth-child(4)::before { background: var(--danger); }

.stat {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
}

.stat strong {
  display: block;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -.04em;
  color: var(--ink);
  margin-top: 6px;
  line-height: 1;
}

/* === CARD === */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

/* === TABLA === */
table {
  width: 100%;
  border-collapse: collapse;
}

thead tr {
  border-bottom: 1.5px solid var(--border);
}

th {
  padding: 10px 12px;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-3);
  white-space: nowrap;
}

td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--surface-3);
  font-size: .875rem;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background .12s;
}
tbody tr:hover {
  background: var(--surface-2);
}

/* === CÓDIGO INLINE (license key) === */
code {
  font-family: var(--font-mono);
  font-size: .78rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--brand-dark);
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  letter-spacing: .04em;
  font-weight: 600;
}

/* === BADGES === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--surface-3);
  color: var(--ink-2);
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge.active    { background: #dcfce7; color: #15803d; }
.badge.trial     { background: #dbeafe; color: #1d4ed8; }
.badge.lifetime  { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.badge.suspended,
.badge.cancelled,
.badge.expired   { background: #fee2e2; color: #b91c1c; }
.badge.grace_period,
.badge.past_due  { background: #fef3c7; color: #b45309; }
.badge.activated { background: #dcfce7; color: #15803d; }
.badge.device_limit,
.badge.device_blocked { background: #fee2e2; color: #b91c1c; }
.badge.not_found { background: var(--surface-3); color: var(--ink-3); }
.badge.blocked   { background: #fee2e2; color: #b91c1c; }

/* === BOTONES === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  padding: 9px 18px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 600;
  letter-spacing: -.01em;
  transition: background .15s, box-shadow .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--brand-dark);
  color: #fff;
  box-shadow: var(--shadow-brand);
  transform: translateY(-1px);
}

.btn:active { transform: translateY(0); }

.btn.secondary {
  background: var(--surface);
  color: var(--ink-2);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.btn.secondary:hover {
  background: var(--surface-2);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.btn.danger {
  background: var(--danger);
}
.btn.danger:hover {
  background: #c62828;
  box-shadow: 0 4px 16px rgba(224, 53, 53, .3);
}

/* === FORMULARIOS === */
label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
  letter-spacing: .01em;
}

input, select, textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: .875rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

input::placeholder { color: var(--ink-3); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-grid p { margin: 0; }

/* === ALERTAS === */
.error {
  background: #fff5f5;
  color: #b91c1c;
  border: 1.5px solid #fecaca;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: 16px;
}

.ok {
  background: #f0fdf4;
  color: #15803d;
  border: 1.5px solid #bbf7d0;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: 16px;
}

/* === UTILIDADES === */
.muted { color: var(--ink-3); font-size: .8rem; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Separador entre h1 y botón de acción */
.actions[style*="space-between"] {
  margin-bottom: 20px;
}

/* === LOGIN === */
body.login-body {
  background: var(--surface-2);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Patrón sutil de fondo en login */
body.login-body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(14, 163, 107, .06) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(59, 130, 246, .05) 0%, transparent 50%);
  pointer-events: none;
}

.login-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
  position: relative;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-logo-icon {
  width: 40px;
  height: 40px;
  background: var(--brand);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.login-logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--ink);
}

.login-logo-text span { color: var(--brand); }

.login-card h1 {
  font-size: 1.3rem;
  margin-bottom: 6px;
  letter-spacing: -.03em;
}

.login-card .subtitle {
  color: var(--ink-3);
  font-size: .875rem;
  margin-bottom: 28px;
}

.login-card .btn {
  width: 100%;
  justify-content: center;
  padding: 11px;
  font-size: .95rem;
  margin-top: 4px;
}

/* === RESPONSIVE === */
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .grid,
  .form-grid { grid-template-columns: 1fr; }

  .topbar { padding: 0 16px; }
  .topbar nav a:not(:last-child) { display: none; }

  .container { padding: 0 14px; margin: 16px auto; }
  .card { padding: 16px; }
}