/* =====================================================================
   Genius — Gestão Comercial e OS
   ===================================================================== */
:root {
    --sidebar-w: 248px;
    --sidebar-mini-w: 68px;
    --topbar-h: 60px;
    --sidebar-bg: #0f172a;
    --sidebar-fg: #cbd5e1;
    --sidebar-muted: #64748b;
    --sidebar-active: #1e293b;
    --brand: #4f46e5;
    --brand-2: #06b6d4;
    --radius: .75rem;
    --bs-orange-rgb: 253, 126, 20;
    --bs-indigo-rgb: 102, 16, 242;
}
[data-bs-theme="light"] body { background: #f4f6fb; }
[data-bs-theme="dark"] body { background: #0b1120; }
[data-bs-theme="dark"] { --bs-body-bg: #0b1120; --bs-tertiary-bg: #111a2e; --bs-secondary-bg: #131c31; --bs-border-color: #1f2a44; }

body { font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: .925rem; }
.text-bg-orange { color: #fff !important; background-color: #fd7e14 !important; }
.text-bg-indigo { color: #fff !important; background-color: #6610f2 !important; }
.bg-orange { background-color: #fd7e14 !important; }
.bg-indigo { background-color: #6610f2 !important; }
.text-orange { color: #fd7e14 !important; }
.text-indigo { color: #6610f2 !important; }
[data-bs-theme="dark"] .text-indigo { color: #a78bfa !important; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-content { padding: 1.25rem; flex: 1; }
@media (max-width: 575.98px) { .app-content { padding: .75rem; } }

.app-sidebar { background: var(--sidebar-bg) !important; color: var(--sidebar-fg); width: var(--sidebar-w); display: flex; flex-direction: column; }
@media (min-width: 992px) {
    .app-sidebar { position: sticky; top: 0; height: 100vh; flex-shrink: 0; transition: width .2s; }
    .sidebar-mini .app-sidebar { width: var(--sidebar-mini-w); }
    .sidebar-mini .app-sidebar .brand-text, .sidebar-mini .app-sidebar .nav-link span, .sidebar-mini .app-sidebar .nav-title { display: none; }
    .sidebar-mini .app-sidebar .nav-link { justify-content: center; }
    .sidebar-mini #sidebarToggle i { transform: rotate(180deg); }
}
.sidebar-brand { height: var(--topbar-h); display: flex; align-items: center; padding: 0 1rem; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); flex-shrink: 0; }
.brand-text { color: #fff; font-weight: 700; font-size: 1.1rem; line-height: 1; display: flex; flex-direction: column; }
.brand-text small { color: var(--sidebar-muted); font-weight: 500; font-size: .7rem; margin-top: 3px; }
.sidebar-nav { padding: .75rem .6rem; overflow-y: auto; flex: 1; }
.sidebar-nav .nav-title { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); padding: .9rem .75rem .35rem; font-weight: 600; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: .75rem; color: var(--sidebar-fg); padding: .55rem .75rem; border-radius: .55rem; font-size: .88rem; margin-bottom: 2px; white-space: nowrap; }
.sidebar-nav .nav-link i { color: var(--sidebar-muted); width: 1.1rem; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar-nav .nav-link.active { background: linear-gradient(90deg, rgba(79,70,229,.35), rgba(79,70,229,.08)); color: #fff; }
.sidebar-nav .nav-link.active i { color: #a5b4fc; }
.sidebar-footer { padding: .5rem; border-top: 1px solid rgba(255,255,255,.06); text-align: right; }

.app-topbar { height: var(--topbar-h); position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; background: var(--bs-body-bg); border-bottom: 1px solid var(--bs-border-color); }
[data-bs-theme="light"] .app-topbar { background: rgba(255,255,255,.92); backdrop-filter: blur(8px); }
@media (max-width: 575.98px) { .app-topbar { padding: 0 .6rem; gap: .4rem; } }
.btn-icon { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: 0; background: transparent; color: var(--bs-body-color); }
.btn-icon:hover { background: var(--bs-tertiary-bg); }
.user-chip { width: auto; border-radius: 2rem; padding: 0 .4rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 600; font-size: .85rem; flex-shrink: 0; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.5rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.search-trigger { display: flex; align-items: center; gap: .6rem; background: var(--bs-tertiary-bg); border: 1px solid var(--bs-border-color); color: var(--bs-secondary-color); border-radius: 2rem; padding: .4rem 1rem; min-width: 0; max-width: 460px; flex: 1; text-align: left; font-size: .88rem; }
.search-trigger span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-trigger kbd { background: var(--bs-body-bg); color: var(--bs-secondary-color); border: 1px solid var(--bs-border-color); font-size: .7rem; }
[data-bs-theme="dark"] .theme-icon-dark, [data-bs-theme="light"] .theme-icon-light { display: none; }

/* ---------- Busca global ---------- */
.search-dialog { margin-top: 8vh; }
.search-group-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--bs-secondary-color); margin: .75rem .5rem .25rem; font-weight: 600; }
.search-item { display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; border-radius: .5rem; color: var(--bs-body-color); text-decoration: none; }
.search-item .icon { width: 34px; height: 34px; border-radius: .5rem; display: grid; place-items: center; background: var(--bs-tertiary-bg); flex-shrink: 0; }
.search-item small { color: var(--bs-secondary-color); display: block; }
.search-item.active, .search-item:hover { background: rgba(79,70,229,.12); }

/* ---------- Componentes ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1.1rem; }
.page-header h1 { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-header .subtitle { color: var(--bs-secondary-color); font-size: .85rem; }
.page-header .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: .5rem; }
.card { border-radius: var(--radius); border-color: var(--bs-border-color); }
[data-bs-theme="light"] .card { border-color: #e7eaf3; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: transparent; font-weight: 600; padding: .85rem 1rem; }
.card-title-sm { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); font-weight: 600; }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .6rem .75rem; vertical-align: middle; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); font-weight: 600; border-bottom-width: 1px; white-space: nowrap; }
.table thead th a { color: inherit; text-decoration: none; }
.table-hover tbody tr { cursor: default; }
.row-link { cursor: pointer; }
.stat-card { padding: 1rem 1.1rem; height: 100%; }
.stat-card .label { font-size: .78rem; color: var(--bs-secondary-color); font-weight: 500; }
.stat-card .value { font-size: 1.45rem; font-weight: 700; margin-top: .15rem; letter-spacing: -.01em; }
.stat-card .icon { width: 42px; height: 42px; border-radius: .7rem; display: grid; place-items: center; font-size: 1.1rem; }
.soft-primary { background: rgba(79,70,229,.12); color: #4f46e5; }
.soft-success { background: rgba(16,185,129,.13); color: #059669; }
.soft-info { background: rgba(6,182,212,.13); color: #0891b2; }
.soft-warning { background: rgba(245,158,11,.15); color: #d97706; }
.soft-danger { background: rgba(239,68,68,.13); color: #dc2626; }
.soft-secondary { background: rgba(100,116,139,.13); color: #64748b; }
[data-bs-theme="dark"] .soft-primary { color: #a5b4fc; } [data-bs-theme="dark"] .soft-success { color: #34d399; }
[data-bs-theme="dark"] .soft-info { color: #67e8f9; } [data-bs-theme="dark"] .soft-warning { color: #fbbf24; }
[data-bs-theme="dark"] .soft-danger { color: #f87171; }
.quick-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; padding: 1rem .5rem; border-radius: var(--radius); text-decoration: none; font-weight: 600; font-size: .85rem; border: 1px solid var(--bs-border-color); background: var(--bs-body-bg); color: var(--bs-body-color); transition: transform .1s, box-shadow .1s; height: 100%; }
.quick-btn i { font-size: 1.4rem; }
.quick-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16,24,40,.08); color: var(--bs-body-color); }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--bs-secondary-color); }
.empty-state i { font-size: 2.2rem; opacity: .4; margin-bottom: .6rem; }
.progress-thin { height: .5rem; }
.dl-grid { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: .35rem .75rem; margin: 0; }
.dl-grid dt { color: var(--bs-secondary-color); font-weight: 500; font-size: .85rem; }
.dl-grid dd { margin: 0; word-break: break-word; }
.filters { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: var(--radius); padding: .75rem; margin-bottom: 1rem; }
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .3rem; }
.required > .form-label::after, .required > label::after { content: " *"; color: #dc2626; }
.form-check.required > label::after { content: ""; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--bs-secondary-color); font-weight: 700; margin: .5rem 0 .75rem; padding-bottom: .4rem; border-bottom: 1px dashed var(--bs-border-color); }
.pagination { margin: 0; }
.ts-wrapper.form-select, .ts-wrapper.form-control { padding: 0; }
.ts-control { min-height: 38px; }
.badge { font-weight: 600; }
.money-input { text-align: right; }
.nowrap { white-space: nowrap; }
.cursor-pointer { cursor: pointer; }
.tabular { font-variant-numeric: tabular-nums; }
.photo-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: .5rem; border: 1px solid var(--bs-border-color); }
.thumb-sm { width: 44px; height: 44px; object-fit: cover; border-radius: .4rem; }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: .85rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.kanban-col { flex: 0 0 290px; background: var(--bs-tertiary-bg); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 190px); border: 1px solid var(--bs-border-color); }
.kanban-col-header { padding: .7rem .85rem; display: flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .85rem; border-bottom: 1px solid var(--bs-border-color); }
.kanban-col-header .dot { width: 10px; height: 10px; border-radius: 50%; }
.kanban-list { padding: .6rem; overflow-y: auto; flex: 1; min-height: 80px; }
.kanban-card { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-left: 4px solid var(--bs-border-color); border-radius: .6rem; padding: .6rem .7rem; margin-bottom: .55rem; cursor: grab; font-size: .84rem; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.kanban-card:hover { box-shadow: 0 4px 14px rgba(16,24,40,.1); }
.kanban-card.prio-alta { border-left-color: #f59e0b; }
.kanban-card.prio-urgente { border-left-color: #ef4444; }
.kanban-card.prio-baixa { border-left-color: #94a3b8; }
.kanban-card.prio-normal { border-left-color: #06b6d4; }
.kanban-card.late { background: rgba(239,68,68,.06); }
.kanban-card .os-no { font-weight: 700; }
.sortable-ghost { opacity: .4; }
.sortable-drag { transform: rotate(2deg); }

/* ---------- Linha do tempo ---------- */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 4px; bottom: 4px; width: 2px; background: var(--bs-border-color); }
.timeline li { position: relative; padding-left: 44px; padding-bottom: 1rem; }
.timeline .tl-icon { position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--bs-body-bg); border: 2px solid var(--bs-border-color); font-size: .8rem; }
.timeline .tl-meta { font-size: .78rem; color: var(--bs-secondary-color); }

/* ---------- PDV ---------- */
.pdv { display: grid; grid-template-columns: 1fr 380px; gap: 1rem; }
@media (max-width: 1199.98px) { .pdv { grid-template-columns: 1fr; } }
.pdv-search { position: relative; }
.pdv-search input { font-size: 1.15rem; padding: .8rem 1rem .8rem 2.8rem; border-radius: .75rem; }
.pdv-search > i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--bs-secondary-color); }
.pdv-results { position: absolute; z-index: 1050; left: 0; right: 0; top: calc(100% + 4px); background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: .75rem; box-shadow: 0 12px 32px rgba(0,0,0,.15); max-height: 380px; overflow-y: auto; }
.pdv-results .res { display: flex; align-items: center; gap: .75rem; padding: .6rem .9rem; cursor: pointer; border-bottom: 1px solid var(--bs-border-color); }
.pdv-results .res:last-child { border-bottom: 0; }
.pdv-results .res.active, .pdv-results .res:hover { background: rgba(79,70,229,.1); }
.pdv-total { font-size: 2.1rem; font-weight: 800; letter-spacing: -.02em; }
.pdv-items td { vertical-align: middle; }
.pdv-items input.form-control-sm { max-width: 95px; }
.kbd-hint kbd { font-size: .7rem; }
.type-pill { font-size: .65rem; padding: .2rem .45rem; border-radius: 1rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.type-produto { background: rgba(79,70,229,.12); color: #4f46e5; }
.type-servico { background: rgba(16,185,129,.14); color: #059669; }
[data-bs-theme="dark"] .type-produto { color: #a5b4fc; } [data-bs-theme="dark"] .type-servico { color: #34d399; }

/* ---------- Assinatura ---------- */
.signature-box { border: 2px dashed var(--bs-border-color); border-radius: .75rem; background: #fff; position: relative; touch-action: none; }
.signature-box canvas { width: 100%; height: 200px; display: block; border-radius: .75rem; }

/* ---------- Login ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(1200px 600px at 10% -10%, rgba(79,70,229,.25), transparent), radial-gradient(900px 500px at 110% 110%, rgba(6,182,212,.2), transparent); }
.auth-card { width: 100%; max-width: 400px; }

/* ---------- Impressão ---------- */
@media print {
    .app-sidebar, .app-topbar, .no-print, .toast-container { display: none !important; }
    .app-content { padding: 0 !important; }
    body { background: #fff !important; }
    .card { border: 0 !important; box-shadow: none !important; }
}

/* ---------- Gráficos (paleta validada) ---------- */
.viz-root { --surface-1: #ffffff; --text-primary: #191919; --text-secondary: #666666; --grid: #e7e7e7; --axis: #c2c2c2; --series-1: #257de0; --series-2: #f47230; }
[data-bs-theme="dark"] .viz-root { --surface-1: #111a2e; --text-primary: #efefef; --text-secondary: #9c9c9c; --grid: #26324c; --axis: #3a4763; --series-1: #338ced; --series-2: #e76624; }
.legend-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: baseline; }
.key-s1 { background: var(--series-1); } .key-s2 { background: var(--series-2); }
.chart-box { position: relative; height: 280px; }
.meter { height: 10px; border-radius: 6px; background: var(--bs-tertiary-bg); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 6px; background: var(--series-1, #257de0); }
.meter.warn > span { background: #fbb315; } .meter.crit > span { background: #dc3c3d; }
.mini-bar { height: 6px; border-radius: 4px; background: var(--bs-tertiary-bg); overflow: hidden; }
.mini-bar > span { display: block; height: 100%; background: #257de0; border-radius: 4px; }
[data-bs-theme="dark"] .mini-bar > span, [data-bs-theme="dark"] .meter:not(.warn):not(.crit) > span { background: #338ced; }
[x-cloak] { display: none !important; }
.qr svg { width: 100%; height: 100%; } .qr svg path { fill: #000; }
/* x-show (Alpine) precisa vencer utilitários do Bootstrap com !important (d-flex etc.) */
[style*="display: none"] { display: none !important; }
@media (max-width: 575.98px) {
    .card.stat-card .value { font-size: 1.15rem; white-space: nowrap; }
    .card.stat-card .icon { display: none; }
    .page-header h1 { font-size: 1.15rem; }
    .kanban-col { flex-basis: 85vw; }
}
