:root {
    --bg: #f7f3ee;
    --surface: #ffffff;
    --text: #241f19;
    --muted: #77705f;
    --line: #e6ddd0;
    --brand: #9d4e2f;
    --brand-dark: #7c3b21;
    --brand-contrast: #ffffff;
    --green: #2f5d50;
    --soft: #f3e8dc;
    --input-bg: #ffffff;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --radius: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
}

img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.topbar-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }

.brand-area { display: flex; align-items: center; gap: 18px; }

.brand { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; color: var(--text); display: flex; align-items: center; }
.brand span { color: var(--brand); }
.brand img { max-height: 52px; width: auto; object-fit: contain; }

.social-links { display: flex; gap: 10px; align-items: center; }
.social-links a { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: var(--brand-contrast); transition: transform 0.2s ease; }
.social-links a:hover { transform: translateY(-2px); }

.nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nav a { color: var(--text); font-weight: 600; }
.nav a:hover { color: var(--brand); }

.user-chip { padding: 8px 12px; border-radius: 999px; background: var(--soft); color: var(--brand-dark); font-weight: 700; font-size: 0.92rem; }

main { padding: 28px 0 70px; min-height: calc(100vh - 170px); }

.footer { border-top: 1px solid var(--line); padding: 18px 0; color: var(--muted); background: var(--surface); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.footer-map-container { display: inline-block; overflow: hidden; border-radius: 12px; border: 1px solid var(--line); transition: transform 0.15s ease, border-color 0.15s ease; position: relative; }
.footer-map-container:hover { border-color: var(--brand); transform: translateY(-2px); }
.footer-map-container a { display: block; position: relative; text-decoration: none; color: inherit; }

.footer-credits {
    text-align: center;
    margin-top: 18px;
    font-size: 0.85rem;
    border-top: 1px solid var(--line);
    padding-top: 18px;
    color: var(--muted);
}
.footer-credits a {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    color: var(--brand);
    font-weight: bold;
    margin-left: 4px;
}
.footer-credits a:hover { text-decoration: underline; }
.footer-credits svg { width: 16px; height: 16px; fill: currentColor; margin-left: 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 12px; padding: 11px 16px; font-weight: 700; cursor: pointer; transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--brand); color: var(--brand-contrast); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--surface); border-color: rgba(163, 50, 36, 0.35); color: #a33224; }
.btn-danger:hover { background: rgba(163, 50, 36, 0.08); }
.btn-large { padding: 14px 22px; font-size: 1rem; }

.loading, .empty { padding: 42px 0; color: var(--muted); text-align: center; }

.banner { position: relative; overflow: hidden; min-height: 340px; border-radius: 24px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); display: grid; align-items: end; }
.banner-carousel { position: absolute; inset: 0; }
.banner-carousel img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.8s ease; }
.banner-carousel img.active { opacity: 1; }
.banner-fallback { position: absolute; inset: 0; background: linear-gradient(120deg, rgba(36, 31, 25, 0.12), rgba(36, 31, 25, 0.35)), repeating-linear-gradient(45deg, #d8b79a 0px, #d8b79a 18px, #cfa882 18px, #cfa882 36px, #c69a72 36px, #c69a72 54px); }

.banner-content { position: relative; z-index: 2; padding: 34px; width: 100%; background: linear-gradient(180deg, transparent, var(--bg)); }
.banner-content h1 { margin: 0 0 10px; font-size: clamp(2rem, 4vw, 4rem); line-height: 1.02; letter-spacing: -0.04em; max-width: 18ch; color: var(--brand); }
.banner-content p { margin: 0 0 18px; max-width: 58ch; color: var(--text); font-weight: 600; }

.toolbar { margin: 26px 0 18px; display: grid; gap: 14px; }
.toolbar input[type="search"] { width: 100%; max-width: 420px; border: 1px solid var(--line); background: var(--input-bg); color: var(--text); border-radius: 14px; padding: 13px 15px; outline: none; }
.toolbar input[type="search"]:focus { border-color: var(--brand); }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 9px 14px; cursor: pointer; font-weight: 700; }
.chip.active { background: var(--green); border-color: var(--green); color: var(--brand-contrast); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); cursor: pointer; transition: transform 0.18s ease, border-color 0.18s ease; }
.card:hover { transform: translateY(-3px); border-color: var(--brand); }

.thumb, .thumb-sm, .gallery { background: var(--soft); }
.thumb { height: 220px; }
.thumb img, .thumb-sm img, .gallery img, .banner-preview img, .cart-item .thumb img, .theme-preview img { width: 100%; height: 100%; object-fit: cover; }
.no-image { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 0.9rem; text-align: center; padding: 12px; }

.card-body { padding: 16px; display: grid; gap: 12px; }
.card-body h3 { margin: 0; font-size: 1.05rem; line-height: 1.25; min-height: 2.6em; }
.price { font-size: 1.15rem; font-weight: 800; color: var(--green); }

.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 4px 10px; border-radius: 999px; background: var(--soft); color: var(--brand-dark); font-size: 0.8rem; font-weight: 800; }
.badge-lista_salva { background: rgba(47, 93, 80, 0.12); color: var(--green); }
.badge-aguardando_retorno { background: rgba(157, 78, 47, 0.12); color: var(--brand); }
.badge-concluido { background: rgba(49, 74, 122, 0.12); color: #314a7a; }

.auth-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 24px; }
.auth-card { max-width: 520px; margin: 28px auto; }
.auth-card h2, .panel h2 { margin-top: 0; }

label { display: grid; gap: 7px; font-weight: 700; margin-bottom: 14px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], input[type="tel"], input[type="file"], select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; background: var(--input-bg); color: var(--text); outline: none; }
input[type="color"] { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 6px; background: var(--input-bg); height: 48px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(125, 90, 40, 0.15); }
textarea { resize: vertical; min-height: 110px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.check input { width: auto; }

.contact-box { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.cart-item { display: grid; grid-template-columns: 84px 1fr 110px 120px 44px; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 12px; }
.cart-item .thumb, .thumb-sm { width: 84px; height: 84px; border-radius: 14px; overflow: hidden; }
.cart-item .info { display: grid; gap: 6px; }
.cart-item .qty { max-width: 100%; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); color: #a33224; width: 40px; height: 40px; border-radius: 12px; cursor: pointer; font-size: 1.2rem; }
.cart-footer { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-top: 18px; }
.total { font-size: 1.2rem; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }

.order-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; margin-bottom: 14px; display: grid; gap: 10px; }
.order-card header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.tabs { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0; }
.tab { border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 11px 15px; border-radius: 999px; cursor: pointer; font-weight: 800; }
.tab.active { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }
.tab-content { min-height: 280px; }

.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--soft); color: var(--muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: 0; }

.thumb-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.thumb-row img { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }

.banner-preview { width: min(560px, 100%); height: 220px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); margin: 14px 0; }
.theme-preview { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; max-width: 420px; margin: 16px 0; }
.tp-topbar { padding: 10px 14px; font-weight: 800; }
.tp-banner { height: 90px; display: grid; place-items: center; font-weight: 700; }
.tp-card { padding: 14px; display: grid; gap: 8px; }
.tp-title { font-weight: 700; }
.tp-price { font-weight: 800; }
.tp-btn { display: inline-block; padding: 8px 14px; border-radius: 10px; font-weight: 700; }

.modal { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-box { position: relative; width: min(920px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); color: var(--text); border-radius: 22px; padding: 26px; box-shadow: var(--shadow); }
.modal-close { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 12px; cursor: pointer; font-size: 1.4rem; line-height: 1; }

.product-detail { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 22px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; min-height: 320px; }
.gallery img { height: 160px; border-radius: 14px; border: 1px solid var(--line); }
.info h2 { margin: 0 0 10px; }
.meta { color: var(--muted); margin: 8px 0 14px; }
.qty-row { display: grid; gap: 8px; max-width: 160px; margin: 16px 0; }

.toast { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 10px; }
.toast-item { background: #25201a; color: #fff; padding: 13px 16px; border-radius: 14px; box-shadow: var(--shadow); max-width: 320px; animation: toastIn 0.2s ease; }
.toast-item.error { background: #a33224; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
    .product-detail { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .topbar-inner { 
        flex-direction: column; 
        padding: 16px 0; 
        gap: 15px; 
        text-align: center;
    }
    .brand-area {
        flex-direction: column;
        gap: 12px;
    }
    .brand img { max-height: 60px; }
    
    .nav { width: 100%; justify-content: center; }
    .banner { min-height: 280px; }
    .banner-content { padding: 22px; }
    .cart-item { grid-template-columns: 70px 1fr; }
    .cart-item .qty, .cart-item .subtotal, .cart-item .icon-btn { justify-self: start; }
    .cart-footer { align-items: flex-start; }
    
    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
}