/* ============================================================
   ADSys Caixa — Design System
   ============================================================ */

:root {
    --bg: #f3f5fa;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #eef2f9;
    --border: #e3e8f0;
    --border-strong: #d3dae6;
    --text: #0f172a;
    --text-2: #44506a;
    --muted: #7b879c;

    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --primary-soft: #e8efff;
    --success: #0f9d58;
    --success-soft: #e4f7ec;
    --warning: #c2740a;
    --warning-soft: #fdf1de;
    --danger: #dc2626;
    --danger-soft: #fdeaea;
    --info: #0e7490;
    --info-soft: #e2f5fa;

    --sidebar: #0d1526;
    --sidebar-2: #111c33;
    --sidebar-text: #a9b4ca;
    --sidebar-active: #2563eb;

    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 10px 30px -16px rgba(15, 23, 42, .22);
    --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .35);
    --topbar-h: 68px;
    --sidebar-w: 250px;
}

html[data-theme="dark"] {
    --bg: #080d18;
    --surface: #111a2c;
    --surface-2: #162034;
    --surface-3: #1b2740;
    --border: #22304a;
    --border-strong: #2c3c5b;
    --text: #eef2f9;
    --text-2: #b8c4d9;
    --muted: #8794ab;

    --primary-soft: #1a2b52;
    --success-soft: #113224;
    --warning-soft: #3a2a10;
    --danger-soft: #3a1a1a;
    --info-soft: #10303a;

    --sidebar: #0a1120;
    --sidebar-2: #0f172a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 14px 34px -18px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 12px; }

code {
    background: var(--surface-3);
    border-radius: 6px;
    padding: 1px 6px;
    font-size: 12.5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.icon { flex: 0 0 auto; }

/* --------------------------------------------------- Auth (login/instalação) */

.auth-body {
    background: radial-gradient(1200px 600px at 10% -10%, #1e3a8a 0%, #0d1526 55%, #070c16 100%);
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
}

.auth-wrap {
    width: min(1040px, 100%);
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    background: var(--surface);
    border-radius: 22px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.auth-side {
    background: linear-gradient(160deg, #12203c 0%, #0d1526 60%, #0a1220 100%);
    color: #e8eefc;
    padding: 46px 44px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

.auth-side::after {
    content: "";
    position: absolute;
    inset: auto -40% -55% auto;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37, 99, 235, .45), transparent 65%);
    pointer-events: none;
}

.auth-side h1 { font-size: 27px; margin: 26px 0 10px; }
.auth-side p { color: #a8b7d4; font-size: 14.5px; line-height: 1.7; max-width: 40ch; }

.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand strong { display: block; font-size: 16px; }
.auth-brand small { color: #8fa1c2; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }

.auth-logo {
    width: 46px; height: 46px;
    display: grid; place-items: center;
    border-radius: 13px;
    background: linear-gradient(140deg, #2563eb, #1e40af);
    color: #fff;
    box-shadow: 0 10px 24px -10px rgba(37, 99, 235, .9);
}

.auth-list { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 12px; }
.auth-list li { display: flex; align-items: center; gap: 10px; color: #cdd8ee; font-size: 13.5px; }
.auth-list .icon { color: #4ade80; }

.auth-card {
    padding: 46px 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.auth-card h2 { font-size: 22px; margin-bottom: 6px; }
.auth-card .form { margin-top: 16px; }
.auth-card .btn { margin-top: 8px; }

@media (max-width: 860px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-side { padding: 30px; }
    .auth-side p, .auth-list { display: none; }
    .auth-card { padding: 32px 26px; }
}

/* --------------------------------------------------- Shell / Sidebar */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    border-right: 1px solid rgba(255, 255, 255, .04);
}

.sidebar-brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.brand-logo {
    width: 36px; height: 36px;
    border-radius: 11px;
    display: grid; place-items: center;
    background: linear-gradient(140deg, #2563eb, #1e40af);
    color: #fff;
    box-shadow: 0 8px 18px -8px rgba(37, 99, 235, .95);
}

.sidebar-brand strong { color: #f3f6fd; font-size: 14.5px; display: block; line-height: 1.2; }
.sidebar-brand small { color: #7d8dad; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 12px 20px; }

.nav-title {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: #62718f;
    padding: 16px 10px 7px;
    font-weight: 700;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 11px;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-size: 13.8px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background .15s, color .15s;
}

.nav-item:hover { background: rgba(255, 255, 255, .06); color: #eaf0fb; }

.nav-item.active {
    background: linear-gradient(100deg, rgba(37, 99, 235, .95), rgba(37, 99, 235, .55));
    color: #fff;
    box-shadow: 0 10px 22px -14px rgba(37, 99, 235, 1);
}

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
}

.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .07); }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .05);
}

.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: linear-gradient(140deg, #334155, #1e293b);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    flex: 0 0 auto;
}

.user-chip-meta { min-width: 0; flex: 1; }
.user-chip-meta strong { display: block; color: #eef3fb; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip-meta span { display: block; color: #8494b3; font-size: 11px; }

.user-chip .btn-icon { color: #93a3c1; }
.user-chip .btn-icon:hover { color: #fff; background: rgba(255, 255, 255, .1); }

.app-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-h);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 26px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar-title { min-width: 0; }
.topbar-title strong { display: block; font-size: 15.5px; }
.topbar-title span { display: block; color: var(--muted); font-size: 12.5px; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.page { padding: 24px 26px 48px; max-width: 1500px; width: 100%; }

.sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(8, 13, 24, .55);
    z-index: 39;
    display: none;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

.sidebar-toggle { display: none; }

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .sidebar-toggle { display: inline-flex; }
    .page { padding: 18px 16px 40px; }
    .topbar { padding: 0 16px; }
}

/* --------------------------------------------------- Botões */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 13.8px;
    font-weight: 600;
    padding: 9px 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.25;
}

.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 8px 18px -10px rgba(37, 99, 235, .95); }
.btn-primary:hover { background: var(--primary-600); }

.btn-success { background: var(--success); color: #fff; box-shadow: 0 8px 18px -10px rgba(15, 157, 88, .9); }
.btn-success:hover { filter: brightness(.94); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover { filter: brightness(.96); }

.btn-dark { background: var(--sidebar); color: #fff; }

.btn-sm { padding: 6px 11px; font-size: 12.8px; border-radius: 9px; }
.btn-lg { padding: 13px 20px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }

.btn-icon {
    padding: 7px;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    border: 1px solid transparent;
    display: inline-flex;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* --------------------------------------------------- Formulários */

.form { display: grid; gap: 15px; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > label { font-size: 12.8px; font-weight: 600; color: var(--text-2); }

.input, .select, .textarea {
    width: 100%;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 9px 12px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    min-height: 40px;
}

.input:focus, .select:focus, .textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3.5px rgba(37, 99, 235, .14);
}

.input::placeholder { color: var(--muted); }
.input-sm { min-height: 34px; padding: 6px 10px; font-size: 13.2px; border-radius: 9px; }
.textarea { min-height: 78px; 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) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

.hint { font-size: 12px; color: var(--muted); }

.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }

@media (max-width: 760px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.input-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.input-group .input { flex: 1; min-width: 160px; }
.input-group .btn { flex: 0 0 auto; }
.input-group .btn-cam { padding-left: 11px; padding-right: 11px; }

/* --------------------------------------------------- Consulta por código de barras */

.lookup-result { margin-top: 8px; }

.lookup-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
}

.lookup-thumb {
    width: 64px;
    height: 64px;
    flex: 0 0 auto;
    object-fit: contain;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
}

.lookup-body { flex: 1; min-width: 0; }
.lookup-body .title { font-size: 13.6px; font-weight: 650; }
.lookup-body .sub { font-size: 12.2px; color: var(--muted); }
.lookup-actions { margin-top: 8px; }

/* --------------------------------------------------- Cards */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-head h3 { font-size: 14.8px; }
.card-head .sub { font-size: 12.4px; color: var(--muted); }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

.stack { display: grid; gap: 18px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* --------------------------------------------------- KPIs */

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .kpi-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .kpi-grid-3 { grid-template-columns: 1fr; } }

/* --------------------------------------------------- Layouts de 2 colunas */

.split { display: grid; gap: 18px; align-items: start; }
.split-main { grid-template-columns: minmax(0, 1fr) 400px; }
.split-side { grid-template-columns: 400px minmax(0, 1fr); }
.split-wide { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }

@media (max-width: 1100px) {
    .split-main, .split-side, .split-wide { grid-template-columns: 1fr; }
}

.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.kpi-icon {
    width: 42px; height: 42px;
    border-radius: 12px;
    display: grid; place-items: center;
    background: var(--primary-soft);
    color: var(--primary);
    flex: 0 0 auto;
}
.kpi-icon.green { background: var(--success-soft); color: var(--success); }
.kpi-icon.amber { background: var(--warning-soft); color: var(--warning); }
.kpi-icon.red { background: var(--danger-soft); color: var(--danger); }
.kpi-icon.teal { background: var(--info-soft); color: var(--info); }

.kpi-label { font-size: 12.4px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 24px; font-weight: 750; letter-spacing: -.02em; margin-top: 2px; }
.kpi-hint { font-size: 12.3px; color: var(--text-2); margin-top: 3px; }

/* --------------------------------------------------- Tabelas */

.table-wrap { width: 100%; overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 13.8px; }
.table th {
    text-align: left;
    font-size: 11.6px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    font-weight: 700;
    padding: 11px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .strong { font-weight: 650; }
.table .muted { color: var(--muted); font-size: 12.6px; }

.table.compact td { padding: 8px 14px; }
.table.compact th { padding: 8px 14px; }

/* --------------------------------------------------- Badges / alerts */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.6px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text-2);
    white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--primary-soft); color: var(--primary); }
.badge-teal { background: var(--info-soft); color: var(--info); }

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 11px;
    font-size: 13.5px;
    line-height: 1.5;
    margin-bottom: 14px;
    border: 1px solid transparent;
}
.alert .icon { margin-top: 1px; }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 22%, transparent); }

.empty {
    padding: 34px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 13.5px;
}
.empty .icon { display: block; margin: 0 auto 10px; opacity: .5; }

/* --------------------------------------------------- Toasts */

.toast-wrap {
    position: fixed;
    top: 16px; right: 16px;
    z-index: 90;
    display: grid;
    gap: 10px;
    max-width: min(380px, calc(100vw - 32px));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: var(--shadow-lg);
    font-size: 13.5px;
    animation: toast-in .22s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.success .icon { color: var(--success); }
.toast.error .icon { color: var(--danger); }
.toast.warning .icon { color: var(--warning); }
.toast .icon { color: var(--primary); }
.toast.hide { animation: toast-out .2s ease forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* --------------------------------------------------- Modal */

.modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: none;
    padding: 20px;
    background: rgba(8, 13, 24, .55);
    backdrop-filter: blur(3px);
    overflow-y: auto;
}
.modal.open { display: grid; place-items: center; }

.modal-card {
    background: var(--surface);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    width: min(560px, 100%);
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    animation: modal-in .2s ease;
    border: 1px solid var(--border);
}
.modal-card.wide { width: min(760px, 100%); }

@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }

.modal-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 17px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 15.5px; }
.modal-head .btn-icon { margin-left: auto; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 15px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* --------------------------------------------------- Paginação */

.pagination { display: flex; align-items: center; gap: 6px; padding: 14px 16px; flex-wrap: wrap; }
.page-link {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 13.2px;
    font-weight: 600;
    background: var(--surface);
}
.page-link:hover { background: var(--surface-3); }
.page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-link.disabled { opacity: .5; pointer-events: none; }

/* --------------------------------------------------- Filtros */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.filters .field { gap: 4px; }
.filters .field > label { font-size: 11.4px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.filters .grow { flex: 1 1 190px; }
.filters .spacer { flex: 1; }

/* --------------------------------------------------- Chart (barras) */

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 170px;
    padding: 8px 4px 0;
}
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.chart-bar {
    width: 100%;
    max-width: 46px;
    background: linear-gradient(180deg, #3b82f6, #2563eb);
    border-radius: 8px 8px 4px 4px;
    min-height: 4px;
    position: relative;
    transition: filter .15s;
}
.chart-col:hover .chart-bar { filter: brightness(1.08); }
.chart-label { font-size: 11.3px; color: var(--muted); font-weight: 600; }
.chart-value { font-size: 11px; color: var(--text-2); font-weight: 700; }
.chart-bar::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--sidebar);
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
}
.chart-col:hover .chart-bar::after { opacity: 1; }

/* --------------------------------------------------- Barra de progresso */

.meter { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.meter.success > span { background: var(--success); }
.meter.warning > span { background: var(--warning); }
.meter.danger > span { background: var(--danger); }

/* --------------------------------------------------- PDV */

.pdv {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 18px;
    align-items: start;
}

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

.pdv-left { display: flex; flex-direction: column; min-height: 520px; overflow: hidden; }

.pdv-search { padding: 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.pdv-search-inner { position: relative; display: flex; align-items: center; }
.pdv-search-inner > .icon { position: absolute; left: 14px; color: var(--muted); }
.pdv-search-input {
    padding-left: 44px;
    height: 52px;
    font-size: 16px;
    border-radius: 12px;
    background: var(--surface);
}
.pdv-hint { margin-top: 9px; font-size: 12px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.pdv-hint kbd {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 0 5px;
    font-size: 11px;
    font-family: inherit;
    color: var(--text-2);
}

.pdv-search-input { padding-right: 58px; }

.pdv-camera-btn {
    position: absolute;
    right: 8px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.pdv-camera-btn:hover { background: var(--surface-3); color: var(--primary); border-color: var(--primary); }

/* Leitor de código de barras pela câmera */
.scanner-card { width: min(680px, 100%); }
.scanner-body { display: grid; gap: 12px; }

.scanner-frame {
    position: relative;
    background: #05070d;
    border-radius: 14px;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    display: grid;
    place-items: center;
}

.scanner-frame video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.scanner-reticle {
    position: absolute;
    left: 10%;
    right: 10%;
    top: 50%;
    transform: translateY(-50%);
    height: 30%;
    border: 2px solid rgba(255, 255, 255, .9);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, .3);
    pointer-events: none;
    overflow: hidden;
}

.scanner-reticle::after {
    content: "";
    position: absolute;
    left: 5%;
    right: 5%;
    top: 50%;
    height: 2px;
    background: #ef4444;
    box-shadow: 0 0 10px #ef4444;
    animation: scanline 2.4s ease-in-out infinite;
}

@keyframes scanline {
    0%, 100% { transform: translateY(-340%); }
    50% { transform: translateY(340%); }
}

.scanner-status { font-size: 13px; color: var(--text-2); text-align: center; min-height: 20px; }
.scanner-status.ok { color: var(--success); font-weight: 650; }
.scanner-status.error { color: var(--danger); font-weight: 650; }

.scanner-last { font-size: 12.6px; color: var(--muted); text-align: center; }

@media (max-width: 600px) {
    .scanner-frame { aspect-ratio: 3 / 4; }
}

.pdv-results { padding: 12px; display: grid; gap: 8px; align-content: start; overflow-y: auto; max-height: calc(100vh - 290px); }

.product-hit {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    cursor: pointer;
    text-align: left;
    width: 100%;
    font-family: inherit;
    color: var(--text);
    transition: border-color .12s, background .12s, transform .05s;
}
.product-hit:hover, .product-hit.active { border-color: var(--primary); background: var(--primary-soft); }
.product-hit:active { transform: scale(.995); }
.product-hit-main { min-width: 0; flex: 1; }
.product-hit-main strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-hit-main span { display: block; font-size: 12px; color: var(--muted); }
.product-hit-price { text-align: right; }
.product-hit-price strong { display: block; font-size: 14.5px; color: var(--success); }
.product-hit-price span { display: block; font-size: 11.5px; color: var(--muted); }
.product-hit.out { opacity: .55; }

.pdv-right {
    position: sticky;
    top: calc(var(--topbar-h) + 18px);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--topbar-h) - 40px);
    overflow: hidden;
}

.pdv-cart-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
}
.pdv-cart-head h2 { font-size: 14.5px; }
.pdv-cart-head .btn { margin-left: auto; }

.pdv-cart-list { flex: 1; overflow-y: auto; padding: 10px; display: grid; gap: 8px; align-content: start; min-height: 120px; }

.cart-line {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    display: grid;
    gap: 8px;
    background: var(--surface);
}
.cart-line-top { display: flex; gap: 8px; align-items: flex-start; }
.cart-line-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; }
.cart-line-name small { display: block; font-weight: 500; color: var(--muted); font-size: 11.6px; }
.cart-line-bottom { display: flex; align-items: center; gap: 8px; }
.cart-qty { display: flex; align-items: center; gap: 0; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; background: var(--surface); }
.cart-qty button {
    width: 30px; height: 30px;
    border: none;
    background: var(--surface-2);
    color: var(--text-2);
    cursor: pointer;
    display: grid; place-items: center;
    font-size: 15px;
}
.cart-qty button:hover { background: var(--surface-3); }
.cart-qty input {
    width: 52px;
    height: 30px;
    border: none;
    text-align: center;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    background: var(--surface);
    color: var(--text);
    outline: none;
}
.cart-line-total { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

.pdv-totals { border-top: 1px solid var(--border); padding: 15px 18px; background: var(--surface-2); display: grid; gap: 9px; }
.pdv-totals .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.6px; color: var(--text-2); }
.pdv-totals .row .input { max-width: 130px; text-align: right; }
.pdv-totals .row.total { font-size: 20px; font-weight: 750; color: var(--text); padding-top: 6px; border-top: 1px dashed var(--border-strong); }
.pdv-totals .row.total strong { font-size: 26px; color: var(--success); letter-spacing: -.02em; }

.pay-methods { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.pay-method {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: 12px;
    background: var(--surface);
    cursor: pointer;
    font-family: inherit;
    font-size: 13.8px;
    font-weight: 600;
    color: var(--text-2);
    transition: all .12s;
}
.pay-method:hover { border-color: var(--primary); }
.pay-method.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

.quick-cash { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }
.quick-cash button {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 9px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
}
.quick-cash button:hover { background: var(--surface-3); }

.change-box {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--success-soft);
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}
.change-box strong { font-size: 22px; }

.modal-total {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    margin-bottom: 16px;
    font-size: 13.5px;
    color: var(--text-2);
}
.modal-total strong { font-size: 24px; color: var(--text); letter-spacing: -.02em; }

.sale-success-big {
    text-align: center;
    padding: 6px 0 4px;
}
.sale-success-big .ok-circle {
    width: 62px; height: 62px;
    border-radius: 50%;
    background: var(--success-soft);
    color: var(--success);
    display: grid;
    place-items: center;
    margin: 0 auto 14px;
}
.sale-success-big h3 { font-size: 19px; margin-bottom: 6px; }
.sale-success-big .value { font-size: 40px; font-weight: 800; color: var(--success); letter-spacing: -.03em; margin: 6px 0 4px; }
.sale-success-big small { color: var(--muted); display: block; }

/* --------------------------------------------------- Recibo (80mm) */

.receipt-page { background: #eef1f6; min-height: 100vh; padding: 24px; display: grid; place-items: start center; }
.receipt {
    width: 300px;
    background: #fff;
    color: #000;
    padding: 16px 14px;
    font-family: ui-monospace, "Courier New", monospace;
    font-size: 11.5px;
    line-height: 1.45;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .16);
}
.receipt.center { text-align: center; }
.receipt hr { border: none; border-top: 1px dashed #999; margin: 8px 0; }
.receipt .big { font-size: 13px; font-weight: 700; }
.receipt table { width: 100%; border-collapse: collapse; font-size: 10.8px; }
.receipt table td { padding: 1px 0; vertical-align: top; }
.receipt .total-line { display: flex; justify-content: space-between; font-size: 14px; font-weight: 700; margin-top: 6px; }
.receipt-toolbar { display: flex; gap: 10px; margin-bottom: 16px; }

@media print {
    .no-print, .sidebar, .topbar, .toast-wrap { display: none !important; }
    .receipt-page { background: #fff; padding: 0; display: block; }
    .receipt { box-shadow: none; width: 300px; margin: 0; }
    body { background: #fff; }
    .print-hide { display: none !important; }
}

/* --------------------------------------------------- Utilitários */

.text-muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.8px; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; } .mt-4 { margin-top: 26px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; }
.flex { display: flex; } .between { justify-content: space-between; } .center { align-items: center; }
.gap-1 { gap: 6px; } .gap-2 { gap: 12px; } .gap-3 { gap: 18px; }
.wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.small { font-size: 12.4px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

.def-list { display: grid; gap: 10px; }
.def-list .item { display: flex; justify-content: space-between; gap: 14px; font-size: 13.5px; }
.def-list .item span { color: var(--muted); }
.def-list .item strong { text-align: right; }

.table-toolbar-note { font-size: 12.4px; color: var(--muted); }

.list-plain { display: grid; gap: 10px; }
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; font-size: 13.6px; }
.list-item .sub { font-size: 12.2px; color: var(--muted); }

/* --------------------------------------------------- Autocomplete de produto */

.picker { display: grid; gap: 6px; }
.picker-field { position: relative; }

.picker-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 25;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 6px;
    display: grid;
    gap: 4px;
    max-height: 300px;
    overflow-y: auto;
}
.picker-results .list-item { border: none; padding: 8px 10px; }
.picker-results .list-item:hover,
.picker-results .list-item.active { background: var(--surface-2); }
