:root {
    --dark: #0d0e12;
    --dark-2: #17191f;
    --accent: #13ade1;
    --accent-claro: #64caed;
    --green: #16a34a;
    --orange: #f59e0b;
    --red: #dc2626;
    --blue: #2563eb;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f4f5f7;
}

* { box-sizing: border-box; }
img { max-width: 100%; display: block; }
body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: #111827;
}

/* ---- Layout ---- */
.painel-wrapper { display: flex; min-height: 100vh; }

.topbar-mobile { display: none; }

.sidebar {
    width: 250px;
    background: var(--dark);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
}
.sidebar-logo {
    padding: 0 24px 20px;
    overflow: hidden;
}
.sidebar-logo img { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; }
.sidebar nav { flex: 1; overflow-y: auto; }
.sidebar-titulo {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    padding: 16px 24px 6px;
    margin: 0;
}
.sidebar a {
    display: block;
    padding: 10px 24px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14.5px;
    border-left: 3px solid transparent;
}
.sidebar a:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar a.ativo { background: rgba(99,102,241,0.15); color: #fff; border-left-color: var(--accent); font-weight: 600; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: 10px;
}
.sidebar-user .avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}
.sidebar-user strong { display: block; font-size: 13px; color: #fff; }
.sidebar-user small { font-size: 11px; color: #9ca3af; }
.sidebar-user a { margin-left: auto; color: #9ca3af; text-decoration: none; font-size: 16px; padding: 0; }

.conteudo { flex: 1; padding: 28px 32px; overflow-x: hidden; }

/* ---- Topo de página ---- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 { font-size: 22px; margin: 0; }
.page-header p { color: var(--text-muted); margin: 4px 0 0; font-size: 13.5px; }

/* ---- Botões ---- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--accent); color: #fff;
    border: none; padding: 10px 18px;
    border-radius: 8px; font-size: 14px; font-weight: 600;
    text-decoration: none; cursor: pointer;
}
.btn:hover { opacity: 0.9; }
.btn-secundario { background: #fff; color: #111827; border: 1px solid var(--border); }
.btn-perigo { background: var(--red); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---- Cards de métricas ---- */
.metricas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 24px; }
.metrica-card {
    background: #fff; border-radius: 12px; padding: 18px 20px;
    border-top: 3px solid var(--accent);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.metrica-card.laranja { border-top-color: var(--orange); }
.metrica-card.verde { border-top-color: var(--green); }
.metrica-card.vermelho { border-top-color: var(--red); }
.metrica-topo { display: flex; justify-content: space-between; align-items: flex-start; }
.metrica-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; }
.metrica-valor { font-size: 26px; font-weight: 700; margin: 6px 0 2px; }
.metrica-sub { font-size: 12.5px; color: var(--text-muted); }
.metrica-icone { font-size: 20px; background: var(--bg); padding: 8px; border-radius: 10px; }
.up { color: var(--green); font-weight: 600; }
.down { color: var(--red); font-weight: 600; }

/* ---- Painéis / blocos ---- */
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; margin-bottom: 18px; }
.bloco {
    background: #fff; border-radius: 12px; padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.bloco-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.bloco-header h2 { font-size: 15.5px; margin: 0; }
.bloco-header a { font-size: 13px; color: var(--accent); text-decoration: none; }
.vazio { color: var(--text-muted); text-align: center; padding: 40px 0; font-size: 14px; }

/* ---- Tabelas ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; color: var(--text-muted); padding: 10px 8px; border-bottom: 1px solid var(--border); }
td { padding: 12px 8px; border-bottom: 1px solid #f1f1f3; }
tr:last-child td { border-bottom: none; }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-aguardando_pagamento { background: #fef3c7; color: #92400e; }
.badge-pago { background: #dcfce7; color: #166534; }
.badge-em_preparo { background: #dbeafe; color: #1e40af; }
.badge-enviado { background: #e0e7ff; color: #3730a3; }
.badge-entregue { background: #d1fae5; color: #065f46; }
.badge-cancelado { background: #fee2e2; color: #991b1b; }

/* ---- Formulários ---- */
.form-box { background: #fff; padding: 24px; border-radius: 12px; max-width: 720px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.form-linha { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
textarea { resize: vertical; min-height: 90px; }

/* ---- Alertas ---- */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert-erro { background: #fee2e2; color: #991b1b; }
.alert-sucesso { background: #dcfce7; color: #166534; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* ---- Login ---- */
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; background: var(--dark); padding: 16px; }
.login-box { background: #fff; padding: 40px; border-radius: 14px; width: 340px; max-width: 100%; text-align: center; box-sizing: border-box; }
.login-box h1 { margin: 0; color: var(--accent); }
.login-sub { color: var(--text-muted); margin-top: 4px; margin-bottom: 20px; font-size: 13.5px; }
.login-box form { text-align: left; }
.login-box button { width: 100%; margin-top: 20px; padding: 12px; }

/* ==========================================================
   RESPONSIVO / MOBILE
   ========================================================== */

/* Barra superior só aparece no mobile, com o botão de menu */
.topbar-mobile {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: var(--dark);
    color: #fff;
    padding: 14px 16px;
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar-mobile .logo-mobile { font-size: 18px; font-weight: 700; display: flex; align-items: center; overflow: hidden; }
.topbar-mobile .logo-mobile img { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; }
.btn-menu {
    background: none; border: none; color: #fff; font-size: 22px;
    cursor: pointer; padding: 4px 8px; line-height: 1;
}

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 40;
}
.sidebar-overlay.aberto { display: block; }

@media (max-width: 900px) {
    .topbar-mobile { display: flex; }

    .painel-wrapper { flex-direction: column; }

    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 260px;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
    }
    .sidebar.aberto { transform: translateX(0); }

    .conteudo { padding: 18px 14px; }

    .metricas { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .metrica-valor { font-size: 21px; }
    .metrica-card { padding: 14px; }

    .grid-2 { grid-template-columns: 1fr; }

    .page-header { align-items: flex-start; }
    .page-header h1 { font-size: 19px; }
    .btn { width: 100%; justify-content: center; }
    .page-header .btn { width: auto; }

    .form-linha { grid-template-columns: 1fr; }
    .form-box { padding: 18px; }

    /* Tabelas viram "cards" empilhados no mobile */
    table { border: none; }
    table thead { display: none; }
    table tr {
        display: block;
        background: #fff;
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 12px;
        padding: 6px 12px;
    }
    table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        text-align: right;
        border-bottom: 1px solid #f4f5f7;
        padding: 10px 0;
    }
    table td:last-child { border-bottom: none; }
    table td::before {
        content: attr(data-label);
        font-size: 11.5px;
        text-transform: uppercase;
        color: var(--text-muted);
        font-weight: 600;
        text-align: left;
    }
    table td a.btn, table td a.btn-sm { margin-left: 6px; }
}

/* ==========================================================
   PDV
   ========================================================== */
.pdv-layout { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }

.pdv-categorias { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.pdv-categoria-pill {
    padding: 7px 14px; border-radius: 20px; background: #f4f5f7; color: #374151;
    font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.pdv-categoria-pill.ativa { background: var(--accent); color: #fff; }

.pdv-grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.pdv-card {
    background: #fff; border-radius: 12px; overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06); display: flex; flex-direction: column;
}
.pdv-card-img {
    width: 100%; aspect-ratio: 1 / 1; background: #f4f5f7;
    display: flex; align-items: center; justify-content: center; position: relative;
}
.pdv-card-img img { width: 100%; height: 100%; object-fit: cover; }
.pdv-card-esgotado {
    position: absolute; top: 8px; right: 8px; background: var(--red); color: #fff;
    font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 20px;
}
.pdv-card-corpo { padding: 10px 12px 12px; display: flex; flex-direction: column; flex: 1; }
.pdv-card-nome { font-size: 13px; line-height: 1.3; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pdv-card-preco { font-size: 15px; font-weight: 700; color: var(--accent); }
.pdv-card-variacoes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pdv-chip {
    background: #eef2ff; color: var(--accent); border: 1px solid #e0e7ff;
    border-radius: 20px; padding: 5px 10px; font-size: 11.5px; font-weight: 600;
    cursor: pointer;
}
.pdv-chip:hover { background: var(--accent); color: #fff; }
.pdv-chip:disabled { opacity: 0.4; cursor: not-allowed; }

.pdv-carrinho-sticky { position: sticky; top: 16px; }
.pdv-itens-carrinho { max-height: 46vh; overflow-y: auto; }
.pdv-item-carrinho {
    display: flex; align-items: center; gap: 10px; padding: 10px 0;
    border-bottom: 1px solid #f1f1f3;
}
.pdv-item-carrinho img, .pdv-item-sem-img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: #f4f5f7; }
.pdv-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 12.5px; }
.pdv-item-info strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdv-item-info small { color: var(--text-muted); }
.pdv-item-info span { color: var(--text-muted); }
.pdv-item-qtd { display: flex; align-items: center; gap: 6px; }
.pdv-item-qtd button { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-weight: 700; }
.pdv-item-qtd span { font-size: 13px; font-weight: 600; min-width: 16px; text-align: center; }
.pdv-item-remover { color: var(--red); font-size: 15px; text-decoration: none; flex-shrink: 0; }

.pdv-total { display: flex; justify-content: space-between; align-items: center; font-size: 15px; font-weight: 700; padding-top: 14px; margin-top: 6px; border-top: 2px solid #111827; }
.pdv-total span { font-size: 20px; color: var(--accent); }

@media (max-width: 1100px) {
    .pdv-layout { grid-template-columns: 1fr; }
    .pdv-carrinho-sticky { position: static; }
}
@media (max-width: 500px) {
    .pdv-grade { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Variações de produto ---- */
@media (max-width: 900px) {
    .linha-variacao { flex-wrap: wrap; }
    .linha-variacao input[type=text], .linha-variacao input[type=number] { flex: 1 1 100% !important; width: 100% !important; }
}

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