/* ============================================================
   INCORPORA PRÉ-MOLDADOS — identidade visual
   Cores do manual: Black C #0F0F13 · 7510 U #BE8B60 · 179-5 C #B4B4B4 · 179-1 C #F2F1F0
   Fontes: Mansory (títulos) · Montserrat (texto)
   ============================================================ */

/* Mansory não está no Google Fonts; enquanto isso, os títulos usam Playfair Display.
   Para usar a Mansory: coloque o arquivo em fonts/Mansory.woff2 e tire este bloco do comentário.
@font-face {
  font-family: "Mansory";
  src: url("../fonts/Mansory.woff2") format("woff2");
  font-display: swap;
}
*/

:root {
  --preto: #0F0F13;
  --cobre: #BE8B60;
  --cinza: #B4B4B4;
  --offwhite: #F2F1F0;

  --bg: var(--offwhite);
  --surface: #FFFFFF;
  --surface-2: #F8F7F5;
  --text: var(--preto);
  --muted: #5F5F68;
  --line: #E3E1DD;
  --accent: var(--cobre);
  --accent-ink: #85582F;      /* cobre escurecido para texto sobre fundo claro */
  --accent-soft: #F3E9DF;
  --ok: #2E7A57;
  --ok-soft: #E3F1EA;
  --warn: #A76712;
  --warn-soft: #FBEFD9;
  --danger: #B23A33;
  --danger-soft: #F8E2E0;
  --side-bg: var(--preto);
  --side-text: #D9D8D5;
  --destaque-bg: var(--preto);      /* cards e botões escuros */
  --destaque-borda: var(--preto);
  --destaque-texto: var(--offwhite);
  --destaque-muted: #A9A9B1;

  --font-title: "Mansory", "Playfair Display", Georgia, serif;
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 15, 19, .05), 0 4px 16px rgba(15, 15, 19, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F0F13; --surface: #17171C; --surface-2: #1E1E25; --text: #F2F1F0; --muted: #A3A3AC;
    --line: #2A2A33; --accent-ink: #D7AA82; --accent-soft: #2A2119; --ok: #5DBB8E; --ok-soft: #15281F;
    --warn: #E0A14A; --warn-soft: #2C2213; --danger: #E77A72; --danger-soft: #2E1716;
    --side-bg: #09090C; --shadow: none; color-scheme: dark;
    --destaque-bg: #241C15; --destaque-borda: #4A3828; --destaque-texto: #F2F1F0; --destaque-muted: #C9B5A2;
  }
}
:root[data-theme="dark"] {
  --bg: #0F0F13; --surface: #17171C; --surface-2: #1E1E25; --text: #F2F1F0; --muted: #A3A3AC;
  --line: #2A2A33; --accent-ink: #D7AA82; --accent-soft: #2A2119; --ok: #5DBB8E; --ok-soft: #15281F;
  --warn: #E0A14A; --warn-soft: #2C2213; --danger: #E77A72; --danger-soft: #2E1716;
  --side-bg: #09090C; --shadow: none; color-scheme: dark;
  --destaque-bg: #241C15; --destaque-borda: #4A3828; --destaque-texto: #F2F1F0; --destaque-muted: #C9B5A2;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.app { min-height: 100dvh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--preto);
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  display: flex; align-items: center; justify-content: center;
}
.topbar-logo img { height: 22px; width: auto; }
.main { padding: 18px 16px calc(96px + var(--safe-b)); max-width: 1180px; margin: 0 auto; outline: none; min-width: 0; }
.loading { padding: 60px 0; text-align: center; color: var(--muted); }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--preto); padding: 6px 4px calc(6px + var(--safe-b));
  border-top: 1px solid #22222a;
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-decoration: none; color: #9D9DA5; font-size: 11px; font-weight: 500; padding: 6px 0; border-radius: 10px;
}
.bottomnav a svg { width: 22px; height: 22px; }
.bottomnav a.active { color: var(--cobre); }

.fab {
  position: fixed; right: 16px; bottom: calc(76px + var(--safe-b)); z-index: 31;
  width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--cobre); color: var(--preto); font-size: 30px; font-weight: 500; line-height: 1;
  box-shadow: 0 6px 20px rgba(0,0,0,.28);
}

@media (min-width: 960px) {
  .app { display: grid; grid-template-columns: 252px minmax(0, 1fr); }
  .topbar, .bottomnav, .fab { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100dvh;
    background: var(--side-bg); color: var(--side-text); padding: 26px 16px 20px;
  }
  .sidebar-logo { display: block; padding: 4px 18px 22px; }
  .sidebar-logo img { width: 100%; max-width: 170px; margin: 0 auto; }
  .sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  .sidebar-nav a {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px;
    text-decoration: none; font-weight: 500; font-size: 14px; color: var(--side-text);
  }
  .sidebar-nav a svg { width: 19px; height: 19px; opacity: .75; }
  .sidebar-nav a:hover { background: #1B1B22; }
  .sidebar-nav a.active { background: #1F1A16; color: var(--cobre); }
  .sidebar-nav a.active svg { opacity: 1; }
  .sidebar-cta { width: 100%; }
  .install-btn {
    margin-top: 8px; background: none; border: 1px solid #33333c; color: var(--side-text);
    border-radius: 10px; padding: 9px; font-size: 13px; cursor: pointer;
  }
  .main { padding: 32px 36px 48px; width: 100%; }
}

/* ---------- Cabeçalho de página ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-family: var(--font-title); font-weight: 600; font-size: 28px; letter-spacing: -.01em; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: 4px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
/* Botão de voltar (topo das páginas internas) */
.back {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  min-height: 36px; padding: 0 14px 0 10px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--text); text-decoration: none; font-size: 13px; font-weight: 600;
  transition: border-color .15s, background .15s;
}
.back svg { width: 18px; height: 18px; flex: none; color: var(--accent-ink); stroke-width: 2.2; transition: transform .15s; }
.back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back:hover { border-color: var(--accent); background: var(--accent-soft); }
.back:hover svg { transform: translateX(-3px); }
.back:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--cinza); }
.btn-primary { background: var(--cobre); border-color: var(--cobre); color: var(--preto); }
.btn-primary:hover { background: #C99A71; border-color: #C99A71; }
.btn-dark { background: var(--destaque-bg); border-color: var(--destaque-borda); color: var(--destaque-texto); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 38px; min-height: 38px; padding: 0; }
.btn svg { width: 18px; height: 18px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Cartões e grade ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2, .section-title { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.card-head a { font-size: 13px; color: var(--accent-ink); text-decoration: none; font-weight: 600; }
.grid { display: grid; gap: 14px; }
.grid-2 { display: grid; gap: 14px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.stack > * + * { margin-top: 14px; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); text-decoration: none; display: block; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-note { font-size: 12px; color: var(--muted); }
.kpi.dark { background: var(--destaque-bg); border-color: var(--destaque-borda); color: var(--destaque-texto); }
.kpi.dark .kpi-label, .kpi.dark .kpi-note { color: var(--destaque-muted); }
.kpi.dark .kpi-value { color: var(--cobre); }

.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 760px) { .quick { grid-template-columns: repeat(4, 1fr); } }
.quick button {
  display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; font-weight: 600; font-size: 14px;
}
.quick button:hover { border-color: var(--cobre); }
.quick .qi { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.quick .qi svg { width: 18px; height: 18px; }

/* ---------- Listas ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: 12px; padding: 11px 2px; text-decoration: none; color: inherit; width: 100%;
  background: none; border: 0; text-align: left; cursor: pointer;
}
.row:hover .row-title { color: var(--accent-ink); }
.row-main { flex: 1; min-width: 0; }
.row-title, .row-sub { display: block; }
.row-title { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12.5px; color: var(--muted); }
.row-qty { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.row-qty small { font-weight: 500; font-size: 11px; color: var(--muted); display: block; }
.thumb {
  width: 44px; height: 44px; border-radius: 10px; flex: none; object-fit: cover;
  background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .ph { width: 20px; opacity: .55; }
.qtybox {
  min-width: 52px; height: 36px; padding: 0 8px; border-radius: 9px; display: grid; place-items: center; flex: none;
  font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px;
}
.empty { text-align: center; color: var(--muted); padding: 22px 8px; font-size: 14px; }

/* ---------- Selos ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; 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-neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge-accent { background: var(--accent-soft); color: var(--accent-ink); }
.t-prod { background: var(--ok-soft); color: var(--ok); }
.t-saida { background: var(--accent-soft); color: var(--accent-ink); }
.t-entrada { background: #E4EDF7; color: #2D5F8F; }
.t-perda, .t-consumo { background: var(--danger-soft); color: var(--danger); }
.t-ajuste { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
:root[data-theme="dark"] .t-entrada { background: #16222F; color: #86B5E3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .t-entrada { background: #16222F; color: #86B5E3; } }

/* ---------- Filtros / abas ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.search {
  flex: 1 1 220px; min-height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  padding: 0 14px 0 38px; outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238a8a92' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 13px center;
}
.search:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--cobre); box-shadow: 0 0 0 3px rgba(190, 139, 96, .18); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; max-width: 100%; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--preto); color: var(--offwhite); border-color: var(--preto); }
:root[data-theme="dark"] .chip.active { background: var(--cobre); color: var(--preto); border-color: var(--cobre); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.active { background: var(--cobre); color: var(--preto); border-color: var(--cobre); } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 11px 14px; border: 0; background: none; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab.active { color: var(--text); border-bottom-color: var(--cobre); }
/* foco por teclado nas abas: fundo suave (o contorno ficava cortado pela barra de abas) */
.tabs .tab:focus-visible { outline: none; background: var(--accent-soft); border-radius: 8px 8px 0 0; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); padding: 4px; border-radius: 11px; }
.segmented button { border: 0; background: none; padding: 8px 6px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--muted); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---------- Formulários ---------- */
.form { display: grid; gap: 14px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
@media (min-width: 760px) { .form-grid.three { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .form-grid.four { grid-template-columns: repeat(4, 1fr); } }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  padding: 10px 12px; outline: none;
}
.field textarea { min-height: 84px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--muted); }
.input-affix { position: relative; }
.input-affix input { padding-left: 38px; }
.input-affix b { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--muted); font-weight: 600; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--cobre); margin-top: 2px; flex: none; }
fieldset { border: 0; margin: 0; padding: 0; }
legend { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 12px; padding: 0; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.table a { text-decoration: none; font-weight: 600; }
.table a:hover { color: var(--accent-ink); }
.table input { width: 100px; min-height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 6px 8px; text-align: right; }
.neg { color: var(--danger); }
.pos { color: var(--ok); }

.dl { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 0; margin: 0; }
.dl dt, .dl dd { padding: 9px 0; border-bottom: 1px solid var(--line); margin: 0; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { font-weight: 500; white-space: pre-wrap; }
.dl > :nth-last-child(-n+2) { border-bottom: 0; }

/* ---------- Peças ---------- */
.pecas-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .pecas-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .pecas-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
.peca-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.peca-card:hover { border-color: var(--cobre); }
.peca-img { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; border-bottom: 1px solid var(--line); }
.peca-img img { width: 100%; height: 100%; object-fit: cover; }
.peca-img .ph { width: 38px; opacity: .35; }
.peca-body { padding: 11px 12px 12px; display: grid; gap: 6px; }
.peca-name { font-weight: 600; font-size: 14px; line-height: 1.25; }
.peca-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.peca-meta strong { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }

.peca-hero { display: grid; gap: 16px; margin-bottom: 18px; }
@media (min-width: 760px) { .peca-hero { grid-template-columns: 300px 1fr; align-items: start; } }
.peca-hero-img { aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; }
.peca-hero-img img { width: 100%; height: 100%; object-fit: cover; }
.peca-hero-img .ph { width: 64px; opacity: .3; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat span { font-size: 11.5px; color: var(--muted); font-weight: 500; display: block; }
.stat b { font-size: 18px; font-variant-numeric: tabular-nums; }

.img-picker { display: flex; gap: 14px; align-items: center; }
.img-picker .peca-hero-img { width: 140px; flex: none; }

.receita-row { display: grid; grid-template-columns: 1fr 110px 38px; gap: 8px; align-items: center; }
.receita-row + .receita-row { margin-top: 8px; }

/* ---------- Diário ---------- */
.datebar { display: flex; align-items: center; gap: 6px; }
.datebar input { min-height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px; }
.day-section + .day-section { margin-top: 14px; }
.mv-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.mv-row + .mv-row { border-top: 1px solid var(--line); }
.mv-row .row-main { cursor: pointer; }
.mv-num { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 54px; text-align: right; font-size: 16px; }


/* ---------- Barras (produção 7 dias) ---------- */
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 150px; padding-top: 10px; }
.bar { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-fill { width: 100%; max-width: 34px; border-radius: 4px 4px 0 0; background: var(--cobre); min-height: 2px; }
.bar.today .bar-fill { background: var(--preto); }
:root[data-theme="dark"] .bar.today .bar-fill { background: var(--offwhite); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bar.today .bar-fill { background: var(--offwhite); } }
.bar-val { font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-lbl { font-size: 11px; color: var(--muted); }

/* ---------- Modal ---------- */
dialog.modal {
  border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
dialog.modal.wide { width: min(760px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(15, 15, 19, .55); backdrop-filter: blur(2px); }
.modal-inner { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px; gap: 10px; }
.modal-head h2 { font-size: 18px; font-weight: 700; }
.modal-body { padding: 6px 20px 16px; overflow-y: auto; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; border-top: 1px solid var(--line); }
@media (max-width: 600px) {
  dialog.modal, dialog.modal.wide { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 92dvh; }
  .modal-inner { max-height: 92dvh; }
  .modal-foot { padding-bottom: calc(18px + var(--safe-b)); }
  .modal-foot .btn { flex: 1; }
}
.stock-hint { font-size: 13px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stock-hint b { color: var(--text); }

/* ---------- Toast ---------- */
.toast-host { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-b)); z-index: 100; display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
@media (min-width: 960px) { .toast-host { bottom: 28px; } }
.toast { background: var(--preto); color: var(--offwhite); padding: 11px 16px; border-radius: 11px; font-size: 14px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.3); border-left: 3px solid var(--cobre); animation: toast-in .2s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 14px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.callout { background: var(--accent-soft); border: 1px solid #E6D3C1; color: var(--text); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13.5px; }
:root[data-theme="dark"] .callout { border-color: #3A2D21; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .callout { border-color: #3A2D21; } }
img.ph, .thumb img.ph, .peca-img img.ph, .peca-hero-img img.ph { height: auto; object-fit: contain; }
.more-list a { display: flex; align-items: center; gap: 14px; padding: 15px 4px; text-decoration: none; font-weight: 600; }
.more-list a svg { width: 20px; height: 20px; color: var(--accent-ink); }
.more-list li + li { border-top: 1px solid var(--line); }

/* ---------- Focus (teclado) ---------- */
button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }
.btn:focus-visible, .quick button:focus-visible, .chip:focus-visible, .tab:focus-visible, .row:focus-visible, .kpi:focus-visible {
  outline: 2px solid var(--cobre); outline-offset: 2px;
}

/* ---------- Resumo diário (documento sempre claro, para exportar) ---------- */
.rs-actions { margin-bottom: 16px; }
.rs-scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px 8px; }
.resumo-doc {
  --rs-ink: #0F0F13; --rs-cobre: #BE8B60; --rs-cobre-txt: #85582F; --rs-muted: #6A6A72; --rs-line: #E6E3DF; --rs-soft: #F7F5F2;
  background: #FFFFFF; color: var(--rs-ink); font-family: var(--font);
  max-width: 820px; margin: 0 auto; padding: 36px 40px 28px; border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 10px 30px rgba(0,0,0,.08); border: 1px solid #E8E6E2;
  font-size: 13px; line-height: 1.4;
}
.rs-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 2px solid var(--rs-ink); }
.rs-logo { width: 230px; height: auto; }
.rs-head-r { text-align: right; }
.rs-eyebrow { font-size: 10.5px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; color: var(--rs-cobre-txt); }
.rs-date { font-family: var(--font-title); font-size: 30px; font-weight: 600; line-height: 1.1; margin-top: 2px; }
.rs-weekday { font-size: 12px; color: var(--rs-muted); }

.rs-band { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--rs-ink); color: #F2F1F0; border-radius: 10px; margin-top: 20px; }
.rs-band .rs-kpi { padding: 14px 16px; border-left: 1px solid #2A2A32; }
.rs-band .rs-kpi:first-child { border-left: 0; }
.rs-band .rs-kpi b { color: var(--rs-cobre); font-size: 28px; }
.rs-band .rs-kpi span, .rs-band .rs-kpi small { color: #A9A9B1; }
.rs-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border: 1px solid var(--rs-line); border-radius: 10px; margin-top: 10px; }
.rs-kpis .rs-kpi { padding: 12px 16px; border-left: 1px solid var(--rs-line); }
.rs-kpis .rs-kpi:first-child { border-left: 0; }
.rs-kpi span { display: block; font-size: 11px; font-weight: 600; color: var(--rs-muted); }
.rs-kpi b { display: block; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; }
.rs-kpi small { display: block; font-size: 10.5px; color: var(--rs-muted); }

.rs-sec { margin-top: 24px; }
.rs-sec h3 {
  display: flex; align-items: center; gap: 8px; height: 18px; line-height: 18px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; margin: 0 0 8px;
}
.rs-sec h3::before { content: ""; width: 3px; height: 14px; background: var(--rs-cobre); flex: none; }
.rs-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rs-table th { text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--rs-muted); padding: 6px 8px; border-bottom: 1px solid var(--rs-ink); }
.rs-table td { padding: 6px 8px; border-bottom: 1px solid var(--rs-line); vertical-align: top; }
.rs-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rs-table tfoot td { font-weight: 700; border-top: 1.5px solid var(--rs-ink); border-bottom: 0; background: var(--rs-soft); }
.rs-sub { display: block; font-size: 11px; color: var(--rs-muted); }
.rs-vazio { color: var(--rs-muted); font-style: italic; text-align: center; padding: 12px 8px !important; }
.rs-cat td { background: var(--rs-soft); font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--rs-cobre-txt); padding-top: 7px; padding-bottom: 5px; }
.rs-estoque td { padding-top: 4px; padding-bottom: 4px; }
.rs-zero td { color: #9A3A33; }
.rs-pos { color: #2E7A57; font-weight: 600; }
.rs-neg { color: #B23A33; font-weight: 600; }
.rs-nulo { color: #B4B4B4; }
.rs-tag { display: inline-block; font-size: 9.5px; font-weight: 700; height: 16px; line-height: 16px; padding: 0 6px; border-radius: 99px; margin-left: 4px; vertical-align: middle; }
.rs-tag.zero { background: #F8E2E0; color: #B23A33; }
.rs-tag.baixo { background: #FBEFD9; color: #A76712; }
.rs-alertas { display: flex; flex-wrap: wrap; gap: 6px; }
.rs-pill { display: inline-block; font-size: 11.5px; font-weight: 600; height: 24px; line-height: 24px; padding: 0 10px; border-radius: 99px; white-space: nowrap; }
.rs-pill.zero { background: #F8E2E0; color: #B23A33; }
.rs-pill.baixo { background: #FBEFD9; color: #A76712; }
.rs-foot { display: flex; align-items: center; gap: 10px; margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--rs-line); font-size: 11px; color: var(--rs-muted); }
.rs-foot img { width: 18px; height: auto; }

@media (max-width: 640px) {
  .resumo-doc { padding: 20px 16px; font-size: 12px; }
  .resumo-doc .rs-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .resumo-doc .rs-head-r { text-align: left; }
  .resumo-doc .rs-logo { width: 180px; }
  .resumo-doc .rs-band, .resumo-doc .rs-kpis { grid-template-columns: repeat(2, 1fr); }
  .resumo-doc .rs-band .rs-kpi:nth-child(3) { border-left: 0; border-top: 1px solid #2A2A32; }
  .resumo-doc .rs-band .rs-kpi:nth-child(4) { border-top: 1px solid #2A2A32; }
  .resumo-doc .rs-kpis .rs-kpi:nth-child(3) { border-left: 0; }
  .resumo-doc .rs-kpis .rs-kpi:nth-child(n+3) { border-top: 1px solid var(--rs-line); }
  .resumo-doc .rs-band .rs-kpi b { font-size: 22px; }
  .resumo-doc .rs-table { font-size: 12px; }
  .resumo-doc .rs-table td, .resumo-doc .rs-table th { padding-left: 5px; padding-right: 5px; }
}

/* ---------- Login ---------- */
body.deslogado .app { display: none; }
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 32px 16px calc(32px + var(--safe-b));
  background: var(--preto) url("../assets/simbolo-cobre.png") no-repeat right -60px bottom -40px / 340px auto;
}
.login-box { width: 100%; max-width: 380px; display: grid; gap: 28px; }
.login-logo { width: 210px; margin: 0 auto; }
.login-card {
  background: var(--surface); color: var(--text); border-radius: 18px; padding: 26px 22px 22px;
  display: grid; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-card h1 { font-family: var(--font-title); font-weight: 600; font-size: 26px; }
.login-info { margin: -4px 0 0; color: var(--muted); font-size: 13.5px; }
.login-erro { margin: 0; color: var(--danger); background: var(--danger-soft); border-radius: 10px; padding: 9px 12px; font-size: 13.5px; font-weight: 500; }
.login-btn { width: 100%; min-height: 46px; margin-top: 4px; font-size: 15px; }

.sidebar-user { display: none; }
@media (min-width: 960px) {
  .sidebar-user {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    margin-top: 10px; padding: 10px 6px 0 10px; border-top: 1px solid #23232b; font-size: 13px; color: var(--side-text);
  }
  .sidebar-user span { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .sidebar-user span b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar-user svg { width: 17px; height: 17px; opacity: .7; flex: none; }
  .sidebar-user button { background: none; border: 1px solid #33333c; color: var(--side-text); border-radius: 8px; padding: 5px 10px; font-size: 12.5px; cursor: pointer; }
  .sidebar-user button:hover { border-color: var(--cobre); color: var(--cobre); }
}
.thumb svg { width: 20px; height: 20px; color: var(--accent-ink); }

/* ---------- Sincronização ---------- */
.sync { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--side-text); }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: #5DBB8E; flex: none; }
.sync-sinc i { background: var(--cobre); animation: pulsar 1.2s ease-in-out infinite; }
.sync-off i { background: #8A8A93; }
.sync-erro i { background: #E77A72; }
@keyframes pulsar { 50% { opacity: .35; } }
#sync-status { display: none; }
@media (min-width: 960px) { #sync-status { display: flex; margin-top: 12px; padding-left: 10px; } }
.topbar { position: sticky; }
#sync-topo { position: absolute; right: 14px; bottom: 15px; font-size: 11px; color: #A9A9B1; }
#sync-topo span { display: none; }
#sync-topo.sync-off span, #sync-topo.sync-erro span, #sync-topo.sync-sinc span { display: inline; }
.prep { text-align: center; padding: 36px 22px; max-width: 620px; margin: 30px auto; }
.prep img { width: 46px; margin: 0 auto 14px; }
.prep h2 { font-family: var(--font-title); font-weight: 600; font-size: 24px; margin-bottom: 8px; }
.login-rodape { text-align: center; font-size: 12.5px; margin: 0; }

/* ---------- Orçamento: linhas de itens ---------- */
.orc-item {
  display: grid; gap: 10px; align-items: end; padding: 12px 0; border-bottom: 1px solid var(--line);
  grid-template-columns: 1fr 1fr; grid-template-areas: "peca peca" "desc desc" "un qtd" "preco sub" "del del";
}
.orc-item:first-child { padding-top: 0; }
.orc-peca { grid-area: peca; } .orc-desc { grid-area: desc; } .orc-un { grid-area: un; } .orc-qtd { grid-area: qtd; }
.orc-preco { grid-area: preco; } .orc-sub { grid-area: sub; } .orc-del { grid-area: del; justify-self: end; }
.orc-sub b { display: flex; align-items: center; min-height: 44px; font-size: 15px; font-variant-numeric: tabular-nums; }
@media (min-width: 900px) {
  .orc-item { grid-template-columns: 1.3fr 1.6fr 70px 90px 120px 120px 38px; grid-template-areas: "peca desc un qtd preco sub del"; }
  .orc-del { justify-self: center; margin-bottom: 3px; }
}
.orc-total { display: flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 10px; background: var(--destaque-bg); color: var(--cobre); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pend-row .row-title a { text-decoration: none; }

.aviso-banco { margin-bottom: 16px; }

/* ---------- Barra lateral compacta: usuário e "Sair" sempre visíveis ---------- */
@media (min-width: 960px) {
  .sidebar { gap: 4px; padding: 18px 14px 14px; overflow: hidden; }
  .sidebar-logo { padding: 2px 18px 12px; flex: none; }
  .sidebar-logo img { max-width: 140px; }
  .sidebar-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #33333c transparent; }
  .sidebar-nav a { padding: 8px 14px; }
  .sidebar-cta, .install-btn, #sync-status, .sidebar-user { flex: none; }
  .sidebar-cta { margin-top: 8px; }
  .install-btn { margin-top: 4px; padding: 7px; }
  #sync-status { margin-top: 8px; }
  .sidebar-user { margin-top: 8px; padding-top: 8px; }
}
@media (min-width: 960px) and (max-height: 720px) {
  .sidebar-logo img { max-width: 110px; }
  .sidebar-nav a { padding: 6px 14px; font-size: 13.5px; }
  .sidebar-cta { min-height: 38px; }
}

/* Campos lado a lado alinhados pelo topo (um texto de ajuda não "estica" os vizinhos) */
.form-grid { align-items: start; }
.field { align-content: start; }
.orc-total { height: 44px; min-height: 0; }

/* Itens do orçamento: alinhados pelo topo (a linha "Estoque" não desloca os campos) */
.orc-item { align-items: start; }
@media (min-width: 900px) {
  .orc-del { align-self: start; margin-top: 27px; margin-bottom: 0; }
}

/* Diário: número na mesma linha do nome da peça */
.mv-row { align-items: baseline; }
.mv-row > .btn { align-self: center; }

/* Cards lado a lado não recebem o espaço de cards empilhados */
.grid-2 > .card + .card, .grid > .card + .card { margin-top: 0; }
/* Gráfico de produção ocupa a altura toda do card */
.card-grafico { display: flex; flex-direction: column; }
.card-grafico .bars { flex: 1; height: auto; min-height: 150px; }

/* ---------- Card "Instale o app" (Início) ---------- */
.instalar-card {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px;
  margin-bottom: 18px; padding: 18px 20px; overflow: hidden;
  background: var(--destaque-bg); border-color: var(--destaque-borda); color: var(--destaque-texto);
}
.instalar-card::after {
  content: ""; position: absolute; right: -40px; top: -60px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(190, 139, 96, .28), transparent 70%); pointer-events: none;
}
.instalar-icone { width: 56px; height: 56px; border-radius: 14px; box-shadow: 0 0 0 1px rgba(190, 139, 96, .45); }
.instalar-texto { min-width: 0; }
.instalar-card .eyebrow { color: var(--cobre); margin-bottom: 2px; }
.instalar-card h2 { font-family: var(--font-title); font-weight: 600; font-size: 20px; line-height: 1.2; }
.instalar-card p { color: var(--destaque-muted); font-size: 13.5px; margin-top: 4px; }
.instalar-passos { margin: 8px 0 0; padding-left: 18px; color: var(--destaque-texto); font-size: 13.5px; display: grid; gap: 4px; }
.instalar-ico { display: inline-flex; vertical-align: -3px; color: var(--cobre); }
.instalar-ico svg { width: 17px; height: 17px; }
.instalar-acoes { position: relative; z-index: 1; display: flex; gap: 6px; padding-right: 26px; }
.instalar-acoes .btn-ghost { color: var(--destaque-muted); }
.instalar-acoes .btn-ghost:hover { color: var(--destaque-texto); }
.instalar-fechar {
  position: absolute; top: 8px; right: 8px; z-index: 2; width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: none; color: var(--destaque-muted); cursor: pointer;
}
.instalar-fechar:hover { background: rgba(255, 255, 255, .08); color: var(--destaque-texto); }
.instalar-fechar svg { width: 16px; height: 16px; }
@media (max-width: 640px) {
  .instalar-card { grid-template-columns: auto 1fr; gap: 14px; padding: 16px; }
  .instalar-icone { width: 48px; height: 48px; border-radius: 12px; align-self: start; }
  .instalar-texto { padding-right: 24px; }
  .instalar-acoes { grid-column: 1 / -1; padding-right: 0; }
  .instalar-acoes .btn-primary { flex: 1; }
}

/* ---------- Obras do cliente ---------- */
.obras-topo { justify-content: space-between; align-items: center; gap: 12px; }
.obras-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 14px; }
.obras-grid > .card + .card { margin-top: 0; }
.obra-card { container-type: inline-size; }
.obra-card.concluida { opacity: .78; }
.obra-card .card-head h2 { text-transform: none; letter-spacing: 0; font-size: 16px; }
.obra-local { font-size: 13.5px; margin-top: 2px; }
.obra-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.obra-nums > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; gap: 2px; min-width: 0; }
.obra-nums span { font-size: 11.5px; color: var(--muted); }
.obra-nums b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.obra-nums small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@container (max-width: 560px) { .obra-nums { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Lançamento com vários itens ---------- */
.lanc-itens { display: grid; gap: 10px; }
.lanc-item {
  display: grid; gap: 8px 10px; align-items: end; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
  grid-template-columns: minmax(0, 1fr) 110px 38px; grid-template-areas: "item qtd del" "hint hint hint";
}
.lanc-itens.com-valor .lanc-item { grid-template-columns: minmax(0, 1fr) 90px 120px 38px; grid-template-areas: "item qtd valor del" "hint hint hint hint"; }
.lanc-c-item { grid-area: item; } .lanc-c-qtd { grid-area: qtd; } .lanc-c-valor { grid-area: valor; display: none; }
.lanc-itens.com-valor .lanc-c-valor { display: grid; }
.lanc-item .lanc-del { grid-area: del; margin-bottom: 2px; color: var(--muted); }
.lanc-item .lanc-del:hover { color: var(--danger); background: var(--danger-soft); }
.lanc-hint { grid-area: hint; font-size: 12.5px; color: var(--muted); }
.lanc-hint:empty { display: none; }
.lanc-hint b { color: var(--text); }
.lanc-preencher { justify-self: start; margin-top: 8px; }
.campo-com-botao { display: flex; gap: 8px; }
.campo-com-botao select { flex: 1; min-width: 0; }
.campo-com-botao .btn-icon { font-size: 20px; font-weight: 500; flex: none; }

/* ---------- Lixeira (excluir registro) ---------- */
.btn-excluir { color: var(--muted); }
.btn-excluir:hover { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.table .col-acao { width: 44px; padding-top: 2px; padding-bottom: 2px; text-align: right; }
.table .btn-excluir { width: 32px; min-height: 32px; }
.table .btn-excluir svg { width: 16px; height: 16px; }
@media (max-width: 560px) {
  .modal [data-so-saida].form-grid { grid-template-columns: 1fr; }
  .lanc-item { grid-template-columns: minmax(0, 1fr) 84px 34px; padding: 10px; }
  .lanc-itens.com-valor .lanc-item { grid-template-columns: 1fr 1fr 34px; grid-template-areas: "item item item" "qtd valor del" "hint hint hint"; }
}

/* ---------- Etapas do pagamento (sinal / entrega / vencido) ---------- */
.pag-etapas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.pag-etapas > div { border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 8px 10px; display: grid; gap: 2px; min-width: 0; }
.pag-etapas span { font-size: 11.5px; color: var(--muted); }
.pag-etapas b { font-size: 15px; }
.pag-etapas small { font-size: 11.5px; color: var(--muted); }
.pag-etapas .falta { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.pag-etapas small.neg, .pag-etapas small.pos { font-weight: 600; }
.pag-etapas .falta b { color: var(--danger); }
@media (max-width: 560px) { .pag-etapas { grid-template-columns: 1fr; } }
.pag-atalhos { margin-top: 8px; flex-wrap: wrap; overflow: visible; }
.pag-atalhos:empty { display: none; }

/* ---------- Faixa de categorias deslizável ---------- */
.deslize { position: relative; margin-bottom: 16px; }
.deslize .chips { scroll-behavior: auto; overscroll-behavior-x: contain; cursor: grab; user-select: none; -webkit-user-select: none; padding: 2px 0 4px; }
.deslize .chips.arrastando { cursor: grabbing; }
.deslize .chips.arrastando .chip { pointer-events: none; }
.deslize .chip { flex: none; }
.deslize-seta {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; display: none; place-items: center;
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18); cursor: pointer;
}
.deslize-seta svg { width: 16px; height: 16px; }
.deslize-seta:hover { border-color: var(--cobre); color: var(--cobre); }
.deslize-seta.esq { left: -4px; }
.deslize-seta.dir { right: -4px; }
.deslize.tem-antes .deslize-seta.esq, .deslize.tem-depois .deslize-seta.dir { display: grid; }
/* esmaece as pontas para indicar que há mais categorias */
.deslize.tem-antes .chips { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 48px); mask-image: linear-gradient(to right, transparent 0, #000 48px); }
.deslize.tem-depois .chips { -webkit-mask-image: linear-gradient(to left, transparent 0, #000 48px); mask-image: linear-gradient(to left, transparent 0, #000 48px); }
.deslize.tem-antes.tem-depois .chips {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
}
@media (hover: none) { .deslize-seta { display: none !important; } }

/* Histórico: coluna do estoque no fim do período em destaque */
.table .col-final { background: var(--accent-soft); white-space: nowrap; }
.table th.col-final { color: var(--accent-ink); }
.tabela-resumo td:first-child { min-width: 160px; }

/* ---------- Financeiro ---------- */
.fin-periodo { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 14px; }
.fin-periodo .chips { flex-wrap: wrap; }
.fin-datas { display: grid; grid-template-columns: repeat(2, minmax(150px, 200px)); gap: 10px 16px; }
/* rótulo "De" / "Até" à esquerda da data */
.fin-datas .field { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; }
.fin-datas .field > span { font-size: 13px; }
.fin-kpi { font-size: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-aviso { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.fin-aviso > svg { width: 20px; height: 20px; flex: none; color: var(--accent-ink); }
.fin-aviso.fin-aviso-neg > svg { color: var(--danger); }
.fin-aviso > span { flex: 1; min-width: 0; }
.fin-bars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; align-items: end; height: 170px; padding-top: 8px; }
.fin-mes { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; height: 100%; min-width: 0; }
.fin-par { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.fin-bar { width: 42%; max-width: 20px; min-height: 2px; border-radius: 4px 4px 0 0; }
.fin-bar.ent, .fin-legenda i.ent { background: var(--ok); }
.fin-bar.sai, .fin-legenda i.sai { background: var(--cobre); }
.fin-mes.atual .bar-lbl { color: var(--text); font-weight: 700; }
.fin-saldo { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; min-height: 14px; }
.fin-legenda { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12px; }
.fin-legenda span { display: inline-flex; align-items: center; gap: 6px; }
.fin-legenda i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.fin-cats { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.fin-cat-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.fin-cat-top b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-cat-bar { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; margin: 5px 0 2px; }
.fin-cat-bar i { display: block; height: 100%; background: var(--cobre); border-radius: 99px; }
.card-grafico .fin-bars { flex: 1; height: auto; min-height: 170px; }
.fin-desc { display: flex; gap: 8px; align-items: flex-start; min-width: 180px; }
.fin-desc a { font-weight: 600; }
.fin-tipo { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; flex: none; margin-top: -1px; }
.fin-tipo svg { width: 14px; height: 14px; }
.fin-tipo.entrada { background: var(--ok-soft); color: var(--ok); }
.fin-tipo.saida { background: var(--accent-soft); color: var(--accent-ink); }
.fin-extrato td { vertical-align: top; }
.fin-linha { flex-wrap: wrap; }
.fin-linha .row-qty small.neg { color: var(--danger); font-weight: 600; }
.fin-linha .row-qty small .badge { margin-top: 3px; }
/* abas do Financeiro (Visão geral, Despesas, Pagamentos, Impostos, Folha) */
.fin-abas { display: flex; gap: 6px; margin: -6px 0 16px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.fin-abas::-webkit-scrollbar { display: none; }
.fin-abas a { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; }
.fin-abas a:hover { color: var(--text); }
.fin-abas a.active { background: var(--destaque-bg); border-color: var(--destaque-borda); color: var(--destaque-texto); }
.fin-alerta { font-style: normal; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.fin-sub { max-width: 480px; margin-bottom: 14px; }
.fin-select { min-height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 0 10px; font: inherit; font-size: 14px; max-width: 100%; }
.fin-grupo .card-head b { font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (min-width: 760px) { .kpis-3 { grid-template-columns: repeat(3, 1fr); } }
/* minmax(0, …): a tabela rola dentro do cartão em vez de alargar a página */
.fin-grid-lista { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .fin-grid-lista { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (min-width: 1100px) { .fin-grid-lista { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); } }
@media (max-width: 560px) {
  .fin-datas { grid-template-columns: minmax(0, 1fr); width: 100%; }
  .fin-datas .field { grid-template-columns: 30px minmax(0, 1fr); }
  .fin-datas .field, .fin-datas input { min-width: 0; width: 100%; }
  .fin-linha > .btn { margin-left: auto; }
  .fin-bars { gap: 6px; }
}

/* ---------- Site: fotos das peças e da empresa ---------- */
.site-fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.site-foto { margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); display: grid; }
.site-foto-img { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); }
.site-foto-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.site-foto-img .badge { position: absolute; left: 8px; top: 8px; }
.site-foto input { border: 0; border-top: 1px solid var(--line); padding: 9px 10px; font: inherit; font-size: 13px; background: var(--surface); color: var(--text); min-width: 0; }
.site-foto input:focus { outline: 2px solid var(--cobre); outline-offset: -2px; }
.site-foto-acoes { display: flex; justify-content: space-between; padding: 2px 4px; border-top: 1px solid var(--line); }
.site-foto-acoes .btn-icon { width: 34px; min-height: 34px; }
.site-foto-app { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); font-size: 13px; }
.site-foto-app img { width: 72px; height: 54px; object-fit: cover; border-radius: 8px; flex: none; }
