* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'NaruSans-Regular', sans-serif;
}

/* ===== OTIMIZAÇÕES DE PERFORMANCE ===== */
html {
    scroll-behavior: auto; /* Desativa smooth scroll nativo para melhor performance */
}

body {
    background: #d5e3da;
    display: flex;
    justify-content: center;
    padding: 20px;
    height: 100%;
    /* Otimização de renderização */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeSpeed;
}

/* Garantir fundo claro no mobile */
@media (max-width: 768px) {
    body {
        background: #d5e3da;
        padding: 0;
    }
}

/* ========== OTIMIZAÇÕES DE PERFORMANCE PARA VIRTUAL SCROLLING ========== */
.tags-grid {
    /* Contenção de layout - impede reflows em cascata */
    contain: layout style;
    /* Suaviza scroll em iOS */
    -webkit-overflow-scrolling: touch;
}

/* Otimiza renderização das tags individuais */
.tag {
    /* Isolamento de cada tag - CRITICAL para performance */
    contain: layout paint;
    /* Backface oculta melhora composição */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* NOVO: content-visibility pula renderização de elementos fora do viewport */
    content-visibility: auto;
    /* Tamanho intrínseco para content-visibility calcular espaço */
    contain-intrinsic-size: 260px 350px;
}

/* Otimizações específicas para imagens nas tags */
.tag img {
    /* Decode assíncrono de imagens */
    decoding: async;
    /* Melhora renderização */
    image-rendering: auto;
    /* Força tamanho para evitar reflow */
    width: 100%;
    height: auto;
    display: block;
    /* NOVO: Força dimensões para evitar reflow */
    min-height: 200px;
    max-height: 280px;
    object-fit: cover;
}

/* Contenção para container de scroll */
.content {
    /* Suaviza scroll */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Otimiza scroll rendering */
    overflow-anchor: none;
}

/* Reduz carga durante scroll */
body.is-scrolling .tag {
    pointer-events: none;
}

body.is-scrolling .tag * {
    /* Desativa todas as transições durante scroll */
    transition: none !important;
    animation: none !important;
}

/* NOVA OTIMIZAÇÃO: Simplificar box-shadows globalmente */
body.is-scrolling .tag img,
body.is-scrolling button,
body.is-scrolling .modal-content {
    box-shadow: none !important;
}

/* Pausar animação de blink durante scroll */
body.is-scrolling .comment-bubble {
    animation-play-state: paused !important;
}

/* Keyframes para animação de blink (otimizado) */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

body.is-scrolling .tag img {
    /* Desativa transições durante scroll para melhor performance */
    transition: none !important;
}

:root {
    --topbar-h: 64px;
    --secondbar-h: 96px;
    --sidebar-w: 280px;
}

@font-face {
    font-family: 'NaruSans-Bold';
    src: url(/font/NaruSans-Bold.ttf) format('truetype');
    font-weight: bold;
}

@font-face {
    font-family: 'NaruSans-Regular';
    src: url(/font/NaruSans-Regular.ttf) format('truetype');
    font-weight: normal;
}

/* ========== TOPBAR UNIFICADA ========== */
.topbar {
    background: #108e64;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 24px;
    height: var(--topbar-h);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100001;
    box-sizing: border-box;
}

.topbar .logo {
    justify-self: start;
    display: flex;
    align-items: center;
}

.topbar .logo img {
    width: 190px;
}

.user-info {
    justify-self: center;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info button {
    background: transparent;
    padding: 12px 28px;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 18px;
    font-family: 'NaruSans-Bold', sans-serif;
    border-radius: 0 10px 10px 10px;
    transition: background .15s;
}

.user-info button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-info button:active,
.user-info button.active {
    background-color: #0c6749;
}

.topbar .topbar-right {
    justify-self: end;
    display: flex;
    align-items: center;
}

/* Session badge — estilo "SIGLA – Sair", sem contorno */
.topbar .session-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    font-family: 'NaruSans-Regular', sans-serif;
    font-size: 14px;
}

.topbar .session-badge .id {
    font-family: 'NaruSans-Bold', sans-serif;
}

.topbar .session-badge .sep {
    opacity: 0.6;
}

.topbar .session-badge .logout-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-family: 'NaruSans-Bold', sans-serif;
    font-size: 14px;
    padding: 0;
    opacity: 0.85;
}

.topbar .session-badge .logout-btn:hover {
    opacity: 1;
    text-decoration: underline;
}

.second-header {
    background-color: white;
    display: grid;
    grid-template-columns: auto 1fr;
    /* title + actions row */
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    height: var(--secondbar-h);
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    z-index: 9;
}

:root {
    --action-height: 56px;
}

.actions-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 18px;
}

.action-button {
    width: 100%;
    height: var(--action-height);
    background-color: #108e64;
    color: white;
    border: none;
    cursor: pointer;
    font-family: 'NaruSans-Regular', sans-serif;
    font-size: 12px;
    border-radius: 10px;
}

.btn-upload {
    width: 100%;
    height: var(--action-height);
    border: 2px dashed #108e64;
    border-radius: 10px;
    background-color: #f3faf7;
    color: #108e64;
    cursor: pointer;
    font-family: 'NaruSans-Regular', sans-serif;
    font-size: 12px;
}

.comentario input {
    border: none;
    background-color: rgb(221, 221, 221);
    border-radius: 10px;
    padding: 5px 10px;
    font-family: 'NaruSans-Regular', sans-serif;
    font-size: 12px;
    width: 200px;
    /* default; overridden in actions row */
    height: 40px;
    /* default; overridden in actions row */
}

.actions-row .comentario input {
    width: 100%;
    height: var(--action-height);
    background-color: #c8d4cf;
}

/* --- Selecionar Cluster Modal: visual feedback de seleção --- */
.store-item {
    background: #eef5f2;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    border: 2px solid #c8d4cf;
    transition: background 0.18s, border 0.18s, color 0.18s;
}

.store-item.selected {
    background-color: #108e64;
    color: #fff;
    border: 2px solid #108e64;
    box-shadow: 0 2px 8px rgba(16, 142, 100, 0.10);
}

.store-item.selected .store-code {
    color: #fff;
}

/* Botões do modal Selecionar Cluster/Ação */
.btn-primary,
.action-button,
.btn-filter-tags,
#btn-cluster,
#btn-action {
    background-color: #108e64;
    color: #fff;
    border: none;
    border-radius: 0 10px 10px 10px;
    font-size: 12px;
    padding: 12px 24px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(16, 142, 100, 0.08);
    transition: background 0.18s, box-shadow 0.18s, transform 0.12s;
    outline: none;
}

.btn-primary:hover,
.action-button:hover,
.btn-filter-tags:hover,
#btn-cluster:hover,
#btn-action:hover {
    background-color: #108e64;
    box-shadow: 0 4px 16px rgba(16, 142, 100, 0.16);
    transform: translateY(-2px) scale(1.03);
}

.btn-primary:active,
.action-button:active,
.btn-filter-tags:active,
#btn-cluster:active,
#btn-action:active {
    background: #0c6749;
    box-shadow: none;
}

/* --- select-section centralizado e fixo --- */
.select-section {
    position: sticky;
    top: calc(var(--topbar-h) + var(--secondbar-h) + 8px);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 16px;
    box-shadow: 0 2px 16px rgba(16, 142, 100, 0.07);
    margin: 0 auto 18px auto;
    max-width: 1000px;
    padding: 30px 18px;
    top: 0;

    /* Animation for smooth fade/slide */
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.28s cubic-bezier(.4, 0, .2, 1), transform 0.32s cubic-bezier(.4, 0, .2, 1);
}

/* Collapsed state: hidden from flow when turning into FAB */
.select-section.collapsed {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-16px);
    transition: opacity 0.22s cubic-bezier(.4, 0, .2, 1), transform 0.22s cubic-bezier(.4, 0, .2, 1);
}

/* Floating panel when opened from FAB */
.select-section.floating {
    position: fixed;
    bottom: 90px;
    right: 20px;
    left: auto;
    top: auto;
    width: max-content;
    max-width: 90vw;
    transform: scale(1);
    z-index: 1200;
    opacity: 1;
    pointer-events: auto;
    height: auto;
    margin: 0;
    padding: 16px 18px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
    transition: opacity 0.28s cubic-bezier(.4, 0, .2, 1), transform 0.32s cubic-bezier(.4, 0, .2, 1);
}

/* Scrim behind floating panel */
.select-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 1090;
    display: none;
}

/* Floating Action Button (FAB) */
.select-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #108e64;
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    z-index: 1150;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92);
    transition: opacity 0.22s cubic-bezier(.4, 0, .2, 1), transform 0.22s cubic-bezier(.4, 0, .2, 1);
}

.select-fab.visible {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.select-fab:hover {
    filter: brightness(0.95);
}

.select-fab i {
    font-size: 22px;
}

.select-section label {
    font-family: 'NaruSans-Bold', sans-serif;
    font-size: 15px;
    color: #108e64;
    margin-right: 6px;
}

.select-section input[type="checkbox"] {
    accent-color: #108e64;
    width: 18px;
    height: 18px;
}

.select-section input[type="text"] {
    font-size: 15px;
    border-radius: 10px;
    border: 1px solid #6b8c74;
    padding: 0 15px;
}

.select-section .btn-filter-tags {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    padding: 10px 18px;
}

/* Fade out degradee para as tags ao rolar */


#comment::placeholder {
    color: #2a3b35;
    opacity: 1;
}

#search-lojas::placeholder {
    color: #ffffff;
    opacity: 1;
}

.side-bar {
    position: fixed;
    top: calc(var(--topbar-h) + var(--secondbar-h));
    left: 0;
    width: var(--sidebar-w);
    height: calc(100vh - (var(--topbar-h) + var(--secondbar-h)));
    background: #108e64;
    /* requested background */
    border-radius: 0 12px 12px 0;
    /* rounded corners */
    padding: 12px 16px;
    overflow-y: auto;
    /* own scroll */
    z-index: 8;
    scrollbar-width: thin;
    /* Firefox */
    scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
}

/* Minimal custom scrollbar (Chromium/WebKit) */
.side-bar::-webkit-scrollbar {
    width: 8px;
}

.side-bar::-webkit-scrollbar-track {
    background: transparent;
}

.side-bar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    /* rounded "bolinha" */
    border: 2px solid transparent;
    background-clip: content-box;

}

.side-bar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.5);
}

/* Central scrollable content area */
.content {
    position: fixed;
    top: calc(var(--topbar-h) + var(--secondbar-h));
    left: var(--sidebar-w);
    right: 0;
    bottom: 0;
    overflow: auto;
    /* its own scroll separate from sidebar */
    padding: 16px;
}

/* Minimal custom scrollbar for central content */
.content {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
}

.content::-webkit-scrollbar {
    width: 8px;
}

.content::-webkit-scrollbar-track {
    background: transparent;
}

.content::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.content::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.5);
}

.sidebar-header {
    color: #e8f5f0;
    font-family: 'NaruSans-Bold', sans-serif;
    font-size: 18px;
    margin-bottom: 12px;
}

.sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.sidebar-search input[type="text"] {
    width: 100%;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: #0c6749;
    padding: 6px 10px;
    font-family: 'NaruSans-Regular', sans-serif;
    font-size: 12px;
    outline: none;
    color: rgb(255, 255, 255);
}

#lojas-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

#lojas-list li {
    color: #e8f5f0;
    font-family: 'NaruSans-Regular', sans-serif;
    font-size: 13px;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background-color 0.15s ease-in-out;
    cursor: default;
}

#lojas-list li:hover {
    background: #0c6749;
}

/* Estilos para controles do sidebar */
.sidebar-controls {
    padding: 8px 12px;
    border-bottom: 1px solid #e0e0e0;
}

.select-all-btn {
    width: 100%;
    padding: 8px 12px;
    background-color: #108e64;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'NaruSans-Regular', sans-serif;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    transition: background-color 0.2s;
}

.select-all-btn:hover {
    background-color: #0c6749;
}

.select-all-btn.all-selected {
    background-color: #0c6749;
}

/* Estilos para lojas com checkboxes - Override dos estilos existentes */
#lojas-list li {
    display: block;
    padding: 6px 8px;
    cursor: pointer;
    font-family: 'NaruSans-Regular', sans-serif;
    font-size: 13px;
    border-radius: 8px;
    transition: background-color 0.15s ease-in-out;
    background: transparent;
    margin-bottom: 2px;
}

#lojas-list li.selected {
    background: #0c6749;
    color: white;
}

#lojas-list li:hover {
    background: #0c6749;
    color: white;
}

#lojas-list li input[type="checkbox"] {
    display: none;
}

#lojas-list li label {
    display: block;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

/* Tags area keep page background (no white panel) */

/* === NOVO LAYOUT GRID DE TAGS (igual main.html) === */
.tags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 2px;
    justify-items: center;
    width: 100%;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    background: transparent;
    /* Otimizações de performance */
    contain: layout style;
}
.tags-grid > .tag {
    width: 100%;
    max-width: 260px;
    /* CRÍTICO: content-visibility: auto pula renderização de elementos fora da viewport */
    content-visibility: auto;
    contain-intrinsic-size: 260px 350px;
    /* Otimização: isola repaint de cada tag */
    contain: layout paint;
    /* NOVO: Usar transform para animações (GPU accelerated) */
    transform: translateZ(0);
}


.container {
    background: #fff;
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header */
header {
    text-align: center;

    margin: 0;
    color: #6b8c74;
    font-size: 24px;
}

/* Formulário */
.form-section {
    background: #f1f8f4;
    padding: 15px;
    border-radius: 12px;
}

.form-section h2 {
    margin-bottom: 10px;
    color: #6b8c74;
}

form {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
}

form input,
form button {
    border: 1px solid #6b8c74;
    border-radius: 8px;
    padding: 10px;
    height: 50px;
}

/* Custom nicer file button (keeps native input for compatibility) */
input[type="file"] {
    border: 1px dashed #6b8c74;
    padding: 7px;
    border-radius: 10px;
    background: #f7faf8;
}

input[type="file"]::file-selector-button {
    margin-right: 12px;
    border: 1px solid #6b8c74;
    background: #6b8c74;
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: filter .2s ease, background-color .2s ease;
}

input[type="file"]::file-selector-button:hover {
    filter: brightness(0.95);
}

input[type="file"]:focus-visible {
    outline: 3px solid rgba(107, 140, 116, .35);
    outline-offset: 2px;
}

.file-info {
    display: block;
    margin-top: 6px;
    color: #344b3b;
    font-size: 12px;
    opacity: .85;
}

form button {
    background: #6b8c74;
    color: white;
    border: none;
    cursor: pointer;
    transition: 0.3s;
}

form button:hover {
    background: #56735d;
}

#tagForm button,
.btn-filter {
    margin-top: 12px;
    width: 100%;
    height: 58px;
    padding: 0 10px;
    font-size: 13px;
    line-height: 28px;

}

#openFilters {
    background: #566473;
}

#openFilters:hover {
    background: #406085;
}

/* Date Range Picker - leve e embutido */
.drp {
    position: absolute;
    /* overlaid, not pushing layout */
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
    width: 280px;
    z-index: 10000;
}

.drp header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
}

.drp .controls button {
    background: #eee;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.drp .grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.drp .dow {
    font-weight: 600;
    font-size: 12px;
    text-align: center;
    opacity: .7;
}

.drp .day {
    font-size: 13px;
    text-align: center;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
}

.drp .day.muted {
    opacity: .35;
    cursor: default;
}

.drp .day.selected {
    background: #096949;
    color: #fff;
}

.drp .day.in-range {
    background: #6cd4b138;
}

.drp .day.today {
    border: 1.5px solid #108e64;
    font-weight: 600;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    /* Raised above select-section floating panel (z-index:1200) and its scrim (1090) */
    z-index: 2147483600;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
}

.modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    width: 890px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);

    /* Checkbox grid compacto */
    .modal-content .checkbox-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px 10px;
        margin-bottom: 12px;
        padding: 0 8px;
        max-height: 180px;
        overflow-y: none;
    }

    .modal-content .checkbox-label {
        font-size: 0.98em;
        padding: 2px 0 2px 4px;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    /* Botões do filtro */
    .modal-content .filter-btns {
        display: flex;
        gap: 10px;
        justify-content: flex-end;
        margin-top: 10px;
    }

    .modal-content .filter-btns button {
        font-size: 0.98em;
        padding: 7px 16px;
        border-radius: 7px;
        min-width: 80px;
    }
}

.close {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 22px;
    cursor: pointer;
}

.filter-section {
    margin-bottom: 20px;
}

.stores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.stores-grid label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
}

.btn-apply {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
}

.btn-apply:hover {
    background: #218838;
}

/* Loading overlay (bloqueia cliques) */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: none;
    /* shown via JS */
    align-items: center;
    justify-content: center;
    z-index: 100000;
    /* OTIMIZAÇÃO: backdrop-filter removido - muito custoso para painting */
    /* backdrop-filter: blur(1px); */
    background: rgba(0, 0, 0, 0.5);
}

/* Loader circular em verde do projeto */
.loader {
    width: 56px;
    aspect-ratio: 1;
    border-radius: 50%;
    background:
        radial-gradient(farthest-side, #27ae60 94%, #0000) top/10px 10px no-repeat,
        conic-gradient(#0000 30%, #27ae60);
    mask: radial-gradient(farthest-side, #0000 calc(100% - 10px), #000 0);
    -webkit-mask: radial-gradient(farthest-side, #0000 calc(100% - 10px), #000 0);
    animation: l13 1s infinite linear;
}

@keyframes l13 {
    100% {
        transform: rotate(1turn)
    }
}

/* Session badge (user + role + logout) */
.session-badge {
    position: fixed;
    right: 12px;
    top: 12px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 6px 10px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 9999;
    font-size: 12px;
    /* OTIMIZAÇÃO: backdrop-filter removido - muito custoso para painting */
    /* backdrop-filter: saturate(150%) blur(2px); */
    background: #0c6749;
}

.session-badge .id {
    font-weight: 600;
}

.session-badge .sep {
    opacity: .7;
}

.session-badge .flag {
    background: #2d6a4f;
    color: #e9f5ef;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 11px;
}

.session-badge .logout-btn {
    margin-left: 4px;
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 11px;
}

.session-badge .logout-btn:hover {
    background: #b02a37;
}


/* Grid Tags */
.tags-grid {
    display: grid;
    /* Largura fixa para cada card: evita que cresçam ocupando linha inteira quando há poucas tags */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px; /* espaço entre os cards */
    padding: 20px; /* espaço entre os cards e a borda do container */
    justify-content: start; /* alinha à esquerda sem esticar */
}


.tag {
    background: #fff;
    border: 2px solid #0c6749;
    border-radius: 14px;
    padding: 8px 8px 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    text-align: left;
    box-sizing: border-box;
}
.tag img {
    width: 100%;
    height: 260px;
    object-fit: cover;
    border-radius: 8px;
    /* OTIMIZAÇÃO: box-shadow reduzida - estava causando painting excessivo */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.tag .price {
    font-size: 18px;
    font-weight: bold;
    color: #e74c3c;
}


.form-group {
    display: flex;
    flex-direction: column;

}

.form-group p {
    font-size: 12px;
    text-align: center;
    margin: 10px;
}

.form-group textarea {
    resize: vertical;
    padding: 14px 0 34px 0;
    border: 1px solid #6b8c74;
    border-radius: 6px;
    text-align: center;
}

.form-group #comment {
    height: 42%;
}


.tags-grid .tag {
    position: relative;
    border: 2px solid #27ae60;
    padding: 8px;
    border-radius: 8px;
    /* width removed to prevent overflow; cards fill their grid column */
    text-align: center;
}

.tags-grid .tag .comment-bubble {
    position: absolute;
    top: 15px;
    right: 48px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: #f39c12;
    animation: blink 1s infinite;
    cursor: pointer;
}

.comment-bubble {
    width: 22px;
    height: 22px;
    background-color: #f39c12;
    border-radius: 50%;
    position: absolute;
    top: 8px;
    right: 8px;
    cursor: pointer;
}

.comment-text {
    display: none;
}

.tag {
    position: relative;
}

/* Menu popup da bolinha de comentário (ADM) */
.comment-bubble-menu {
    display: none;
    position: absolute;
    top: 32px;
    right: 8px;
    background: #ffffff;
    border: 1px solid #d6e2dc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    padding: 12px;
    z-index: 1000;
    min-width: 200px;
    max-width: 280px;
}

.comment-bubble-menu.show {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comment-bubble-menu .comment-display {
    background: #fff5e6;
    border: 1px solid #f39c12;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    color: #2d4739;
    line-height: 1.5;
    word-wrap: break-word;
    max-height: 120px;
    overflow-y: auto;
}

.comment-bubble-menu .menu-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 4px;
    border-top: 1px solid #e6efe9;
}

.comment-bubble-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #2d4739;
    text-align: left;
    transition: background 0.2s ease;
}

.comment-bubble-menu button:hover {
    background: #e2f2ea;
}

.comment-bubble-menu button i {
    width: 16px;
    text-align: center;
}

.comment-bubble-menu button.edit-comment {
    color: #0c6749;
}

.comment-bubble-menu button.delete-comment {
    color: #b23124;
}

.comment-bubble-menu button.delete-comment:hover {
    background: #ffecea;
}



.actions button {
    background: none;
    border: none;
    cursor: pointer;
    margin-right: 5px;
}

.select-section {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    white-space: nowrap;
    /* allow wrapping to avoid overflow */
}

.select-section input[type="checkbox"] {
    transform: scale(1.4);
    cursor: pointer;
}

.select-section button {
    padding: 8px 12px;
    font-size: 14px;
    background: #aa6969;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.3s;
    height: 40px;
    /* uniform height */
    line-height: 24px;
    white-space: nowrap;
}

/* Improve Select All control look */
input#selectAll+label[for="selectAll"] {
    padding: 6px 10px;
    border: 1px solid #6b8c74;
    border-radius: 8px;
    background: #f8fbf9;
    color: #344b3b;
    user-select: none;
    cursor: pointer;
}

input#selectAll:checked+label[for="selectAll"] {
    background: #e3efe7;
    border-color: #27ae60;
    color: #205b38;
}

input#selectAll:focus+label[for="selectAll"],
input#selectAll:focus-visible+label[for="selectAll"] {
    outline: 2px solid #27ae60;
    outline-offset: 2px;
}

/* Search input sizing and responsiveness */
#tagsQuickSearch {
    flex: 1 1 280px;
    width: 100%;
    max-width: 420px;
    min-width: 0;
    /* allow shrinking in flex */
    box-sizing: border-box;
    margin-left: 0 !important;
    /* override inline margin on small screens */
    height: 40px;
}

/* Make filter button match delete button size/shape */
#openFilters-tags {
    height: 40px;
    padding: 8px 12px;
    border-radius: 6px;
}


.tag input[type="checkbox"] {
    position: absolute;
    top: 8px;
    left: 8px;
    transform: scale(1.4);
    cursor: pointer;
    z-index: 20;
    /* Garante que checkbox fique acima das imagens */
}

.tags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    /* desktop/médio */
    gap: 24px;
    padding: 20px;
}



@media (min-width: 1200px) {
    .tags-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 4px;
    }
}

/* ====== DESKTOP MÉDIO (992px até 1199px) ====== */
@media (min-width: 992px) and (max-width: 1199px) {
    .container {
        padding: 20px;
    }

    form {
        flex-wrap: nowrap;
        flex-direction: row;
        gap: 15px;
    }

    .tags-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 2px;
    }
}

/* ====== TABLETS (768px até 991px) ====== */
@media (min-width: 768px) and (max-width: 991px) {
    form {
        flex-direction: column;
    }

    #tagForm button,
    .btn-filter {
        width: 100%;
        font-size: 14px;
        height: 50px;
    }

    .tags-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 2px;
        margin: 0 20px 0 0;
    }

    .modal-content {
        width: 90%;
    }

    .drop-image {
        display: none;
    }


    /* Modal */
    .modal,
    .popup {
        display: none;
        position: fixed;
        z-index: 999;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
    }

    .modal-content,
    .popup-content {
        background: #fff;
        margin: 10% auto;
        padding: 20px;
        border-radius: 8px;
        width: 90%;
        max-width: 500px;
    }

    .close,
    .close-popup {
        float: right;
        font-size: 20px;
        cursor: pointer;
    }

    .filters {
        display: flex;
        gap: 10px;
        flex-wrap: wrap;
    }

    .stores-list {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

}

/* ====== CELULARES GRANDES (576px até 767px) ====== */
@media (min-width: 576px) and (max-width: 767px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
    }

    form {
        flex-direction: column;
    }

    .tags-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 2px;
    }

    .modal-content {
        width: 95%;
    }

    .select-section {
        flex-direction: row;
        align-items: center;
        margin-left: 0;
        /* prevent horizontal overflow */
        gap: 8px;
        flex-wrap: wrap;
    }

    #tagsQuickSearch {
        flex-basis: 100%;
        max-width: 100%;
        width: 100%;
    }

    .select-section button,
    #openFilters-tags {
        flex: 1 1 calc(50% - 8px);
    }

    .drop-image {
        display: none;
    }
}

/* ====== CELULARES PEQUENOS (< 576px) ====== */
@media (max-width: 575px) {

    header h1 {
        font-size: 18px;
    }

    .form-section h2 {
        font-size: 16px;
    }

    form {
        flex-direction: column;
        gap: 8px;
    }

    #tagForm button,
    .btn-filter {
        height: 45px;
        font-size: 12px;
    }

    .tags-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1px;
        padding: 4px;
    }

    .tags-grid .tag {
        max-width: 100%;
        /* ocupa o espaço da coluna */
    }

    .modal-content {
        width: 95%;
        padding: 15px;
    }

    .drop-image {
        display: none;
    }

    .select-section {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
        margin-left: 0;
    }

    #tagsQuickSearch {
        flex-basis: 100%;
        max-width: 100%;
        width: 100%;
        margin-left: 0 !important;
        /* ensure no push to the right */
    }

    .select-section button,
    #openFilters-tags {
        flex: 1 1 calc(50% - 8px);
        height: 44px;
        /* touch-friendly */
    }


}

/* Responsive buyer chips row */
.sales-team {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 0px;
    width: 100%;
    margin: 0;
    padding: 0;
    align-items: stretch;
}

.sales-team .sales-pill {
    margin: 0;
    border-radius: 16px;
    border: none;
    width: 100%;
    height: 48px;
    font-size: 15px;
    font-weight: 600;
    background: #f0f5f3;
    color: #0c6749;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    cursor: pointer;
    outline: none;
    padding: 0;
}

.sales-team .sales-pill.active {
    background: #0c6749;
    color: #fff;
}

@media (max-width: 900px) {
    .sales-team {
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    }
    .sales-team .sales-pill {
        font-size: 13px;
        height: 40px;
    }
}