/* ═══════════════════════════════════════════════════════════════════════
   RYMGA LICENSES — Panel de administración
   v4.0 · Consola de operaciones

   Principio rector: el color significa algo. El acento NO es decorativo.
   Verde/ámbar/rojo se reservan en exclusiva para el estado de una licencia,
   así que un vistazo a la tabla basta para leer la salud del sistema. Las
   acciones primarias usan contraste (claro sobre oscuro), no color — así
   nunca compiten con el estado ni lo enmascaran.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    color-scheme: dark;

    /* ── Superficies: grafito neutro, escalones muy cortos ────────────
       Separadas por luminancia, no por saturación: evita el tinte azulado
       que arrastra todo panel oscuro mal calibrado. */
    --bg:         #0d0f12;
    --surface:    #15181d;
    --surface-2:  #1b1f25;
    --surface-3:  #22272e;
    --inset:      #0a0c0e;

    /* ── Líneas: el panel se estructura con filetes, no con sombras ── */
    --line-soft:   #1a1d22;
    --line:        #262b32;
    --line-strong: #363d46;

    /* ── Texto: cuatro niveles, suficientes para toda la jerarquía ─── */
    --fg:    #e9ebee;
    --fg-2:  #9ba3ad;
    --fg-3:  #7b848f;
    --fg-4:  #67707a;

    /* ── Acción: contraste en vez de color ─────────────────────────── */
    --action:       #f2f4f6;
    --action-hover: #ffffff;
    --action-fg:    #0d0f12;

    /* ── Estado: el único color del sistema ────────────────────────── */
    --ok:     #4ade80;
    --ok-bg:  rgba(74, 222, 128, 0.10);
    --ok-br:  rgba(74, 222, 128, 0.22);

    --warn:    #fbbf24;
    --warn-bg: rgba(251, 191, 36, 0.10);
    --warn-br: rgba(251, 191, 36, 0.22);

    --bad:     #f87171;
    --bad-bg:  rgba(248, 113, 113, 0.10);
    --bad-br:  rgba(248, 113, 113, 0.22);

    --info:    #7dd3fc;
    --info-bg: rgba(125, 211, 252, 0.10);
    --info-br: rgba(125, 211, 252, 0.22);

    /* ── Alias de compatibilidad ─────────────────────────────────────
       Varias paginas llevan estilos inline que todavia nombran los tokens
       del tema anterior. Se mapean aqui para no tener que editar el PHP;
       al migrar esos inline a clases, este bloque se puede borrar. */
    --accent:         var(--fg);
    --accent-hover:   var(--action-hover);
    --accent-deep:    var(--fg-2);
    --danger:         var(--bad);
    --success:        var(--ok);
    --warning:        var(--warn);
    --bg-base:        var(--bg);
    --bg-surface:     var(--surface);
    --bg-elevated:    var(--surface-2);
    --bg-card:        var(--surface);
    --bg-card-solid:  var(--surface);
    --bg-input:       var(--inset);
    --bg-code:        var(--inset);
    --border-hair:    var(--line-soft);
    --border-subtle:  var(--line);
    --border-default: var(--line);
    --border-strong:  var(--line-strong);
    --text-primary:   var(--fg);
    --text-secondary: var(--fg-2);
    --text-muted:     var(--fg-3);
    --text-faint:     var(--fg-4);

    /* ── Geometría: radios deliberadamente distintos por familia ─────
       Controles 5px, contenedores 10px, píldoras completas. Un radio
       único para todo es justo lo que delata una plantilla. */
    --r-control: 5px;
    --r-box: 10px;
    --r-pill: 999px;

    --sidebar-width: 236px;

    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ═══════════════════════════════════════════════════════════════════════
   Base
   ═══════════════════════════════════════════════════════════════════════ */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    background: var(--bg) !important;
    color: var(--fg) !important;
}

body {
    font-family: var(--sans) !important;
    min-height: 100vh;
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Sin degradados de fondo: una superficie plana no compite con los datos. */

a { color: var(--fg); text-decoration: none; }
a:hover { color: var(--action-hover); text-decoration: underline; text-underline-offset: 2px; }

code, pre, .mono, .text-mono { font-family: var(--mono); }

h1, h2, h3, h4, h5 { font-weight: 600; letter-spacing: -0.015em; }

::selection { background: rgba(255, 255, 255, 0.16); color: #fff; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* ═══════════════════════════════════════════════════════════════════════
   Barra lateral
   ═══════════════════════════════════════════════════════════════════════ */

.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--surface) !important;
    border-right: 1px solid var(--line) !important;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 18px 18px 16px;
    border-bottom: 1px solid var(--line-soft);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header .logo-icon {
    width: 30px; height: 30px;
    background: var(--action);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    color: var(--action-fg);
    flex-shrink: 0;
}
.sidebar-header .logo-icon i { font-size: 14px; color: var(--action-fg); }

.sidebar-header .brand-text {
    display: flex; flex-direction: column; gap: 1px;
    min-width: 0;
}
.sidebar-header h3 {
    font-size: 13px; font-weight: 600;
    color: var(--fg);
    line-height: 1.2;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-header .version {
    font-size: 10px; font-weight: 500;
    color: var(--fg-3);
    font-family: var(--mono);
    letter-spacing: 0.02em;
}

.nav-menu {
    list-style: none;
    padding: 8px;
    flex: 1; overflow-y: auto;
}

.nav-section {
    padding: 14px 10px 5px;
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--fg-4);
    text-transform: uppercase;
}

.nav-item a {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px;
    color: var(--fg-2);
    border-radius: var(--r-control);
    font-size: 13px; font-weight: 450;
    transition: background 0.12s, color 0.12s;
}
.nav-item a:hover {
    color: var(--fg);
    background: var(--surface-2);
    text-decoration: none;
}

/* El activo se marca con contraste y peso, no con un bloque de color. */
.nav-item.active a {
    background: var(--surface-3);
    color: var(--fg);
    font-weight: 550;
}

.nav-item a i {
    width: 15px; text-align: center; font-size: 13px;
    color: var(--fg-3);
}
.nav-item.active a i { color: var(--fg); }

.nav-item .nav-badge {
    margin-left: auto;
    font-size: 11px; font-weight: 500;
    color: var(--fg-3);
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
}

.nav-divider { height: 1px; background: var(--line-soft); margin: 8px 10px; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--line-soft);
}
.user-info {
    display: flex; align-items: center; gap: 9px;
    color: var(--fg-2);
    font-size: 13px;
}
.user-info i {
    width: 24px; height: 24px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-control);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; color: var(--fg-3);
}

/* ═══════════════════════════════════════════════════════════════════════
   Contenido principal
   ═══════════════════════════════════════════════════════════════════════ */

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 28px 32px 56px;
    max-width: 1560px;
}

.top-bar {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 24px;
    gap: 20px; flex-wrap: wrap;
}

/* Título grande de verdad: la jerarquía la marca el tamaño, no el color. */
.page-title h1 {
    font-size: 25px; font-weight: 600;
    color: var(--fg);
    letter-spacing: -0.025em;
    display: flex; align-items: center; gap: 10px;
}
.page-title h1 i { color: var(--fg-3); font-size: 19px; }
.page-title p {
    color: var(--fg-3);
    font-size: 13px; margin-top: 3px;
}

.top-actions { display: flex; gap: 7px; align-items: center; }

/* ═══════════════════════════════════════════════════════════════════════
   Botones
   ═══════════════════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 13px;
    border-radius: var(--r-control);
    font-family: var(--sans);
    font-size: 13px; font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.3;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn i { font-size: 12px; }

/* Primaria = contraste. Es la única acción clara de la pantalla. */
.btn-primary {
    background: var(--action); color: var(--action-fg);
    border-color: var(--action);
    font-weight: 550;
}
.btn-primary:hover { background: var(--action-hover); border-color: var(--action-hover); color: var(--action-fg); }

.btn-outline {
    background: var(--surface);
    border-color: var(--line);
    color: var(--fg-2);
}
.btn-outline:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--fg); }

.btn-ghost {
    background: transparent; border-color: transparent;
    color: var(--fg-3);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--fg); }

/* Destructivas y de estado: contorno coloreado, nunca relleno macizo.
   Un bloque rojo sólido pesa más en la página que el dato que describe. */
.btn-danger {
    background: var(--bad-bg); color: var(--bad);
    border-color: var(--bad-br);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.18); border-color: var(--bad); color: var(--bad); }

.btn-success {
    background: var(--ok-bg); color: var(--ok);
    border-color: var(--ok-br);
}
.btn-success:hover { background: rgba(74, 222, 128, 0.18); border-color: var(--ok); color: var(--ok); }

.btn-warning {
    background: var(--warn-bg); color: var(--warn);
    border-color: var(--warn-br);
}
.btn-warning:hover { background: rgba(251, 191, 36, 0.18); border-color: var(--warn); color: var(--warn); }

.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-sm i { font-size: 11px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

.btn:disabled, .btn[disabled],
button:disabled, input:disabled, select:disabled, textarea:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════
   Tarjetas
   ═══════════════════════════════════════════════════════════════════════ */

.card {
    background: var(--surface) !important;
    border: 1px solid var(--line) !important;
    border-radius: var(--r-box);
    overflow: hidden;
    color: var(--fg) !important;
}

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line-soft);
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; flex-wrap: wrap;
}
.card-header h5 {
    font-size: 13px; font-weight: 550;
    color: var(--fg);
    display: flex; align-items: center; gap: 8px;
}
.card-header h5 i { color: var(--fg-3); font-size: 13px; }
.card-body { padding: 16px; }
.card-body.p-0 { padding: 0 !important; }

/* ═══════════════════════════════════════════════════════════════════════
   Cabecera de página (antes "hero")
   ═══════════════════════════════════════════════════════════════════════ */

/* Panel de resumen sobrio: sin degradados ni halos. El borde izquierdo
   le da peso de "cabecera" sin recurrir a un bloque de color. */
.hero {
    padding: 20px 22px;
    border: 1px solid var(--line);
    border-left: 2px solid var(--line-strong);
    border-radius: var(--r-box);
    background: var(--surface);
    margin-bottom: 20px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 28px; flex-wrap: wrap;
}
.hero h2 {
    font-size: 17px; font-weight: 550;
    color: var(--fg);
    letter-spacing: -0.015em;
}
.hero p {
    color: var(--fg-3);
    font-size: 13px; margin-top: 5px; max-width: 68ch;
    line-height: 1.55;
}

.hero-mono {
    font-family: var(--mono);
    color: var(--fg-3);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 7px;
}

/* ═══════════════════════════════════════════════════════════════════════
   Métricas
   ═══════════════════════════════════════════════════════════════════════ */

/* Una sola placa dividida por filetes, no cuatro tarjetas flotando.
   El gap de 1px sobre el color de línea dibuja los separadores. */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--r-box);
    overflow: hidden;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    padding: 15px 18px;
    display: flex; flex-direction: column; gap: 0;
    min-width: 0;
}

/* El icono pasa a marca discreta junto a la etiqueta; deja de ser un
   cuadrado de color que compite con la cifra. */
.stat-icon {
    order: 2;
    display: none;
}

.stat-info { min-width: 0; order: 1; }

.stat-info h3 {
    font-size: 27px; font-weight: 550;
    color: var(--fg);
    line-height: 1.1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}
.stat-info p {
    color: var(--fg-3);
    font-size: 12px; margin-top: 4px;
    font-weight: 450;
    overflow-wrap: break-word;
}

/* El estado se indica con un punto, no tiñendo toda la tarjeta. */
.stat-card.stat-success .stat-info p::before,
.stat-card.stat-warning .stat-info p::before,
.stat-card.stat-danger .stat-info p::before {
    content: '';
    display: inline-block;
    width: 5px; height: 5px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: 1px;
}
.stat-card.stat-success .stat-info p::before { background: var(--ok); }
.stat-card.stat-warning .stat-info p::before { background: var(--warn); }
.stat-card.stat-danger  .stat-info p::before { background: var(--bad); }

/* ═══════════════════════════════════════════════════════════════════════
   Tablas
   ═══════════════════════════════════════════════════════════════════════ */

.table {
    width: 100%;
    border-collapse: collapse;
    color: var(--fg) !important;
    background: transparent !important;
}
.table td, .table th {
    color: var(--fg) !important;
    background: transparent !important;
    border-color: var(--line-soft) !important;
}
.table thead th {
    background: var(--surface-2) !important;
    padding: 9px 14px;
    font-size: 11px; font-weight: 550;
    letter-spacing: 0.01em;
    color: var(--fg-3) !important;
    text-align: left;
    border-bottom: 1px solid var(--line) !important;
    white-space: nowrap;
}
.table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line-soft) !important;
    vertical-align: middle;
    font-size: 13px;
}
.table tbody tr:hover { background: var(--surface-2) !important; }
.table tbody tr:last-child td { border-bottom: none !important; }

/* Identificadores en mono y tono apagado: se leen cuando hacen falta
   y no gritan el resto del tiempo. */
/* Un identificador partido a mitad deja de ser legible y de poder
   copiarse de un vistazo: se mantiene entero y la tabla desplaza. */
.table code {
    background: transparent;
    color: var(--fg-2);
    padding: 0;
    font-size: 12px;
    font-family: var(--mono);
    border: none;
    white-space: nowrap;
}

.table-responsive { overflow-x: auto; }

/* ═══════════════════════════════════════════════════════════════════════
   Estado y etiquetas
   ═══════════════════════════════════════════════════════════════════════ */

.status-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 0;
    background: none !important;
    border: none !important;
    font-size: 13px; font-weight: 450;
    text-transform: none;
    letter-spacing: 0;
}
.status-badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.status-active   { color: var(--ok) !important; }
.status-expired  { color: var(--warn) !important; }
.status-disabled { color: var(--bad) !important; }
.status-pending  { color: var(--fg-3) !important; }

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px;
    border-radius: var(--r-pill);
    font-size: 11px; font-weight: 500;
    background: var(--surface-3);
    color: var(--fg-2);
    border: none;
    line-height: 1.5;
}

.chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 8px;
    border-radius: var(--r-control);
    font-size: 12px; font-weight: 450;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--fg-2);
    font-family: var(--mono);
}
.chip i { font-size: 10px; color: var(--fg-3); }
.chip.chip-accent { color: var(--fg); border-color: var(--line-strong); }
.chip.chip-danger { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-br); }
.chip.chip-warn   { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-br); }

/* Los tiers se distinguen por peso y filete, no por tres colores nuevos
   que competirían con los del estado. */
.tier-badge {
    padding: 2px 8px;
    border-radius: var(--r-control);
    font-size: 11px; font-weight: 500;
    font-family: var(--sans);
    background: transparent;
    color: var(--fg-3);
    border: 1px solid var(--line);
}
.tier-badge.tier-standard   { color: var(--fg-3); }
.tier-badge.tier-premium    { color: var(--fg-2); border-color: var(--line-strong); }
.tier-badge.tier-enterprise { color: var(--fg); border-color: var(--fg-4); font-weight: 550; }

/* ═══════════════════════════════════════════════════════════════════════
   Formularios
   ═══════════════════════════════════════════════════════════════════════ */

.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--fg-2);
    font-size: 13px;
}
.form-label .req { color: var(--bad); }

.form-control, .form-select, .form-input,
input[type="text"], input[type="number"], input[type="email"],
input[type="password"], input[type="date"], select, textarea {
    width: 100%;
    padding: 8px 11px;
    background: var(--inset) !important;
    border: 1px solid var(--line) !important;
    border-radius: var(--r-control);
    color: var(--fg) !important;
    font-family: var(--sans);
    font-size: 13px;
    transition: border-color 0.12s;
    -webkit-appearance: none; appearance: none;
}

.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b747e' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.6' d='M6 8l4 4 4-4'/%3e%3c/svg%3e") !important;
    background-position: right 9px center !important;
    background-repeat: no-repeat !important;
    background-size: 15px !important;
    padding-right: 30px !important;
    background-color: var(--inset) !important;
}

/* Foco sin halo de color: un borde claro basta y no mancha el formulario. */
.form-control:focus, .form-select:focus, .form-input:focus,
input:focus, select:focus, textarea:focus {
    outline: none !important;
    border-color: var(--line-strong) !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06) !important;
    background: var(--inset) !important;
    color: var(--fg) !important;
}
.form-control::placeholder, .form-input::placeholder { color: var(--fg-4); }

.form-select option { background: var(--surface-2); color: var(--fg); }
.form-text { font-size: 12px; color: var(--fg-3); margin-top: 4px; }

textarea.form-control { resize: vertical; min-height: 76px; font-family: var(--mono); font-size: 13px; }

input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

input[readonly], textarea[readonly] { color: var(--fg-2) !important; }

.check {
    display: inline-flex; align-items: center; gap: 8px;
    cursor: pointer; user-select: none;
    padding: 7px 11px; border-radius: var(--r-control);
    border: 1px solid var(--line);
    background: var(--inset);
    transition: border-color 0.12s;
    font-size: 13px;
}
.check:hover { border-color: var(--line-strong); }
.check input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--action); cursor: pointer; }
.check.on { border-color: var(--line-strong); background: var(--surface-2); color: var(--fg); }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; cursor: pointer;
    inset: 0; background: var(--surface-3);
    border: 1px solid var(--line);
    transition: 0.16s; border-radius: var(--r-pill);
}
.switch .slider::before {
    content: ''; position: absolute;
    height: 14px; width: 14px; left: 2px; bottom: 2px;
    background: var(--fg-3);
    transition: 0.16s; border-radius: 50%;
}
.switch input:checked + .slider { background: var(--action); border-color: var(--action); }
.switch input:checked + .slider::before { transform: translateX(16px); background: var(--action-fg); }

.input-wrap { position: relative; }
.input-wrap i {
    position: absolute; left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--fg-4); font-size: 13px;
    pointer-events: none;
}
.input-wrap .form-input, .input-wrap .form-control { padding-left: 34px; }

/* ═══════════════════════════════════════════════════════════════════════
   Clave de licencia
   ═══════════════════════════════════════════════════════════════════════ */

/* El dato es el protagonista: fondo plano y la clave a tamaño grande.
   Sin halos ni degradados que distraigan de lo único que hay que copiar. */
.license-key-display {
    background: var(--inset);
    border: 1px solid var(--line);
    border-radius: var(--r-box);
    padding: 24px;
    text-align: center;
    margin-bottom: 18px;
}
.license-key-display h4 {
    font-size: 11px; font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--fg-4);
    margin-bottom: 12px;
    font-family: var(--sans);
}
.license-key-display code {
    font-family: var(--mono);
    font-size: 19px; font-weight: 500;
    background: transparent;
    color: var(--fg);
    padding: 0;
    display: inline-block;
    border: none;
    letter-spacing: 0.06em;
    word-break: break-all;
}
.license-key-display .copy-btn {
    margin-top: 16px;
    background: var(--action);
    color: var(--action-fg);
    border: none;
    padding: 7px 16px;
    border-radius: var(--r-control);
    cursor: pointer;
    font-family: var(--sans);
    font-size: 13px; font-weight: 550;
    display: inline-flex; align-items: center; gap: 7px;
    transition: background 0.12s;
}
.license-key-display .copy-btn:hover { background: var(--action-hover); }

/* ═══════════════════════════════════════════════════════════════════════
   Avisos
   ═══════════════════════════════════════════════════════════════════════ */

/* Filete lateral en vez de fondo saturado: visible sin secuestrar la vista. */
.alert {
    padding: 11px 14px;
    border-radius: var(--r-control);
    margin-bottom: 16px;
    display: flex; align-items: flex-start; gap: 10px;
    font-size: 13px; font-weight: 450;
    border: 1px solid var(--line);
    border-left-width: 2px;
    background: var(--surface);
    color: var(--fg-2);
    line-height: 1.5;
}
.alert i { font-size: 13px; margin-top: 1px; flex-shrink: 0; }
.alert strong { color: var(--fg); font-weight: 600; }

.alert-success { border-left-color: var(--ok); }
.alert-success i { color: var(--ok); }
.alert-danger  { border-left-color: var(--bad); }
.alert-danger i { color: var(--bad); }
.alert-warning { border-left-color: var(--warn); }
.alert-warning i { color: var(--warn); }
.alert-info    { border-left-color: var(--info); }
.alert-info i { color: var(--info); }

/* ═══════════════════════════════════════════════════════════════════════
   Productos y actividad
   ═══════════════════════════════════════════════════════════════════════ */

.product-stat {
    display: flex; justify-content: space-between; align-items: center;
    padding: 9px 16px;
    border-bottom: 1px solid var(--line-soft);
}
.product-stat:last-child { border-bottom: none; }
.product-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.product-info i {
    font-size: 12px; width: 22px;
    display: flex; align-items: center; justify-content: center;
    color: var(--fg-4);
}
.product-info span { font-weight: 450; font-size: 13px; }

.activity-list { max-height: 440px; overflow-y: auto; }
.activity-item {
    display: flex; align-items: flex-start; gap: 11px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--line-soft);
}
.activity-item:last-child { border-bottom: none; }

/* Punto de color en lugar de cuadrado relleno: la lista se lee como una
   secuencia, no como una cuadrícula de iconos. */
.activity-icon {
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
    font-size: 0;
    background: var(--fg-4);
}
.activity-icon.success { background: var(--ok); }
.activity-icon.danger  { background: var(--bad); }
.activity-icon.warning { background: var(--warn); }
.activity-icon.info    { background: var(--info); }
.activity-icon i { display: none; }

.activity-info { min-width: 0; }
.activity-info p { font-size: 13px; margin-bottom: 2px; color: var(--fg); }
.activity-info small { color: var(--fg-3); font-size: 12px; font-family: var(--mono); }

/* ═══════════════════════════════════════════════════════════════════════
   Pares clave/valor y rejillas (portal)
   ═══════════════════════════════════════════════════════════════════════ */

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--r-box);
    overflow: hidden;
}

.kv {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 16px;
    padding: 11px 16px;
    background: var(--surface);
}
.kv .k { color: var(--fg-3); font-size: 12px; flex-shrink: 0; }
.kv .v {
    color: var(--fg); font-size: 13px; font-weight: 450;
    font-family: var(--mono);
    text-align: right;
    word-break: break-all;
}

/* ═══════════════════════════════════════════════════════════════════════
   Estados vacíos y rejilla de features
   ═══════════════════════════════════════════════════════════════════════ */

.empty-state {
    text-align: center;
    padding: 52px 20px;
    color: var(--fg-3);
}
.empty-state i {
    font-size: 25px; color: var(--fg-4);
    margin-bottom: 12px; display: block;
}
.empty-state h4 { color: var(--fg); font-size: 15px; margin-bottom: 5px; font-weight: 550; }
.empty-state p { font-size: 13px; margin-bottom: 16px; }

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 8px;
    margin-top: 10px;
}
.feature-cell {
    background: var(--inset);
    border: 1px solid var(--line);
    border-radius: var(--r-control);
    padding: 9px 11px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
}
.feature-cell .fname { font-size: 12px; color: var(--fg-2); font-family: var(--mono); }
.feature-cell.on { border-color: var(--line-strong); background: var(--surface-2); }
.feature-cell.on .fname { color: var(--fg); }

/* ═══════════════════════════════════════════════════════════════════════
   Utilidades
   ═══════════════════════════════════════════════════════════════════════ */

.text-muted   { color: var(--fg-3) !important; }
.text-accent  { color: var(--fg) !important; }
.text-danger  { color: var(--bad) !important; }
.text-success { color: var(--ok) !important; }
.text-warning { color: var(--warn) !important; }

.action-buttons { display: flex; gap: 4px; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════════════════════
   Barra de desplazamiento
   ═══════════════════════════════════════════════════════════════════════ */

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--r-pill); border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--fg-4); }

/* ═══════════════════════════════════════════════════════════════════════
   Modales
   ═══════════════════════════════════════════════════════════════════════ */

.modal-backdrop { background-color: rgba(0, 0, 0, 0.6) !important; }
.modal-content {
    background: var(--surface) !important;
    border: 1px solid var(--line-strong) !important;
    border-radius: var(--r-box) !important;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5) !important;
    color: var(--fg) !important;
}
.modal-header { border-bottom: 1px solid var(--line-soft); padding: 14px 18px; }
.modal-title {
    font-size: 14px; font-weight: 550;
    color: var(--fg);
    display: flex; align-items: center; gap: 8px;
}
.modal-title i { color: var(--fg-3); }
.modal-body { padding: 18px; }
.modal-footer { border-top: 1px solid var(--line-soft); padding: 12px 18px; gap: 7px; display: flex; justify-content: flex-end; }

.btn-close { filter: invert(1) brightness(0.65); opacity: 0.6; }
.btn-close:hover { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════════════
   Páginas públicas (login y portal)
   ═══════════════════════════════════════════════════════════════════════ */

.public-shell {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 40px 20px;
    background: var(--bg);
}
.public-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: var(--r-box);
    padding: 32px 30px;
    border: 1px solid var(--line);
}
.public-card .brand {
    display: flex; align-items: center; gap: 11px;
    margin-bottom: 24px;
}
.public-card .brand .logo-icon {
    width: 34px; height: 34px;
    background: var(--action);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--action-fg); font-size: 15px;
    flex-shrink: 0;
}
.public-card .brand-text h1 { font-size: 15px; font-weight: 600; }
.public-card .brand-text p { color: var(--fg-3); font-size: 12px; }

.portal-shell { min-height: 100vh; padding: 32px 20px; background: var(--bg); }
.portal-container { max-width: 940px; margin: 0 auto; }
.portal-topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

/* ═══════════════════════════════════════════════════════════════════════
   Avisos flotantes
   ═══════════════════════════════════════════════════════════════════════ */

.toast-notification {
    position: fixed;
    bottom: 20px; right: 20px;
    z-index: 10000;
    display: flex; align-items: center; gap: 9px;
    padding: 11px 16px;
    border-radius: var(--r-control);
    border: 1px solid var(--line-strong);
    background: var(--surface-2);
    color: var(--fg);
    font-family: var(--sans);
    font-size: 13px; font-weight: 450;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
    animation: toastIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: min(360px, calc(100vw - 40px));
}
.toast-notification.is-out { animation: toastOut 0.18s ease forwards; }
.toast-notification i { font-size: 13px; flex-shrink: 0; }
.toast-notification.toast-success i { color: var(--ok); }
.toast-notification.toast-error i { color: var(--bad); }
.toast-notification.toast-info i { color: var(--info); }

@keyframes toastIn {
    from { transform: translateY(10px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
@keyframes toastOut {
    from { transform: translateY(0); opacity: 1; }
    to   { transform: translateY(6px); opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Foco y accesibilidad
   ═══════════════════════════════════════════════════════════════════════ */

:where(a, button, .btn, .check, summary, [tabindex]):focus-visible,
:where(input, select, textarea):focus-visible {
    outline: 2px solid var(--action);
    outline-offset: 2px;
    border-radius: var(--r-control);
}
.nav-item a:focus-visible { outline-offset: -2px; }

.skip-link {
    position: absolute;
    left: 12px; top: -60px;
    z-index: 500;
    padding: 9px 15px;
    background: var(--action);
    color: var(--action-fg);
    font-weight: 550; font-size: 13px;
    border-radius: var(--r-control);
    transition: top 0.16s ease;
}
.skip-link:focus { top: 12px; color: var(--action-fg); text-decoration: none; }

/* ═══════════════════════════════════════════════════════════════════════
   Compatibilidad con Bootstrap
   ═══════════════════════════════════════════════════════════════════════ */

.row { --bs-gutter-x: 16px; }
.mb-4 { margin-bottom: 18px !important; }
.mt-4 { margin-top: 18px !important; }
.mb-3 { margin-bottom: 13px !important; }
.mt-3 { margin-top: 13px !important; }
.ms-2 { margin-left: 7px !important; }
.me-2 { margin-right: 7px !important; }
.p-0 { padding: 0 !important; }
.w-100 { width: 100% !important; }
.text-center { text-align: center !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.align-items-center { align-items: center !important; }
.align-items-end { align-items: flex-end !important; }
.justify-content-between { justify-content: space-between !important; }
.gap-2 { gap: 7px !important; }
.gap-3 { gap: 11px !important; }
.g-3 > * { padding: 7px; }
.py-4 { padding-top: 20px !important; padding-bottom: 20px !important; }
.py-5 { padding-top: 36px !important; padding-bottom: 36px !important; }

.bg-success { background: var(--ok) !important; color: #06240f !important; }
.bg-danger  { background: var(--bad) !important; color: #2b0a0a !important; }

.form-select:not(:focus) { color: var(--fg) !important; }

input[type="number"], input[type="text"], input[type="email"],
input[type="password"], input[type="date"] {
    background-color: var(--inset) !important;
    color: var(--fg) !important;
    -webkit-text-fill-color: var(--fg) !important;
}
input:not([disabled]):not([readonly]) {
    -webkit-text-fill-color: var(--fg) !important;
    opacity: 1 !important;
}

/* ═══════════════════════════════════════════════════════════════════════
   Menú móvil
   ═══════════════════════════════════════════════════════════════════════ */

/* La regla base va ANTES del media query: si no, su display:none gana por
   orden de cascada y el botón nunca llega a mostrarse. */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px; left: 12px;
    z-index: 120;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--fg);
    padding: 8px 13px;
    border-radius: var(--r-control);
    cursor: pointer;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-family: var(--sans);
    font-weight: 500;
}
.sidebar-toggle:hover { border-color: var(--line-strong); }

.sidebar-scrim {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 99;
    border: 0; padding: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   Adaptación a pantalla
   ═══════════════════════════════════════════════════════════════════════ */

@media (max-width: 1200px) {
    .main-content { padding: 26px 24px 48px; }
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
        width: min(var(--sidebar-width), 82vw);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar.open ~ .sidebar-scrim { display: block; }

    .main-content { margin-left: 0; padding: 62px 16px 36px; }
    .sidebar-toggle { display: inline-flex; }

    .top-bar { flex-direction: column; align-items: stretch; }
    .page-title h1 { font-size: 21px; }


    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    /* Con un numero impar de metricas la ultima celda dejaria un hueco que
       se lee como una tarjeta vacia; se estira para cerrar la placa. */
    .stat-card:last-child:nth-child(odd) { grid-column: 1 / -1; }

    /* El hero trae text-align:right inline en su segunda columna; al
       apilarse en una sola hay que devolverlo a la izquierda. */
    .hero { gap: 16px; }
    .hero > div:last-child { text-align: left !important; align-items: flex-start; }

    .license-key-display code { font-size: 15px; }
}

@media (max-width: 560px) {
    .main-content { padding: 58px 13px 32px; }
    .stat-card { padding: 13px 14px; }
    .stat-info h3 { font-size: 21px; }
    .feature-grid { grid-template-columns: 1fr; }
    .top-actions { width: 100%; }
    .top-actions .btn { flex: 1; justify-content: center; }
    .public-card { padding: 26px 20px; }
    .kv { flex-direction: column; gap: 3px; }
    .kv .v { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   Impresión
   ═══════════════════════════════════════════════════════════════════════ */

@media print {
    @page { margin: 14mm; }
    html, body { background: #fff !important; color: #000 !important; }
    .sidebar, .sidebar-toggle, .sidebar-scrim, .top-actions,
    .action-buttons, .toast-notification, .btn, .copy-btn,
    .modal, .modal-backdrop, .skip-link { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; max-width: none; }
    .card, .stat-card, .stats-grid, .hero, .license-key-display, .grid-2 {
        background: #fff !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        break-inside: avoid;
    }
    .card, .stat-card, .hero, .license-key-display, .table, .table td,
    .table th, .page-title h1, .page-title p, .stat-info h3, .stat-info p,
    code, .chip, .kv .k, .kv .v, .activity-info p, .activity-info small {
        color: #000 !important;
    }
    .table thead th { background: #f1f1f1 !important; }
    .activity-list { max-height: none !important; overflow: visible !important; }
}
