/* ==========================================================================
   Inventário — estilos
   As cores principais (--primary, --sidebar) vêm da Personalização.
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-contrast: #fff;
  --sidebar: #0f172a;
  --sidebar-text: #fff;
  --primary-soft: color-mix(in srgb, var(--primary) 10%, #fff);
  --primary-strong: color-mix(in srgb, var(--primary) 82%, #000);
  --bg: #f4f6fa;
  --surface: #fff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0891b2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
  --sidebar-w: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.125rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75em; }
code, .mono { font-family: var(--mono); font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }
.print-only { display: none; }

/* ---------- Estrutura ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column;
  background: var(--sidebar); color: var(--sidebar-text);
}
.sidebar a { color: inherit; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.1rem 1rem; text-decoration: none !important; }
.brand-logo { width: 38px; height: 38px; object-fit: contain; border-radius: 8px; background: #fff; padding: 3px; }
.brand-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--primary); color: var(--primary-contrast); font-size: 1.15rem; flex: none; }
.brand-text { font-weight: 700; font-size: 1.02rem; line-height: 1.2; overflow: hidden; }
.brand-text small { display: block; font-weight: 400; font-size: .75rem; opacity: .65; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { flex: 1; overflow-y: auto; padding: .25rem .65rem 1rem; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 8px; margin: 1px 0; opacity: .78; font-weight: 500; text-decoration: none; }
.nav a i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.nav a:hover { opacity: 1; background: color-mix(in srgb, var(--sidebar-text) 8%, transparent); }
.nav a.active { opacity: 1; background: var(--primary); color: var(--primary-contrast); }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .5; padding: 1rem .75rem .35rem; font-weight: 600; }
.sidebar-user { display: flex; align-items: center; gap: .55rem; padding: .85rem; border-top: 1px solid color-mix(in srgb, var(--sidebar-text) 12%, transparent); }
.sidebar-user .who { flex: 1; min-width: 0; line-height: 1.2; }
.sidebar-user .who strong { display: block; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who small { opacity: .6; font-size: .75rem; }
.sidebar-user .icon-btn { color: inherit; opacity: .75; }
.sidebar-user .icon-btn:hover { opacity: 1; background: color-mix(in srgb, var(--sidebar-text) 10%, transparent); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--primary-contrast); font-weight: 700; font-size: .8rem; flex: none; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .75rem; padding: .7rem 1.5rem; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar-search { flex: 1; max-width: 520px; position: relative; }
.topbar-search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar-search input { width: 100%; padding: .55rem .8rem .55rem 2.2rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font: inherit; }
.topbar-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.menu-btn { display: none; }
.content { flex: 1; padding: 1.5rem; width: 100%; max-width: 1400px; }
.footer { padding: 1rem 1.5rem 1.5rem; color: var(--muted); font-size: .8rem; }
.sidebar-backdrop { display: none; }

/* ---------- Cabeçalho de página ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-header h1 { margin: 0; }
.page-header p { margin: .25rem 0 0; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; line-height: 1.2;
  cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.btn:disabled, .btn.disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-danger { background: var(--surface); border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: color-mix(in srgb, var(--text) 6%, transparent); border-color: transparent; }
.btn-sm { padding: .38rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1.05rem; text-decoration: none !important; }
.icon-btn:hover { background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--text); }

/* ---------- Cartões ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .9rem 1.15rem; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { margin: 0; font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
.card-header h2 i, .card-header h3 i { color: var(--primary); }
.card-body { padding: 1.15rem; }
.card-body.p-0 { padding: 0; }
.card-footer { padding: .85rem 1.15rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }

.grid { display: grid; gap: 1.25rem; margin-bottom: 1.25rem; }
.grid > .card { margin-bottom: 0; }
.grid > div:not(.card) { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
.grid > div:not(.card) > .card, .grid > div:not(.card) > form > .card { margin-bottom: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.grid-list-form { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }

/* ---------- Indicadores ---------- */
.stat { display: flex; gap: .9rem; align-items: center; padding: 1.1rem; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; background: var(--primary-soft); color: var(--primary); flex: none; }
.stat-value { font-size: 1.55rem; font-weight: 750; line-height: 1.1; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: .85rem; }

.bars { display: flex; flex-direction: column; gap: .7rem; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem .75rem; align-items: center; font-size: .9rem; }
.bar-row .bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-value { font-weight: 650; font-variant-numeric: tabular-nums; }
.bar-track { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--c, var(--primary)); }

/* ---------- Formulários ---------- */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem; }
.col-12 { grid-column: span 12; } .col-8 { grid-column: span 8; } .col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field > label, .label { font-weight: 600; font-size: .85rem; color: color-mix(in srgb, var(--text) 85%, #fff); }
.field .req { color: var(--danger); }
.hint { font-size: .8rem; color: var(--muted); }
.error-text { font-size: .8rem; color: var(--danger); }
.input, select.input, textarea.input {
  width: 100%; padding: .55rem .75rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; line-height: 1.35; min-height: 40px;
}
textarea.input { min-height: 92px; resize: vertical; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.is-invalid { border-color: var(--danger); }
.input-group { display: flex; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .addon { display: flex; align-items: center; padding: 0 .75rem; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.input-group .input + .input { border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; max-width: 110px; }
.check { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 500; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.checks { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.color-field { display: flex; gap: .5rem; align-items: center; }
.color-field input[type=color] { width: 46px; height: 40px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 3px; background: #fff; cursor: pointer; }
.color-field { flex-wrap: wrap; }
.color-field input[type=text] { flex: 1 1 120px; width: auto; min-width: 0; }
.color-field .check { flex: 0 0 100%; }
.color-field input:disabled { opacity: .45; }
.theme-preview { display: grid; grid-template-columns: 150px minmax(0, 1fr); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-height: 210px; font-size: .85rem; }
.tp-sidebar { background: var(--tp-sidebar); color: var(--tp-sidebar-text); padding: .75rem .5rem; display: flex; flex-direction: column; gap: .2rem; }
.tp-brand { font-weight: 700; padding: .2rem .45rem .6rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-item { padding: .4rem .5rem; border-radius: 6px; opacity: .8; white-space: nowrap; overflow: hidden; }
.tp-item.active { background: var(--tp-primary); color: var(--tp-button-text); opacity: 1; }
.tp-main { background: var(--bg); color: var(--tp-text); padding: .9rem; display: flex; flex-direction: column; gap: .45rem; align-items: flex-start; min-width: 0; }
.tp-title { font-weight: 750; font-size: 1.05rem; }
.tp-muted { color: var(--tp-muted); font-size: .8rem; }
.tp-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: .55rem .7rem; display: flex; flex-direction: column; width: 100%; }
.tp-btn { background: var(--tp-primary); color: var(--tp-button-text); padding: .35rem .7rem; border-radius: 6px; font-weight: 600; }
.form-section { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin: .5rem 0 -.25rem; grid-column: 1 / -1; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1rem; }

/* ---------- Filtros ---------- */
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.filters .field { flex: 1 1 160px; }
.filters .field.grow { flex: 2 1 260px; }
.filters .filter-actions { display: flex; gap: .5rem; }
details.more-filters { width: 100%; }
details.more-filters summary { cursor: pointer; color: var(--primary); font-weight: 550; font-size: .88rem; list-style: none; display: inline-flex; gap: .35rem; align-items: center; }
details.more-filters summary::-webkit-details-marker { display: none; }
details.more-filters .filters { margin-top: .75rem; }

/* ---------- Tabelas ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .65rem .85rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; background: var(--surface-2); white-space: nowrap; }
.table tbody tr:hover { background: color-mix(in srgb, var(--primary) 3%, #fff); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border); }
.table .check-col { width: 38px; }
.table .thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); display: block; }
.table .thumb-empty { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.item-name { font-weight: 600; color: var(--text); }
.item-sub { font-size: .8rem; color: var(--muted); }
.tag { font-family: var(--mono); font-size: .85rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .08rem .4rem; white-space: nowrap; color: var(--text); }
.row-actions { display: flex; gap: .15rem; justify-content: flex-end; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Selos ---------- */
.badge { --c: #64748b; display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 650; white-space: nowrap; color: color-mix(in srgb, var(--c) 85%, #000); background: color-mix(in srgb, var(--c) 13%, #fff); border: 1px solid color-mix(in srgb, var(--c) 28%, #fff); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.badge-muted { --c: #94a3b8; }
.pill { display: inline-block; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .75rem; color: var(--muted); font-weight: 600; }
.pill-ok { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.pill-off { background: #f8fafc; color: #94a3b8; }

/* ---------- Alertas ---------- */
.alert { display: flex; align-items: flex-start; gap: .6rem; padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid; font-size: .92rem; }
.alert > i { font-size: 1.1rem; margin-top: .05rem; }
.alert > span { flex: 1; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }
.alert-close { border: 0; background: none; font-size: 1.3rem; line-height: 1; cursor: pointer; color: inherit; opacity: .6; padding: 0 .2rem; }
.alert ul { margin: .25rem 0 0; padding-left: 1.1rem; }

/* ---------- Estado vazio ---------- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state > i { font-size: 2.6rem; color: var(--border-strong); display: block; margin-bottom: .5rem; }
.empty-state h2 { color: var(--text); }

/* ---------- Paginação ---------- */
.pagination { display: flex; gap: .25rem; flex-wrap: wrap; align-items: center; }
.pagination a, .pagination span { min-width: 34px; height: 34px; padding: 0 .5rem; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: .88rem; text-decoration: none; }
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); font-weight: 650; }
.pagination .disabled { opacity: .4; }
.pagination .gap { border: 0; background: none; }
.list-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .85rem 1.15rem; border-top: 1px solid var(--border); }

/* ---------- Barra de seleção em massa ---------- */
.bulk-bar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .7rem 1.15rem; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: .9rem; }
.bulk-bar .count { margin-right: auto; color: var(--muted); }

/* ---------- Detalhes do material ---------- */
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0; }
.detail-list > div { padding: .75rem 1.15rem; border-bottom: 1px solid var(--border); min-width: 0; }
.detail-list > div:nth-child(odd) { border-right: 1px solid var(--border); }
.detail-list dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: .15rem; }
.detail-list dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.detail-list .full { grid-column: 1 / -1; border-right: 0 !important; }
.detail-list dd.text { font-weight: 400; white-space: pre-line; }
.item-hero { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.item-hero .meta { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .4rem; }
.qr-box { width: 100%; max-width: 220px; margin: 0 auto; aspect-ratio: 1; }
.qr-box svg { width: 100%; height: 100%; display: block; }
.photo-box { border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.photo-box img { display: block; width: 100%; max-height: 320px; object-fit: contain; }
.route { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-weight: 550; }
.route i { color: var(--muted); }

/* ---------- Linha do tempo ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 17px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 1.25rem 3.1rem; }
.timeline li:last-child { padding-bottom: 0; }
.tl-icon { position: absolute; left: 0; top: 0; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--c, var(--primary)); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.tl-head { display: flex; gap: .5rem; flex-wrap: wrap; align-items: baseline; }
.tl-head strong { font-weight: 650; }
.tl-meta { color: var(--muted); font-size: .82rem; }
.tl-changes { margin: .4rem 0 0; padding: .5rem .75rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .86rem; list-style: none; }
.tl-changes li { padding: .15rem 0; }
.tl-changes .old { color: var(--muted); text-decoration: line-through; }
.tl-changes .arrow { color: var(--muted); margin: 0 .3rem; }
.tl-note { margin-top: .4rem; padding: .5rem .75rem; border-left: 3px solid var(--c, var(--primary)); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: .9rem; white-space: pre-line; }

/* ---------- Abas ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs a { padding: .65rem 1rem; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; display: inline-flex; gap: .4rem; align-items: center; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--primary); border-color: var(--primary); }

/* ---------- Relatórios ---------- */
.report-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.report-type { display: flex; gap: .75rem; padding: .9rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none !important; box-shadow: var(--shadow); transition: border-color .15s; }
.report-type i { font-size: 1.25rem; color: var(--primary); }
.report-type strong { display: block; font-size: .92rem; }
.report-type span { font-size: .78rem; color: var(--muted); line-height: 1.35; display: block; }
.report-type:hover { border-color: var(--primary); }
.report-type.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary); }
.report-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.report-head img { max-height: 48px; }
.report-head h1 { font-size: 1.3rem; margin: 0; }
.report-summary { display: flex; gap: 1.5rem; flex-wrap: wrap; padding: .85rem 1.15rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
.report-summary strong { font-size: 1.05rem; }

/* ---------- Login / instalador ---------- */
.bare { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 410px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 2rem; }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand img { max-height: 64px; margin-bottom: .5rem; }
.auth-brand .brand-icon { width: 54px; height: 54px; font-size: 1.6rem; margin: 0 auto .75rem; border-radius: 14px; }
.auth-brand h1 { font-size: 1.35rem; margin: 0; }
.auth-card form { display: grid; gap: 1rem; }
.install-card { max-width: 640px; }
.steps { display: flex; gap: .5rem; margin-bottom: 1.5rem; }
.steps span { flex: 1; height: 5px; border-radius: 99px; background: var(--border); }
.steps span.done { background: var(--primary); }
.req-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.req-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.ok { color: var(--success); font-weight: 600; }
.fail { color: var(--danger); font-weight: 600; }

/* ---------- Página pública do QR ---------- */
.public-card { width: 100%; max-width: 460px; }
.public-card .card-body { display: grid; gap: .75rem; }

/* ---------- Etiquetas ---------- */
.label-sheet { display: flex; flex-wrap: wrap; gap: 3mm; align-content: flex-start; }
.etq {
  width: var(--lw); height: var(--lh); padding: 2.2mm; background: #fff; color: #000;
  border: 1px dashed #b6bfcc; border-radius: 2mm; display: flex; gap: 2.2mm; align-items: stretch;
  overflow: hidden; break-inside: avoid; page-break-inside: avoid; font-family: Arial, Helvetica, sans-serif;
}
.etq.square { flex-direction: column; align-items: center; text-align: center; }
.etq .l-qr { height: 100%; aspect-ratio: 1; flex: none; }
.etq.square .l-qr { height: auto; width: 62%; }
.etq .l-qr svg { width: 100%; height: 100%; display: block; }
.etq .l-text { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: .6mm; line-height: 1.12; }
.etq .l-logo { max-height: 5.5mm; max-width: 100%; object-fit: contain; object-position: left; }
.etq.square .l-logo { object-position: center; }
.etq .l-company { font-size: calc(var(--fs) * .78); font-weight: 700; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.etq .l-name { font-size: var(--fs); font-weight: 700; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.etq .l-tag { font-family: "Courier New", monospace; font-weight: 700; font-size: calc(var(--fs) * 1.25); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.etq .l-small { font-size: calc(var(--fs) * .8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label-preview { background: #e9edf3; padding: 1rem; border-radius: var(--radius); overflow: auto; }

/* ---------- Ficha ---------- */
.sheet { max-width: 900px; margin: 0 auto; background: #fff; padding: 2rem; border: 1px solid var(--border); border-radius: var(--radius); }
.sheet-toolbar { max-width: 900px; margin: 1rem auto; display: flex; gap: .5rem; justify-content: flex-end; }
.sheet-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; border-bottom: 2px solid #0f172a; padding-bottom: 1rem; margin-bottom: 1rem; }
.sheet-head img { max-height: 54px; }
.sheet table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.sheet th, .sheet td { border: 1px solid #cbd5e1; padding: .4rem .55rem; text-align: left; vertical-align: top; }
.sheet th { background: #f1f5f9; width: 26%; font-weight: 600; }
.sheet .hist th { width: auto; }
.sheet-qr { width: 120px; }

/* ---------- Termos: documento ---------- */
.doc-wrap { background: #e9edf3; padding: 1.25rem; border-radius: var(--radius); overflow-x: auto; }
.doc {
  background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 2.5rem 2.75rem; box-shadow: var(--shadow-lg);
  font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.65; border-radius: 4px;
}
.doc h1, .doc h2, .doc h3, .doc h4 { font-family: var(--font); color: #111; margin: 0 0 .6em; }
.doc h2 { font-size: 1.25rem; letter-spacing: .02em; }
.doc h3 { font-size: 1.05rem; }
.doc p { margin: 0 0 .9em; text-align: justify; }
.doc ol, .doc ul { margin: 0 0 1em; padding-left: 1.6em; }
.doc li { margin-bottom: .35em; text-align: justify; }
.doc table { width: 100%; border-collapse: collapse; margin: .4em 0 1.2em; font-family: var(--font); font-size: 13px; }
.doc th, .doc td { border: 1px solid #94a3b8; padding: .35em .5em; text-align: left; vertical-align: top; }
.doc th { background: #f1f5f9; font-weight: 650; }
.doc tfoot td { font-weight: 700; background: #f8fafc; }
.doc hr { border-top: 1px solid #94a3b8; }
.doc blockquote { margin: 0 0 1em; padding-left: 1em; border-left: 3px solid #cbd5e1; color: #334155; }
.sig-block { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; margin-top: 2.5rem; font-family: var(--font); page-break-inside: avoid; }
.sig-col { text-align: center; min-width: 0; }
.sig-space { height: 70px; }
.sig-img { height: 70px; max-width: 100%; object-fit: contain; display: block; margin: 0 auto; }
.sig-line { border-top: 1px solid #111; margin: .2rem 0 .35rem; }
.sig-name { font-weight: 650; font-size: 13.5px; }
.sig-meta { font-size: 11.5px; color: #475569; }
.sig-evidence { margin-top: 1.25rem; padding: .6rem .8rem; border: 1px dashed #94a3b8; border-radius: 6px; font: 11.5px/1.5 var(--font); color: #334155; text-align: center; page-break-inside: avoid; }
.term-sheet { padding: 1.5rem 2rem; }
.term-sheet .doc { box-shadow: none; padding: .5rem 0 0; max-width: none; }
.sheet-foot { margin-top: 1.5rem; padding-top: .5rem; border-top: 1px solid #cbd5e1; font-size: 11px; color: #64748b; text-align: center; }
.cancel-stamp { border: 3px solid #dc2626; color: #dc2626; font-weight: 800; text-align: center; padding: .4rem; margin-bottom: 1rem; letter-spacing: .05em; }

/* ---------- Termos: assinatura ---------- */
.sign-body { background: var(--bg); }
.sign-body .bare { display: block; padding: 1rem; }
.sign-page { max-width: 880px; margin: 0 auto; }
.sign-head { display: flex; gap: .8rem; align-items: center; margin: .5rem 0 1rem; }
.sign-head img { max-height: 44px; }
.sigpad { position: relative; border: 2px dashed var(--border-strong); border-radius: var(--radius-sm); background: #fff; height: 210px; touch-action: none; }
.sigpad canvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; border-radius: var(--radius-sm); }
.sigpad-hint { position: absolute; left: 50%; bottom: 30%; transform: translateX(-50%); color: #94a3b8; pointer-events: none; font-size: .95rem; white-space: nowrap; }
.sigpad::after { content: ""; position: absolute; left: 8%; right: 8%; bottom: 28%; border-bottom: 1px solid #cbd5e1; pointer-events: none; }
.sigpad-clear { position: absolute; right: .5rem; top: .5rem; }

/* ---------- Editor de texto ---------- */
.editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem; padding: .5rem .6rem; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; position: sticky; top: 57px; z-index: 5; }
.editor-toolbar .sep { width: 1px; height: 22px; background: var(--border-strong); margin: 0 .3rem; }
.editor-toolbar .icon-btn { width: 32px; height: 32px; color: var(--text); }
.editor-toolbar .placeholder-select { width: auto; min-height: 32px; padding: .3rem .5rem; margin-left: auto; font-size: .85rem; }
.editor { outline: none; min-height: 420px; }
.editor:focus { box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow-lg); }
.placeholder-help { max-height: 70vh; overflow-y: auto; }
.ph-chip { display: flex; width: 100%; justify-content: space-between; gap: .5rem; align-items: center; padding: .35rem .5rem; margin-bottom: .25rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; text-align: left; font: inherit; }
.ph-chip:hover { border-color: var(--primary); background: var(--primary-soft); }
.ph-chip code { font-size: .78rem; color: var(--primary-strong); }
.ph-chip span { font-size: .78rem; color: var(--muted); text-align: right; }

/* ---------- Seletor de materiais ---------- */
.picker { position: relative; }
.picker > i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.picker > .input { padding-left: 2.2rem; }
.picker-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; }
.picker-results button { display: flex; width: 100%; gap: .6rem; align-items: center; padding: .55rem .8rem; border: 0; border-bottom: 1px solid var(--border); background: none; text-align: left; cursor: pointer; font: inherit; }
.picker-results button:hover, .picker-results button:focus { background: var(--primary-soft); outline: none; }
.picker-results button:disabled { opacity: .5; cursor: default; }
.picker-results .holder { margin-left: auto; font-size: .78rem; color: var(--warning); white-space: nowrap; }
.picker-results .none { padding: .75rem; color: var(--muted); font-size: .9rem; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main, .grid-list-form { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15, 23, 42, .45); }
  .main { margin-left: 0; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: .6rem 1rem; }
  .content { padding: 1rem; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .col-8, .col-6, .col-4, .col-3 { grid-column: span 12; }
  .detail-list { grid-template-columns: minmax(0, 1fr); }
  .detail-list > div { border-right: 0 !important; }
  .hide-sm { display: none; }
  .doc-wrap { padding: .5rem; }
  .doc { padding: 1.25rem 1.1rem; font-size: 14.5px; }
  .sig-block { gap: 1.25rem; }
  .editor-toolbar { top: 53px; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  h1 { font-size: 1.3rem; }
}

/* ---------- Impressão ---------- */
@media print {
  body { background: #fff; font-size: 11px; }
  .sidebar, .topbar, .footer, .no-print, .alert, .pagination, .bulk-bar, .sidebar-backdrop { display: none !important; }
  .print-only { display: block !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; margin: 0 0 8px; }
  .card-header, .card-body { padding-left: 0; padding-right: 0; }
  .table th, .table td { padding: 4px 6px; border-bottom: 1px solid #ddd; }
  .table th { background: #f1f5f9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .table-wrap { overflow: visible; }
  .badge, .bar-fill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit; text-decoration: none; }
  .sheet { border: 0; padding: 0; max-width: none; }
  .label-preview { background: none; padding: 0; }
  .label-sheet.cut-off .etq { border-color: transparent; }
  .doc-wrap { background: none; padding: 0; }
  .doc { box-shadow: none; padding: 0; max-width: none; font-size: 12pt; }
  .doc th { background: #f1f5f9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sign-body .bare { padding: 0; }
  tr { page-break-inside: avoid; }
}
