/* Prime ERP — tema e componentes. Sem dependências externas. */

:root {
    --bg: #f4f5f9;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --border: #e6e8f0;
    --text: #161a24;
    --muted: #6b7286;
    --primary: #4f46e5;
    --primary-600: #4338ca;
    --primary-soft: #eef0ff;
    --ok: #059669;
    --ok-soft: #e7f8f1;
    --warn: #b45309;
    --warn-soft: #fff4e0;
    --danger: #dc2626;
    --danger-soft: #fdecec;
    --sidebar: #111425;
    --sidebar-text: #aab1c8;
    --sidebar-active: #ffffff;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

:root[data-theme="dark"] {
    --bg: #0d0f16;
    --surface: #161a25;
    --surface-2: #1b2030;
    --border: #262c3d;
    --text: #e8eaf2;
    --muted: #9aa2b8;
    --primary: #818cf8;
    --primary-600: #6366f1;
    --primary-soft: #1f2347;
    --ok: #34d399;
    --ok-soft: #0f2d24;
    --warn: #fbbf24;
    --warn-soft: #33270c;
    --danger: #f87171;
    --danger-soft: #3a1717;
    --sidebar: #0a0c13;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0d0f16;
        --surface: #161a25;
        --surface-2: #1b2030;
        --border: #262c3d;
        --text: #e8eaf2;
        --muted: #9aa2b8;
        --primary: #818cf8;
        --primary-600: #6366f1;
        --primary-soft: #1f2347;
        --ok: #34d399;
        --ok-soft: #0f2d24;
        --warn: #fbbf24;
        --warn-soft: #33270c;
        --danger: #f87171;
        --danger-soft: #3a1717;
        --sidebar: #0a0c13;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h2 { font-size: 1.45rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
.icon { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.inline { display: inline; margin: 0; }
.req { color: var(--danger); }
.only-mobile { display: none; }
.mono { font-family: var(--mono); font-size: .9em; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
    background: var(--sidebar); color: var(--sidebar-text); padding: 12px 10px; overflow-y: auto;
}
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
    height: 64px; padding: 0 28px; background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 1.05rem; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; gap: 8px; }
.content { padding: 28px; width: 100%; max-width: 1280px; margin: 0 auto; }

/* ---------- Sidebar ---------- */
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; color: #fff; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
    background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; font-weight: 800; font-size: 18px;
    box-shadow: 0 6px 16px rgba(99, 102, 241, .35);
}
.brand-mark.lg { width: 46px; height: 46px; font-size: 22px; border-radius: 14px; }
.brand-name { font-size: 1.1rem; font-weight: 600; letter-spacing: .01em; color: #fff; }
.brand-name b { font-weight: 800; color: #a5b4fc; margin-left: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
/* Grupos recolhíveis: só o grupo da tela atual começa aberto */
.nav-grupo { margin-top: 2px; }
.nav-grupo > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
    padding: 6px 10px; border-radius: 8px; font-size: .66rem; font-weight: 700; letter-spacing: .1em;
    text-transform: uppercase; color: #7d86a8; user-select: none;
}
.nav-grupo > summary::-webkit-details-marker { display: none; }
.nav-grupo > summary::after { content: "▸"; font-size: .85rem; transition: transform .15s; }
.nav-grupo[open] > summary::after { transform: rotate(90deg); }
.nav-grupo > summary:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.nav-itens { display: flex; flex-direction: column; gap: 1px; padding: 2px 0 6px; }
.nav-link {
    display: block; padding: 5px 10px 5px 16px; border-radius: 8px; color: var(--sidebar-text);
    font-size: .86rem; line-height: 1.35; transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link.is-active { background: rgba(129, 140, 248, .16); color: var(--sidebar-active); font-weight: 600; }
.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 10px; display: grid; gap: 8px; }
.user { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
    background: #262c45; color: #c7d2fe; font-weight: 700; font-size: .9rem;
}
.user-nome { color: #fff; font-size: .9rem; font-weight: 600; }
.user-perfil { font-size: .75rem; text-transform: capitalize; }

/* ---------- Page ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
.back { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--muted); margin-bottom: 6px; }
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.empty { text-align: center; padding: 60px 20px; }
.empty h2 { margin-bottom: 8px; }

/* ---------- Botões ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
    text-decoration: none !important;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(79, 70, 229, .25); }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-lg { height: 48px; font-size: 1rem; padding: 0 22px; }
.btn-sm { height: 32px; padding: 0 10px; font-size: .84rem; }
.btn-block { width: 100%; }
.sidebar .btn-ghost { color: var(--sidebar-text); border-color: rgba(255, 255, 255, .12); background: transparent; }
.sidebar .btn-ghost:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.icon-btn {
    width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
    color: var(--text); display: inline-grid; place-items: center; cursor: pointer; padding: 0; text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); text-decoration: none; }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: var(--danger-soft); }
.inline .icon-btn, form.inline .icon-btn { border: 0; background: transparent; }
:root[data-theme="dark"] .ic-moon { display: none; }
:root[data-theme="light"] .ic-sun { display: none; }
.ic-sun { display: none; }
:root[data-theme="dark"] .ic-sun { display: block; }
:root[data-theme="dark"] .ic-moon { display: none; }
:root:not([data-theme="dark"]) .ic-sun { display: none; }
:root:not([data-theme="dark"]) .ic-moon { display: block; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .ic-sun { display: block; }
    :root:not([data-theme="light"]) .ic-moon { display: none; }
}

/* ---------- Badges e alertas ---------- */
.badge {
    display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
    font-size: .76rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.alert {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius-sm);
    margin-bottom: 18px; border: 1px solid var(--border); background: var(--surface); animation: fadeIn .25s ease;
}
.alert-sucesso { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.alert-erro { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.alert-aviso { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- KPIs e atalhos ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px 20px; display: flex; flex-direction: column; gap: 4px;
}
.kpi-label { font-size: .82rem; color: var(--muted); font-weight: 500; }
.kpi-valor { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .8rem; color: var(--muted); }
.kpi-alerta { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.kpi-alerta .kpi-valor { color: var(--warn); }

.bars { display: flex; align-items: flex-end; gap: 12px; height: 220px; padding: 10px 4px 0; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; position: relative; }
.bar-fill {
    width: 100%; max-width: 56px; border-radius: 10px 10px 4px 4px;
    background: linear-gradient(180deg, #818cf8, #4f46e5); transition: height .6s cubic-bezier(.2,.8,.2,1);
}
.bar-valor { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1em; }
.bar-dia { font-size: .78rem; color: var(--muted); }

.grid-atalhos { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.atalho {
    display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.atalho .icon { color: var(--primary); width: 22px; height: 22px; }
.atalho:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); text-decoration: none; }

/* ---------- Detalhes (lista chave/valor) ---------- */
.page-head-acoes { display: flex; gap: 10px; flex-wrap: wrap; }
.dados { display: grid; grid-template-columns: max-content 1fr; gap: 10px 22px; margin: 0; font-size: .94rem; }
.dados dt { color: var(--muted); font-weight: 500; }
.dados dd { margin: 0; min-width: 0; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }

/* ---------- Tabelas ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search { flex: 1; min-width: 200px; position: relative; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 38px; }
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
.table th {
    text-align: left; font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .vazio { text-align: center; color: var(--muted); padding: 40px; }
.col-acoes { width: 1%; white-space: nowrap; text-align: right; }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.page {
    min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px;
    border: 1px solid var(--border); color: var(--text); font-size: .88rem;
}
.page.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Formulários ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span-2 { grid-column: 1 / -1; }
.field label { font-size: .86rem; font-weight: 600; color: var(--text); }
.field .ajuda { font-size: .78rem; color: var(--muted); }
.field .erro { font-size: .8rem; color: var(--danger); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
input[type="text"], input[type="email"], input[type="number"], input[type="date"], input[type="tel"],
input[type="password"], input[type="search"], input[type="search"], select, textarea {
    width: 100%; height: 42px; padding: 0 12px; font: inherit; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; padding-top: 22px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.form .field.span-2 { grid-column: 1 / -1; }

/* ---------- Modal ---------- */
dialog {
    border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 32px));
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(10, 12, 20, .5); backdrop-filter: blur(3px); }
.dialog-body { padding: 24px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2); }

/* ---------- Toasts ---------- */
.toast-zona { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 100; }
.toast {
    padding: 12px 16px; border-radius: 12px; background: var(--text); color: var(--bg);
    box-shadow: var(--shadow-lg); font-size: .9rem; animation: fadeIn .25s ease; max-width: 340px;
}
.toast.erro { background: var(--danger); color: #fff; }
.toast.sucesso { background: var(--ok); color: #fff; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; background: radial-gradient(1200px 600px at 10% -10%, #c7d2fe 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #e9d5ff 0%, transparent 60%), var(--bg); }
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.login-card {
    width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border);
    border-radius: 20px; padding: 36px 32px; box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-brand .brand-name { color: var(--text); }
.login-brand .brand-name b { color: var(--primary); }
.login h1 { font-size: 1.5rem; margin-bottom: 6px; }
.login-card .muted { margin-bottom: 22px; }
.login-card .form { display: grid; gap: 16px; }
.login-foot { margin-top: 20px; font-size: .8rem; color: var(--muted); }

/* ---------- PDV (tela cheia, touch) ---------- */
.modo-pdv { background: var(--bg); }
.pdv { display: grid; grid-template-columns: minmax(0, 1fr) 420px; height: 100vh; }
.pdv-esq { display: flex; flex-direction: column; min-width: 0; padding: 18px; gap: 14px; overflow: hidden; }
.pdv-dir { overflow-y: auto; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border); min-height: 0; }
.pdv-top { display: flex; align-items: center; gap: 12px; }
.pdv-top .brand { padding: 0; }
.pdv-busca { flex: 1; position: relative; }
.pdv-busca input { height: 52px; font-size: 1.05rem; padding-left: 46px; border-radius: 14px; }
.pdv-busca .icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.pdv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; overflow-y: auto; padding: 4px 2px 12px; align-content: start; }
.pdv-prod {
    text-align: left; padding: 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface);
    color: var(--text); cursor: pointer; font: inherit; display: flex; flex-direction: column; gap: 8px;
    min-height: 116px; transition: transform .12s, box-shadow .15s, border-color .15s;
}
.pdv-prod:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.pdv-prod:active { transform: scale(.98); }
.pdv-prod .nome { font-weight: 600; line-height: 1.25; flex: 1; }
.pdv-prod .preco { font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.pdv-prod .sku { font-size: .74rem; color: var(--muted); }
.pdv-cart-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.pdv-cart { flex: 1; overflow-y: auto; padding: 8px 12px; min-height: 0; }
.pdv-item {
    display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 8px; border-bottom: 1px dashed var(--border);
}
.pdv-item .nome { font-weight: 600; font-size: .92rem; }
.pdv-item .detalhe { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pdv-item .total { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.pdv-qtd { display: inline-flex; align-items: center; gap: 6px; }
.pdv-qtd button { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; font-weight: 700; }
.pdv-qtd span { min-width: 28px; text-align: center; font-weight: 600; }
.produto-destaque { flex: 1; min-height: 0; display: flex; align-items: stretch; }
.produto-destaque > * { width: 100%; }
.destaque-card {
    align-self: center; margin: auto; width: min(560px, 100%); padding: 28px 30px; border-radius: 20px;
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.destaque-sku { font-family: var(--mono); font-size: .85rem; color: var(--muted); }
.destaque-nome { font-size: 1.9rem; font-weight: 700; line-height: 1.15; margin: 6px 0 10px; letter-spacing: -.02em; }
.destaque-preco { font-size: 2.2rem; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.destaque-vazio { margin: auto; text-align: center; color: var(--muted); padding: 30px; border: 2px dashed var(--border); border-radius: 20px; }
.destaque-vazio p { margin: 6px 0; font-size: 1.05rem; }
.visor-cliente {
    display: flex; flex-direction: column; width: 100%; min-height: 0; padding: 18px 22px; border-radius: 20px;
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
    font-variant-numeric: tabular-nums;
}
.visor-cab, .visor-item {
    display: grid; grid-template-columns: 60px 64px 80px 110px 1fr 100px 110px; gap: 10px; align-items: center;
}
.visor-cab { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.visor-cab span:nth-child(n+6), .visor-item .visor-unit, .visor-item .visor-tot { text-align: right; }
.visor-item { cursor: pointer; }
.visor-item .visor-num { font-family: var(--mono); font-weight: 700; color: var(--muted); }
.visor-item.is-sel { background: var(--surface-2); border-radius: 10px; box-shadow: inset 0 0 0 2px var(--primary); }
.visor-acoes {
    display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 0; margin-top: 8px; border-top: 1px solid var(--border); font-size: .9rem;
}
.visor-acoes-btns { display: flex; gap: 8px; }
.visor-acoes .danger { color: #b3261e; }
.abertura-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.abertura-grid h4 { margin: 0 0 6px; font-size: .9rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ab-linha { display: grid; grid-template-columns: 80px 1fr 110px; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.ab-linha input {
    height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
    padding: 0 10px; font: inherit; text-align: right;
}
.ab-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.ab-sub { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.abertura-total {
    display: flex; justify-content: space-between; align-items: baseline; margin-top: 16px; padding-top: 12px;
    border-top: 2px solid var(--border); font-weight: 600;
}
.abertura-total strong { font-size: 1.6rem; color: var(--primary); font-variant-numeric: tabular-nums; }
.multi-campo { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; }
.imagem-campo { display: flex; flex-direction: column; gap: 8px; }
.imagem-atual { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }
@media (max-width: 640px) { .abertura-grid { grid-template-columns: 1fr; } }
/* Fechamento de caixa: notas, moedas e canhotos lado a lado (empilha no celular) */
.fech-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.fech-bloco { border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; margin: 0; min-width: 0; }
.fech-bloco legend { padding: 0 6px; font-weight: 600; color: var(--muted); }
.fech-bloco .multi-campo { grid-template-columns: 1fr; }
.fech-bloco .multi-campo label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.form-acoes { display: flex; justify-content: flex-end; margin-top: 16px; }
.visor-foto {
    width: 56px; height: 56px; border-radius: 12px; object-fit: cover; display: block;
    background: var(--surface-2); border: 1px solid var(--border);
}
.visor-foto-vazia {
    display: grid; place-items: center; font-family: var(--serif, inherit); font-size: 1.4rem; font-weight: 700; color: var(--muted);
}
.visor-lista { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; }
.visor-item { padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 1.05rem; }
.visor-item.is-ultimo { background: var(--surface-2); border-radius: 10px; padding-left: 8px; padding-right: 8px; }
.visor-item .visor-cod { font-family: var(--mono); font-size: .85rem; color: var(--muted); }
.visor-item .visor-tot { font-weight: 700; }
.visor-item .visor-desc-val { grid-column: 5 / -1; font-size: .85rem; color: var(--muted); }
.visor-total {
    display: flex; justify-content: space-between; align-items: baseline; margin-top: 14px; padding-top: 14px;
    border-top: 2px solid var(--border); font-size: 1.1rem; font-weight: 600;
}
.visor-total strong { font-size: 2rem; font-weight: 800; color: var(--primary); }
.cupom-vivo { border-top: 1px solid var(--border); background: var(--surface); flex: none; }
.cupom-vivo-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px 4px 16px; font-size: .8rem; font-weight: 600; letter-spacing: .02em; }
.cupom-vivo-txt {
    margin: 0; padding: 6px 12px 10px 16px; max-height: 230px; overflow: auto; white-space: pre;
    font-family: "Courier New", Consolas, monospace; font-size: 11.5px; line-height: 1.35;
    background: var(--surface-2); color: var(--text); border-top: 1px dashed var(--border);
}
.cupom-vivo-txt.is-recolhido { display: none; }
/* Coluna de venda compacta: cabe na altura da tela sem rolagem (regras só para .pdv-dir) */
.pdv-dir { gap: 0; }
.pdv-dir .pdv-cart-head { padding: 8px 14px; }
.pdv-dir .pdv-cart { padding: 4px 8px; }
.pdv-dir .pdv-item { padding: 6px 6px; }
.pdv-dir .pdv-item .nome { font-size: .86rem; }
.pdv-dir .pdv-totais { padding: 8px 14px; gap: 2px; }
.pdv-dir .pdv-linha { font-size: .85rem; }
.pdv-dir .pdv-total { font-size: .95rem; margin-top: 0; }
.pdv-dir .pdv-total strong { font-size: 1.5rem; }
.pdv-dir input, .pdv-dir select { height: 34px !important; font-size: .88rem !important; }
.pdv-dir .btn { height: 36px !important; }
.pdv-dir .pdv-pag { margin-top: 6px; gap: 6px; }
.pdv-dir .pdv-pag button { height: 40px !important; flex-direction: row !important; gap: 6px !important; font-size: .82rem; }
.pdv-dir .pdv-pag button .icon { width: 16px; height: 16px; }
.pdv-dir .pdv-acoes { padding: 8px 14px 12px; gap: 8px; }
.pdv-dir .pdv-acoes .btn-finalizar { height: 46px !important; font-size: 1rem; }
.pdv-dir .cupom-vivo-txt { max-height: 120px; font-size: 10.5px; }
.pdv-dir .cupom-vivo-head { padding: 4px 14px 2px 14px; }
.pdv-dir #lista-pag li { padding: 5px 10px !important; }
.pdv-vazio { text-align: center; color: var(--muted); padding: 50px 16px; }
.pdv-totais { padding: 16px 20px; border-top: 1px solid var(--border); background: var(--surface-2); display: grid; gap: 6px; }
.pdv-linha { display: flex; justify-content: space-between; font-size: .95rem; color: var(--muted); }
.pdv-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.1rem; font-weight: 600; margin-top: 4px; }
.pdv-total strong { font-size: 2rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--text); }
.pdv-acoes { padding: 14px 20px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pdv-acoes .btn-finalizar { grid-column: 1 / -1; height: 56px; font-size: 1.05rem; }
.pdv-pag { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.pdv-pag button {
    height: 64px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.pdv-pag button .icon { width: 20px; height: 20px; color: var(--primary); }
.pdv-pag button.is-on { border-color: var(--primary); background: var(--primary-soft); }
.pdv-atalhos { font-size: .76rem; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
kbd { font-family: var(--mono); font-size: .72rem; padding: 1px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }

@media (max-width: 1100px) {
    .pdv { grid-template-columns: minmax(0, 1fr) 360px; }
}
@media (max-width: 900px) {
    .pdv { grid-template-columns: 1fr; height: auto; }
    .pdv-dir { border-left: 0; border-top: 1px solid var(--border); }
    .pdv-grid { max-height: 52vh; }
}

/* ---------- Responsivo ---------- */
@media (max-width: 1000px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; width: 260px; height: 100vh; z-index: 40;
        transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg);
    }
    .sidebar.is-open { transform: none; }
    .only-mobile { display: inline-grid; }
    .topbar { padding: 0 16px; }
    .content { padding: 18px 16px; }
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .page-head h2 { font-size: 1.25rem; }
    .kpi-valor { font-size: 1.35rem; }
    .table-wrap { margin: 0 -16px; padding: 0 16px; }
    .bars { height: 170px; gap: 6px; }
    .pdv-acoes { grid-template-columns: 1fr; }
    .pdv-pag { grid-template-columns: repeat(3, 1fr); }
}

@media print {
    .sidebar, .topbar, .toolbar, .col-acoes, .toast-zona, .btn, .form-actions { display: none !important; }
    .app { display: block; }
    .content { padding: 0; }
    body { background: #fff; color: #000; }
    .card { box-shadow: none; border: 0; }
}
