*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --white: #ffffff;
  --off-white: #f8f8f9;
  --gray-50: #f4f4f6;
  --gray-100: #e8e8ed;
  --gray-200: #d1d1db;
  --gray-400: #9898a8;
  --gray-600: #5a5a70;
  --gray-800: #28283a;
  --black: #0f0f1a;
  --accent: #4f46e5;
  --accent-light: #eef2ff;
  --accent-mid: #818cf8;
  --success: #10b981;
  --success-light: #ecfdf5;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --shadow-sm: 0 1px 3px rgba(15,15,26,.06), 0 1px 2px rgba(15,15,26,.04);
  --shadow: 0 4px 16px rgba(15,15,26,.08), 0 1px 4px rgba(15,15,26,.04);
  --shadow-lg: 0 16px 48px rgba(15,15,26,.12), 0 4px 12px rgba(15,15,26,.06);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --font: 'Sora', sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--white);
  color: var(--black);
  -webkit-font-smoothing: antialiased;
}

/* ─── SCREENS ─── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; }

/* ─── LOGIN ─── */
#login-screen {
  align-items: center;
  justify-content: center;
  background: var(--white);
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 50% at 20% 10%, rgba(79,70,229,.06) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 85% 90%, rgba(129,140,248,.07) 0%, transparent 70%);
}

.login-dots {
  position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(circle, rgba(79,70,229,.12) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 30%, transparent 80%);
}

.login-card {
  position: relative; z-index: 1;
  width: 420px;
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 48px 44px 44px;
  animation: fadeUp .5s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 36px;
}

.login-logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 9px;
  display: grid; place-items: center;
}

.login-logo-icon svg { width: 18px; height: 18px; fill: white; }

.login-logo-text {
  font-size: 17px; font-weight: 700;
  letter-spacing: -.3px; color: var(--black);
}

.login-logo-text span { color: var(--accent); }

.login-title {
  font-size: 26px; font-weight: 700;
  letter-spacing: -.5px; color: var(--black);
  margin-bottom: 6px;
}

.login-sub {
  font-size: 13.5px; color: var(--gray-400);
  margin-bottom: 32px;
}

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 12.5px; font-weight: 600;
  color: var(--gray-600); text-transform: uppercase;
  letter-spacing: .5px; margin-bottom: 8px;
}

.form-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1.5px solid var(--gray-100);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--black);
  background: var(--off-white);
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}

.form-input:focus {
  border-color: var(--accent);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

.form-input::placeholder { color: var(--gray-200); }

.btn-login {
  width: 100%; height: 46px;
  background: var(--accent);
  color: white;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px; font-weight: 600;
  letter-spacing: .2px;
  cursor: pointer;
  margin-top: 8px;
  transition: background .2s, transform .15s, box-shadow .2s;
  box-shadow: 0 4px 14px rgba(79,70,229,.3);
}

.btn-login:hover { background: #4338ca; box-shadow: 0 6px 20px rgba(79,70,229,.35); }
.btn-login:active { transform: scale(.98); }
.btn-login:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.login-error {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-light);
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
  display: none;
}

.login-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 12px; color: var(--gray-400);
}

/* ─── PANEL ─── */
#panel-screen {
  flex-direction: row;
  background: var(--gray-50);
}

@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}

/* SIDEBAR */
.sidebar {
  width: 240px; height: 100vh;
  position: sticky; top: 0;
  background: var(--white);
  border-right: 1px solid var(--gray-100);
  display: flex; flex-direction: column;
  padding: 28px 0;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 0 24px; margin-bottom: 32px;
}

.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: grid; place-items: center;
}
.sidebar-logo-icon svg { width: 16px; height: 16px; fill: white; }

.sidebar-logo-text {
  font-size: 15px; font-weight: 700;
  color: var(--black); letter-spacing: -.3px;
}
.sidebar-logo-text span { color: var(--accent); }

.sidebar-section-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--gray-200);
  padding: 0 24px; margin-bottom: 6px; margin-top: 20px;
}

.sidebar-nav { padding: 0 12px; flex: 1; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
  user-select: none;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.nav-item:hover { background: var(--gray-50); color: var(--black); }
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; }

.sidebar-bottom {
  padding: 16px 12px 0;
  border-top: 1px solid var(--gray-100);
  margin: 0 12px;
}

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
}
.user-chip:hover { background: var(--gray-50); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: white;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--black); }
.user-role { font-size: 11px; color: var(--gray-400); }

.logout-btn {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; color: var(--gray-600);
  cursor: pointer; margin-top: 4px;
  transition: background .15s, color .15s;
}
.logout-btn:hover { background: var(--danger-light); color: var(--danger); }

/* ─── HAMBURGER / MOBILE ─── */
.hamburger-btn {
  display: none;
}

.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 1100;
  height: 52px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-100);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}

.mobile-header-logo {
  display: flex; align-items: center; gap: 8px;
  flex: 1;
}
.mobile-header-logo-icon {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: grid; place-items: center;
}
.mobile-header-logo-icon svg { width: 14px; height: 14px; fill: white; }
.mobile-header-logo-text {
  font-size: 14px; font-weight: 700; color: var(--black); letter-spacing: -.2px;
}
.mobile-header-logo-text span { color: var(--accent); }

.hamburger-btn {
  width: 36px; height: 36px;
  background: transparent;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.hamburger-btn svg { width: 18px; height: 18px; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.4);
}

@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .hamburger-btn { display: grid; }

  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 1050;
    transform: translateX(-100%);
    transition: transform .25s ease;
    height: 100dvh;
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.open { display: block; }

  #panel-screen { flex-direction: column; }

  .main { padding-top: 52px !important; }

  .hide-mobile { display: none !important; }

  /* Login: bloqueado, sin scroll, sin zoom */
  #login-screen {
    position: fixed;
    inset: 0;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    align-items: center;
    justify-content: center;
    padding: 0;
  }
  .login-card {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    overflow-y: auto;
    border-radius: 0;
    box-shadow: none;
    border: none;
    padding: 40px 24px 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .login-bg, .login-dots { display: none; }

  /* Tabla licencias: sin scroll horizontal */
  .table-scroll { overflow-x: visible; }
  .table-scroll table { min-width: 0; width: 100%; }
}
.logout-btn svg { width: 14px; height: 14px; }

/* MAIN */
.main {
  flex: 1; overflow-y: auto;
  padding: 40px;
}

.main-header {
  margin-bottom: 32px;
}

.page-title {
  font-size: 24px; font-weight: 700;
  letter-spacing: -.5px; color: var(--black);
  margin-bottom: 4px;
}

.page-sub { font-size: 13.5px; color: var(--gray-400); }

/* TABS */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeUp .3s ease; }

/* STATS CARDS */
.stats-grid {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 12px; margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow); }

.stat-label {
  font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--gray-400); margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}

.stat-label-dot {
  width: 6px; height: 6px; border-radius: 50%;
}

.stat-value {
  font-size: 28px; font-weight: 700;
  letter-spacing: -1px; color: var(--black);
  margin-bottom: 4px;
}

.stat-delta {
  font-size: 12px; color: var(--success);
  font-weight: 500;
}

/* TABLE */
.card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
}

.card-title {
  font-size: 15px; font-weight: 700;
  color: var(--black);
}

.card-sub {
  font-size: 12.5px; color: var(--gray-400);
  margin-top: 2px;
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all .15s;
}

.btn svg { width: 14px; height: 14px; }

.btn-primary {
  background: var(--accent); color: white;
  box-shadow: 0 2px 8px rgba(79,70,229,.25);
}
.btn-primary:hover { background: #4338ca; }

.btn-secondary {
  background: var(--white); color: var(--gray-600);
  border: 1.5px solid var(--gray-100);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-200); }

.btn-danger { background: var(--danger-light); color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }

.btn-sm { padding: 6px 11px; font-size: 12px; }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  padding: 10px 10px;
  font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--gray-400);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
}

th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--gray-700); }
th.sortable .si { margin-left:4px; opacity:.3; font-size:10px; }
th.sort-asc .si, th.sort-desc .si { opacity:1; color:var(--accent,#6366f1); }

td {
  padding: 10px 10px;
  font-size: 13px; color: var(--gray-800);
  border-bottom: 1px solid var(--gray-50);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--off-white); }

/* El equipo informó un identificador distinto al que quedó registrado en la licencia.
   Es una alerta de revisión: no altera el estado ni bloquea la licencia. */
.license-machine-mismatch td { background: #fff1f2; border-bottom-color: #fecdd3; }
.license-machine-mismatch td:first-child { box-shadow: inset 3px 0 0 #fb7185; }
.license-machine-mismatch:hover td { background: #ffe4e6; }
.machine-mismatch-alert {
  display: block; margin-top: 4px; color: #be123c;
  font-size: 10.5px; font-weight: 700; line-height: 1.25;
}
.machine-mismatch-badge {
  display: inline-flex; margin-top: 5px; padding: 2px 7px;
  border-radius: 999px; background: #ffe4e6; color: #be123c;
  font-size: 10px; font-weight: 700; white-space: nowrap;
}

.mono { font-family: var(--mono); font-size: 12.5px; color: var(--gray-600); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}

.badge-dot { width: 5px; height: 5px; border-radius: 50%; }
.badge-active   { background: var(--success-light); color: #059669; }
.badge-active .badge-dot   { background: var(--success); }
.badge-inactive  { background: var(--gray-100); color: var(--gray-600); }
.badge-inactive .badge-dot { background: var(--gray-400); }
.badge-expired   { background: var(--danger-light); color: var(--danger); }
.badge-expired .badge-dot  { background: var(--danger); }
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-pending .badge-dot  { background: #f59e0b; }
.badge-grace     { background: #fff7ed; color: #c2410c; }
.badge-grace .badge-dot    { background: #f97316; }
.badge-blocked    { background: #fef2f2; color: #991b1b; }
.badge-blocked .badge-dot  { background: #dc2626; }

.actions { display: flex; gap: 6px; }
.kebab-wrap { position: relative; display: inline-block; }
.kebab-btn { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--gray-400); padding: 2px 8px; border-radius: 6px; line-height: 1; letter-spacing: -1px; }
.kebab-btn:hover { background: var(--gray-100); color: var(--black); }
.kebab-menu { display: none; position: absolute; right: 0; top: 100%; background: white; border: 1px solid var(--gray-200); border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.13); z-index: 999; min-width: 150px; overflow: hidden; }
.kebab-menu.open { display: block; }
.kebab-menu button { display: block; width: 100%; text-align: left; padding: 9px 16px; background: none; border: none; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--black); white-space: nowrap; }
.kebab-menu button:hover { background: var(--gray-50); }
.kebab-menu button.danger { color: #dc2626; }

/* SEARCH BAR */
.search-bar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px;
}

.search-input-wrap {
  position: relative; flex: 1;
}

.search-input-wrap svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--gray-400);
}

.search-input {
  width: 100%; height: 40px;
  padding: 0 14px 0 38px;
  border: 1.5px solid var(--gray-100);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-family: var(--font);
  font-size: 13.5px; color: var(--black);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

/* MODAL */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1300; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }

/* pill switcher licencia online */
.lic-on-tab {
  border: 2px solid transparent;
  cursor: pointer; border-radius: 7px;
  padding: 6px 16px; font-size: 13px; font-weight: 600;
  background: transparent; color: var(--gray-500,#6b7280);
  transition: all .15s;
}
.lic-on-tab--active {
  background: var(--primary,#6366f1);
  color: #fff;
  border-color: var(--primary-700,#4338ca);
  box-shadow: 0 0 0 3px rgba(99,102,241,.25);
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 520px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  box-shadow: var(--shadow-lg);
  animation: fadeUp .25s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  flex-shrink: 0;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}

.modal-title { font-size: 17px; font-weight: 700; color: var(--black); }

.modal-close {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer; color: var(--gray-400);
  transition: background .15s;
}
.modal-close:hover { background: var(--gray-100); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body { padding: 24px 28px; overflow-y: auto; flex: 1; }

.modal-footer {
  flex-shrink: 0;
  padding: 16px 28px 24px;
  border-top: 1px solid var(--gray-100);
  display: flex; gap: 10px; justify-content: flex-end;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.modal .form-group { margin-bottom: 16px; }

.modal .form-input, .modal select {
  width: 100%; height: 42px;
  padding: 0 12px;
  border: 1.5px solid var(--gray-100);
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13.5px;
  color: var(--black); background: var(--off-white);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  appearance: none;
}

.modal .form-input:focus, .modal select:focus {
  border-color: var(--accent);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

.select-wrap { position: relative; }
.select-wrap select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
}
.select-wrap::after {
  content: '';
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  border: 4px solid transparent;
  border-top-color: var(--gray-400);
  pointer-events: none;
}

/* Apple-style distribuidor picker */
.dist-picker { display:flex; flex-wrap:wrap; gap:5px; background:var(--gray-100,#f3f4f6); border-radius:12px; padding:4px; }
.dist-pill { border:none; padding:7px 16px; border-radius:9px; font-size:13px; font-weight:500; cursor:pointer; background:transparent; color:var(--gray-500,#6b7280); transition:all .18s cubic-bezier(.4,0,.2,1); white-space:nowrap; line-height:1; }
.dist-pill:hover:not(.dist-pill--active) { background:rgba(0,0,0,.05); color:var(--gray-700,#374151); }
.dist-pill--active { background:#fff; color:var(--primary,#6366f1); box-shadow:0 1px 3px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.06); font-weight:600; }
.dist-pill--default { color:var(--gray-400,#9ca3af); }
.dist-pill--default.dist-pill--active { color:var(--gray-600,#4b5563); }

/* Apple segmented control (CIF/NIE y otros) */
.seg-ctrl { display:inline-flex; background:var(--gray-100,#f3f4f6); border-radius:8px; padding:3px; gap:2px; }
.seg-ctrl__btn { border:none; padding:4px 14px; border-radius:6px; font-size:12px; font-weight:500; cursor:pointer; background:transparent; color:var(--gray-500,#6b7280); transition:all .18s cubic-bezier(.4,0,.2,1); white-space:nowrap; line-height:1.4; }
.seg-ctrl__btn:hover:not(.seg-ctrl__btn--active) { color:var(--gray-700,#374151); }
.seg-ctrl__btn--active { background:#fff; color:var(--black,#111); font-weight:600; box-shadow:0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.07); }

/* DISTRIBUTOR CARDS */
.dist-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.dist-card {
  background: var(--white);
  border: 1.5px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, border-color .2s;
  cursor: default;
}

.dist-card:hover { box-shadow: var(--shadow); border-color: var(--gray-200); }

.dist-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}

.dist-avatar {
  width: 42px; height: 42px; border-radius: 10px;
  display: grid; place-items: center;
  font-size: 16px; font-weight: 700; color: white;
  flex-shrink: 0;
}

.dist-name { font-size: 15px; font-weight: 700; color: var(--black); margin-bottom: 2px; }
.dist-email { font-size: 12px; color: var(--gray-400); }
.dist-meta { display: flex; gap: 16px; margin-top: 14px; border-top: 1px solid var(--gray-50); padding-top: 14px; }
.dist-meta-item { font-size: 12px; color: var(--gray-400); }
.dist-meta-item strong { display: block; font-size: 15px; font-weight: 700; color: var(--black); }

/* EMPTY STATE */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ─── RESPONSIVE ─── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dist-grid { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 24px; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .dist-grid  { grid-template-columns: 1fr; }
  .main { padding: 16px; padding-top: 72px !important; }
  .main-header { margin-bottom: 20px; }
  .page-title { font-size: 20px; }
  .nav-item { min-height: 44px; font-size: 15px; padding: 12px 14px; }
  .lic-drawer, .cli-drawer { width: 100vw !important; }
}

/* ─── LIC EDIT DRAWER ─── */
.lic-drawer-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,15,26,.45);
  z-index: 1200; justify-content: flex-end;
}
.lic-drawer-overlay.open { display: flex; animation: fadeIn .2s ease; }

.lic-drawer {
  width: 400px; height: 100vh;
  background: var(--white);
  box-shadow: -8px 0 40px rgba(15,15,26,.12);
  display: flex; flex-direction: column;
  animation: slideIn .25s ease;
  overflow-y: auto;
}

@keyframes slideIn {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.drawer-header {
  padding: 28px 28px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-shrink: 0;
}

.drawer-title { font-size: 17px; font-weight: 700; color: var(--black); margin-bottom: 3px; }
.drawer-sub   { font-size: 12.5px; color: var(--gray-400); }

.drawer-close {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer; color: var(--gray-400); flex-shrink: 0;
  transition: background .15s;
}
.drawer-close:hover { background: var(--gray-100); }
.drawer-close svg { width: 16px; height: 16px; }

.drawer-body { padding: 24px 28px; flex: 1; }

.drawer-info-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 24px;
}

.drawer-info-item {
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.drawer-info-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--gray-400); margin-bottom: 5px;
}

.drawer-info-value { font-size: 13.5px; font-weight: 600; color: var(--black); }
.drawer-info-value.mono { font-family: var(--mono); font-size: 12px; }

.drawer-divider {
  border: none; border-top: 1px solid var(--gray-100);
  margin: 20px 0;
}

.drawer-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--gray-400); margin-bottom: 14px;
}

/* Custom calendar */
.cal-wrap {
  background: var(--white);
  border: 1.5px solid var(--gray-100);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
}

.cal-nav {
  width: 28px; height: 28px; border-radius: 6px;
  display: grid; place-items: center;
  cursor: pointer; color: var(--gray-600);
  border: 1.5px solid var(--gray-100);
  background: var(--white);
  transition: all .15s;
}
.cal-nav:hover { border-color: var(--accent); color: var(--accent); }
.cal-nav svg { width: 14px; height: 14px; }

.cal-month-label { font-size: 14px; font-weight: 700; color: var(--black); }

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  padding: 10px;
  gap: 2px;
}

.cal-day-name {
  text-align: center; font-size: 10.5px; font-weight: 700;
  color: var(--gray-400); text-transform: uppercase;
  padding: 6px 0;
}

.cal-day {
  text-align: center; padding: 7px 0;
  font-size: 13px; border-radius: 6px;
  cursor: pointer; color: var(--gray-800);
  transition: background .12s, color .12s;
  user-select: none;
}

.cal-day:hover:not(.empty):not(.selected) { background: var(--accent-light); color: var(--accent); }
.cal-day.today { font-weight: 700; color: var(--accent); }
.cal-day.selected { background: var(--accent); color: white; font-weight: 700; }
.cal-day.past { color: var(--gray-200); cursor: default; }
.cal-day.empty { cursor: default; }

.selected-date-display {
  background: var(--accent-light);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px; font-weight: 600; color: var(--accent);
  text-align: center; margin-bottom: 14px;
}

.drawer-footer {
  padding: 20px 28px;
  border-top: 1px solid var(--gray-100);
  display: flex; flex-direction: column; gap: 10px;
  flex-shrink: 0;
}

.btn-block {
  background: var(--danger-light); color: var(--danger);
  border: 1.5px solid #fecaca;
  width: 100%; height: 44px;
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all .15s;
}
.btn-block:hover { background: #fee2e2; border-color: var(--danger); }
.btn-block svg { width: 15px; height: 15px; }

.btn-unblock {
  background: var(--success-light); color: var(--success);
  border: 1.5px solid #6ee7b7;
  width: 100%; height: 44px;
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all .15s;
}
.btn-unblock:hover { background: #d1fae5; border-color: var(--success); }
.btn-unblock svg { width: 15px; height: 15px; }

.btn-save-date {
  background: var(--accent); color: white;
  border: none; width: 100%; height: 44px;
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s;
  box-shadow: 0 2px 8px rgba(79,70,229,.25);
}
.btn-save-date:hover { background: #4338ca; }
.btn-save-date svg { width: 15px; height: 15px; }

tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover td { background: #f0f0ff !important; }

/* ─── TABLE SCROLL ─── */
.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: 780px; }

/* compact columns for licencias */
.lic-table th:nth-child(1), .lic-table td:nth-child(1) { width: 130px; white-space: nowrap; }
.lic-table th:nth-child(4), .lic-table td:nth-child(4) { width: 120px; }
.lic-table th:nth-child(5), .lic-table td:nth-child(5),
.lic-table th:nth-child(6), .lic-table td:nth-child(6) { width: 100px; white-space: nowrap; }
.lic-table th:nth-child(7), .lic-table td:nth-child(7) { width: 100px; }
.lic-table th:nth-child(8), .lic-table td:nth-child(8) { width: 90px; }

/* ─── CLIENT EDIT DRAWER ─── */
.cli-drawer-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,15,26,.45);
  z-index: 1200; justify-content: flex-end;
}
.cli-drawer-overlay.open { display: flex; animation: fadeIn .2s ease; }
.cli-drawer {
  width: 420px; height: 100vh;
  background: var(--white);
  box-shadow: -8px 0 40px rgba(15,15,26,.12);
  display: flex; flex-direction: column;
  animation: slideIn .25s ease;
  overflow-y: auto;
}
.drawer-field { margin-bottom: 14px; }
.drawer-field-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--gray-400); margin-bottom: 6px; display: block;
}
.drawer-input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1.5px solid var(--gray-100);
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13.5px;
  color: var(--black); background: var(--off-white);
  outline: none; appearance: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.drawer-input:focus {
  border-color: var(--accent); background: var(--white);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.drawer-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cli-drawer-avatar {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--accent);
  display: grid; place-items: center;
  font-size: 18px; font-weight: 800; color: white; flex-shrink: 0;
}
.btn-save-cli {
  background: var(--accent); color: white; border: none;
  width: 100%; height: 44px; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s; box-shadow: 0 2px 8px rgba(79,70,229,.25);
}
.btn-save-cli:hover { background: #4338ca; }
.btn-save-cli svg { width: 15px; height: 15px; }
.btn-toggle-cli {
  background: var(--gray-50); color: var(--gray-600);
  border: 1.5px solid var(--gray-100);
  width: 100%; height: 40px; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: all .15s;
}
.btn-toggle-cli:hover { border-color: var(--gray-200); background: var(--gray-100); }
.btn-toggle-cli.danger { background: var(--danger-light); color: var(--danger); border-color: #fecaca; }
.btn-toggle-cli.danger:hover { background: #fee2e2; }
.btn-toggle-cli svg { width: 14px; height: 14px; }
.cli-stat-row {
  display: flex; gap: 10px; margin-bottom: 20px;
}
.cli-stat-pill {
  flex: 1; background: var(--gray-50); border: 1px solid var(--gray-100);
  border-radius: var(--radius-sm); padding: 10px 12px; text-align: center;
}
.cli-stat-pill strong { display: block; font-size: 20px; font-weight: 700; color: var(--black); }
.cli-stat-pill span { font-size: 11px; color: var(--gray-400); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }

/* ─── DIST EDIT DRAWER ─── */
.dist-drawer-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,15,26,.45);
  z-index: 200; justify-content: flex-end;
}
.dist-drawer-overlay.open { display: flex; animation: fadeIn .2s ease; }
.dist-drawer {
  width: 420px; height: 100vh;
  background: var(--white);
  box-shadow: -8px 0 40px rgba(15,15,26,.12);
  display: flex; flex-direction: column;
  animation: slideIn .25s ease;
  overflow-y: auto;
}
.clave-box {
  background: var(--gray-50);
  border: 1.5px solid var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  gap: 10px;
}
.clave-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--gray-400);
  margin-bottom: 4px;
}
.clave-value {
  font-family: var(--mono); font-size: 18px; font-weight: 800;
  color: var(--black); letter-spacing: 4px;
}
.clave-copy {
  background: var(--gray-100); border: none;
  border-radius: 6px; width: 32px; height: 32px;
  display: grid; place-items: center;
  cursor: pointer; flex-shrink: 0;
  transition: background .15s; color: var(--gray-600);
}
.clave-copy:hover { background: var(--gray-200); }
.clave-copy svg { width: 14px; height: 14px; }

.dist-card { cursor: pointer; }
