:root {
    --bg-main: #070a17;
    --bg-card: #0c1228;
    --bg-card-hover: #121a38;
    --bg-sidebar: #060914;
    --border-color: #1a2342;
    --text-primary: #ffffff;
    --text-secondary: #9aa8c2;
    --text-muted: #5e6d8a;
    --neon-cyan: #00e5ff;
    --neon-purple: #7c4dff;
    --neon-pink: #ff007a;
    --neon-orange: #ff6d00;
    --neon-yellow: #ffd600;
    --neon-green: #00e676;
    --gradient-rainbow: linear-gradient(135deg, #ffd600, #ff6d00, #ff007a, #7c4dff, #00e5ff);
    --radius: 14px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */

.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Barra Lateral */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: 6px;
    padding-bottom: 22px;
    margin-bottom: 20px;
    border-bottom: none;
}

.sidebar-logo-img {
    width: 100%;
    max-width: 215px;
    height: auto;
    display: block;
    margin: 0 auto;
    filter: none;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 24px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.25s ease;
}

.nav-icon {
    flex-shrink: 0;
}

.nav-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.nav-text span {
    text-align: left;
    display: block;
}

.nav-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    text-align: left;
}

.nav-item button:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.nav-item button.active {
    background: rgba(255, 0, 122, 0.08);
    color: #ffffff;
    font-weight: 600;
    border: 1px solid #ff007a;
    box-shadow: 0 0 18px rgba(255, 0, 122, 0.35), inset 0 0 10px rgba(255, 109, 0, 0.2);
}

.nav-item button.active svg {
    stroke: #ff6d00;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.admin-badge-neon {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-card);
    border-radius: 24px;
    font-size: 13px;
    border: 1px solid #ff6d00;
    box-shadow: 0 0 16px rgba(255, 109, 0, 0.3), 0 0 8px rgba(255, 0, 122, 0.2);
}

.admin-badge-neon .admin-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-badge-neon .avatar-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 109, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ff6d00;
}

.admin-badge-neon .admin-meta strong {
    display: block;
    font-size: 13px;
    color: #fff;
}

.admin-badge-neon .admin-meta span {
    font-size: 11px;
    color: var(--neon-cyan);
}

.btn-logout {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    transition: color 0.2s;
    padding: 4px;
}

.btn-logout:hover {
    color: #ff5252;
}

/* Conteúdo Principal */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: radial-gradient(circle at 85% 12%, rgba(124, 77, 255, 0.08) 0%, transparent 45%),
                radial-gradient(circle at 15% 85%, rgba(0, 229, 255, 0.06) 0%, transparent 40%),
                var(--bg-main);
}

/* Header Superior com Seletor de Tenant */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 36px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(7, 10, 23, 0.9);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.tenant-selector-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid #ff6d00;
    box-shadow: 0 0 12px rgba(255, 109, 0, 0.25);
    border-radius: 10px;
    padding: 8px 14px;
    min-width: 320px;
}

.tenant-selector-box svg {
    color: #ff6d00;
    flex-shrink: 0;
}

.tenant-selector-box select {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 13px;
    font-weight: 500;
    outline: none;
    width: 100%;
    cursor: pointer;
}

.tenant-selector-box select option {
    background: #0c1228;
    color: #fff;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 16px;
    width: 260px;
}

.search-box input {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 13px;
    outline: none;
    width: 100%;
}

.search-box svg {
    color: var(--text-muted);
}

.btn-icon {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    border-color: var(--neon-cyan);
    color: #fff;
}

/* Botões de Ação */
.btn-primary {
    background: linear-gradient(135deg, #00e5ff, #7c4dff);
    color: #000;
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s;
    box-shadow: 0 4px 16px rgba(0, 229, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(0, 229, 255, 0.5);
}

.btn-secondary {
    background: var(--bg-card);
    color: #fff;
    border: 1px solid var(--border-color);
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: var(--neon-cyan);
    background: var(--bg-card-hover);
}

.btn-danger-sm {
    background: rgba(255, 82, 82, 0.1);
    color: #ff5252;
    border: 1px solid rgba(255, 82, 82, 0.3);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}

.btn-danger-sm:hover {
    background: #ff5252;
    color: #fff;
}

/* Telas / Seções */
.view-section {
    padding: 28px 36px;
    display: none;
}

.view-section.active {
    display: block;
}

/* ==========================================================================
   KPI CARDS COM BORDAS NEON VIBRANTES (IDÊNTICO AO MOCKUP)
   ========================================================================== */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 22px;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
}

/* Cartão 1: Dispositivos - Neon Roxo/Violeta */
.kpi-card.neon-purple {
    border: 1px solid #7c4dff;
    box-shadow: 0 0 20px rgba(124, 77, 255, 0.4), inset 0 0 12px rgba(124, 77, 255, 0.05);
}

/* Cartão 2: Projetos - Neon Magenta/Rosa */
.kpi-card.neon-magenta {
    border: 1px solid #ff007a;
    box-shadow: 0 0 20px rgba(255, 0, 122, 0.4), inset 0 0 12px rgba(255, 0, 122, 0.05);
}

/* Cartão 3: Total Apps - Neon Ciano/Azul */
.kpi-card.neon-cyan {
    border: 1px solid #00e5ff;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.4), inset 0 0 12px rgba(0, 229, 255, 0.05);
}

/* Cartão 4: Downloads - Neon Laranja/Âmbar */
.kpi-card.neon-orange {
    border: 1px solid #ff6d00;
    box-shadow: 0 0 20px rgba(255, 109, 0, 0.4), inset 0 0 12px rgba(255, 109, 0, 0.05);
}

.kpi-label {
    font-size: 12.5px;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.2px;
}

.kpi-value {
    font-size: 34px;
    font-weight: 800;
    margin: 10px 0 4px 0;
    color: #ffffff;
    letter-spacing: -0.5px;
}

/* ==========================================================================
   ÁREA DE UPLOAD DRAG & DROP COM BORDA NEON RAINBOW SUNSET
   ========================================================================== */

.upload-dropzone-sunset {
    border: 2px dashed #ff007a;
    box-shadow: 0 0 24px rgba(255, 0, 122, 0.25), inset 0 0 20px rgba(255, 109, 0, 0.05);
    background: rgba(12, 18, 40, 0.6);
    border-radius: var(--radius);
    padding: 36px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.upload-dropzone-sunset:hover {
    border-color: #00e5ff;
    box-shadow: 0 0 30px rgba(0, 229, 255, 0.4), inset 0 0 24px rgba(0, 229, 255, 0.1);
    transform: scale(1.005);
}

.upload-dropzone-sunset svg {
    color: #ffffff;
    width: 38px;
    height: 38px;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.6));
}

.upload-dropzone-sunset p {
    font-size: 15px;
    color: #ffffff;
    font-weight: 500;
}

/* ==========================================================================
   TABELA DE APLICATIVOS (COM BADGES E ÍCONES DO MOCKUP)
   ========================================================================== */

.card-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 28px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header h3 {
    font-size: 17px;
    font-weight: 700;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    text-align: left;
}

table.data-table th {
    padding: 14px 18px;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    font-size: 12.5px;
}

table.data-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

table.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge-xapk-gold {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #ffb74d;
    border: 1px solid #ff9800;
    background: rgba(255, 152, 0, 0.12);
}

.badge-apk-cyan {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #00e5ff;
    border: 1px solid #00e5ff;
    background: rgba(0, 229, 255, 0.12);
}

.badge-apkm-purple {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #e040fb;
    border: 1px solid #d500f9;
    background: rgba(213, 0, 249, 0.14);
    box-shadow: 0 0 8px rgba(213, 0, 249, 0.25);
}

.badge-directus {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    color: #d1c4e9;
    border: 1px solid #7c4dff;
    background: rgba(124, 77, 255, 0.15);
    box-shadow: 0 0 12px rgba(124, 77, 255, 0.25);
}

.app-icon-thumb {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    object-fit: cover;
    background: #141c38;
}

.clickable-app-title {
    cursor: pointer;
    color: #ffffff;
    transition: color 0.2s ease;
}

.clickable-app-title:hover {
    color: var(--neon-cyan);
    text-decoration: underline;
}

.action-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-table-icon {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-table-icon:hover {
    color: #00e5ff;
    background: rgba(0, 229, 255, 0.1);
    border-color: rgba(0, 229, 255, 0.4);
}

.btn-table-icon.edit {
    color: var(--neon-cyan);
    border-color: rgba(0, 229, 255, 0.2);
}

.btn-table-icon.edit:hover {
    color: #ffffff;
    background: rgba(0, 229, 255, 0.2);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

.btn-table-icon.delete:hover {
    color: #ff5252;
    background: rgba(255, 82, 82, 0.1);
    border-color: rgba(255, 82, 82, 0.4);
}

/* ==========================================================================
   MODAIS E FORMULÁRIOS COM FLUTUAÇÃO NEON E SCROLL SUAVE
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 5, 14, 0.88);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
}

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

.modal-card {
    background: var(--bg-card);
    border: 1px solid rgba(124, 77, 255, 0.8);
    box-shadow: 0 0 35px rgba(124, 77, 255, 0.35), 0 20px 50px rgba(0, 0, 0, 0.8);
    border-radius: 20px;
    width: 700px;
    max-width: 95vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalPopIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 26px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.btn-close:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.modal-body {
    padding: 22px 26px;
    overflow-y: auto;
    flex: 1;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}
.modal-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(124, 77, 255, 0.4);
    border-radius: 3px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(124, 77, 255, 0.8);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 26px;
    border-top: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
}

.auto-fill-notice {
    background: rgba(0, 229, 255, 0.06);
    border: 1px dashed rgba(0, 229, 255, 0.3);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12px;
    color: var(--neon-cyan);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-input[readonly] {
    background: rgba(255, 255, 255, 0.03);
    color: var(--neon-cyan);
    border-color: rgba(255, 255, 255, 0.08);
    cursor: default;
    font-weight: 600;
}

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

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
}

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

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

/* ==========================================================================
   TELA DE LOGIN COM O LOGO OFICIAL
   ========================================================================== */

.login-page {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #101633 0%, #050814 100%);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid #7c4dff;
    box-shadow: 0 0 40px rgba(124, 77, 255, 0.35);
    border-radius: 20px;
    width: 440px;
    padding: 42px 36px;
    text-align: center;
}

.login-logo-img {
    width: 250px;
    height: auto;
    margin: 0 auto 20px;
    display: block;
    filter: none;
}

.login-sub {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}
