/* ==========================================================================
   Componentes UI (Sidebar App Shell)
   ========================================================================== */

/* Topbar Mobile / User Header */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    min-height: 80px;
    background-color: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 40;
}

/* Sidebar */
.sidebar {
    background-color: #000000;
    color: #ffffff;
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform var(--transition-base);
    overflow-x: hidden;
    overflow-y: auto;
}

.sidebar-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
    z-index: 2;
}

.sidebar-logo {
    font-family: var(--font-logo);
    font-size: 1.4rem;
    font-weight: 700;
    text-transform: lowercase;
    letter-spacing: -0.05em;
    padding: 0;
    display: flex;
    align-items: center;
    transition: all var(--transition-base);
    transform-origin: left center;
    position: relative;
    z-index: 1;
    
    background: linear-gradient(135deg, #ffb3ba 0%, #baffc9 50%, #bae1ff 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientFlow 5s ease infinite;
}

.auth-brand-logo {
    display: inline-block;
    font-family: var(--font-logo);
    font-weight: 700;
    letter-spacing: -0.05em;
    text-transform: lowercase;
    background: linear-gradient(135deg, #ff0000 0%, #0044ff 50%, #00ff00 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--color-primary);
    animation: gradientFlow 5s ease infinite;
}

.sidebar-logo:hover {
    transform: scale(1.05);
    filter: saturate(2.5) brightness(1.1);
}

.sidebar-logo-text-short {
    display: none;
}

.sidebar-collapse-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #94a3b8;
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 0;
}

.sidebar-collapse-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.25);
}

.sidebar-badge {
    margin-left: auto;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    letter-spacing: 0.04em;
}

.sidebar-badge-accent {
    margin-left: auto;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 9999px;
    background: rgba(99, 102, 241, 0.25);
    color: #a5b4fc;
    border: 1px solid rgba(129, 140, 248, 0.4);
    letter-spacing: 0.04em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    gap: 0.5rem;
    position: relative;
    z-index: 1;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 2rem;
    color: #a0a0a0;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.sidebar-link svg {
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.sidebar-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.05);
    transform: translateX(4px);
}

.sidebar-link:hover svg {
    opacity: 1;
}

.sidebar-link.active {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(129, 140, 248, 0.2) 100%);
    border-left: 3px solid #818cf8;
}

.sidebar-link.active svg {
    opacity: 1;
    color: #818cf8;
}

.dropdown-arrow {
    margin-left: auto;
    transition: transform 0.3s ease;
}

.sidebar-submenu {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease-in-out;
}

.sidebar-submenu.open {
    grid-template-rows: 1fr;
}

.sidebar-submenu-content {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-submenu-content .sidebar-link {
    padding-left: 3.5rem;
    font-size: 0.95em;
}

.sidebar-link.active-dropdown {
    background-color: rgba(255, 255, 255, 0.08);
}

/* Títulos de Sección en Sidebar */
.sidebar-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 1.25rem 2rem 0.35rem 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-section-title:first-child {
    padding-top: 0.5rem;
}

/* Pie de Usuario del Sidebar */
.sidebar-user-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background-color: rgba(0, 0, 0, 0.25);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.sidebar-user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
    transition: opacity var(--transition-fast);
    overflow: hidden;
}

.sidebar-user-profile:hover {
    opacity: 0.85;
}

.sidebar-user-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-highlight) 0%, #a855f7 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-weight: 700;
    font-size: 0.85rem;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.85rem;
    color: #f1f5f9;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: #f87171;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.sidebar-logout-btn:hover {
    color: #ef4444;
}

/* Botón Toggle de Tema */
.btn-theme-toggle {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.btn-theme-toggle:hover {
    background-color: var(--color-surface-hover);
    border-color: var(--color-border-hover);
    color: var(--color-highlight);
    transform: translateY(-1px);
}

/* Envoltorio de Título y Breadcrumbs en Topbar */
.topbar-header-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Hamburguesa (solo visible en móvil, oculto por defecto) */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    padding: 0.5rem;
}

/* Overlay cuando el sidebar está abierto (por defecto oculto y sin participar en el grid) */
.sidebar-overlay {
    display: none;
}

/* Mobile Logo */
.mobile-logo {
    display: none;
    padding: 0;
    color: var(--color-primary);
    background: linear-gradient(135deg, #ff0000 0%, #0044ff 50%, #00ff00 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientFlow 5s ease infinite;
    transition: transform var(--transition-base);
}

.mobile-logo:hover {
    transform: scale(1.05);
}

/* Media Queries Responsivas */
@media (max-width: 1024px) {
    .app-wrapper {
        display: block; /* Quitamos el grid */
    }

    .mobile-logo {
        display: flex;
    }

    .hamburger-btn {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-100%);
        width: 260px;
        box-shadow: none;
        transition: transform var(--transition-base), box-shadow var(--transition-base);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 45;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.open {
        display: block;
    }
}

/* Modo Mini-Sidebar Colapsable en Escritorio */
@media (min-width: 1025px) {
    .sidebar-collapse-toggle {
        display: inline-flex;
    }

    html[data-sidebar-collapsed="true"] .app-wrapper {
        grid-template-columns: 72px 1fr !important;
    }

    html[data-sidebar-collapsed="true"] .sidebar {
        width: 72px;
    }

    html[data-sidebar-collapsed="true"] .sidebar-header-row {
        padding: 1.25rem 0.5rem;
        justify-content: center;
        flex-direction: column;
        gap: 0.75rem;
    }

    html[data-sidebar-collapsed="true"] .sidebar-logo-text-full {
        display: none;
    }

    html[data-sidebar-collapsed="true"] .sidebar-logo-text-short {
        display: inline-block;
        font-size: 1.4rem;
        font-weight: 800;
    }

    html[data-sidebar-collapsed="true"] .sidebar-collapse-toggle {
        margin: 0;
    }

    html[data-sidebar-collapsed="true"] .sidebar-collapse-toggle svg {
        transform: rotate(180deg);
    }

    html[data-sidebar-collapsed="true"] .sidebar-section-title {
        height: 1px;
        padding: 0;
        margin: 0.75rem 0.75rem;
        background: rgba(255, 255, 255, 0.08);
        color: transparent;
        font-size: 0;
        overflow: hidden;
    }

    html[data-sidebar-collapsed="true"] .sidebar-link {
        padding: 0.75rem 0;
        justify-content: center;
        gap: 0;
    }

    html[data-sidebar-collapsed="true"] .sidebar-link-text,
    html[data-sidebar-collapsed="true"] .dropdown-arrow,
    html[data-sidebar-collapsed="true"] .sidebar-badge,
    html[data-sidebar-collapsed="true"] .sidebar-badge-accent {
        display: none !important;
    }

    html[data-sidebar-collapsed="true"] .sidebar-link::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(100% + 12px);
        top: 50%;
        transform: translateY(-50%);
        background: #0f172a;
        color: #f8fafc;
        padding: 0.45rem 0.85rem;
        border-radius: 6px;
        font-size: 0.8rem;
        font-weight: 600;
        white-space: nowrap;
        pointer-events: none;
        opacity: 0;
        visibility: hidden;
        transition: opacity var(--transition-fast), visibility var(--transition-fast);
        box-shadow: var(--shadow-lg);
        border: 1px solid rgba(255, 255, 255, 0.15);
        z-index: 1000;
    }

    html[data-sidebar-collapsed="true"] .sidebar-link:hover::after {
        opacity: 1;
        visibility: visible;
    }

    html[data-sidebar-collapsed="true"] .sidebar-submenu {
        display: none !important;
    }

    html[data-sidebar-collapsed="true"] .sidebar-user-footer {
        padding: 1rem 0.5rem;
        align-items: center;
    }

    html[data-sidebar-collapsed="true"] .sidebar-user-info,
    html[data-sidebar-collapsed="true"] .sidebar-logout-btn span {
        display: none;
    }

    html[data-sidebar-collapsed="true"] .sidebar-footer-actions {
        border-top: none;
        padding-top: 0.25rem;
        justify-content: center;
    }
}


/* Tarjetas (Cards) */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 1.5rem;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    will-change: transform, box-shadow; /* Hardware acceleration */
}

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

.card-header {
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 1rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0;
}

/* Botones ultra-diseñados con micro-animaciones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.75rem;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    gap: 0.5rem;
    border-radius: 12px;
    cursor: pointer;
    border: none;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast);
    transform: translateZ(0); /* Hardware acceleration */
    will-change: transform, box-shadow, filter;
    line-height: 1.2;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.15) 0%, transparent 100%);
    border-radius: inherit;
    pointer-events: none;
}

.btn:active {
    transform: scale(0.96);
    filter: brightness(0.9);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-highlight) 0%, #818cf8 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.39);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
    transform: translateY(-2px);
    color: #ffffff;
}

.topbar .btn-primary {
    background: linear-gradient(135deg, #111111 0%, var(--color-highlight) 50%, #111111 100%);
    background-size: 200% auto;
    animation: gradientFlow 5s ease infinite;
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.39);
}

.topbar .btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
    transform: translateY(-2px);
}

.btn-outline {
    background-color: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-border);
    position: relative;
    z-index: 1;
    overflow: visible;
    transition: transform var(--transition-fast), border-color var(--transition-fast), color 0s, background 0s;
}

.btn-outline:hover {
    border-color: transparent;
    background: linear-gradient(135deg, #111111 0%, var(--color-highlight) 50%, #111111 100%);
    background-size: 200% auto;
    color: transparent;
    -webkit-background-clip: text;
    background-clip: text;
    animation: gradientFlow 5s ease infinite;
    transform: translateY(-2px);
}

.btn-outline::before {
    content: "";
    position: absolute;
    inset: -2px;
    z-index: -1;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, #111111 0%, var(--color-highlight) 50%, #111111 100%);
    background-size: 200% auto;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.btn-outline:hover::before {
    opacity: 1;
    animation: gradientFlow 5s ease infinite;
}

.btn-outline:hover svg {
    stroke: var(--color-highlight);
    fill: none;
}

.btn-outline-danger {
    background-color: transparent;
    color: #ef4444;
    border: 2px solid #fca5a5;
    position: relative;
    z-index: 1;
    overflow: visible;
    transition: transform var(--transition-fast), border-color var(--transition-fast), color 0s, background 0s;
}

.btn-outline-danger:hover {
    border-color: transparent;
    background: linear-gradient(135deg, #7f1d1d 0%, #ef4444 50%, #7f1d1d 100%);
    background-size: 200% auto;
    color: transparent;
    -webkit-background-clip: text;
    background-clip: text;
    animation: gradientFlow 5s ease infinite;
    transform: translateY(-2px);
}

.btn-outline-danger::before {
    content: "";
    position: absolute;
    inset: -2px;
    z-index: -1;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, #7f1d1d 0%, #ef4444 50%, #7f1d1d 100%);
    background-size: 200% auto;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.btn-outline-danger:hover::before {
    opacity: 1;
    animation: gradientFlow 5s ease infinite;
}

.btn-outline-danger:hover svg {
    stroke: #ef4444;
    fill: none;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

/* Grid Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

/* Stats (Telemetría) */
.stat-value {
    font-family: var(--font-display);
    font-size: 2.5rem;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* Formularios Premium */
.koulos-form {
    width: 100%;
}

.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
}

label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--color-text);
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--color-text);
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-highlight);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-control[readonly] {
    background-color: var(--color-bg-alt);
    color: var(--color-text-muted);
    cursor: not-allowed;
}

/* Selectores nativos premium */
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23666666%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem top 50%;
    background-size: 0.65rem auto;
    padding-right: 2.5rem;
}

/* ==========================================================================
   Utility: Responsive Grid System
   ========================================================================== */

.grid { display: grid; }

.grid-cols-1 { grid-template-columns: 1fr; }

.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

.flex { display: flex; }
.justify-end { justify-content: flex-end; }
.items-center { align-items: center; }

.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: 1rem; }
.m-0 { margin: 0; }
.p-4 { padding: 1rem; }
.p-8 { padding: 2rem; }

/* md: 768px+ */
@media (min-width: 768px) {
    .md\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .md\:col-span-2 { grid-column: span 2; }
}

/* lg: 1024px+ */
@media (min-width: 1024px) {
    .lg\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
}

/* xl: 1280px+ */
@media (min-width: 1280px) {
    .xl\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ==========================================================================
   Koulos Modern Backoffice & Client Portal Component System
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Badges & Status Indicators
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    border: 1px solid transparent;
    line-height: 1.3;
    letter-spacing: 0.02em;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.badge-sm {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
}

.badge-lg {
    font-size: 0.85rem;
    padding: 0.35rem 0.85rem;
}

.badge-success, .badge-pagada {
    background-color: var(--color-success-bg);
    color: var(--color-success-text);
    border-color: var(--color-success-border);
}

.badge-warning, .badge-pendiente {
    background-color: var(--color-warning-bg);
    color: var(--color-warning-text);
    border-color: var(--color-warning-border);
}

.badge-danger, .badge-anulada {
    background-color: var(--color-danger-bg);
    color: var(--color-danger-text);
    border-color: var(--color-danger-border);
}

.badge-info, .badge-borrador {
    background-color: var(--color-info-bg);
    color: var(--color-info-text);
    border-color: var(--color-info-border);
}

.badge-purple, .badge-devuelta, .badge-rectificativa {
    background-color: var(--color-purple-bg);
    color: var(--color-purple-text);
    border-color: var(--color-purple-border);
}

.badge-neutral {
    background-color: var(--color-bg-alt);
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}

.badge-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
    flex-shrink: 0;
}

.badge-pulse {
    animation: badgePulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes badgePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.15); }
}

/* --------------------------------------------------------------------------
   2. Modern Tables
   -------------------------------------------------------------------------- */
.table-container {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    width: 100%;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table-modern {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

.table-modern th {
    padding: 0.875rem 1rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    background-color: var(--color-bg-alt);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}

.table-modern td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--color-border-subtle);
    color: var(--color-text);
    vertical-align: middle;
    transition: background-color var(--transition-fast);
}

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

.table-modern tbody tr:hover td {
    background-color: var(--color-surface-hover);
}

.table-modern .text-mono {
    font-family: var(--font-mono);
    font-size: 0.825rem;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
}

/* --------------------------------------------------------------------------
   3. Stat Cards & High-Impact Metrics
   -------------------------------------------------------------------------- */
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 1.5rem;
    transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-fast);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.stat-card-accent-highlight { border-top: 3px solid var(--color-highlight); }
.stat-card-accent-primary   { border-top: 3px solid var(--color-primary); }
.stat-card-accent-success   { border-top: 3px solid var(--color-success); }
.stat-card-accent-warning   { border-top: 3px solid var(--color-warning); }
.stat-card-accent-danger    { border-top: 3px solid var(--color-danger); }
.stat-card-accent-purple    { border-top: 3px solid var(--color-purple); }

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.stat-card-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-highlight-subtle);
    color: var(--color-highlight);
    flex-shrink: 0;
}

.stat-card-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1.1;
    margin-bottom: 0.35rem;
    letter-spacing: -0.02em;
}

.stat-card-subtext {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.trend-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
}

.trend-up {
    background-color: var(--color-success-bg);
    color: var(--color-success-text);
}

.trend-down {
    background-color: var(--color-danger-bg);
    color: var(--color-danger-text);
}

.trend-neutral {
    background-color: var(--color-bg-alt);
    color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   4. Empty States
   -------------------------------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 3.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border-radius: 14px;
    border: 1px dashed var(--color-border);
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--color-highlight-subtle);
    color: var(--color-highlight);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    box-shadow: 0 0 0 8px rgba(99, 102, 241, 0.05);
}

.empty-state-icon svg {
    width: 28px;
    height: 28px;
}

.empty-state-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.empty-state-description {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    max-width: 440px;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.empty-state-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   5. Breadcrumbs
   -------------------------------------------------------------------------- */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.breadcrumb-item a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.breadcrumb-item a:hover {
    color: var(--color-highlight);
}

.breadcrumb-item.active {
    color: var(--color-text);
    font-weight: 600;
}

.breadcrumb-separator {
    color: var(--color-text-subtle);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
}

/* --------------------------------------------------------------------------
   6. Dropdown Menus & Popovers
   -------------------------------------------------------------------------- */
.dropdown-menu {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 0.4rem;
    min-width: 180px;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text);
    border-radius: 8px;
    text-decoration: none;
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background-color: var(--color-surface-hover);
    color: var(--color-highlight);
}

.dropdown-item.danger {
    color: var(--color-danger);
}

.dropdown-item.danger:hover {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
}

.dropdown-divider {
    height: 1px;
    background-color: var(--color-border-subtle);
    margin: 0.35rem 0;
}

/* --------------------------------------------------------------------------
   7. Code & Key Badges
   -------------------------------------------------------------------------- */
.code-badge {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: var(--color-bg-alt);
    color: var(--color-text);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    word-break: break-all;
}

/* --------------------------------------------------------------------------
   8. Topbar Search & Command Palette (Ctrl+K / Cmd+K)
   -------------------------------------------------------------------------- */
.topbar-search-btn {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 210px;
}

.topbar-search-btn:hover {
    border-color: var(--color-border-hover);
    background: var(--color-surface-hover);
    color: var(--color-text);
    box-shadow: var(--shadow-sm);
}

.topbar-search-btn .shortcut-badge {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.15rem 0.45rem;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 5px;
    color: var(--color-text-subtle);
}

@media (max-width: 768px) {
    .topbar-search-btn {
        min-width: auto;
        padding: 0.5rem;
    }
    .topbar-search-btn .search-text,
    .topbar-search-btn .shortcut-badge {
        display: none;
    }
}

.command-palette-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.command-palette-backdrop.open {
    display: block;
}

.command-palette-modal {
    display: none;
    position: fixed;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 620px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    z-index: 1001;
    overflow: hidden;
    animation: modalPopIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.command-palette-modal.open {
    display: flex;
    flex-direction: column;
}

@keyframes modalPopIn {
    from {
        opacity: 0;
        transform: translate(-50%, -15px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }
}

.command-palette-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.command-palette-icon {
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.command-palette-input {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--color-text);
    outline: none;
    font-family: inherit;
}

.command-palette-input::placeholder {
    color: var(--color-text-subtle);
}

.command-palette-esc {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    color: var(--color-text-subtle);
    background: var(--color-bg-alt);
    flex-shrink: 0;
}

.command-palette-body {
    max-height: 380px;
    overflow-y: auto;
    padding: 0.75rem;
}

.command-palette-group-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-subtle);
    padding: 0.5rem 0.75rem 0.25rem 0.75rem;
}

.command-palette-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.command-palette-item:hover,
.command-palette-item.selected {
    background: var(--color-surface-hover);
    color: var(--color-highlight);
    transform: translateX(2px);
}

.command-palette-item svg {
    color: var(--color-text-muted);
    flex-shrink: 0;
    transition: color var(--transition-fast);
}

.command-palette-item:hover svg,
.command-palette-item.selected svg {
    color: var(--color-highlight);
}

.command-palette-item-text {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.command-palette-item-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

.command-palette-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-muted);
}

.command-palette-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1.25rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-alt);
    font-size: 0.75rem;
    color: var(--color-text-subtle);
}

.command-palette-hints {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.command-palette-hint {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.command-palette-hint kbd {
    font-family: var(--font-mono);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    font-size: 0.7rem;
}

body.command-palette-open {
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   9. Active Filters Indicator
   -------------------------------------------------------------------------- */
.btn-filter-has-active {
    border-color: var(--color-highlight) !important;
    background: var(--color-highlight-subtle) !important;
    color: var(--color-highlight) !important;
}

.badge-filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-highlight);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9999px;
    margin-left: 0.35rem;
}

/* --------------------------------------------------------------------------
   10. Modern Toast Notifications
   -------------------------------------------------------------------------- */
.toast-container {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
    align-items: center;
}

.toast-item {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 320px;
    max-width: 480px;
    padding: 0.85rem 1.25rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left-width: 4px;
    animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-item.toast-success {
    border-left-color: var(--color-success);
}

.toast-item.toast-danger {
    border-left-color: var(--color-danger);
}

.toast-item.toast-warning {
    border-left-color: var(--color-warning);
}

.toast-item.toast-info {
    border-left-color: var(--color-info);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast-message {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text);
}

.toast-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    opacity: 0.7;
    padding: 0.25rem;
    margin-left: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: opacity var(--transition-fast), background-color var(--transition-fast);
}

.toast-close-btn:hover {
    opacity: 1;
    color: var(--color-text);
    background-color: var(--color-surface-hover);
}

@keyframes toastSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* --------------------------------------------------------------------------
   11. Client Portal Modern Components
   -------------------------------------------------------------------------- */
.client-hero-banner {
    border-radius: 16px;
    padding: 1.5rem 1.75rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    position: relative;
    overflow: hidden;
}

.client-hero-success {
    border-left: 5px solid var(--color-success);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, var(--color-surface) 100%);
}

.client-hero-pending {
    border-left: 5px solid var(--color-warning);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, var(--color-surface) 100%);
}

.client-hero-content {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    min-width: 0;
}

.client-hero-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.client-hero-success .client-hero-icon {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-success);
}

.client-hero-pending .client-hero-icon {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-warning);
}

.client-hero-text h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
    color: var(--color-text);
}

.client-hero-text p {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin: 0;
    line-height: 1.4;
}

.client-hero-action {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.client-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 1024px) {
    .client-dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.license-cards-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.license-pass-card {
    background-color: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-fast);
}

.license-pass-card:hover {
    border-color: var(--color-border-hover);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.license-pass-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.license-product-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.2rem;
}

.license-key-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-copy-code {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 0;
}

.btn-copy-code:hover {
    color: var(--color-highlight);
    border-color: var(--color-highlight);
    background: var(--color-highlight-subtle);
}

.btn-copy-code.copied {
    color: var(--color-success) !important;
    border-color: var(--color-success) !important;
}

.license-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    padding-top: 0.5rem;
    border-top: 1px dashed var(--color-border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.license-actions-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.select-billing-cycle {
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    font-size: 0.8rem;
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition-fast);
}

.select-billing-cycle:focus {
    border-color: var(--color-highlight);
}

.product-catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.product-card-pricing {
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-surface);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-fast);
}

.product-card-pricing:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-highlight);
}

.product-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.product-card-desc {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin-bottom: 1.25rem;
    min-height: 42px;
}

.product-card-price-value {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--color-text);
    margin-bottom: 1.25rem;
    letter-spacing: -0.02em;
}

.product-card-price-period {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: 500;
    font-family: var(--font-sans);
}

/* --------------------------------------------------------------------------
   12. Financial & Invoice View Components
   -------------------------------------------------------------------------- */
.invoice-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.invoice-totals-wrapper {
    display: flex;
    justify-content: flex-end;
    padding: 1.75rem 2rem;
    background: var(--color-bg-alt);
    border-top: 1px solid var(--color-border);
}

.invoice-totals-box {
    width: 340px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.invoice-totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.invoice-totals-row.grand-total {
    border-top: 2px solid var(--color-border);
    padding-top: 0.85rem;
    margin-top: 0.25rem;
    color: var(--color-highlight);
    font-size: 1.35rem;
    font-weight: 800;
    font-family: var(--font-display);
}

.verifactu-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 5px solid var(--color-success);
    border-radius: 16px;
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.verifactu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.verifactu-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
}

.verifactu-hash-box {
    font-family: var(--font-mono);
    padding: 0.85rem 1rem;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--color-text);
    word-break: break-all;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.chart-legend-pills {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.chart-legend-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.chart-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ==========================================================================
   10. Verifactu Monitor & SaaS License Renewal Components
   ========================================================================== */
.verifactu-monitor-card {
    border-top: 3px solid var(--color-purple);
    background: var(--color-surface);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.verifactu-stats-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    padding: 1rem;
    background: var(--color-bg);
    border-radius: 8px;
    margin: 1.25rem 0;
    border: 1px solid var(--color-border-subtle);
}

.verifactu-stat-item {
    display: flex;
    flex-direction: column;
}

.verifactu-stat-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
}

.verifactu-stat-val {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text);
}

.verifactu-chain-flow {
    display: flex;
    align-items: stretch;
    gap: 0.75rem;
    overflow-x: auto;
    padding: 0.75rem 0.25rem 1rem 0.25rem;
    scrollbar-width: thin;
}

.verifactu-chain-block {
    flex: 0 0 270px;
    background: var(--color-surface-hover);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.verifactu-chain-block:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-purple);
}

.verifactu-chain-connector {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-purple);
    opacity: 0.6;
    flex-shrink: 0;
}

.verifactu-hash-chip {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    word-break: break-all;
}

.renewal-engine-card {
    border-top: 3px solid var(--color-highlight);
    background: var(--color-surface);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

/* ==========================================================================
   11. SaaS Intelligence Hub & 7x24 Telemetry Heatmap
   ========================================================================== */
.saas-metrics-card {
    border-top: 3px solid #06b6d4; /* Cyan accent */
    background: var(--color-surface);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
    position: relative;
}

.saas-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.saas-kpi-box {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1.15rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.saas-kpi-box:hover {
    transform: translateY(-2px);
    border-color: #06b6d4;
    box-shadow: var(--shadow-sm);
}

.saas-kpi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.saas-kpi-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.saas-kpi-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.saas-kpi-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.saas-kpi-subtext {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
}

/* Heatmap Grid & Cells */
.heatmap-card-inner {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    position: relative;
}

.heatmap-scroll-area {
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
}

.heatmap-table {
    min-width: 680px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.heatmap-header-hours {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    padding-left: 55px; /* Day label width */
}

.heatmap-hour-label {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--color-text-subtle);
    text-align: center;
}

.heatmap-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.heatmap-day-label {
    width: 47px;
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-align: right;
}

.heatmap-cells-track {
    display: flex;
    flex: 1;
    gap: 4px;
}

.heatmap-cell {
    flex: 1;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    transition: transform var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .heatmap-cell {
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.heatmap-cell.level-0 {
    background: var(--color-surface);
    opacity: 0.7;
}

.heatmap-cell.level-1 {
    background: rgba(99, 102, 241, 0.28);
}

.heatmap-cell.level-2 {
    background: rgba(99, 102, 241, 0.52);
}

.heatmap-cell.level-3 {
    background: rgba(99, 102, 241, 0.76);
}

.heatmap-cell.level-4 {
    background: #6366f1;
    box-shadow: 0 0 6px rgba(99, 102, 241, 0.5);
}

.heatmap-cell.is-hovered {
    transform: scale(1.35);
    z-index: 20;
    outline: 2px solid var(--color-highlight);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.heatmap-floating-tooltip {
    position: absolute;
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.72rem;
    line-height: 1.35;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35);
    white-space: nowrap;
    text-align: center;
}

.heatmap-legend-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    font-size: 0.72rem;
    color: var(--color-text-muted);
    margin-top: 0.75rem;
}

.heatmap-legend-swatches {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}

.heatmap-legend-swatch {
    width: 13px;
    height: 13px;
    border-radius: 3px;
}

/* Forecast Quarterly Grid */
.saas-forecast-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.saas-forecast-box {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* --- Language / Locale Selector --- */
.koulos-locale-switcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    z-index: 60;
}

.koulos-locale-details {
    position: relative;
}

.koulos-locale-trigger {
    list-style: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    min-height: 40px;
    box-sizing: border-box;
    gap: 0.45rem;
    padding: 0 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--color-border, rgba(148, 163, 184, 0.35));
    background: var(--color-surface, var(--color-bg-secondary, rgba(255, 255, 255, 0.08)));
    color: var(--color-text, #0f172a);
    font-size: 0.84rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.04em;
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-fast, 0.15s ease);
}

/* --- Unified Topbar Header Controls (Height, Font, Icons, Radius) --- */
.topbar-actions-group .btn,
.topbar .topbar-search-btn,
.topbar .koulos-locale-trigger,
.topbar .btn-theme-toggle {
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    border-radius: 10px !important;
    font-size: 0.84rem !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.topbar-actions-group .btn {
    padding: 0 1.05rem !important;
    gap: 0.5rem !important;
    font-weight: 700 !important;
}

.topbar-actions-group .btn-outline {
    border-width: 1px !important;
    background-color: var(--color-surface);
}

.topbar .topbar-search-btn {
    padding: 0 0.95rem !important;
    gap: 0.55rem !important;
    font-weight: 500 !important;
}

.topbar .koulos-locale-trigger {
    padding: 0 0.9rem !important;
    gap: 0.45rem !important;
    font-weight: 700 !important;
}

.topbar .btn-theme-toggle,
.topbar .mobile-only-ctrl.topbar-search-btn,
.topbar .hamburger-btn {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    border-radius: 10px !important;
}

.topbar-actions-group .btn svg,
.topbar .topbar-search-btn svg,
.topbar .btn-theme-toggle svg,
.topbar .koulos-locale-trigger > svg:first-child,
.topbar .mobile-nav-controls svg {
    width: 17px !important;
    height: 17px !important;
    flex-shrink: 0;
}

.topbar .koulos-locale-trigger .koulos-locale-chevron {
    width: 13px !important;
    height: 13px !important;
    flex-shrink: 0;
}

.koulos-locale-trigger::-webkit-details-marker {
    display: none;
}

.koulos-locale-trigger:hover {
    border-color: var(--color-primary, #6366f1);
}

.koulos-locale-details[open] .koulos-locale-chevron {
    transform: rotate(180deg);
}

.koulos-locale-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 205px;
    padding: 0.38rem;
    border-radius: 10px;
    border: 1px solid var(--color-border, #e2e8f0);
    background: var(--color-surface, var(--color-bg, #ffffff));
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 90;
}

.koulos-locale-option {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.48rem 0.65rem;
    border-radius: 7px;
    text-decoration: none;
    color: var(--color-text, #0f172a);
    font-size: 0.84rem;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
}

.koulos-locale-option:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--color-primary, #6366f1);
}

.koulos-locale-option.is-active {
    background: rgba(99, 102, 241, 0.14);
    color: var(--color-primary, #6366f1);
    font-weight: 700;
}

.koulos-locale-option-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    padding: 0.12rem 0.3rem;
    border-radius: 5px;
    background: rgba(148, 163, 184, 0.16);
    font-size: 0.7rem;
    font-weight: 700;
}

.koulos-locale-switcher--landing-mobile {
    width: 100%;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.koulos-locale-switcher--landing-mobile .koulos-locale-menu {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(100% + 6px);
    top: auto;
}






