/* ============================================================
   Redantec ERP — Design System
   Minimalista, sofisticado, profissional.
   Fundo off-white · cinzas sofisticados · verde esmeralda
   como cor de marca · vermelho restrito a alertas/vencidos.
   Tipografia Inter · hierarquia por peso e escala · pouco uso
   de sombra, borda e decoração.
   ============================================================ */

:root {
  /* superfícies */
  --bg: #f1f3f5;
  --surface: #ffffff;
  --surface-2: #f7f9fa;
  --surface-3: #f1f4f6;

  /* linhas */
  --border: #edf0f3;
  --border-strong: #e2e7ec;

  /* texto — cinzas sofisticados */
  --text: #101828;
  --muted: #667085;
  --muted-2: #98a2b3;

  /* marca */
  --accent: #0e9f6e;
  --accent-strong: #0b8a60;
  --accent-deep: #07785a;
  --accent-ink: #045c44;
  --accent-soft: #ecfdf5;

  /* semânticas (uso restrito) */
  --danger: #e11d48;
  --danger-soft: #fdf1f3;
  --warning: #d97706;
  --warning-soft: #fdf4e9;
  --info: #2563eb;
  --info-soft: #eff5fe;
  --violet: #7c3aed;
  --violet-soft: #f4f1fe;

  /* menu — cinza chumbo */
  --sidebar: #343a42;
  --sidebar-hover: #3e454e;
  --sidebar-active: #48505b;
  --sidebar-line: rgba(255, 255, 255, .08);
  --sidebar-text: rgba(255, 255, 255, .78);
  --sidebar-muted: rgba(255, 255, 255, .58);
  --sidebar-strong: #ffffff;

  /* forma */
  --radius: 12px;
  --radius-sm: 8px;

  /* profundidade — discreta */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 16px 40px -16px rgba(16, 24, 40, .22);

  /* ritmo de espaçamento (base 4) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent-deep); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

::selection { background: var(--accent-soft); color: var(--accent-deep); }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-strong);
  border-right: 1px solid rgba(0, 0, 0, .35);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .18) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .18); border-radius: 99px; border: none; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 2px 6px 20px;
  margin-bottom: 12px;
}
.brand-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent);
  display: grid; place-items: center;
  color: #fff; flex-shrink: 0;
  font-size: 17px;
  box-shadow: 0 2px 6px -2px rgba(14, 159, 110, .55);
}
.brand-name { font-weight: 700; color: var(--sidebar-strong); font-size: 15px; letter-spacing: -.02em; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--sidebar-muted); letter-spacing: -.005em; margin-top: 1px; }

.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--sidebar-muted); margin: 18px 8px 7px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-weight: 500; font-size: 13.5px;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-strong); text-decoration: none; }
.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-strong);
  font-weight: 600;
}
.nav-item.active svg { color: var(--accent); }
.nav-item svg {
  width: 17px; height: 17px; flex-shrink: 0;
  color: rgba(255, 255, 255, .5); transition: color .15s;
}
.nav-item:hover svg { color: rgba(255, 255, 255, .85); }
.nav-item.active:hover { background: var(--sidebar-active); color: var(--sidebar-strong); }

.sidebar-foot {
  margin-top: auto; padding: 14px 10px 4px;
  border-top: 1px solid var(--sidebar-line);
  font-size: 11px; color: var(--sidebar-muted); line-height: 1.5;
}

/* ---------- Main ---------- */
.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.6) blur(8px);
  -webkit-backdrop-filter: saturate(1.6) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 18px 32px;
}
.topbar .grow { flex: 1; min-width: 0; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.025em; line-height: 1.25; }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 3px; letter-spacing: -.008em; }
.page-sub strong { color: var(--text); font-weight: 600; }

/* seletor de empresa ativa no topo */
.empresa-switch select {
  width: auto; min-width: 230px; max-width: 300px;
  font-weight: 600; border-radius: 999px;
  padding: 8px 36px 8px 14px;
  border-color: var(--border-strong);
  background-color: var(--surface);
}
@media (max-width: 860px) { .empresa-switch { display: none !important; } }

.container { padding: 32px 32px 64px; max-width: 1320px; }
.container.narrow { max-width: 1080px; }

/* eyebrow: micro-rótulo de hierarquia */
.eyebrow {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted-2);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; letter-spacing: -.01em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
  font-family: inherit; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(14, 159, 110, .22); }

.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 1px 2px rgba(7, 120, 90, .28);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-primary:active:not(:disabled) { background: var(--accent-deep); box-shadow: none; }

.btn-ghost {
  background: var(--surface); color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: #d6dce3; }
.btn-ghost:active:not(:disabled) { box-shadow: none; }

.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-danger:hover:not(:disabled) { background: #fbe4e9; }
.btn-danger:focus-visible { box-shadow: 0 0 0 3px rgba(225, 29, 72, .2); }

.alert-box { display: flex; align-items: flex-start; gap: 8px; padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.5; }
.alert-box svg { flex-shrink: 0; margin-top: 1px; }
.alert-box.warn { background: var(--warning-soft); color: #92400e; border: 1px solid #f5e0c0; }
.btn-mini { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }

.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: inline-grid; place-items: center; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { color: var(--text); border-color: #d6dce3; background: var(--surface-2); }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(14, 159, 110, .2); }
.icon-btn.danger:hover { color: var(--danger); border-color: #f6d0d9; background: var(--danger-soft); }
.icon-btn.emerald:hover { color: var(--accent-deep); border-color: #c8ebdd; background: var(--accent-soft); }

.btn-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Cards & KPIs ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px 24px; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.card-head h3 {
  font-size: 15px; font-weight: 600; letter-spacing: -.017em;
  color: var(--text); line-height: 1.3;
}
.card-head .sub { font-size: 12.5px; color: var(--muted); font-weight: 400; letter-spacing: -.006em; }
.card-head .grow { flex: 1; min-width: 0; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 18px 20px; position: relative; overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.kpi-click { cursor: pointer; }
.kpi-top { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; flex-wrap: wrap; }
.kpi-label {
  font-size: 13px; color: var(--muted); font-weight: 500;
  letter-spacing: -.01em; min-width: 0; line-height: 1.3;
}
.kpi-icon { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.kpi-icon svg { width: 14px; height: 14px; }
.kpi-value {
  font-size: 26px; font-weight: 700; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.kpi-value small { font-size: 13px; font-weight: 600; color: var(--muted-2); letter-spacing: -.01em; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 5px; letter-spacing: -.006em; }
.kpi-sub .up { color: var(--accent-strong); font-weight: 600; }
.kpi-sub .down { color: var(--danger); font-weight: 600; }
.kpi-sub .warn { color: var(--warning); font-weight: 600; }

/* KPIs compactos (contas a pagar) */
.kpi-grid.kpi-min { gap: 14px; margin-bottom: 20px; }
.kpi-min .kpi { padding: 16px 18px; }
.kpi-min .kpi-top { margin-bottom: 10px; }
.kpi-min .kpi-value { font-size: 23px; }

.tint-emerald { background: var(--accent-soft); color: var(--accent-deep); }
.tint-rose { background: var(--danger-soft); color: var(--danger); }
.tint-amber { background: var(--warning-soft); color: var(--warning); }
.tint-blue { background: var(--info-soft); color: var(--info); }
.tint-violet { background: var(--violet-soft); color: var(--violet); }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
.grid-2-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; letter-spacing: -.008em;
  color: var(--muted); font-weight: 600; padding: 11px 16px;
  border-bottom: 1px solid var(--border-strong); white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; letter-spacing: -.012em; }
.table th.num { text-align: right; }
.table .mono { font-family: var(--mono); font-size: 12.5px; }
.cell-strong { font-weight: 600; }
.cell-soft { color: var(--muted); font-size: 12.5px; }

.empty {
  text-align: center; padding: 64px 24px; color: var(--muted);
}
.empty svg { width: 40px; height: 40px; color: var(--muted-2); margin-bottom: 14px; stroke-width: 1.25; }
.empty h4 { font-weight: 600; color: var(--text); margin-bottom: 5px; font-size: 15.5px; letter-spacing: -.015em; }
.empty p { font-size: 13.5px; max-width: 44ch; margin: 0 auto; line-height: 1.6; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  letter-spacing: -.008em; white-space: nowrap; line-height: 1.5;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); flex-shrink: 0; }
.badge svg { color: var(--muted); width: 13px; height: 13px; }
.badge-emerald .dot { background: var(--accent); }
.badge-rose .dot { background: var(--danger); }
.badge-amber .dot { background: var(--warning); }
.badge-blue .dot { background: var(--info); }
.badge-violet .dot { background: var(--violet); }
.badge-zinc .dot { background: var(--muted-2); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label {
  font-size: 13px; font-weight: 600; color: var(--text);
  letter-spacing: -.01em; text-transform: none; line-height: 1.3;
}
.field .hint { font-size: 12.5px; color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: -.006em; }
.hint { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field-label-row .mini-btn {
  font-size: 12px; color: var(--accent-strong); cursor: pointer; font-weight: 600;
  border: none; background: none; letter-spacing: -.01em;
}
.field-label-row .mini-btn:hover { text-decoration: underline; text-underline-offset: 2px; }

/* campo com busca de sugestões (typeahead) */
.field-ta { position: relative; }
.ta-list {
  position: absolute; left: 0; right: 0; top: calc(100% - 8px); z-index: 30;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  max-height: 232px; overflow-y: auto; overflow-x: hidden;
}
.ta-item {
  display: flex; flex-direction: column; gap: 1px; width: 100%;
  padding: 9px 12px; border: none; border-bottom: 1px solid var(--border);
  background: none; text-align: left; font: inherit; cursor: pointer;
}
.ta-item:last-child { border-bottom: none; }
.ta-item:hover, .ta-item:focus { background: var(--accent-soft); outline: none; }
.ta-nome { font-size: 13px; font-weight: 600; color: var(--text); }
.ta-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ta-empty { padding: 12px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 9px 12px; outline: none;
  letter-spacing: -.01em;
  transition: border-color .15s, box-shadow .15s; width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 159, 110, .13);
}
select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px;
}
textarea { resize: vertical; min-height: 74px; }
.input-row { display: flex; gap: 10px; align-items: center; }
.input-row > * { min-width: 0; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* search */
.searchbox { position: relative; }
.searchbox svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-2); pointer-events: none; }
.searchbox input { padding-left: 36px; width: 250px; border-radius: 999px; background: var(--surface); }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .searchbox { margin-right: auto; }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(16, 24, 40, .38); backdrop-filter: blur(2px);
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; animation: pop .18s ease;
  max-height: calc(100vh - 80px); display: flex; flex-direction: column;
}
.modal.sm { max-width: 460px; }
.modal.md { max-width: 640px; }
.modal.lg { max-width: 880px; }
.modal.xl { max-width: 1080px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* hidden deve sempre funcionar, mesmo em elementos com display próprio (.field etc.) */
[hidden] { display: none !important; }

/* ---------- Seções do lançamento de compra ---------- */
.csec { margin-bottom: 20px; }
.csec:last-child { margin-bottom: 0; }
.csec-tt {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted-2); margin-bottom: 10px;
}
.csec-tt svg { color: var(--accent); }
.csec-tt::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.it-count {
  background: var(--surface-3); color: var(--muted); border-radius: 999px;
  padding: 1px 9px; font-size: 11px; font-weight: 700; margin-left: 4px;
}

.csec .editor-wrap { max-height: 320px; min-height: 96px; }
.csec .editor-row { padding: 6px 10px; }
.csec .editor-row.head { padding: 6px 10px; }
.csec .editor-row input { padding: 6px 8px; font-size: 12.5px; }
.csec .sum-row {
  border-top: 1px dashed var(--border-strong); padding-top: 10px; margin-top: 14px !important;
}
.csec .sum-row .val { color: var(--accent); font-size: 20px; }

.form-grid.fg3 { grid-template-columns: repeat(3, 1fr); }

.pay-toggle { display: flex; gap: 8px; }
.pay-opt {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border: 1px solid var(--border-strong); border-radius: 999px;
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted);
  background: var(--surface); transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
}
.pay-opt input { width: auto; margin: 0; }
.pay-opt:has(input:checked) {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent-deep);
}
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.modal-head .close { margin-left: auto; }
.modal-body { padding: 20px 22px; flex: 1; min-height: 0; overflow: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 14px 14px;
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.toast {
  background: var(--text); color: var(--surface-2); border-radius: 10px; padding: 12px 15px;
  box-shadow: var(--shadow-lg); font-size: 13px; display: flex; gap: 10px; align-items: flex-start;
  animation: slidein .2s ease;
}
.toast.success svg { color: #4ade80; }
.toast.error svg { color: #fb7185; }
.toast.info svg { color: #60a5fa; }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.toast.out { opacity: 0; transform: translateX(20px); transition: opacity .25s, transform .25s; }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- Chip filter ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  font-size: 13px; font-weight: 500; letter-spacing: -.01em;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
button.chip { cursor: pointer; }
.chip .num {
  display: inline-grid; place-items: center; min-width: 21px; height: 19px;
  padding: 0 6px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-3); color: var(--muted);
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-2); }
.chip.active {
  background: var(--accent-soft); border-color: #b7ebd7; color: var(--accent-deep);
  font-weight: 600;
}
.chip.active .num { background: rgba(14, 159, 110, .14); color: var(--accent-deep); }
.chip:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(14, 159, 110, .18); }

/* ---------- Item editor (compras/saídas) ---------- */
.editor-wrap { border: 1px solid var(--border); border-radius: 12px; max-height: 420px; overflow: auto; }
.editor-wrap .editor-row.head { position: sticky; top: 0; z-index: 2; }
.editor-row { display: grid; grid-template-columns: 1fr 100px 130px 130px 34px; gap: 10px; padding: 10px 12px; align-items: center; border-bottom: 1px solid var(--border); background: var(--surface); }
.editor-row.head { grid-template-columns: 1fr 100px 130px 130px 34px; background: var(--surface-2); }
.editor-row.head span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 0; }
.editor-row:last-child { border-bottom: none; }
.editor-row .tot { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

.add-line { margin-top: 10px; width: 100%; border-style: dashed; }

/* ---- seletor de material com busca (item editor) ---- */
.picker { position: relative; margin-bottom: 10px; }
.picker-input input { border-radius: 12px; background: var(--surface-2); padding: 12px 14px 12px 40px; font-size: 13.5px; border-color: var(--border-strong); }
.picker-input:focus-within input { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 159, 110, .1); background: var(--surface); }
.picker-results {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 260px; overflow-y: auto; padding: 6px;
}
.picker-item {
  display: flex; flex-direction: column; gap: 1px; width: 100%;
  padding: 9px 12px; border-radius: 9px; border: none; background: none; cursor: pointer;
  text-align: left; font-family: inherit;
}
.picker-item:hover, .picker-item.active { background: var(--accent-soft); }
.picker-item .mat-name { font-weight: 600; font-size: 13.5px; color: var(--text); }
.picker-item .mat-meta { font-size: 11.5px; color: var(--muted); }
.picker-empty { padding: 14px; text-align: center; font-size: 12.5px; color: var(--muted); }

/* associador de material (importação NF-e) */
.assoc.searchbox { margin: 0; width: 100%; min-width: 0; }
.assoc.searchbox input { width: 100%; padding-left: 34px; border-radius: 9px; background: var(--surface); font-size: 12.5px; }
.picker-results.assoc-results { top: calc(100% + 2px); min-width: 260px; }
.assoc-status { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.assoc-status b { color: var(--accent); font-weight: 700; }

.mat-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mat-info { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.mat-info .mat-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat-info .mat-meta { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat-switch { width: 28px; height: 28px; flex-shrink: 0; }

/* ---- parcelas ---- */
.parcela-editor .editor-row { grid-template-columns: 96px 1fr 1fr 26px; gap: 8px; padding: 5px 10px; }
.parcela-editor .editor-row.head { grid-template-columns: 96px 1fr 1fr 26px; padding: 6px 10px; }
.parcela-editor .editor-row.head span { font-size: 9.5px; white-space: nowrap; overflow: hidden; }
.parcela-editor input { padding: 5px 8px; font-size: 12px; border-radius: 8px; min-width: 0; width: 100%; }
.parcela-num { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.parcela-actions { display: flex; gap: 8px; margin-top: 8px; }
.parcela-actions .add-line { margin-top: 0; flex: 1; padding: 6px; font-size: 12px; }

/* ---- lista minimalista (compras / contas) ---- */
.list-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 16px; align-items: center; padding: 15px 20px;
  border-bottom: 1px solid var(--border); transition: background .1s;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-2); }
.list-left { min-width: 0; }
.list-title {
  font-weight: 600; font-size: 14px; letter-spacing: -.01em;
  display: flex; align-items: center; gap: 8px; overflow: hidden;
}
.list-title .mono { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.list-title .sep { color: var(--muted-2); font-weight: 400; }
.list-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub strong { color: var(--muted); }
.list-sub .link, .link { color: var(--accent-deep); font-weight: 600; text-decoration: none; cursor: pointer; }
.list-sub .link:hover, .link:hover { text-decoration: underline; text-underline-offset: 2px; }
.conta-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.conta-meta .meta-item {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; line-height: 1.6;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conta-meta .meta-item svg { color: var(--muted-2); flex-shrink: 0; }
.conta-meta .meta-item a { color: inherit; text-decoration: none; }
.conta-meta .meta-item a:hover { text-decoration: underline; }
.conta-meta .meta-item.violet { background: var(--violet-soft); border-color: transparent; color: var(--violet); }
.conta-meta .meta-item.violet svg { color: var(--violet); }
.conta-meta .meta-item.blue { background: var(--info-soft); border-color: transparent; color: var(--info); }
.conta-meta .meta-item.blue svg { color: var(--info); }
.conta-meta .meta-item.rose { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.conta-meta .meta-item.rose svg { color: var(--danger); }
.conta-meta .meta-item.emerald { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.conta-meta .meta-item.emerald svg { color: var(--accent); }
.conta-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 16px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.conta-sub svg { color: var(--muted-2); vertical-align: -2px; }
.conta-sub .obs { font-style: italic; }
.list-val { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; text-align: right; white-space: nowrap; }
.list-val.muted { color: var(--muted-2); }
.list-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; white-space: nowrap; }
.list-badge { white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.aberta { background: var(--info); }
.dot.paga { background: var(--accent); }
.dot.atrasada { background: var(--danger); }
.dot.cancelada { background: var(--muted-2); }

@media (max-width: 760px) {
  .list-row { grid-template-columns: 1fr auto; row-gap: 8px; }
  .list-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .chip-date { margin-left: 0; }
  .cpt-row { grid-template-columns: auto minmax(0, 1fr); row-gap: 10px; }
  .cpt-right { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
  .cpr-row { grid-template-columns: auto minmax(0, 1fr); row-gap: 10px; }
  .cpr-right { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
}

/* ---- módulos (cadastros) ---- */
.module-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.module-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; cursor: pointer; display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s, box-shadow .15s, transform .15s; box-shadow: var(--shadow-sm);
}
.module-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.module-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 159, 110, .1), var(--shadow); }
.module-card-top { display: flex; align-items: center; justify-content: space-between; }
.module-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; }
.module-ico svg { width: 20px; height: 20px; }
.module-count { font-size: 24px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.module-card h3 { font-size: 15.5px; font-weight: 600; letter-spacing: -.017em; }
.module-card p { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.module-arrow { margin-left: auto; color: var(--muted-2); transition: color .15s, transform .15s; }
.module-card.active .module-arrow, .module-card:hover .module-arrow { color: var(--accent); transform: translateX(3px); }
.section-head { display: flex; align-items: center; gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.grow2 { flex: 1; }
.section-head .grow2 { flex: 1; }
.section-head h3 { font-size: 15.5px; font-weight: 600; letter-spacing: -.017em; }
.section-head .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  padding: 26px; text-align: center; color: var(--muted); cursor: pointer;
  transition: border-color .15s, background .15s, color .15s; background: var(--surface-2);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone svg { width: 30px; height: 30px; margin-bottom: 8px; }
.dropzone strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 2px; }
.dropzone .file-name { display: block; color: var(--accent); font-weight: 600; font-size: 12.5px; margin-top: 4px; }

/* ---------- Progress ---------- */
.progress { height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.progress > i.warn { background: var(--warning); }
.progress > i.danger { background: var(--danger); }

/* ---------- Obras cards ---------- */
.obra-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.obra-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  display: flex; flex-direction: column; gap: 14px;
}
.obra-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.obra-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.obra-card h3 { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; }
.obra-card .meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.obra-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.obra-kpi { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.obra-kpi .v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.obra-kpi .l { font-size: 11px; color: var(--muted); font-weight: 600; }

/* -------- Visão da obra (modal repaginado) -------- */
.modal.obra-view { max-width: 1160px; max-height: calc(100vh - 56px); border-radius: 20px; overflow: hidden; }
.obra-hero {
  background: linear-gradient(135deg, #1d2939 0%, #293748 55%, #344054 100%);
  padding: 22px 28px 0; color: #fff; position: relative; overflow: hidden;
}
.obra-hero::after {
  content: ""; position: absolute; top: -140px; right: -90px;
  width: 360px; height: 360px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.22), transparent 62%);
  pointer-events: none;
}
.obra-hero > * { position: relative; z-index: 1; }
.obra-hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.obra-hero-id { font-size: 11px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: rgba(255,255,255,.8); }
.obra-hero .icon-btn.close { background: rgba(255,255,255,.14); color: #fff; }
.obra-hero .icon-btn.close:hover { background: rgba(255,255,255,.28); }
.obra-hero-title { font-size: 25px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin-top: 10px; }
.obra-hero-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; font-size: 12.5px; color: rgba(255,255,255,.86); }
.obra-hero-meta span { display: inline-flex; align-items: center; gap: 6px; }
.obra-hero-meta svg { width: 13px; height: 13px; opacity: .85; }
.obra-hero .badge { background: rgba(255,255,255,.15) !important; color: #fff !important; border: 1px solid rgba(255,255,255,.24) !important; }
.obra-hero-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 20px; padding-bottom: 24px; }
.ohk {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.16);
  border-radius: 14px; padding: 14px 16px; backdrop-filter: blur(3px);
}
.ohk-l { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,.75); }
.ohk-v { font-size: 21px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.ohk-bar { height: 6px; background: rgba(255,255,255,.26); border-radius: 999px; margin-top: 10px; overflow: hidden; }
.ohk-bar i { display: block; height: 100%; border-radius: 999px; background: #fff; }
.ohk-sub { font-size: 11px; color: rgba(255,255,255,.78); margin-top: 6px; }
.obra-body { padding: 22px 28px 28px; }
.obra-tools { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.obra-search { position: relative; flex: 1; display: flex; align-items: center; min-width: 220px; }
.obra-search svg { position: absolute; left: 13px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.obra-search input {
  width: 100%; height: 40px; border: 1px solid var(--border); border-radius: 10px;
  padding: 0 12px 0 38px; font-size: 13.5px; font-family: inherit;
  background: var(--surface-2); color: var(--text);
}
.obra-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: #fff; }
.obra-select {
  height: 40px; border: 1px solid var(--border); border-radius: 10px; padding: 0 12px;
  font-size: 13px; font-family: inherit; color: var(--text); cursor: pointer; background: var(--surface-2);
}
.obra-mats { display: flex; flex-direction: column; gap: 10px; }
.oma { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.oma:hover { border-color: var(--border-strong); }
.oma.open { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.oma-head { display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer; }
.oma-ava { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex-shrink: 0; }
.oma-ava svg { width: 19px; height: 19px; }
.oma-main { flex: 1; min-width: 0; }
.oma-title { font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.oma-uni { font-size: 10.5px; font-weight: 700; background: var(--surface-3); color: var(--muted); border-radius: 999px; padding: 2px 8px; text-transform: uppercase; letter-spacing: .05em; }
.oma-meta { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.oma-meta b { color: var(--text); font-weight: 700; }
.oma-right { text-align: right; flex-shrink: 0; min-width: 148px; }
.oma-val { font-size: 15px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.oma-pct-wrap { height: 5px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-top: 7px; }
.oma-pct { height: 100%; background: var(--accent); border-radius: 999px; }
.oma-pct-txt { font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.oma-chev { color: var(--muted-2); flex-shrink: 0; display: grid; place-items: center; transition: transform .2s; transform: rotate(90deg); }
.oma.open .oma-chev { transform: rotate(-90deg); }
.oma-details { display: none; border-top: 1px dashed var(--border-strong); background: var(--surface-2); padding: 8px 14px 14px; overflow-x: auto; }
.oma.open .oma-details { display: block; }
.oma-details .table { margin-top: 8px; min-width: 640px; }
@media (max-width: 900px) { .obra-hero-kpis { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) {
  .obra-tools { flex-direction: column; align-items: stretch; }
  .obra-select { width: 100%; }
  .oma-head { flex-wrap: wrap; }
  .oma-right { min-width: 120px; }
}

/* -------- Despesas manuais da obra -------- */
.obra-despesas { margin-top: 18px; }
.od-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.od-head h4 { font-size: 13.5px; font-weight: 700; margin: 0; }
.od-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.obra-despesas .table { margin-top: 0; }
.od-empty {
  border: 1px dashed var(--border-strong); border-radius: 10px;
  padding: 16px 18px; font-size: 12.5px; color: var(--muted); background: var(--surface-2);
}

/* ---------- Misc ---------- */
.text-right { text-align: right; }
.text-danger { color: var(--danger); }
.text-muted { color: var(--muted); }
.text-strong { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; }
.w-100 { width: 100%; }

.detail-list { display: flex; flex-direction: column; gap: 0; }
.detail-item { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.detail-item:last-child { border-bottom: none; }
.detail-item .k { color: var(--muted); }

.pill-stock { font-weight: 700; font-variant-numeric: tabular-nums; }
.pill-stock.ok { color: var(--accent); }
.pill-stock.warn { color: var(--warning); }
.pill-stock.danger { color: var(--danger); }

.sticky-hint {
  background: var(--info-soft); color: #1d4ed8; border: 1px solid #d3e3fd;
  border-radius: 12px; padding: 12px 16px; font-size: 12.5px; display: flex; gap: 10px; align-items: center; margin-bottom: 18px;
}
.sticky-hint svg { width: 17px; height: 17px; flex-shrink: 0; }

.avatar {
  width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center;
  background: var(--violet-soft); color: var(--violet); font-weight: 700; font-size: 13px; flex-shrink: 0;
}

.sum-row { display: flex; align-items: baseline; gap: 8px; }
.sum-row .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.sum-row .val { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }

.login-pill { font-size: 13px; font-weight: 700; }

.menu-toggle { display: none; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 90; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-toggle { display: grid; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .module-grid { grid-template-columns: 1fr; }
}

/* ---- relatório de contas a pagar ---- */
.report-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 16px; }
.report-filters .field { min-width: 150px; }
.report { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: #fff; }
.report-head { padding: 20px 22px; border-bottom: 3px solid var(--accent); background: var(--surface-2); }
.report-head .row1 { display: flex; align-items: center; gap: 12px; }
.report-head .row1 .logo { color: var(--accent); }
.report-head h2 { font-size: 19px; letter-spacing: -.01em; margin: 0; }
.report-head .org { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.report-head .meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 12.5px; color: var(--muted); }
.report-head .meta b { color: var(--text); }
.report table { width: 100%; border-collapse: collapse; }
.report th { background: var(--surface-3); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border-strong); }
.report td { padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text); vertical-align: middle; }
.report tr:nth-child(even) td { background: var(--surface-2); }
.report .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.report tfoot td { background: var(--surface-2); border-top: 2px solid var(--border-strong); font-weight: 700; font-size: 14px; }
.report .cbx { display: inline-block; width: 17px; height: 17px; border: 1.6px solid var(--text); border-radius: 4px; background: #fff; }
.report .col-pagar { text-align: center; }
.report-foot { padding: 70px 22px 12px; }
.report-foot .ass-block { display: flex; justify-content: center; gap: 70px; }
.report-foot .ass-col { text-align: center; min-width: 220px; }
.report-foot .ass-line { border-top: 1.5px solid var(--muted); height: 22px; }
.report-foot .ass-label { margin-top: 6px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .03em; }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd2de; border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Modal gerenciar lista (formas, autorizadores etc.) ---------- */
.ger-add { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.ger-add input { flex: 1; min-width: 160px; }
.ger-list { display: flex; flex-direction: column; gap: 8px; }
.ger-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.ger-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ger-info strong { font-size: 13.5px; }
.ger-info .cell-soft { font-size: 12px; }
.ger-actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* ---------- Visualização da compra ---------- */
.cp-hero {
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 24px;
  background: linear-gradient(135deg, #101828 0%, #1d2939 55%, #344054 100%);
  border-radius: var(--radius); padding: 26px 28px; color: #fff;
  margin-bottom: 22px;
}
.cp-hero-main { display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.cp-hero-label {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255, 255, 255, .82); background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .16);
  padding: 5px 12px; border-radius: 999px;
}
.cp-hero-total {
  font-size: 42px; font-weight: 700; font-variant-numeric: tabular-nums;
  letter-spacing: -.02em; line-height: 1; text-shadow: none;
}
.cp-hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.cp-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(255,255,255,.1); color: rgba(255,255,255,.92);
  border: 1px solid rgba(255,255,255,.16);
}
.cp-hero-chips .badge { background: rgba(255,255,255,.1) !important; color: rgba(255,255,255,.94) !important; border: 1px solid rgba(255,255,255,.18); }
.cp-hero-chips .badge svg { color: inherit !important; }
.cp-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start; }
.cp-fact {
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.13); border-radius: 13px;
  padding: 11px 13px; display: flex; gap: 10px; align-items: flex-start; min-width: 0;
}
.cp-fact.span2 { grid-column: span 2; }
.cp-fact-ic { color: rgba(255, 255, 255, .7); display: flex; margin-top: 2px; flex-shrink: 0; }
.cp-fact-tx { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cp-fact-tx .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: rgba(255,255,255,.55); font-weight: 700; }
.cp-fact-tx strong { font-size: 12.5px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-fact.span2 .cp-fact-tx strong { white-space: normal; }
.cp-mat { display: flex; align-items: center; gap: 11px; }
.cp-mat-ic {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
}
.cp-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.cp-sec-head .cp-prog {
  font-size: 11.5px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px;
}
.cp-prog-bar { width: 78px; height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; }
.cp-prog-bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.cp-card-table {
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.cp-fo { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cp-totalrow td { background: var(--surface-2); border-top: 1px solid var(--border-strong); font-weight: 700; }
.cp-totalrow .num { color: var(--accent); font-size: 15px; }

/* filtro de período na mesma linha dos chips (contas a pagar) */
.chip-date {
  display: flex; align-items: center; gap: 6px;
  margin-left: auto; padding: 7px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; color: var(--muted); box-shadow: var(--shadow-sm);
}
.chip-date > svg { flex-shrink: 0; }
.chip-date > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.chip-date .sep { font-weight: 400; }
.chip-date input[type="date"] {
  border: none; background: transparent; padding: 0; margin: 0;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text);
  width: 128px; cursor: pointer;
}
.chip-date input[type="date"]:focus { outline: none; color: var(--accent); }
.chip-date .cd-x {
  display: grid; place-items: center; width: 18px; height: 18px;
  border: none; border-radius: 50%; padding: 0; margin-left: 2px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.chip-date .cd-x:hover { background: #e8ecf4; color: var(--text); }
.df-info { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.df-info b { color: var(--text); font-weight: 700; }

/* ---- contas a pagar (listagem) ---- */
.cpt-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px; align-items: center; padding: 15px 20px;
  border-bottom: 1px solid var(--border); transition: background .12s;
}
.cpt-row:last-child { border-bottom: none; }
.cpt-row:hover { background: var(--surface-2); }

/* seleção múltipla para baixa em massa */
.cpt-sel { display: flex; align-items: center; min-width: 17px; }
.cpt-sel input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.cpt-row.selecionada { background: var(--accent-soft) !important; }

/* cabeçalho: selecionar todas */
.cpt-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 20px; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}
.cpt-all {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  cursor: pointer; user-select: none; letter-spacing: -.01em;
}
.cpt-all input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.cpt-all:hover { color: var(--text); }
.cpt-all-num {
  font-size: 12px; font-weight: 600; color: var(--muted);
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}

/* barra de baixa em massa */
.baixa-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px 16px; margin-bottom: 14px;
}
.baixa-bar strong { color: var(--text); font-weight: 700; }
.baixa-bar .grp { display: flex; gap: 8px; align-items: center; }

.cpt-main { min-width: 0; }
.cpt-title {
  font-weight: 600; font-size: 14px; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cpt-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.cpt-tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.cpt-tag svg { vertical-align: -1px; }
.cpt-tag.violet { background: var(--surface-3); border-color: transparent; color: var(--muted); }
.cpt-tag.violet svg { color: var(--muted-2); }
.cpt-tag.blue { background: var(--surface-3); border-color: transparent; color: var(--muted); }
.cpt-tag.blue svg { color: var(--muted-2); }
.cpt-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 14px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.cpt-meta .meta-item { display: inline-flex; align-items: center; gap: 4px; }
.cpt-meta .meta-item svg { color: var(--muted-2); }
.cpt-meta .obs { font-style: italic; }
.cpt-days {
  display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 11.5px;
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--border);
}
.cpt-days svg { vertical-align: -1px; }
.cpt-days.rose { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.cpt-days.amber { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.cpt-days.blue { background: var(--info-soft); border-color: transparent; color: var(--info); }
.cpt-days.emerald { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

.cpt-right { display: flex; flex-direction: column; align-items: flex-end; gap: 9px; }
.cpt-valrow { display: flex; align-items: center; gap: 10px; }
.cpt-val {
  font-weight: 700; font-size: 15.5px; font-variant-numeric: tabular-nums;
  letter-spacing: -.02em; white-space: nowrap;
}
.cpt-val.muted { color: var(--muted-2); }
.cpt-val.rose { color: var(--danger); }

.ct-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ct-fact {
  background: var(--surface); border: 1px solid var(--border); border-radius: 13px;
  padding: 11px 14px; display: flex; gap: 10px; align-items: flex-start;
  box-shadow: var(--shadow-sm); min-width: 0;
}
.ct-fact.span2 { grid-column: span 2; }
.ct-fact-ic { color: var(--accent); display: flex; margin-top: 2px; flex-shrink: 0; }
.ct-fact .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.ct-fact strong { display: block; margin-top: 3px; font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-fact.span2 strong { white-space: normal; line-height: 1.5; }

/* ---- estoque (listagem) ---- */
.stk-mat { display: flex; align-items: center; gap: 11px; min-width: 0; }
.stk-av {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.stk-av.ok { background: #ecfdf5; color: var(--accent); }
.stk-av.warn { background: #fffbeb; color: var(--warning); }
.stk-av.danger { background: #fff1f2; color: var(--danger); }
.stk-cat {
  display: inline-block; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 9px; font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.stk-saldo { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; margin-right: 5px; }
.stk-saldo.ok { color: var(--accent); }
.stk-saldo.warn { color: var(--warning); }
.stk-saldo.danger { color: var(--danger); }
.stk-bar {
  display: block; width: 84px; height: 5px; border-radius: 99px;
  background: var(--border); overflow: hidden; margin: 6px 0 0 auto;
}
.stk-bar i { display: block; height: 100%; border-radius: 99px; }
.stk-bar.ok i { background: var(--accent); }
.stk-bar.warn i { background: var(--warning); }
.stk-bar.danger i { background: var(--danger); }

/* escopo do estoque (empresa ativa) */
.stock-scope {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted); white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 13px;
}
.stock-scope svg { color: var(--accent); flex: 0 0 auto; }
.stock-scope strong { color: var(--text); font-weight: 600; }

/* modal de transferência entre estoques */
.transfer-flow {
  display: grid; grid-template-columns: 1fr auto 1fr;
  gap: 0 14px; align-items: start;
}
.transfer-flow .field { margin-bottom: 12px; }
.transfer-arrow {
  display: flex; align-items: center; justify-content: center;
  height: 38px; margin-top: 27px; padding: 0 9px;
  color: var(--accent); background: var(--accent-soft); border-radius: 999px;
}
.transfer-hint {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted); line-height: 1.5;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px; margin: 0 0 18px;
}
.transfer-hint svg { color: var(--accent); flex: 0 0 auto; }
.transfer-hint strong { color: var(--text); font-weight: 600; }
@media (max-width: 640px) {
  .transfer-flow { grid-template-columns: 1fr; gap: 0; }
  .transfer-arrow { margin: 0 0 12px; height: 30px; align-self: center; }
}

/* ---- compras (listagem) ---- */
.cpr-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px; align-items: center; padding: 16px 20px;
  border-bottom: 1px solid var(--border); transition: background .12s;
}
.cpr-row:last-child { border-bottom: none; }
.cpr-row:hover { background: var(--surface-2); }

.cpr-av {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
}

.cpr-main { min-width: 0; }
.cpr-title {
  font-weight: 700; font-size: 14.5px; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cpr-title .mono { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--info); }
.cpr-title .sep { color: var(--muted-2); margin: 0 8px; }
.cpr-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; align-items: center; }
.cpr-right { display: flex; flex-direction: column; align-items: flex-end; gap: 9px; }
.cpr-val {
  font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums;
  letter-spacing: -.02em; white-space: nowrap;
}

/* ---------- Login ---------- */
.login-root {
  position: fixed; inset: 0; z-index: 60; overflow: hidden;
  display: grid; place-items: center; padding: 24px;
  background-color: var(--bg);
}
.login-root::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(900px 520px at 50% -12%, rgba(14, 159, 110, .10), transparent 62%),
    radial-gradient(700px 480px at 108% 108%, rgba(14, 159, 110, .07), transparent 68%);
}
.login-root::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(560px 380px at 50% 44%, rgba(255, 255, 255, .92), transparent 72%);
}
.login-root[hidden], .layout[hidden] { display: none; }
.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 404px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 44px 38px 36px; text-align: center;
  box-shadow: 0 24px 48px -28px rgba(16, 24, 40, .28), 0 2px 6px rgba(16, 24, 40, .04);
}
.login-ico {
  width: 52px; height: 52px; margin: 0 auto 16px;
  border-radius: 14px; display: grid; place-items: center;
  background: var(--accent);
  border: none;
  color: #fff;
  overflow: hidden;
  font-size: 24px;
  box-shadow: 0 4px 12px -4px rgba(7, 120, 90, .55);
}
.login-ico.tem-foto { background: #ffffff; border: 1px solid var(--border); box-shadow: none; }
.login-ico img { width: 100%; height: 100%; object-fit: cover; display: block; }
.login-ico svg { width: 24px; height: 24px; }
.login-title { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -.028em; line-height: 1.2; }
.login-sub { font-size: 13.5px; color: var(--muted); margin-top: 6px; letter-spacing: -.01em; }
.login-form { margin-top: 30px; display: flex; flex-direction: column; gap: 15px; text-align: left; }
.login-field { position: relative; display: flex; align-items: center; }
.login-field svg {
  position: absolute; left: 14px; width: 16px; height: 16px;
  color: var(--muted-2); pointer-events: none;
}
.login-field input {
  width: 100%; height: 46px; padding: 0 15px 0 42px;
  background: #ffffff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14.5px; color: var(--text); font-family: inherit; letter-spacing: -.01em;
  box-shadow: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-field input::placeholder { color: var(--muted-2); }
.login-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 159, 110, .13); }
.login-error {
  font-size: 13px; color: var(--danger); background: var(--danger-soft);
  border: 1px solid #f6d5dc; border-radius: var(--radius-sm); padding: 10px 12px;
  line-height: 1.45;
}
.login-btn {
  width: 100%; height: 46px; margin-top: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--accent);
  color: #ffffff; font-size: 14.5px; font-weight: 600;
  letter-spacing: -.012em; text-transform: none; font-family: inherit;
  box-shadow: 0 2px 6px -2px rgba(7, 120, 90, .45);
  transition: background .15s, box-shadow .15s;
}
.login-btn:hover:not(:disabled) { background: var(--accent-strong); }
.login-btn:active:not(:disabled) { background: var(--accent-deep); box-shadow: none; }
.login-btn:disabled { opacity: .7; cursor: wait; }
.login-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(14, 159, 110, .28); }

/* ---------- Usuário na sidebar ---------- */
.user-area {
  margin-top: auto; padding-top: 14px;
  border-top: 1px solid var(--sidebar-line);
}
.user-card { display: flex; align-items: center; gap: 11px; padding: 9px; border-radius: var(--radius-sm); cursor: pointer; transition: background .15s; }
.user-card:hover { background: var(--sidebar-hover); }
.user-ava {
  width: 34px; height: 34px; border-radius: var(--radius-sm); flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: #fff; color: var(--accent-deep); border: 1px solid var(--sidebar-line);
  overflow: hidden;
}
.user-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-ava.tem-foto { border: none; }
.cfg-row { display: flex; align-items: center; gap: 14px; }
.cfg-ava {
  width: 56px; height: 56px; border-radius: 14px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
  background: var(--accent-soft); color: var(--accent); border: none; overflow: hidden;
}
.cfg-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cfg-ava.tem-foto { border: none; }
.cfg-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cfg-info strong { font-size: 14.5px; }
.user-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.user-name { color: var(--sidebar-strong); font-weight: 600; font-size: 13px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-out {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 6px;
  border: none; background: none; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--sidebar-muted); padding: 1px 0;
  font-family: inherit; transition: color .15s;
}
.user-out:hover { color: #fff; }

@media (max-width: 420px) {
  .login-card { padding: 32px 24px 28px; }
}