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

:root {
    --primaria: #1B3A5C;
    --secundaria: #2E86C1;
    --accent: #F39C12;
    --accent2: #27AE60;
    --accent3: #E74C3C;
    --fundo: #F0F2F5;
    --fundo-card: #FFFFFF;
    --texto: #2C3E50;
    --texto-claro: #7F8C8D;
    --borda: #DEE2E6;
    --sidebar-w: 280px;
    --header-h: 0px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--fundo);
    color: var(--texto);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== BRAND LOGOS ===== */
.brand-logo {
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
    border-radius: 4px;
    background: #fff;
    padding: 1px;
}

.layer-title .brand-logo {
    margin-right: 8px;
}

/* Logo tooltip on chart hover */
.logo-tooltip {
    display: none;
    position: absolute;
    z-index: 9999;
    background: var(--primaria);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--fundo-card);
    border-right: 1px solid var(--borda);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-w) + 32px));
}

.sidebar-toggle {
    position: absolute;
    top: 12px;
    right: -0px;
    width: 28px;
    height: 28px;
    background: var(--fundo-card);
    border: 1px solid var(--borda);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--texto-claro);
    z-index: 101;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: var(--fundo);
    color: var(--primaria);
}

.sidebar.collapsed .sidebar-toggle {
    right: -16px;
    transform: rotate(180deg);
}

.sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--borda);
    text-align: center;
}

.logo {
    margin-bottom: 6px;
}

.logo-img {
    width: 100%;
    max-width: 220px;
    height: auto;
    object-fit: contain;
}

.sidebar-slogan {
    font-size: 13px;
    font-weight: 600;
    color: var(--secundaria);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--borda);
}

.sidebar-form {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-divider {
    border: none;
    border-top: 1px solid var(--borda);
    margin: 16px 0;
}

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

.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--texto);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--borda);
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    color: var(--texto);
    background: var(--fundo-card);
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237F8C8D' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.form-group select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-group select:focus {
    outline: none;
    border-color: var(--secundaria);
    box-shadow: 0 0 0 3px rgba(46, 134, 193, 0.1);
}

.btn-gerar {
    width: 100%;
    padding: 12px 16px;
    background: var(--fundo-card);
    border: 1.5px solid var(--borda);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: var(--texto);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    margin-bottom: 10px;
}

.btn-gerar:hover:not(:disabled) {
    border-color: var(--secundaria);
    background: #F0F8FF;
    color: var(--secundaria);
}

.btn-gerar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-gerar .btn-icon {
    font-size: 15px;
}

.btn-pdf {
    width: 100%;
    padding: 10px 16px;
    background: var(--primaria);
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-pdf:hover {
    background: #143050;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--borda);
    text-align: center;
}

.sidebar-footer small {
    font-size: 10px;
    color: var(--texto-claro);
    line-height: 1.5;
}

/* ===== LAYER NAVIGATION ===== */
.layer-nav {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 90;
}

.layer-nav-item {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--borda);
    background: var(--fundo-card);
    color: var(--texto-claro);
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.layer-nav-item:hover:not(.disabled) {
    border-color: var(--secundaria);
    color: var(--secundaria);
}

.layer-nav-item.active {
    background: var(--secundaria);
    border-color: var(--secundaria);
    color: white;
}

.layer-nav-item.disabled {
    opacity: 0.3;
    cursor: default;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    overflow-y: auto;
}

.sidebar.collapsed ~ .main-content {
    margin-left: 32px;
}

/* Estado inicial */
.estado-inicial {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: var(--texto-claro);
    text-align: center;
    padding: 40px;
}

.estado-inicial-icon {
    margin-bottom: 24px;
    opacity: 0.5;
}

.estado-inicial h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--texto);
    margin-bottom: 8px;
}

.estado-inicial p {
    font-size: 13px;
    max-width: 400px;
    line-height: 1.6;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--borda);
    border-top-color: var(--secundaria);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.loading p {
    font-size: 14px;
    color: var(--texto-claro);
}

/* ===== RELATORIO HEADER ===== */
.relatorio-header {
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 120' preserveAspectRatio='xMidYMid slice'%3E%3Cpath d='M0,60 C180,100 360,20 540,60 C720,100 900,20 1080,60 C1260,100 1350,40 1440,60 L1440,120 L0,120 Z' fill='rgba(255,255,255,0.04)'/%3E%3Cpath d='M0,40 C200,80 400,0 600,40 C800,80 1000,10 1200,50 C1320,70 1380,30 1440,45 L1440,120 L0,120 Z' fill='rgba(255,255,255,0.04)'/%3E%3Cpath d='M0,80 C150,50 300,90 450,70 C600,50 750,90 900,65 C1050,40 1200,80 1440,55 L1440,120 L0,120 Z' fill='rgba(255,255,255,0.03)'/%3E%3C/svg%3E")
        bottom / cover no-repeat,
        #0D1B2E;
    color: white;
}

.relatorio-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 28px 14px;
    min-height: 80px;
}

.relatorio-header-left {
    flex: 1;
}

.header-logo-webprice {
    height: 52px;
}

.relatorio-header-center {
    flex: 1;
    text-align: center;
}

.header-categoria-nome {
    font-size: 26px;
    font-weight: 700;
    color: #F39C12;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.relatorio-header-right {
    flex: 1;
    text-align: right;
}

.relatorio-header-bottom {
    display: flex;
    justify-content: space-between;
    padding: 7px 28px;
    background: #ffffff;
    font-size: 11px;
    color: #2C3E50;
    border-top: 1px solid #DEE2E6;
}

.header-logo-marca {
    height: 62px;
    max-width: 180px;
    object-fit: contain;
    background: white;
    padding: 8px 16px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.relatorio-container {
    padding: 24px;
}

/* ===== DASHBOARD LAYERS ===== */
.dashboard-layer {
    margin-bottom: 32px;
    padding-bottom: 32px;
    border-bottom: 2px solid var(--borda);
}

.dashboard-layer:last-child {
    border-bottom: none;
}

.layer-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
}

.layer-badge {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: var(--primaria);
    color: white;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.layer-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--texto);
}

.layer-subtitle {
    font-size: 12px;
    color: var(--texto-claro);
    margin-top: 2px;
}

/* ===== KPI CARDS ===== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.kpi-row-6 {
    grid-template-columns: repeat(6, 1fr);
}

.kpi-card {
    background: var(--fundo-card);
    border: 1px solid var(--borda);
    border-radius: 8px;
    padding: 16px 20px;
    text-align: center;
}

.kpi-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--texto);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.kpi-body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}

.kpi-valor {
    font-size: 20px;
    font-weight: 700;
    color: var(--texto);
}

.kpi-valor-sm {
    font-size: 14px;
}

.kpi-separador {
    color: var(--borda);
    font-size: 20px;
    font-weight: 300;
}

.kpi-variacao {
    font-size: 13px;
    font-weight: 600;
    color: var(--texto-claro);
}

.kpi-variacao.positivo {
    color: var(--accent2);
}

.kpi-variacao.negativo {
    color: var(--accent3);
}

.kpi-sub {
    font-size: 11px;
    color: var(--texto-claro);
    margin-bottom: 2px;
}

.kpi-total {
    font-size: 12px;
    font-weight: 600;
    color: var(--texto-claro);
}

/* ===== GRAFICOS ===== */
.graficos-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.grafico-card {
    background: var(--fundo-card);
    border: 1px solid var(--borda);
    border-radius: 8px;
    padding: 20px;
    min-height: 320px;
    position: relative;
}

.grafico-card canvas {
    max-height: 260px;
}

.grafico-full {
    margin-bottom: 16px;
    position: relative;
    min-height: 380px;
}

.grafico-full canvas {
    width: 100% !important;
    height: 340px !important;
}

.grafico-titulo {
    font-size: 13px;
    font-weight: 700;
    color: var(--texto);
    text-align: center;
    margin-bottom: 4px;
}

.grafico-subtitulo {
    font-size: 11px;
    color: var(--texto-claro);
    text-align: center;
    margin-bottom: 16px;
}

/* ===== COMPARISON CARDS ===== */
.comparison-card {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    background: var(--fundo-card);
    border: 1px solid var(--borda);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
}

.comparison-side {
    padding: 20px 24px;
}

.comparison-side--own {
    border-left: 3px solid var(--secundaria);
}

.comparison-side--competitor {
    border-left: 3px solid var(--accent3);
}

.comparison-divider {
    width: 1px;
    background: var(--borda);
}

.comparison-header {
    font-size: 14px;
    font-weight: 700;
    color: var(--texto);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.comparison-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #F0F2F5;
}

.comparison-metric:last-child {
    border-bottom: none;
}

.comparison-metric span {
    font-size: 12px;
    color: var(--texto-claro);
}

.comparison-metric strong {
    font-size: 13px;
    color: var(--texto);
}

/* ===== PRODUCT CARDS ===== */
.product-card {
    background: var(--fundo-card);
    border: 1px solid var(--borda);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 16px;
}

.product-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--texto);
    margin-bottom: 16px;
    line-height: 1.4;
}

.product-stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
}

.product-stat {
    text-align: center;
}

.product-stat span {
    display: block;
    font-size: 10px;
    color: var(--texto-claro);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.product-stat strong {
    font-size: 14px;
    color: var(--texto);
}

/* ===== SELLERS TABLE ===== */
.sellers-table-wrap {
    max-height: 400px;
    overflow-y: auto;
}

.sellers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sellers-table thead th {
    background: var(--fundo);
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--texto-claro);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    position: sticky;
    top: 0;
}

.sellers-table thead th:nth-child(2),
.sellers-table thead th:nth-child(3) {
    text-align: right;
}

.sellers-table tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid #F0F2F5;
    color: var(--texto);
}

.sellers-table tbody td:nth-child(2),
.sellers-table tbody td:nth-child(3) {
    text-align: right;
}

.sellers-table tbody tr:hover {
    background: #F8F9FA;
}

.sellers-table tbody tr.highlight {
    background: #E8F4FD;
    font-weight: 600;
}

.sellers-table tbody tr.highlight td {
    color: var(--secundaria);
}

/* ===== RESPONSIVO ===== */
@media (max-width: 1200px) {
    .kpi-row-6 {
        grid-template-columns: repeat(3, 1fr);
    }

    .product-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

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

    .kpi-row-6 {
        grid-template-columns: repeat(3, 1fr);
    }

    .graficos-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-w: 260px;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
    }

    .kpi-row {
        grid-template-columns: 1fr 1fr;
    }

    .kpi-row-6 {
        grid-template-columns: 1fr 1fr;
    }

    .comparison-card {
        grid-template-columns: 1fr;
    }

    .comparison-divider {
        width: 100%;
        height: 1px;
    }

    .product-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .layer-nav {
        display: none !important;
    }

    .h2h-val {
        min-width: 70px !important;
        font-size: 13px !important;
    }

    .h2h-brand-initial {
        width: 48px !important;
        height: 48px !important;
        font-size: 22px !important;
    }

    .h2h-brand-name {
        font-size: 13px !important;
    }
}

/* ===== COMPARATIVO BARRAS (Layer 3) ===== */
.comparativo-barras {
    background: var(--fundo-card, #FFFFFF);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border: 1px solid #E8ECF0;
    padding: 24px;
}

.comparativo-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #E2E8F0;
}

.comparativo-marca {
    font-size: 15px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.comparativo-marca--own {
    color: #2E86C1;
}

.comparativo-marca--conc {
    color: #F39C12;
}

.comparativo-vs {
    font-size: 12px;
    font-weight: 800;
    color: #8E44AD;
    letter-spacing: 3px;
}

.comparativo-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.comparativo-row {
    display: flex;
    align-items: center;
}

.comparativo-val {
    min-width: 100px;
    font-size: 15px;
    font-weight: 700;
    color: #2C3E50;
    padding: 8px 12px;
}

.comparativo-val--own {
    text-align: right;
}

.comparativo-val--conc {
    text-align: left;
}

.comparativo-bar-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.comparativo-bars {
    width: 100%;
    display: flex;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
    gap: 2px;
}

.comparativo-bar {
    height: 100%;
    transition: width 0.6s ease;
    min-width: 2px;
}

.comparativo-bar--own {
    background: linear-gradient(90deg, #AED6F1, #2E86C1);
    border-radius: 6px 0 0 6px;
}

.comparativo-bar--conc {
    background: linear-gradient(90deg, #F39C12, #F5D89A);
    border-radius: 0 6px 6px 0;
}

.comparativo-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: 700;
    color: #FFFFFF;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    background: rgba(44, 62, 80, 0.75);
    padding: 3px 14px;
    border-radius: 3px;
    z-index: 1;
    white-space: nowrap;
    pointer-events: none;
}

/* ===== TOP 3 MENORES PRECOS ===== */
.top3-table-container {
    padding: 5px 0;
}

.top3-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.top3-table thead th {
    background: var(--primaria);
    color: white;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.top3-table thead th:first-child {
    border-radius: 8px 0 0 0;
}

.top3-table thead th:last-child {
    border-radius: 0 8px 0 0;
    text-align: right;
}

.top3-table tbody tr {
    border-bottom: 1px solid var(--borda);
    transition: background 0.2s;
}

.top3-table tbody tr:hover {
    background: #F0F7FF;
}

.top3-table tbody tr.top3-best {
    background: #E8F8F0;
}

.top3-table tbody tr.top3-best:hover {
    background: #D5F2E3;
}

.top3-table td {
    padding: 14px 16px;
    vertical-align: middle;
}

.top3-pos {
    font-weight: 700;
    font-size: 15px;
    width: 90px;
}

.top3-loja {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top3-logo {
    height: 24px;
    max-width: 80px;
    object-fit: contain;
}

.top3-loja-nome {
    font-weight: 500;
    color: var(--texto);
}

.top3-preco {
    text-align: right;
    font-weight: 700;
    font-size: 16px;
    color: var(--primaria);
}

.top3-best .top3-preco {
    color: #27AE60;
}


/* ===== LOGIN ===== */
.login-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.login-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--texto);
    margin-bottom: 16px;
}

.login-form .form-group input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--borda);
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    color: var(--texto);
    background: var(--fundo-card);
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.login-form .form-group input:focus {
    outline: none;
    border-color: var(--secundaria);
    box-shadow: 0 0 0 3px rgba(46, 134, 193, 0.1);
}

.login-erro {
    font-size: 11px;
    color: var(--accent3);
    background: #fdf0ef;
    border: 1px solid #f5c6c2;
    border-radius: 6px;
    padding: 8px 10px;
    text-align: center;
    margin-bottom: 8px;
}

.btn-login {
    width: 100%;
    padding: 12px 16px;
    background: var(--primaria);
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: white;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 4px;
}

.btn-login:hover {
    background: #143050;
}

.btn-login:active {
    transform: scale(0.98);
}

.btn-logout {
    width: 100%;
    margin-top: 8px;
    padding: 7px;
    background: transparent;
    color: var(--texto-claro);
    border: 1px solid var(--borda);
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, color 0.2s;
}

.btn-logout:hover {
    background: #fdf0ef;
    color: var(--accent3);
    border-color: #f5c6c2;
}

.sidebar-usuario {
    font-size: 11px;
    color: var(--texto-claro);
    text-align: center;
    margin-bottom: 4px;
}