/**
 * Estilos do Painel N-GATEWAY
 * NTECH NETWORK E COMUNICAÇÃO LTDA
 */

/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ==========================================================================
   Tokens do tema
   ==========================================================================
   A paleta do painel passou a ser a da IDENTIDADE N-GATEWAY (assets/brand.css,
   tokens --ngw-*): teal sobre neutro frio, no lugar do azul genérico original.
   Os nomes antigos (--primary-color, --gray-*) foram MANTIDOS de propósito —
   dezenas de telas e regras já os consomem, e renomeá-los obrigaria a reescrever
   todas elas para trocar uma cor. Aqui eles viraram um mapeamento: quem quiser
   mudar a marca mexe em brand.css; quem quiser mudar o tema do painel mexe nesta
   lista. Nenhuma página deve voltar a escrever hex de tema direto no HTML.

   Os --gray-* não são mais o cinza neutro do Tailwind: são um cinza AZULADO frio
   (slate), que é o que faz o painel claro parecer da mesma família do teal e do
   fundo escuro da sidebar. Trocar por cinza puro deixa o teal parecendo um
   acidente sobre a tela. */
:root {
    --primary-color: #216778;     /* azul-petróleo: menu ativo, botões, links, foco */
    --primary-dark: #1A505E;      /* estado :hover dos botões primários */
    --primary-light: #2E8AA1;     /* realce sobre fundo escuro (links da sidebar) */
    --primary-soft: #E7F0F3;      /* fundo de destaque leve (chips, pastilha de ícone) */
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #0ea5e9;
    --gray-50: #F7F9FC;
    --gray-100: #F1F5F9;
    --gray-200: #E4E9F0;
    --gray-300: #CBD4E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;

    /* Superfícies escuras (sidebar, barra de topo do celular) — vêm da marca. */
    --shell-bg: #10141B;
    --shell-bg-deep: #0B0E13;
    --shell-border: #1C2432;
    --shell-text: #E8ECF2;
    --shell-text-muted: #93A1B5;

    /* Fundo da aplicação e cartões */
    --app-bg: #F4F6FA;
    --card-bg: #ffffff;
    --card-border: #E7ECF3;
    --card-radius: 16px;
    --card-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -16px rgba(15, 23, 42, 0.14);

    --sidebar-width: 260px;
    --topbar-height: 60px;        /* barra de topo do celular (drawer) */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-800);
    background-color: var(--app-bg);
    -webkit-text-size-adjust: 100%;   /* iOS não pode reescalar o texto sozinho ao girar a tela */
}

/* Títulos e números em Space Grotesk (a fonte da marca, carregada em
   includes/brand-head.php). O corpo de texto continua na fonte do sistema: é a
   que rende melhor em bloco corrido e não custa uma requisição a mais. */
h1, h2, h3, h4,
.stat-value, .login-header h1 {
    font-family: var(--ngw-font-display, 'Space Grotesk'), -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: -0.01em;
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ==================== LOGIN PAGE ==================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    /* O fundo do login segue os tokens da marca (brand.css), não um azul próprio:
       era o último lugar do painel que ainda dizia "azul" enquanto o resto passou
       ao teal sobre neutro escuro. */
    background: radial-gradient(120% 120% at 20% 0%, #131A24 0%, var(--ngw-bg, #0B0E13) 60%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-box {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.company-logo {
    margin-bottom: 20px;
}

.company-logo img {
    max-width: 180px;
    max-height: 80px;
    object-fit: contain;
}

.logo-fallback {
    width: 80px;
    height: 80px;
    margin: 0 auto;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: 16px;
    display: none;
    align-items: center;
    justify-content: center;
}

.logo-icon {
    font-size: 40px;
}

.logo-text {
    font-size: 24px;
    font-weight: 800;
    color: white;
    letter-spacing: 2px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.login-header p {
    color: var(--gray-500);
    font-size: 14px;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-weight: 500;
    color: var(--gray-700);
    font-size: 14px;
}

.form-group input {
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 103, 120, 0.16);
}

/* Selects: aparência consistente com os inputs em todo o painel — herdam a fonte
   e ganham borda arredondada + seta própria, eliminando o visual nativo "quadrado"
   e a fonte do sistema. Regras locais que ajustem padding/cor devem usar
   "background-color" (NÃO o shorthand "background"), para não apagar a seta. */
select {
    font-family: inherit;
    font-size: 14px;
    color: var(--gray-800);
    padding: 12px 40px 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    background-color: #fff;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 103, 120, 0.16);
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--gray-500);
}

.copyright {
    text-align: center;
    margin-top: 24px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.copyright p {
    margin: 4px 0;
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    background: var(--gray-100);
}

.btn-block {
    width: 100%;
}

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

.data-table .action-cell {
    white-space: nowrap;
}

.data-table .action-cell .action-buttons {
    gap: 6px;
    align-items: center;
}

.data-table .action-cell .btn-sm {
    padding: 4px 8px;
    font-size: 13px;
    min-width: 34px;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* ==================== ALERTS ==================== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert a {
    color: inherit;
    text-decoration: underline;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
}

/* ==================== DASHBOARD LAYOUT ==================== */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-700);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.sidebar-logo {
    width: 100%;
    display: flex;
    justify-content: center;
}

.sidebar-logo img {
    max-width: 160px;
    max-height: 60px;
    object-fit: contain;
}

.logo-fallback-small {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
}

.sidebar-title h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 2px;
}

.router-name {
    font-size: 11px;
    color: var(--gray-400);
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--gray-300);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--gray-800);
    color: white;
    text-decoration: none;
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
}

/* A forma e o tamanho do ícone do menu estão no bloco TEMA N-GATEWAY, no fim
   deste arquivo — os ícones deixaram de ser emoji e viraram SVG. */

.nav-text {
    font-size: 14px;
}

/* Selo "Beta" ao lado de itens do menu ainda em maturação */
.nav-beta {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #f59e0b;
    color: #1f2937;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-700);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-icon {
    font-size: 16px;
}

.user-name {
    font-size: 13px;
    color: var(--gray-300);
}

.sidebar-footer .btn-outline {
    border-color: var(--gray-600);
    color: var(--gray-300);
}

.sidebar-footer .btn-outline:hover {
    background: var(--gray-800);
    border-color: var(--gray-500);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px 32px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

.content-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

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

.last-update {
    font-size: 12px;
    color: var(--gray-500);
}

.connection-count {
    font-size: 12px;
    color: var(--gray-600);
    background: var(--gray-200);
    padding: 4px 10px;
    border-radius: 12px;
}

/* ==================== STATS GRID ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.stat-card-link {
    text-decoration: none;
    color: inherit;
}

.stat-card-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.connected { background: #dbeafe; }
.stat-icon.users { background: #fef3c7; }
.stat-icon.uptime { background: #d1fae5; }
.stat-icon.cpu { background: #fce7f3; }

.stat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-value-small {
    font-size: 16px;
}

.stat-label {
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==================== CONTENT SECTION ==================== */
.content-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.content-section h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.section-description {
    color: var(--gray-600);
    margin-bottom: 24px;
    margin-top: -12px;
}

/* ==================== VPN SERVERS GRID ==================== */
.vpn-servers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.server-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
    transition: all 0.2s;
}

.server-card.active {
    border-color: var(--success-color);
    background: #f0fdf4;
}

.server-card.inactive {
    border-color: var(--gray-300);
    background: var(--gray-50);
}

.server-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-bottom: 12px;
}

.server-status.online {
    background: var(--success-color);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.server-status.offline {
    background: var(--gray-400);
}

.server-name {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.server-state {
    font-size: 12px;
    color: var(--gray-500);
}

/* ==================== TABLES ==================== */
.table-responsive {
    overflow-x: auto;
}

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

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    font-weight: 600;
    color: var(--gray-600);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--gray-50);
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.data-table tbody tr.row-online {
    background: #f0fdf4;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online {
    background: var(--success-color);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.status-dot.offline {
    background: var(--gray-400);
}

code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 12px;
}

.uptime-badge {
    font-size: 13px;
    color: var(--gray-700);
}

.text-muted {
    color: var(--gray-400);
}

/* ==================== BADGES ==================== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-secondary {
    background: var(--gray-200);
    color: var(--gray-600);
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

/* ==================== SEARCH / TOOLBAR ==================== */
.section-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 103, 120, 0.16);
}

.search-box input::placeholder {
    color: var(--gray-400);
}

.search-filters select {
    padding: 10px 40px 10px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    background-color: white;
    cursor: pointer;
    min-width: 150px;
}

.search-filters select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-info {
    font-size: 13px;
    color: var(--gray-500);
    white-space: nowrap;
}

.search-info span {
    font-weight: 600;
    color: var(--gray-700);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--gray-700);
    margin-bottom: 8px;
}

/* ==================== SYSTEM INFO GRID ==================== */
.system-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 8px;
}

.info-label {
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-weight: 600;
    color: var(--gray-900);
}

/* ==================== CONFIG FORM ==================== */
.config-form {
    max-width: 700px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group .required {
    color: var(--danger-color);
}

.form-help {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

/* ==================== INSTRUCTIONS ==================== */
.instructions {
    color: var(--gray-700);
}

.instructions h3 {
    font-size: 14px;
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 8px;
}

.instructions h3:first-child {
    margin-top: 0;
}

.instructions p {
    margin-bottom: 8px;
}

.code-block {
    background: var(--gray-900);
    color: #e5e7eb;
    padding: 12px 16px;
    border-radius: 8px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.config-info {
    background: var(--gray-50);
    padding: 16px;
    border-radius: 8px;
}

.config-info p {
    margin: 4px 0;
}

/* ==================== FOOTER ==================== */
.main-footer {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
    text-align: center;
}

/* ==================== MODAL ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    margin: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    /* Limita a altura à viewport e deixa o corpo rolar, para o rodapé
       (botão Salvar) nunca ser cortado em modais altos. */
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-700);
}

/* Quando o conteúdo do modal está dentro de um <form>, o form precisa
   participar do flex-column para o corpo poder rolar e o rodapé ficar fixo. */
.modal-content > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
}

.modal-body {
    padding: 24px;
    /* Rola apenas o conteúdo; header e footer permanecem fixos. */
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.modal-body p {
    margin-bottom: 16px;
    color: var(--gray-600);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 0 0 12px 12px;
    flex-shrink: 0;
}

/* ==================== INPUT WITH UNIT ==================== */
.input-with-unit {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-with-unit input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
}

.input-with-unit input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 103, 120, 0.16);
}

.input-unit {
    color: var(--gray-500);
    font-size: 14px;
    white-space: nowrap;
}

.info-display {
    padding: 12px 16px;
    background: var(--gray-100);
    border-radius: 8px;
    color: var(--gray-700);
    font-weight: 500;
}

/* ==================== ADD USER SECTION ==================== */
.add-user-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

.add-user-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--gray-800);
}

/* ==================== ACTION BUTTONS ==================== */
.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ==================== USER DETAILS IN SIDEBAR ==================== */
.user-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-role {
    font-size: 11px;
    color: var(--gray-500);
}

/* ==================== SIDEBAR CLIENT INFO ==================== */
.sidebar-client-info {
    padding: 12px 20px;
    background: var(--gray-800);
    border-bottom: 1px solid var(--gray-700);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.client-label {
    font-size: 11px;
    color: var(--gray-400);
}

.client-name {
    font-size: 13px;
    color: white;
}

.change-client {
    font-size: 11px;
    color: var(--primary-light);
    text-decoration: none;
    margin-left: auto;
}

.change-client:hover {
    text-decoration: underline;
}

/* ==================== CURRENT CLIENT BADGE ==================== */
.current-client-badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

/* ==================== ACTIVE CLIENT SECTION ==================== */
.active-client-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 16px 24px !important;
}

.active-client-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.active-client-label {
    font-size: 12px;
    opacity: 0.8;
}

.active-client-name {
    font-size: 18px;
}

.active-client-host {
    font-size: 12px;
    opacity: 0.7;
}

/* ==================== CLIENTS GRID ==================== */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.client-card {
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
}

.client-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.client-card.selected {
    border-color: var(--success-color);
    background: #f0fdf4;
}

.client-card.inactive {
    opacity: 0.6;
}

.client-card-header {
    padding: 16px 20px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 12px;
}

.client-card-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.client-card-body {
    padding: 16px 20px;
}

.client-card-body p {
    margin: 4px 0;
    font-size: 13px;
    color: var(--gray-600);
}

.client-card-actions {
    padding: 12px 20px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ==================== ALERT WARNING ==================== */
.alert-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.alert-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

/* ==================== MODAL LARGE ==================== */
.modal-large {
    max-width: 600px;
}

/* ==================== CHECKBOX LABEL ==================== */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

/* ==================== VALIDAÇÃO DE IP / REDE ==================== */
/* Marca campos de endereço IP inválidos (assets/ip-validation.js). */
.input-invalid {
    border-color: var(--danger-color) !important;
    background-color: #fef2f2 !important;
}

.ip-validation-msg {
    display: none;
    color: var(--danger-color);
    font-size: 12px;
    margin-top: 4px;
    line-height: 1.3;
}

/* ==================== EMPTY STATE SMALL ==================== */
.empty-state.small {
    padding: 30px 20px;
}

.empty-state.small p {
    margin: 0;
}

.footer-content {
    color: var(--gray-500);
    font-size: 12px;
}

.footer-content p {
    margin: 2px 0;
}

.footer-version,
.footer-version:visited {
    color: var(--gray-500) !important;
    text-decoration: none;
    font-weight: 600;
}

.footer-version:hover {
    text-decoration: underline;
}

.footer-sub {
    color: var(--gray-400);
}

body.changelog-page {
    background: var(--gray-50);
}

.changelog-shell {
    max-width: 920px;
    margin: 0 auto;
    padding: 36px 24px;
}

.changelog-header {
    display: grid;
    gap: 14px;
    margin-bottom: 30px;
}

.changelog-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-color);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.changelog-header h1 {
    margin: 0;
    font-size: clamp(2rem, 3vw, 2.5rem);
    line-height: 1.05;
}

.changelog-header p {
    margin: 0;
    color: var(--gray-600);
    font-size: 1rem;
    max-width: 720px;
    line-height: 1.75;
}

.changelog-list {
    display: grid;
    gap: 18px;
}

.release-block {
    position: relative;
    border: 1px solid var(--gray-200);
    border-radius: 22px;
    padding: 28px;
    background: white;
    box-shadow: 0 16px 35px rgba(15, 23, 42, 0.06);
}

.release-block::before {
    content: '';
    position: absolute;
    left: 0;
    top: 28px;
    bottom: 28px;
    width: 4px;
    /* Barra de acento na cor da marca — era o azul antigo, cravado em rgba. */
    background: linear-gradient(180deg, rgba(33, 103, 120, 1), rgba(33, 103, 120, 0.18));
    border-radius: 999px;
}

.release-block-top {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.release-title-group {
    min-width: 0;
}

.release-label {
    margin: 0 0 8px;
    color: var(--primary-color);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.release-title {
    margin: 0;
    font-size: 1.5rem;
    color: var(--gray-900);
    line-height: 1.15;
}

.release-meta {
    display: grid;
    gap: 8px;
    text-align: right;
    min-width: 160px;
}

.release-date {
    color: var(--gray-500);
    font-size: 0.95rem;
}

.release-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--gray-700);
    background: var(--gray-100);
}

.release-description {
    margin: 0 0 22px;
    color: var(--gray-600);
    line-height: 1.75;
}

.release-changes {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.release-section h3 {
    margin: 0 0 10px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gray-900);
}

.release-section ul {
    margin: 0;
    padding-left: 18px;
    color: var(--gray-700);
}

.release-section li {
    margin-bottom: 10px;
    line-height: 1.7;
}

.release-empty {
    margin: 0;
    color: var(--gray-500);
    font-size: 0.95rem;
}

@media (max-width: 720px) {
    .changelog-shell {
        padding: 28px 18px;
    }

    .release-block {
        padding: 22px;
    }

    .release-block::before {
        top: 22px;
        bottom: 22px;
    }

    .release-block-top {
        flex-direction: column;
        align-items: stretch;
    }

    .release-meta {
        text-align: left;
        min-width: 0;
    }
}

@media (max-width: 720px) {
    .release-card {
        padding: 20px;
    }

    .release-card::before {
        top: 20px;
        bottom: 20px;
    }

    .release-card-top {
        flex-direction: column;
        align-items: stretch;
    }

    .release-meta {
        text-align: left;
    }
}

@media (max-width: 640px) {
    .changelog-shell {
        padding: 24px 16px;
    }
    .release-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ==================== RESPONSIVE ====================
   As regras responsivas do painel foram unificadas no bloco "TEMA N-GATEWAY"
   no fim deste arquivo. O bloco que ficava aqui empurrava a barra lateral para
   fora da tela sem oferecer nenhuma forma de trazê-la de volta — o painel ficava
   sem menu no celular. Não recriar regras de layout responsivo neste ponto:
   duas listas de breakpoints em arquivos/pontos diferentes é como um ajuste
   passa a valer só em metade das telas.
   ==================================================== */

/* ==================== VPN USERS PAGE ==================== */
.section-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.section-header-actions h2 {
    margin: 0;
}

/* Cabeçalhos de seção com ações ao lado do título (layout flex): o divisor
   precisa ficar no CONTAINER, ocupando a largura toda do card. Quando o
   border-bottom fica no <h2> (regra geral .content-section h2), ele só aparece
   sob o texto do título e parece uma linha "cortada no meio" do card. */
.section-header-with-filter,
.section-header-actions,
.section-head {
    border-bottom: 1px solid var(--gray-200);
    padding-bottom: 16px;
    margin-bottom: 20px;
}
.section-header-with-filter h2,
.section-header-actions h2,
.section-head h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin: 0;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-online {
    background: #d1fae5;
    color: #065f46;
}

.status-offline {
    background: #e5e7eb;
    color: #374151;
}

.status-disabled {
    background: #fef3c7;
    color: #92400e;
}

/* Table row status colors */
.row-online {
    background-color: #f0fdf4;
}

.row-offline {
    background-color: #fff;
}

.row-disabled {
    background-color: #fffbeb;
    opacity: 0.8;
}

.row-disabled td {
    color: var(--gray-500);
}

/* IP online highlight */
.ip-online {
    color: var(--success-color);
    font-weight: 500;
}

/* Text muted */
.text-muted {
    color: var(--gray-500);
    font-size: 12px;
}

/* Badge warning */
.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

/* Button warning */
.btn-warning {
    background: #f59e0b;
    color: white;
    border: none;
}

.btn-warning:hover {
    background: #d97706;
}

/* Button success */
.btn-success {
    background: #10b981;
    color: white;
    border: none;
}

.btn-success:hover {
    background: #059669;
}

/* White Label - Logos */
.sidebar-logo img {
    max-width: 100%;
    max-height: 48px;
    object-fit: contain;
}

.client-logo-thumb {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 4px;
    margin-right: 8px;
}

.client-card-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.client-card-header h3 {
    flex: 1;
}

/* API Type Badge */
.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* ==================== MODO DEMONSTRAÇÃO ==================== */
/* Aviso fixo na barra lateral do tenant fictício: em uma apresentação comercial, o
   prospect precisa saber o tempo todo que os dados não são de uma rede real.
   As regras são deliberadamente à prova de queda: cada filho é bloco por conta
   própria (não depende do flex do pai), com box-sizing e quebra de palavra — se o
   CSS chegar parcialmente ao navegador, o aviso ainda fica legível dentro da barra. */
.demo-badge {
    box-sizing: border-box;
    width: calc(100% - 24px);
    max-width: 100%;
    margin: 0 12px 12px;
    padding: 12px 14px;
    border: 1px dashed #f59e0b;
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.12);
    overflow-wrap: break-word;
    word-break: break-word;
}

.demo-badge strong {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    line-height: 1.3;
    color: #fbbf24;
    letter-spacing: 0.02em;
}

.demo-badge span {
    display: block;
    margin-bottom: 10px;
    font-size: 11px;
    line-height: 1.45;
    color: var(--gray-300);
}

.demo-badge form {
    display: block;
    margin: 0;
}

.demo-badge .btn {
    box-sizing: border-box;
    display: block;
    width: 100%;
    padding: 7px 8px;
    font-size: 11px;
    line-height: 1.3;
    text-align: center;
    border: 1px solid #b45309;
    background: transparent;
    color: #fbbf24;
}

.demo-badge .btn:hover {
    background: rgba(245, 158, 11, 0.18);
    border-color: #f59e0b;
}

/* ==========================================================================
   TEMA N-GATEWAY — refinamento visual e navegação em celular
   ==========================================================================
   Este bloco fica no FIM do arquivo de propósito: ele reescreve regras
   declaradas acima (sidebar, cartões, tabelas) sem que fosse preciso editar
   cada uma no lugar de origem e sem `!important` — quem vence é a ordem da
   cascata. Mexer aqui é o caminho para ajustar a aparência do painel inteiro.

   Referência da linguagem visual: painel escuro à esquerda + área de trabalho
   clara à direita, cartões brancos de canto generoso, números grandes em
   Space Grotesk e micro-rótulos em mono caixa-alta.
   ========================================================================== */

/* --- Barra lateral -------------------------------------------------------- */
.sidebar {
    background: var(--shell-bg);
    border-right: 1px solid var(--shell-border);
    color: var(--shell-text);
}

.sidebar-header {
    border-bottom: 1px solid var(--shell-border);
    padding: 24px 20px 20px;
}

.router-name {
    font-family: var(--ngw-font-mono, monospace);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--shell-text-muted);
}

.sidebar-nav {
    padding: 14px 12px;
}

.nav-item {
    /* Cinza bem claro: o rótulo e o ícone precisam ser legíveis de relance sobre o
       fundo escuro sem competir com o item ativo, que é o único em branco pleno. */
    color: var(--gray-300);
    border-radius: 10px;
    padding: 11px 14px;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--shell-text);
}

/* O item ativo é uma pastilha teal preenchida — é o único elemento cheio de cor
   da barra, e é o que responde "onde eu estou" sem o usuário ler o texto. */
.nav-item.active {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 6px 16px -8px rgba(33, 103, 120, 0.95);
}

.nav-text { font-size: 14px; }

/* Ícones do menu: SVG de traçado que herda a cor do item (stroke="currentColor",
   em includes/nav-icons.php). É por isso que basta mudar `color` no item para o
   ícone acompanhar — item normal em cinza claro, ativo e hover em branco.
   Com os emoji que havia antes isso era impossível: emoji é glifo colorido, não
   herda `color`, e o filtro que tentava branqueá-lo virava um quadrado branco. */
.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    /* O traço fica um fio mais fino que a fonte do rótulo ao lado: no tamanho de
       menu, traço cheio pesa mais que o texto e a coluna vira uma fileira de
       manchas. */
    stroke-width: 1.7;
}

.nav-item        { color: var(--gray-300); }
.nav-item:hover,
.nav-item.active { color: #fff; }

.user-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    color: var(--shell-text-muted);
}

.sidebar-footer {
    border-top: 1px solid var(--shell-border);
    gap: 12px;
}

/* Nome de usuário longo ("Ana Ribeiro — TI Aurora (Demonstração)") quebrava em
   três linhas e empurrava o botão Sair para fora do rodapé. Duas linhas no
   máximo, o resto vira reticências — o nome completo fica no title. */
.user-details { min-width: 0; }

.user-name {
    color: var(--shell-text);
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.25;
}

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

.sidebar-footer .btn-outline {
    border-color: var(--shell-border);
    color: var(--shell-text-muted);
    flex-shrink: 0;
}

.sidebar-footer .btn-outline:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--shell-text-muted);
    color: var(--shell-text);
}

/* Esconde visualmente mas mantém acessível a leitor de tela. Utilitário sem
   uso no momento (o seletor de idioma, que era o único consumidor, passou a
   exibir o nome do idioma visivelmente ao lado da bandeira) — mantido porque
   é padrão de acessibilidade e volta a ser útil no próximo rótulo que precise
   existir só para leitor de tela. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Seletor de idioma: fica no rodapé da sidebar (todo perfil, toda página) porque
   não existe tela "minha conta" para admin/viewer — ver i18n.php.

   DELIBERADAMENTE NÃO é um <select> nativo. Três tentativas de estilizar um
   <select> escuro nesta mesma posição não resolveram de forma confiável:
   nem <option> com cor/fundo explícitos, nem deixar sem estilo nenhum, nem
   "color-scheme: light" — o popup de <option> é desenhado pelo SISTEMA
   OPERACIONAL, e em algumas combinações Chromium/GTK (Linux) o navegador
   escurece linhas dele por conta própria, sem que CSS nenhum controle isso.
   Ver 60-Armadilhas/select-escuro-popup-de-opcoes-fica-branco no vault.
   A troca foi por um botão (.sidebar-language-select) + uma lista <ul> comum
   (.sidebar-language-list) — DOM normal da página, sem popup de SO envolvido,
   então o CSS abaixo vale de verdade em qualquer navegador. */
.sidebar-language {
    padding: 0 20px 12px;
}

.sidebar-language-select {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    /* background-color, nunca o shorthand "background": mantém a convenção do
       resto do painel mesmo não sendo um <select> de verdade aqui. Sólido (não
       rgba translúcido): translúcido sobre um fundo já escuro fica com
       contraste baixo demais pra se distinguir como controle separado. */
    background-color: var(--shell-bg-deep);
    border: 1px solid var(--shell-border);
    border-radius: 8px;
    color: var(--shell-text);
    font-family: inherit;
    line-height: 1;
    padding: 7px 10px;
    cursor: pointer;
}

/* Bandeira + nome do idioma andam juntos: a bandeira identifica de relance, o
   nome é o que de fato se lê. Só a bandeira (sem nome) foi tentado antes e o
   usuário pediu o nome de volta. */
.sidebar-language-current {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

/* A bandeira é emoji: fica maior que o texto de propósito (emoji renderiza
   visualmente menor que letras no mesmo font-size). */
.sidebar-language-flag {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.sidebar-language-name {
    font-size: 12px;
    color: var(--shell-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-language-select:hover,
.sidebar-language-select:focus,
.sidebar-language-select[aria-expanded="true"] {
    outline: none;
    border-color: var(--shell-text-muted);
}

.sidebar-language-caret {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    color: var(--shell-text-muted);
    transition: transform 0.15s;
}

.sidebar-language-select[aria-expanded="true"] .sidebar-language-caret {
    transform: rotate(180deg);
}

/* position:fixed (calculado por JS na hora de abrir), não position:absolute:
   a sidebar rola por dentro (overflow-y:auto) e um dropdown absoluto ficaria
   preso/cortado por esse scroll. Fixed escapa disso — em troca, o JS fecha a
   lista ao rolar, comportamento padrão de qualquer dropdown fixed. */
.sidebar-language-list {
    position: fixed;
    z-index: 200;
    margin: 0;
    padding: 4px;
    list-style: none;
    background-color: var(--shell-bg-deep);
    /* color explícito, não confiar na herança: o <ul> herdaria de .sidebar
       normalmente (position:fixed não muda a árvore do DOM pra herança de
       CSS), mas depois de três rodadas com esse seletor não vale mais supor
       nada — declarar aqui é o que garante, sem depender de nenhum ancestral. */
    color: var(--shell-text);
    border: 1px solid var(--shell-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.sidebar-language-list[hidden] {
    display: none;
}

.sidebar-language-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--shell-text);
    line-height: 1;
    cursor: pointer;
}

.sidebar-language-option:hover,
.sidebar-language-option:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-language-option[aria-selected="true"] {
    background-color: rgba(255, 255, 255, 0.06);
    box-shadow: inset 2px 0 0 var(--primary-light, var(--shell-text-muted));
}

/* O bloco "Cliente: X / Trocar" (só superadmin) mora entre o cabeçalho e o menu:
   ele é uma faixa um tom acima do fundo da barra, não um cartão. */
.sidebar-client-info {
    background: rgba(255, 255, 255, 0.04);
    border-bottom-color: var(--shell-border);
}

.change-client { color: var(--primary-light); }

/* --- Área de trabalho ----------------------------------------------------- */

/* min-width:0 é o que impede a página inteira de esticar por causa de UMA tabela
   larga. Filho de flex/grid nasce com min-width:auto — ou seja, "nunca menor que
   o meu conteúdo" —, então a tabela de 640px empurrava o cartão, o cartão
   empurrava a coluna e o celular ganhava rolagem horizontal na PÁGINA, com o
   botão da direita fora da tela. Com isto, quem rola é só a tabela, dentro do
   cartão. Vale para toda tela nova: se algo largo vazar, o lugar de tratar é
   aqui, não com um overflow local. */
.main-content { min-width: 0; }

.content-section {
    min-width: 0;
    max-width: 100%;
}

.content-header h1 {
    font-size: 26px;
    letter-spacing: -0.02em;
}

.content-section,
.stat-card {
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
}

.content-section h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    border-bottom-color: var(--card-border);
}

/* Micro-rótulos (o "CONEXÕES ATIVAS" embaixo do número, cabeçalho de tabela):
   mono em caixa alta. É o que separa DADO de rótulo quando os dois estão
   empilhados no mesmo cartão. */
.stat-label,
.data-table th,
.info-label {
    font-family: var(--ngw-font-mono, monospace);
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--gray-500);
}

.stat-value {
    font-size: 26px;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

/* Uptime e datas ocupam MUITO mais caracteres que "12" ou "19%" e são o único
   valor que quebra linha no cartão. Menor e com entrelinha apertada, cabe em
   duas linhas em vez de três e o cartão para de esticar a fileira inteira. */
.stat-value-small {
    font-size: 15px;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.stat-icon {
    border-radius: 12px;
    background: var(--gray-100);
}

/* As pastilhas de ícone deixam de ser quatro cores pastel diferentes: a primeira
   é teal (o dado principal do cartão) e as demais são neutras. Quatro cores sem
   significado competem entre si e nenhuma quer dizer nada. */
.stat-icon.connected { background: var(--primary-soft); }
.stat-icon.users     { background: var(--gray-100); }
.stat-icon.uptime    { background: var(--gray-100); }
.stat-icon.cpu       { background: var(--gray-100); }

.stat-card-link:hover {
    border-color: var(--primary-light);
    box-shadow: 0 10px 30px -18px rgba(33, 103, 120, 0.75);
}

/* --- Tabelas -------------------------------------------------------------- */
.data-table th {
    background: var(--gray-50);
    border-bottom-color: var(--card-border);
}

/* Cabeçalho ordenável (assets/sort-table.js) — mesmo comportamento em toda
   tabela de listagem do painel: Links, VPNs, Conexões, Address Lists... */
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.data-table th.sortable:hover { background: var(--gray-100); }
.data-table th.sortable .sort-ind { color: var(--primary-color); margin-left: 2px; }

.data-table td { border-bottom-color: var(--gray-100); }
.data-table tbody tr:hover { background: var(--gray-50); }

/* STATUS continua VERDE, e não na cor da marca. "Online" é um significado, não um
   destaque de interface: pintar de cor institucional faz o operador ter de ler o
   texto para saber se a VPN está no ar — que é exatamente o que a cor evita.
   O mesmo vale para o cartão de servidor ativo, logo abaixo. */
.data-table tbody tr.row-online { background: #F0FDF4; }

.badge-success { background: #D1FAE5; color: #065F46; }
.badge-info    { background: #E0F2FE; color: #075985; }

code {
    font-family: var(--ngw-font-mono, monospace);
    background: var(--gray-100);
    color: var(--gray-700);
}

/* --- Cartões de servidor VPN ---------------------------------------------- */
.server-card { border-radius: 12px; border-color: var(--card-border); }
.server-card.active { border-color: #6EE7B7; background: #F0FDF4; }
.server-card.inactive { background: var(--gray-50); }

/* --- Formulários ---------------------------------------------------------- */
.form-group input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 103, 120, 0.16);
}

/* ==========================================================================
   BARRA DE TOPO E MENU DESLIZANTE (celular/tablet)
   ==========================================================================
   Antes deste bloco o painel simplesmente NÃO era navegável no celular: a regra
   responsiva empurrava a barra lateral para fora da tela (translateX(-100%)) e
   não havia nada que a trouxesse de volta — o usuário abria o painel no telefone
   e ficava preso na primeira página, sem menu nenhum. A barra de topo abaixo é o
   que devolve o acesso ao menu; ela não existe no desktop.
   ========================================================================== */
.app-topbar {
    display: none;              /* só aparece na faixa de celular/tablet */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    z-index: 1100;              /* acima do menu deslizante, para o X ficar clicável */
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    background: var(--shell-bg);
    border-bottom: 1px solid var(--shell-border);
    color: var(--shell-text);
    /* iPhone com "notch": sem isto a barra fica embaixo do recorte da câmera. */
    padding-top: env(safe-area-inset-top);
    height: calc(var(--topbar-height) + env(safe-area-inset-top));
}

.app-topbar__toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    /* 44×44 é o alvo mínimo de toque; abaixo disso o dedo erra o botão. */
    width: 44px;
    height: 44px;
    padding: 0 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
}

.app-topbar__toggle:active { background: rgba(255, 255, 255, 0.08); }

.app-topbar__toggle span {
    display: block;
    height: 2px;
    border-radius: 2px;
    background: var(--shell-text);
    transition: transform 0.2s, opacity 0.2s;
}

/* Hambúrguer vira "X" com o menu aberto: é o mesmo botão que fecha. */
.app-topbar__toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.app-topbar__toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.app-topbar__toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.app-topbar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    text-decoration: none;
}

.app-topbar__brand img {
    max-height: 30px;
    max-width: 120px;
    object-fit: contain;
    background: #fff;
    border-radius: 6px;
    padding: 3px 6px;
}

.app-topbar__client {
    font-size: 13px;
    font-weight: 600;
    color: var(--shell-text);
    /* Nome de cliente longo não pode empurrar o botão para fora da tela. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Véu que escurece o conteúdo com o menu aberto — e que fecha o menu ao toque,
   que é o gesto que todo mundo tenta antes de procurar o X. */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(11, 14, 19, 0.55);
    opacity: 0;
    /* Fechado, o véu fica "display: block" o intervalo inteiro (regra abaixo
       de 900px) só controlado por opacity — sem isto ele continua cobrindo a
       tela inteira, invisível, e captura o clique que deveria ir para o
       conteúdo por baixo. Foi o que deixava o celular preso: só o botão do
       menu (acima dele em z-index) respondia a toque. */
    pointer-events: none;
    transition: opacity 0.25s;
}

.sidebar-overlay.is-visible { opacity: 1; pointer-events: auto; }

/* Trava a rolagem do fundo enquanto o menu está aberto: sem isto, arrastar
   sobre o véu rola a página que está atrás. */
body.nav-open { overflow: hidden; }

@media (max-width: 900px) {
    .app-topbar { display: flex; }
    .sidebar-overlay { display: block; }

    .sidebar {
        width: min(86vw, 300px);
        transform: translateX(-100%);
        transition: transform 0.28s ease;
        z-index: 1050;
        box-shadow: none;
    }

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

    /* A barra de topo é FIXA e cobre o alto da tela: sem este recuo o topo do
       menu (a marca) abre escondido atrás dela, cortado ao meio. */
    .sidebar { padding-top: calc(var(--topbar-height) + env(safe-area-inset-top)); }

    /* Só o respiro do cabeçalho encolhe. O TAMANHO da marca não se reduz por CSS:
       a espessura do colchete e o respiro do N são calculados em PHP a partir do
       `size` (assets/brand.css §Geometry) — mexer só no --ngw-logo-h aqui deixaria
       o traço grosso demais para a altura, que é exatamente a deformação que o
       handoff proíbe. Se um dia a marca precisar ser menor no celular, o caminho é
       o parâmetro `size` de ngatewayLogo(), não uma regra de tela. */
    .sidebar-header { padding: 14px 20px 16px; }

    .main-content {
        margin-left: 0;
        padding: 20px 16px 16px;
        /* Espaço da barra fixa; sem isto o título fica embaixo dela. */
        padding-top: calc(var(--topbar-height) + env(safe-area-inset-top) + 16px);
    }

    /* Alvos de toque: botão de 44px de altura mínima na faixa de celular. */
    .nav-item { padding: 13px 14px; }
    .btn { min-height: 42px; }
    .btn-sm { min-height: 34px; }
}

/* Quem prefere menos movimento não recebe a animação do menu. */
@media (prefers-reduced-motion: reduce) {
    .sidebar, .sidebar-overlay, .app-topbar__toggle span { transition: none; }
}

/* ==========================================================================
   RESPONSIVO — conteúdo
   ========================================================================== */
@media (max-width: 900px) {
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .content-header h1 { font-size: 22px; }

    .header-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 10px;
    }

    .content-section { padding: 18px 16px; border-radius: 14px; }

    /* Tabela larga rola dentro do próprio cartão. A alternativa (quebrar a
       tabela em cartões) esconderia colunas que o operador usa para comparar
       linhas — em tela de monitoramento, ver a linha inteira é o ponto. */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* Sangra até a borda do cartão: a área de rolagem fica visivelmente
           maior que o texto e fica claro que dá para arrastar. */
        margin: 0 -16px;
        padding: 0 16px;
    }

    /* Largura mínima da tabela: abaixo disto as colunas se espremem até a coluna
       de ações quebrar os três botões um embaixo do outro e a linha triplicar de
       altura. É preferível rolar de lado — a rolagem é visível e reversível, a
       linha deformada não. */
    .data-table { min-width: 780px; }

    /* Os botões de ação de uma linha ficam SEMPRE lado a lado: empilhados, cada
       linha da tabela ganha a altura de três botões e a lista deixa de ser
       varrível de cima a baixo. Vale para qualquer .action-buttons dentro da
       tabela — nem toda tela envolve a célula em .action-cell. */
    .data-table .action-buttons { flex-wrap: nowrap; }
    .data-table td:last-child { white-space: nowrap; }
    .data-table th, .data-table td { padding: 10px 12px; }

    /* A coluna que identifica a linha (nome da VPN, do usuário) não pode quebrar:
       espremida, "legado-filial-sorocaba" virava três linhas e a linha da tabela
       ficava quatro vezes mais alta que o dado que ela carrega. Quem resolve a
       largura aqui é a rolagem lateral, que já existe. */
    .data-table .user-cell { white-space: nowrap; }

    .section-toolbar { gap: 10px; }
    .search-box { min-width: 100%; }

    /* Rede de proteção: campo com largura fixa herdada do desktop (um select de
       420px, por exemplo) não pode estourar uma tela de 390px. Trava aqui, uma vez,
       em vez de caçar cada style="width:..." espalhado pelas telas. */
    input, select, textarea { max-width: 100%; }

    .modal-content { width: 94vw; max-height: 88vh; overflow-y: auto; }
}

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

    /* No cartão estreito o ícone empilha em cima do número em vez de espremer
       o texto em duas ou três linhas. */
    .stat-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 16px;
    }

    .stat-icon { width: 38px; height: 38px; font-size: 19px; }
    .stat-value { font-size: 20px; }
    .stat-value-small { font-size: 14px; }

    .vpn-servers-grid { grid-template-columns: repeat(2, 1fr); }
    .system-info-grid { grid-template-columns: repeat(2, 1fr); }

    .form-row { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; }

    /* Só na faixa estreita: título e botão de ação da seção empilham, e aí o botão
       ocupa a linha inteira. Em tablet os dois ainda cabem lado a lado — esticar o
       botão por 700px de largura o transforma numa faixa sem foco. */
    .section-header-actions { flex-direction: column; align-items: stretch; }
    .section-header-actions .btn { width: 100%; }

    .action-buttons { flex-wrap: wrap; }
}

@media (max-width: 380px) {
    .stats-grid { grid-template-columns: 1fr; }
}
