/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --primary-light: #e0e7ff;
    --secondary: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --ml-color: #ffe600;
    --ml-bg: #fff7cc;
    --shopee-color: #ee4d2d;
    --shopee-bg: #fff0ed;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .1), 0 1px 2px rgba(0, 0, 0, .06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -1px rgba(0, 0, 0, .06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px -2px rgba(0, 0, 0, .05);
    --transition: 0.2s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    min-height: 100vh;
    line-height: 1.5;
}

/* ===== HEADER ===== */
header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 54px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.logo-icon {
    font-size: 1.5rem;
}

nav {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .3);
    color: white;
    padding: 0.45rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-btn:hover {
    background: rgba(255, 255, 255, .25);
}

.nav-btn.active {
    background: white;
    color: var(--primary);
    border-color: white;
}

/* ===== CONTAINER ===== */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
}

/* ===== TABS ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== GLOBAL SUMMARY ===== */
.global-summary {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--gray-600);
    box-shadow: var(--shadow);
}

.global-summary strong {
    color: var(--primary);
}

/* ===== CARD ===== */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 0.25rem;
}

.card-subtitle {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

/* ===== FORM ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.75rem;
    font-size: 0.95rem;
    color: var(--gray-800);
    background: white;
    transition: var(--transition);
    outline: none;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

input::placeholder {
    color: var(--gray-400);
}

small {
    font-size: 0.75rem;
    color: var(--gray-500);
    line-height: 1.3;
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.input-with-unit input {
    flex: 1;
}

.unit {
    font-size: 0.875rem;
    color: var(--gray-500);
    font-weight: 600;
    white-space: nowrap;
}

.unit-right {
    font-size: 0.875rem;
    color: var(--gray-500);
    font-weight: 600;
    white-space: nowrap;
}

/* ===== CUSTOM SECTION ===== */
.custom-section {
    margin: 1rem 0;
}

.toggle-custom {
    background: none;
    border: 1.5px dashed var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    width: 100%;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.toggle-custom:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.toggle-custom .arrow {
    transition: transform 0.2s;
}

.toggle-custom.open .arrow {
    transform: rotate(180deg);
}

.custom-fields {
    border: 1.5px dashed var(--gray-200);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    padding: 1rem;
    background: var(--gray-50);
}

.info-box {
    background: #dbeafe;
    border: 1px solid #93c5fd;
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    color: #1d4ed8;
    margin-bottom: 0.75rem;
}

/* ===== BUTTONS ===== */
.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.6rem 1.5rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-danger {
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid #fca5a5;
}

.btn-danger:hover {
    background: #fecaca;
}

.btn-edit {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}

.btn-edit:hover {
    background: #bfdbfe;
}

.btn-detail {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}

.btn-detail:hover {
    background: var(--gray-200);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* ===== PRODUCTS LIST HEADER ===== */
.products-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.products-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-800);
}

#busca {
    width: 280px;
    border: 1.5px solid var(--gray-300);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

/* ===== PRODUCT CARD ===== */
.produto-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 0.65rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.produto-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.produto-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.produto-nome {
    font-size: 0.97rem;
    font-weight: 700;
    color: var(--gray-800);
}

.produto-meta {
    font-size: 0.78rem;
    color: var(--gray-500);
    margin-top: 0.1rem;
}

.produto-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-custom {
    background: #ede9fe;
    color: #5b21b6;
}

.badge-energia {
    background: #fef3c7;
    color: #92400e;
}

.produto-custo {
    font-size: 0.78rem;
    color: var(--gray-600);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 0.35rem 0.75rem;
    margin-bottom: 0.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.produto-custo span {
    display: flex;
    flex-direction: column;
}

.produto-custo .label {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--gray-500);
}

.produto-custo .value {
    font-weight: 700;
    color: var(--gray-800);
}

/* Destaque do lucro */
.produto-custo .lucro-destaque {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 1.5px solid #10b981;
    border-radius: 8px;
    padding: 0.25rem 0.6rem;
}

.produto-custo .lucro-destaque .label {
    color: #065f46;
}

.produto-custo .lucro-destaque .value {
    color: #065f46;
    font-size: 0.95rem;
}

/* ===== PRECOS GRID ===== */
.precos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.preco-box {
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    text-align: center;
    position: relative;
}

.preco-box.ml-premium {
    background: linear-gradient(135deg, #fffde7 0%, #fff9c4 100%);
    border: 2px solid #f9d71c;
}

.preco-box.ml-classico {
    background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
    border: 2px solid #ffc107;
}

.preco-box.shopee {
    background: linear-gradient(135deg, #fff0ed 0%, #ffe4de 100%);
    border: 2px solid #ee4d2d;
}

.preco-plataforma {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.ml-premium .preco-plataforma {
    color: #856400;
}

.ml-classico .preco-plataforma {
    color: #7c6200;
}

.shopee .preco-plataforma {
    color: var(--shopee-color);
}

.preco-valor {
    font-size: 1.25rem;
    font-weight: 800;
    margin: 0.15rem 0;
}

.ml-premium .preco-valor {
    color: #78350f;
}

.ml-classico .preco-valor {
    color: #78350f;
}

.shopee .preco-valor {
    color: #9b1c0a;
}

.preco-detalhe {
    font-size: 0.65rem;
    color: var(--gray-500);
    margin-top: 0.1rem;
}

.preco-box .preco-desconto-tag {
    position: absolute;
    top: -8px;
    right: 8px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
}

/* ===== PRODUTO ACTIONS ===== */
.produto-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    border-top: 1px solid var(--gray-100);
    padding-top: 0.5rem;
    margin-top: 0.35rem;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-400);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state p {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

/* ===== CONFIG SECTION ===== */
.config-section {
    border-bottom: 1px solid var(--gray-100);
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
}

.config-section:last-of-type {
    border-bottom: none;
}

.section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
}

.section-desc {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

/* ===== TAXAS GRID ===== */
.taxas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.taxa-card {
    border-radius: 10px;
    padding: 1rem;
    border: 1.5px solid;
}

.taxa-card.ml-premium {
    background: #fffde7;
    border-color: #f9d71c;
}

.taxa-card.ml-normal {
    background: #fff8e1;
    border-color: #ffc107;
}

.taxa-card.shopee {
    background: var(--shopee-bg);
    border-color: var(--shopee-color);
}

.taxa-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
    font-size: 0.9rem;
}

.taxa-logo {
    font-size: 1.2rem;
}

.taxa-valor-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}

.taxa-info {
    font-size: 0.72rem;
    color: var(--gray-500);
    line-height: 1.4;
    margin-top: 0.5rem;
}

/* ===== EXPLICACAO ===== */
.explicacao-card {}

.steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.step-num {
    min-width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.step-body strong {
    font-size: 0.95rem;
    display: block;
    margin-bottom: 0.25rem;
}

.step-body p {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 0.2rem;
}

.step-body .exemplo {
    color: var(--primary);
    font-weight: 500;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal {
    background: white;
    border-radius: var(--radius);
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-500);
    font-size: 1rem;
    padding: 0.25rem;
    border-radius: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-800);
}

.modal-body {
    padding: 1.5rem;
}

/* Modal detail rows */
.modal-section {
    margin-bottom: 1.25rem;
}

.modal-section h3 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: 0.5rem;
}

.modal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.875rem;
}

.modal-row:last-child {
    border-bottom: none;
}

.modal-row .modal-label {
    color: var(--gray-600);
}

.modal-row .modal-val {
    font-weight: 600;
}

.modal-preco-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--gray-800);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 999;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

/* ===== PRECO BOX EXTRAS ===== */
.preco-label-anuncio {
    font-size: 0.68rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    margin-bottom: 0.1rem;
}

.preco-cliente {
    font-size: 0.67rem;
    color: var(--gray-600);
    margin-top: 0.1rem;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 4px;
    padding: 0.1rem 0.3rem;
}

/* ===== DESTAQUE PADRÃO ===== */
.destaque-padrao {
    box-shadow: 0 0 0 3px #ffc107, var(--shadow-md);
    transform: scale(1.03);
    z-index: 1;
    position: relative;
}

.tag-padrao {
    display: inline-block;
    background: #ffc107;
    color: #78350f;
    font-size: 0.6rem;
    font-weight: 800;
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    margin-left: 0.3rem;
    vertical-align: middle;
    letter-spacing: 0.05em;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .precos-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 640px) {
    .header-inner {
        padding: 0 0.75rem;
    }

    .logo-text {
        display: none;
    }

    .container {
        padding: 0.75rem;
    }

    .precos-grid {
        grid-template-columns: 1fr;
    }

    .taxas-grid {
        grid-template-columns: 1fr;
    }

    .modal-preco-grid {
        grid-template-columns: 1fr;
    }

    #busca {
        width: 100%;
    }

    .products-header {
        flex-direction: column;
        align-items: flex-start;
    }
}