/* ═══════════════════════════════════════════════
   TopaPanel — Tropa Host
   Identidad según el Manual de marca Tropa Circa v1.0 (julio 2026).

   Antes esta hoja decía "inspirado en la identidad Tropa Circa" y usaba un
   turquesa (var(--violeta)) y un ámbar (var(--lima)) que NO están en el manual, con
   Space Grotesk y Plus Jakarta Sans en lugar de las tipografías de la marca.
   Ahora los tokens son los del manual, sección 03 (color) y 04 (tipografía).

   Dos notas sobre lo que el manual no resuelve para una interfaz:

   · El manual escribe la tipografía editorial como «Frauces». La familia que
     existe —y que corresponde por descripción: serif de libro, de Light a Bold
     y con itálicas— es **Fraunces**. Se usa esa.
   · No hay una monoespaciada en el manual, y el panel muestra rutas de archivo,
     expresiones cron y comandos. Se conserva JetBrains Mono para eso: inventar
     una regla de marca donde el manual calla sería peor que declararlo acá.
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300..700;1,9..144,300..700&family=Poppins:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* ── Paleta del manual · sección 03 ────── */
    /* Primarios */
    --negro-tinta: #17131F;      /* CMYK 40·40·20·100 */
    --violeta: #9D49EC;          /* CMYK 55·70·0·0 */
    --lima: #CAFB24;             /* CMYK 25·0·90·0 */
    /* Apoyo y acentos: 5% de la pieza, nunca a superficie plena */
    --violeta-claro: #B08CF1;    /* CMYK 35·50·0·0 */
    --cyan: #00AEEF;             /* tinta madre del offset */
    --magenta: #EC008C;          /* tinta madre del offset */

    /* Proporción de uso (manual 03): negro y blancos 60%, violeta 25%,
       lima 10%, violeta claro/cyan/magenta 5% solo como acento. Por eso el
       violeta es la acción y la lima el realce, no al revés. */
    --primary: var(--violeta);
    --primary-light: var(--violeta-claro);
    --primary-dark: #7B2FD1;
    --primary-bg: rgba(157, 73, 236, 0.14);
    --accent: var(--lima);
    --accent-light: rgba(202, 251, 36, 0.16);

    /* ── Neutrals ──────────────────────────── */
    /* Derivados del Negro Tinta, no de un gris cualquiera: el violeta del
       manual tiene el mismo sesgo de matiz y sobre un negro verdoso se
       ensuciaba. */
    --bg: #17131F;
    --bg-soft: #1E1929;
    --bg-card: rgba(255,255,255,0.04);
    --bg-card-strong: rgba(255,255,255,0.08);
    --bg-sidebar: #110E17;
    --bg-sidebar-hover: rgba(255,255,255,0.06);
    --text: #FAF9FC;
    --text-secondary: #CFC9DA;
    --text-light: #A29BB4;
    --text-sidebar: #ADA3C2;
    --text-sidebar-active: #FFFFFF;
    --border: rgba(255,255,255,0.08);
    --border-light: rgba(255,255,255,0.04);

    /* ── Semantics ─────────────────────────── */
    /* Fuera de la paleta del manual a propósito. Un error tiene que verse rojo
       y un aviso ámbar en cualquier interfaz; forzarlos a violeta y lima los
       volvería decorativos y dejaría de distinguirse un problema de un dato.
       El manual gobierna la identidad, no los estados del sistema. */
    --success: #22C55E;
    --success-bg: rgba(34,197,94,0.12);
    --warning: #F59E0B;
    --warning-bg: rgba(245, 158, 11, 0.14);
    --danger: #F87171;
    --danger-bg: rgba(248,113,113,0.16);
    --info: #60A5FA;
    --info-bg: rgba(96,165,250,0.14);

    /* ── Geometry ──────────────────────────── */
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --shadow-xs: 0 1px 2px rgba(0,0,0,.25);
    --shadow: 0 6px 18px rgba(0,0,0,.18);
    --shadow-md: 0 12px 30px rgba(0,0,0,.25);
    --shadow-lg: 0 24px 60px rgba(0,0,0,.35);
    --shadow-xl: 0 32px 90px rgba(0,0,0,.45);

    /* ── Tipografía del manual · sección 04 ── */
    /* Poppins: cuerpos, botones y etiquetas. Mínimo 14px en pantalla. */
    --font: 'Poppins', system-ui, -apple-system, sans-serif;
    /* Fraunces: títulos y textos editoriales — la voz "tipo libro". */
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    /* Fuera del manual, por necesidad: ver la nota de arriba. */
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    /* LEMON MILK Bold es exclusiva del logotipo y no se usa en títulos ni
       textos (manual 04). No se declara acá a propósito: no hay que poder
       alcanzarla desde una hoja de estilos de interfaz. */

    /* ── Marca ─────────────────────────────── */
    /* El glifo «t» suelto, para la marca de agua del manual (06). Los dos
       archivos salen del PDF del manual: son mapas de bits de 334 px, no los
       originales vectoriales. Alcanza para pantalla, pero si alguna vez hay que
       imprimir algo, hay que reemplazarlos por los archivos de diseño. */
    --glifo-t: url('/assets/img/glifo-t.png');

    /* ── Transitions ───────────────────────── */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ═══════════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    font-family: var(--font);
    /* Halos en violeta y lima, en la proporción del manual: el violeta
       manda y la lima aparece apenas. El tercero es violeta claro, no un
       cuarto color. */
    background: radial-gradient(120% 120% at 20% 20%, rgba(157,73,236,0.10), transparent 40%),
                radial-gradient(120% 120% at 80% 10%, rgba(202,251,36,0.05), transparent 45%),
                radial-gradient(120% 120% at 50% 80%, rgba(176,140,241,0.07), transparent 40%),
                var(--bg);
    color: var(--text);
    line-height: 1.6;
    letter-spacing: -0.01em;
}

/* Jerarquía del manual (04): H1 y H2 en Fraunces, cuerpo en Poppins.
   Se declara sobre los elementos y no sobre clases sueltas para que un título
   nuevo salga bien sin que nadie se acuerde de ponerle una clase. */
h1, h2, h3, .font-display {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.15;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ═══════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    /* Color sólido de última capa, por lo mismo que .venta-page: un degradado
       solo pinta su caja, y si el formulario no entra en 100vh —un teléfono
       apaisado— abajo aparece el lienzo blanco. */
    background: radial-gradient(ellipse at 30% 20%, #221C2E 0%, #17131F 60%, #100D16 100%),
                #100D16;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(157, 73, 236, .08) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(202, 251, 36, .05) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 24px;
    position: relative;
    z-index: 1;
}

.login-card {
    background: linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04));
    backdrop-filter: blur(18px);
    border-radius: var(--radius-xl);
    padding: 44px 36px;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255,255,255,.12);
}

.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 36px;
}

.login-logo .logo-icon {
    width: 56px;
    height: 56px;
    /* Sin caja de color: el isotipo ya trae su propio círculo y su anillo.
       Meterlo dentro de un cuadrado violeta con degradado es recomponer el
       logotipo, y el manual (02) dice que ninguna otra composición está
       permitida. */
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-logo h1 {
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
}

.login-logo span {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.login-form { display: flex; flex-direction: column; gap: 20px; }

.login-footer {
    text-align: center;
    margin-top: 28px;
    color: var(--text-light);
    font-size: 12px;
    font-weight: 500;
}

.login-footer .version {
    display: inline-block;
    background: var(--bg);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    margin-top: 8px;
}

/* ═══════════════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════════════ */
/* Columna, no fila. La barra lateral es `position: fixed`, así que no
   participa del flujo: los únicos hijos en flujo son el main y el footer, y en
   `row` el footer quedaba AL LADO del main comiéndose 326 px de ancho en cada
   pantalla. El offset de la barra lo da el margin-left de cada uno. */
.app-layout { display: flex; flex-direction: column; min-height: 100vh; }

/* ── SIDEBAR ──────────────────────────────────── */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    border-right: 1px solid rgba(255,255,255,.06);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.02), 0 20px 60px rgba(0,0,0,0.35);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo .logo-icon {
    width: 38px;
    height: 38px;
    /* Ver la nota de .login-logo .logo-icon: el isotipo va solo. */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.sidebar-nav .nav-section {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(163,184,168,.4);
    padding: 16px 12px 6px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    transition: all 0.15s var(--ease);
    position: relative;
}

.sidebar-nav a:hover {
    color: var(--text-sidebar-active);
    background: var(--bg-sidebar-hover);
}

.sidebar-nav a.active {
    color: var(--text-sidebar-active);
    background: rgba(157, 73, 236, .15);
    font-weight: 600;
}

.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-nav a .nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.sidebar-nav a .nav-badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.06);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.sidebar-footer .user-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

.sidebar-footer .user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-sidebar-active);
}

.sidebar-footer .user-role {
    font-size: 11px;
    color: var(--text-sidebar);
}

.sidebar-footer .btn-logout {
    width: 100%;
    padding: 9px;
    background: rgba(255,255,255,.04);
    color: var(--text-sidebar);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s var(--ease);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.sidebar-footer .btn-logout:hover {
    background: rgba(220,38,38,.15);
    color: #FCA5A5;
    border-color: rgba(220,38,38,.3);
}

/* ── MAIN CONTENT ────────────────────────────── */
.main-content {
    flex: 1;
    /* Sin min-width: 0 un flex item no se encoge por debajo del ancho
       min-content de su contenido. Con una tabla ancha adentro, el main crecía
       más allá del viewport y la página entera scrolleaba en horizontal, en vez
       de scrollear la tabla dentro de su .table-wrapper. Se notaba en Cuentas y
       en Nodos, que son las tablas con más columnas. */
    min-width: 0;
    margin-left: 260px;
    padding: 32px;
    max-width: 1400px;
}

/* ═══════════════════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════════════════ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.page-header .breadcrumb {
    color: var(--text-light);
    font-size: 13px;
    font-weight: 500;
    margin-top: 4px;
}

/* ═══════════════════════════════════════════════
   STAT CARDS
   ═══════════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: linear-gradient(160deg, var(--bg-card), var(--bg-card-strong));
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s var(--ease);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--primary);
    opacity: 0;
    transition: opacity 0.2s var(--ease);
}

.stat-card:hover::after { opacity: 1; }

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.stat-card .stat-value {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
}

.stat-card .stat-sub {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
}

/* ── Progress bars ────────────────────────── */
.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 6px;
}

.progress-bar .progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s var(--ease);
}

.progress-fill.green { background: linear-gradient(90deg, #059669, #10B981); }
.progress-fill.yellow { background: linear-gradient(90deg, #D97706, #F59E0B); }
.progress-fill.red { background: linear-gradient(90deg, #DC2626, #EF4444); }
.progress-fill.blue { background: linear-gradient(90deg, #0D9488, #14B8A6); }

/* ═══════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════ */
.card {
    background: linear-gradient(180deg, var(--bg-card), var(--bg-card-strong));
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 20px;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
    background: var(--bg);
}

.card-body { padding: 24px; }

/* ═══════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-card);
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 13px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}

table th {
    background: var(--bg-soft);
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

table tbody tr {
    transition: background 0.12s var(--ease);
}

table tbody tr:hover {
    background: rgba(255,255,255,0.04);
}

table tbody tr:last-child td {
    border-bottom: none;
}

table td.actions {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge-green { background: var(--success-bg); color: #065F46; }
.badge-green::before { background: var(--success); }

.badge-red { background: var(--danger-bg); color: #991B1B; }
.badge-red::before { background: var(--danger); }

.badge-gray { background: #F3F4F6; color: #4B5563; }
.badge-gray::before { background: #9CA3AF; }

.badge-blue { background: var(--info-bg); color: #1E40AF; }
.badge-blue::before { background: var(--info); }

.badge-yellow { background: var(--warning-bg); color: #92400E; }
.badge-yellow::before { background: var(--warning); }

/* Heredado del nombre viejo del color. El fondo ahora es violeta
   translúcido, así que el texto va en violeta claro y no en verde. */
.badge-teal { background: var(--primary-bg); color: var(--violeta-claro); }
.badge-teal::before { background: var(--primary); }

/* "Se cotiza" en el catálogo de servicios. Va en lima porque no es un estado
   ni una advertencia: es la respuesta al precio, y en la proporción del manual
   la lima es exactamente eso, el realce. */
.badge-purple { background: var(--accent-light); color: var(--lima); }
.badge-purple::before { background: var(--lima); }

/* Una fila archivada se ve, pero no compite con las activas. */
.fila-archivada { opacity: .5; }

/* ═══════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s var(--ease);
    letter-spacing: -0.01em;
    white-space: nowrap;
    position: relative;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 8px 22px rgba(157, 73, 236, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    box-shadow: 0 12px 28px rgba(157, 73, 236, 0.35);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 2px 8px rgba(5,150,105,.25);
}

.btn-success:hover {
    opacity: .9;
    box-shadow: 0 4px 16px rgba(5,150,105,.35);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover { opacity: .9; }

.btn-outline {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
}

.btn-outline:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 6px;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 15px;
    border-radius: var(--radius);
}

.btn-full { width: 100%; justify-content: center; }

.btn.loading .btn-text { opacity: 0; }
.btn.loading .spinner { display: inline-block; }

.btn .spinner {
    display: none;
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    position: absolute;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════ */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.15s var(--ease);
    background: var(--bg-card);
    color: var(--text);
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: #D1D5DB;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(157, 73, 236, .1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-light);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-hint {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
    font-weight: 500;
}

/* ── Input with icon ──────────────────────── */
.input-icon {
    position: relative;
}

.input-icon input {
    padding-left: 42px;
}

.input-icon .icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 16px;
    opacity: .8;
}

/* ═══════════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════════ */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.tab {
    padding: 11px 22px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s var(--ease);
    letter-spacing: -0.01em;
}

.tab:hover { color: var(--text); }

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ═══════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15,26,20,.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 540px;
    box-shadow: var(--shadow-xl);
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s var(--ease-spring);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s var(--ease);
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--bg);
}

/* ═══════════════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════════════ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
}

.alert-error {
    background: var(--danger-bg);
    color: #991B1B;
    border-color: #FECACA;
}

.alert-success {
    background: var(--success-bg);
    color: #065F46;
    border-color: #A7F3D0;
}

.alert-warning {
    background: var(--warning-bg);
    color: #92400E;
    border-color: #FDE68A;
}

.alert-info {
    background: var(--info-bg);
    color: #1E40AF;
    border-color: #BFDBFE;
}

/* ═══════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: 60px 24px;
}

.empty-state .empty-icon {
    font-size: 52px;
    margin-bottom: 16px;
    opacity: .7;
}

.empty-state h3 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 20px;
}

/* ═══════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s var(--ease-spring);
    max-width: 400px;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }

/* ═══════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════ */
.app-footer {
    /* Acompaña al main: sin esto quedaría debajo de la barra lateral fija. */
    margin-left: 260px;
    /* Empuja el footer al fondo cuando la página es corta. */
    margin-top: auto;
    text-align: center;
    padding: 24px;
    color: var(--text-light);
    font-size: 12px;
    font-weight: 500;
    border-top: 1px solid var(--border-light);
    margin-top: 40px;
    background: rgba(255,255,255,0.02);
}

.app-footer .version {
    background: rgba(157, 73, 236, 0.12);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    color: var(--primary-light);
    font-size: 11px;
    letter-spacing: 0.02em;
    border: 1px solid rgba(157, 73, 236, 0.2);
}

/* ═══════════════════════════════════════════════
   UTILITY
   ═══════════════════════════════════════════════ */
.hidden { display: none !important; }
.text-mono { font-family: var(--font-mono); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-bold { font-weight: 700; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.ml-2 { margin-left: 8px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ═══════════════════════════════════════════════
   CODE / TERMINAL
   ═══════════════════════════════════════════════ */
.code-block {
    background: #1A1C1A;
    color: #A3D9B1;
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 16px 20px;
    border-radius: var(--radius);
    overflow-x: auto;
    line-height: 1.7;
    border: 1px solid rgba(255,255,255,.05);
}

.code-block .prompt { color: var(--primary-light); }
.code-block .cmd { color: #E2E8F0; }
.code-block .output { color: #94A3B8; }

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (max-width: 1280px) {
    .main-content, .app-footer { margin-left: 240px; }
}

@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .sidebar { width: 210px; }
    .main-content { margin-left: 210px; padding: 20px; }
    .app-footer { margin-left: 210px; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .app-footer { margin-left: 0; }
    .main-content { margin-left: 0; padding: 18px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; gap: 12px; }
}

@media (max-width: 560px) {
    .stats-grid { grid-template-columns: 1fr; }
    .card-body { padding: 18px; }
    table th, table td { padding: 10px 12px; }
}

/* ═══════════════════════════════════════════════
   ICONOS
   Sprite SVG de Lucide, inyectado en el documento por el backend. Se dibujan
   con currentColor y se dimensionan con em, así que un icono toma el color y
   el tamaño del texto que lo acompaña sin reglas extra por lugar de uso.
   ═══════════════════════════════════════════════ */
.icon {
    width: 1.15em;
    height: 1.15em;
    flex-shrink: 0;
    /* Alinea el icono con la línea base del texto en vez de dejarlo colgando. */
    vertical-align: -0.16em;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

/* Trazo más fino a tamaño grande: a 40px un stroke de 2 se ve tosco. */
.icon-lg { width: 22px; height: 22px; stroke-width: 1.75; }
.icon-xl { width: 44px; height: 44px; stroke-width: 1.25; }

/* Iconos dentro de botones: separados del texto, nunca pegados. */
.btn .icon { margin-right: 6px; }
.btn .icon:only-child { margin-right: 0; }
.btn-sm .icon { width: 1em; height: 1em; margin-right: 5px; }

/* En la barra lateral el icono es del mismo grosor que el texto de al lado. */
.sidebar-nav a .nav-icon .icon { width: 18px; height: 18px; stroke-width: 1.85; }

/* Cuadro del icono en las tarjetas de estadística. */
.stat-card .stat-icon {
    background: var(--bg-card-strong);
    border: 1px solid var(--border);
    color: var(--primary);
}

/* Ilustración de los estados vacíos: sin peso visual, es un apoyo no un cartel. */
.empty-state .empty-icon {
    display: flex;
    justify-content: center;
    color: var(--text-light);
    opacity: .55;
}

/* Celdas de tabla que empiezan con un icono (archivos, dominios). */
.cell-icon { display: inline-flex; align-items: center; gap: 8px; }
.cell-icon .icon { color: var(--text-light); }
.cell-icon a { display: inline-flex; align-items: center; gap: 8px; }

/* Sí/no en tablas: un tilde verde o un guion, sin emoji. */
.mark-yes { color: var(--success); }
.mark-no { color: var(--text-light); }

/* Estados de un servicio del sistema. */
.dot-run { color: var(--success); }
.dot-stop { color: var(--danger); }

/* ═══════════════════════════════════════════════
   GRILLA DE PERMISOS
   ═══════════════════════════════════════════════ */
.perm-area { margin-bottom: 18px; }

.perm-area-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 6px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-light);
}

.perm-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 4px;
}

.perm-item {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s var(--ease);
}

.perm-item:hover { background: var(--bg-card-strong); }
.perm-item input { margin-top: 2px; flex-shrink: 0; }
.perm-item span { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* Los permisos que exponen secretos o tocan el servidor entero se distinguen
   del resto: marcar uno sin querer no debería pasar desapercibido. */
.perm-sensible .icon { color: var(--warning); }
.perm-item input:disabled + span { opacity: .55; }

/* ═══════════════════════════════════════════════
   EDITOR DE CONTENIDO (/editor)
   Pantalla standalone, sin sidebar ni SPA: solo el login-card de siempre
   (reutilizado) más un formulario simple centrado en la página.
   ═══════════════════════════════════════════════ */
.content-editor-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px 60px;
}

.content-editor-wrap {
    width: 100%;
    max-width: 760px;
}

.content-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.content-editor-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-editor-brand .logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 24px rgba(157, 73, 236, .25);
}

.content-editor-brand h1 {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.content-editor-sub {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
}

.content-editor-key {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    color: var(--text-light);
    margin-left: 6px;
}

.content-editor-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 20px 0 32px;
}

.content-editor-hint {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 600;
}

.content-editor-password summary {
    padding: 18px 24px;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    list-style: none;
}

.content-editor-password summary::-webkit-details-marker { display: none; }

.content-editor-password summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 8px;
    color: var(--text-light);
    transition: transform 0.15s var(--ease);
}

.content-editor-password[open] summary::before { transform: rotate(90deg); }

.content-editor-password .card-body { border-top: 1px solid var(--border-light); }

@media (max-width: 560px) {
    .content-editor-header { flex-direction: column; align-items: flex-start; }
}

/* ═══════════════════════════════════════════════
   RECURSOS GRÁFICOS DE MARCA · manual sección 06
   Tres recursos acompañan al logotipo en las piezas. Están acá y no en la
   hoja de la landing porque valen para todo: panel, login y web de venta.
   ═══════════════════════════════════════════════ */

/* FRANJA DE COLOR — remate inferior de tapas, folletos y facturas.
   Orden y alto fijados por el manual: negro, violeta, lima, magenta, con un
   alto máximo de 8 mm. En pantalla se usa 6px, que es el equivalente óptico
   a esa proporción sobre un documento A4. */
.franja-marca {
    display: flex;
    height: 6px;
    width: 100%;
}
.franja-marca > span { flex: 1; }
.franja-marca > span:nth-child(1) { background: var(--negro-tinta); }
.franja-marca > span:nth-child(2) { background: var(--violeta); }
.franja-marca > span:nth-child(3) { background: var(--lima); }
.franja-marca > span:nth-child(4) { background: var(--magenta); }

/* Sobre fondo oscuro el primer tramo desaparece: es negro sobre negro. Se
   sustituye por blanco para que la franja siga leyéndose como los cuatro
   tramos que el manual define, en vez de como tres. */
.franja-marca-oscura > span:nth-child(1) { background: rgba(255,255,255,.85); }

/* PUNTOS DE PROCESO — firma de imprenta. Siempre los cuatro, en este orden,
   alineados en fila. No es decoración suelta: el manual fija el orden porque
   son las tintas del offset en el orden en que entran al pliego. */
.puntos-proceso {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.puntos-proceso > span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: block;
}
.puntos-proceso > span:nth-child(1) { background: var(--cyan); }
.puntos-proceso > span:nth-child(2) { background: var(--magenta); }
.puntos-proceso > span:nth-child(3) { background: var(--violeta); }
.puntos-proceso > span:nth-child(4) { background: var(--lima); }

/* GLIFO SUELTO — la «t» como marca de agua, al 10–20% de opacidad y recortada
   por el borde. El manual prohíbe ponerlo sobre el logotipo, así que el
   contenedor tiene que ser una sección, nunca un encabezado de marca. */
.glifo-agua {
    position: relative;
    overflow: hidden;
}
.glifo-agua::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -8%;
    width: 420px;
    height: 420px;
    background: var(--glifo-t) center/contain no-repeat;
    opacity: .12;
    pointer-events: none;
    z-index: 0;
}
.glifo-agua > * { position: relative; z-index: 1; }

/* ETIQUETA — el cuarto nivel de la jerarquía tipográfica (manual 04):
   Poppins, mayúsculas, tracking abierto, violeta. */
.etiqueta-marca {
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--violeta-claro);
}


/* El isotipo llena su contenedor y nunca se deforma. El manual (02) prohíbe
   estirarlo, condensarlo, rotarlo e inclinarlo; `object-fit: contain` impide
   los dos primeros aunque el contenedor deje de ser cuadrado. */
.isotipo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* ── CREDENCIALES DE LA DEMO ────────────────
   Solo se dibuja cuando /api/health dice `demo: true`, que el backend solo
   informa si la bandera está prendida Y el provisioning está simulado. En una
   instalación real este bloque no existe en el DOM. */
.demo-creds {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 14px;
    background: rgba(255,255,255,.03);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.demo-creds-titulo {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--violeta-claro);
}

.demo-creds-lista {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.demo-cred {
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    color: var(--text);
    transition: border-color .15s var(--ease), background .15s var(--ease);
}
.demo-cred:hover { border-color: var(--primary); background: var(--primary-bg); }

.demo-cred-user {
    display: block;
    font-family: var(--font-mono);
    font-size: 13px;
}
.demo-cred-rol {
    display: block;
    font-size: 11px;
    color: var(--text-light);
}

.demo-creds-clave {
    font-size: 12px;
    color: var(--text-light);
}
.demo-creds-clave code {
    font-family: var(--font-mono);
    color: var(--lima);
    user-select: all;   /* un click y media selecciona la clave entera */
}
