:root {
  --fett-bg: #e9edf4;
  --fett-sidebar: #111827;
  --fett-sidebar-text: #9ca3af;
  --fett-primary: #4f46e5;
  --fett-primary-hover: #4338ca;
  --fett-borda: #d3d9e3;
  --fett-campo-borda: #b8c1d1;
  --fett-campo-bg: #f8fafd;
  --fett-cabecalho: #f3f5fa;
  --fett-texto-suave: #556070;
  --bs-secondary-color: var(--fett-texto-suave);
  --bs-primary: var(--fett-primary);
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: var(--fett-primary);
  --bs-link-color-rgb: 79, 70, 229;
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --sidebar-largura: 248px;
}

body {
  background: var(--fett-bg);
  color: #1f2937;
  font-size: .925rem;
}

.btn-primary {
  --bs-btn-bg: var(--fett-primary);
  --bs-btn-border-color: var(--fett-primary);
  --bs-btn-hover-bg: var(--fett-primary-hover);
  --bs-btn-hover-border-color: var(--fett-primary-hover);
  --bs-btn-active-bg: var(--fett-primary-hover);
}
.btn-outline-primary {
  --bs-btn-color: var(--fett-primary);
  --bs-btn-border-color: var(--fett-primary);
  --bs-btn-hover-bg: var(--fett-primary);
  --bs-btn-hover-border-color: var(--fett-primary);
}
.btn { border-radius: .6rem; font-weight: 500; }
.btn-light { background: #fff; border-color: var(--fett-campo-borda); color: #374151; }
.btn-light:hover { background: var(--fett-cabecalho); border-color: #9aa5b8; }
.form-control, .form-select, .input-group-text {
  border-radius: .6rem;
  border: 1px solid var(--fett-campo-borda);
  background-color: var(--fett-campo-bg);
  color: #111827;
}
.form-control:hover, .form-select:hover { border-color: #9aa5b8; }
.form-control::placeholder { color: #8a94a6; }
.input-group > :not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group > :not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group-text { background: #e8ecf4; color: #475163; font-size: .8rem; font-weight: 500; }
.form-control:focus, .form-select:focus {
  background-color: #fff;
  border-color: var(--fett-primary);
  box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .2);
}
.form-label { font-weight: 600; font-size: .85rem; color: #1f2937; margin-bottom: .35rem; }
.form-text { color: var(--fett-texto-suave); }
.form-check-input { border-color: var(--fett-campo-borda); }
.text-muted { color: var(--fett-texto-suave) !important; }

/* ---------- Layout ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-largura);
  background: var(--fett-sidebar);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 1040;
  transition: transform .2s ease;
}
.brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  padding: 0 .5rem;
}
.brand-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.sidebar .nav-link {
  color: var(--fett-sidebar-text);
  border-radius: .6rem;
  padding: .6rem .75rem;
  display: flex;
  gap: .7rem;
  align-items: center;
  font-weight: 500;
}
.sidebar .nav-link:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.sidebar .nav-link.active { color: #fff; background: rgba(99, 102, 241, .25); }

.main { margin-left: var(--sidebar-largura); min-height: 100vh; }
.content { padding: 2rem; max-width: 1400px; }
.topbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  background: #fff;
  border-bottom: 1px solid var(--fett-borda);
  position: sticky;
  top: 0;
  z-index: 1030;
}

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .main { margin-left: 0; }
  .content { padding: 1rem; }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; margin: 0; letter-spacing: -.02em; }

/* ---------- Cards ---------- */
.card-soft {
  border: 1px solid var(--fett-borda);
  border-radius: 1rem;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  overflow: hidden;
}
.card-soft > .card-header {
  background: var(--fett-cabecalho);
  color: #111827;
  border-bottom: 1px solid var(--fett-borda);
  padding: .9rem 1.25rem;
}
.card-soft .table { --bs-table-bg: transparent; }
.card-soft .table th:first-child, .card-soft .table td:first-child { padding-left: 1.25rem; }
.card-soft .table td:first-child { min-width: 13rem; }
.card-soft .table td.col-codigo { min-width: 0; width: 1%; }
.card-soft .table td.col-objeto { min-width: 14rem; }
.card-soft .table th:last-child, .card-soft .table td:last-child { padding-right: 1.25rem; }
.table thead th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #475163;
  font-weight: 600;
  background: var(--fett-cabecalho);
  border-bottom-color: var(--fett-borda);
  white-space: nowrap;
}
.table td { border-color: #e4e8ef; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f3f5ff; }
.table td.text-end, .table th.text-end { white-space: nowrap; }
.table tfoot th { background: var(--fett-cabecalho); }
.linha-link { cursor: pointer; }

.stat {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #fff;
  border: 1px solid var(--fett-borda);
  border-radius: 1rem;
  padding: 1.1rem 1.25rem;
  height: 100%;
}
.stat-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 1.2rem;
}
.stat-label { font-size: .78rem; color: var(--fett-texto-suave); font-weight: 600; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }

.destaque {
  background: #fff;
  border: 1px solid var(--fett-borda);
  border-radius: 1rem;
  padding: 1.1rem 1.25rem;
  height: 100%;
}
.destaque-valor { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin: .15rem 0; }
.destaque-primario {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border: 0;
  color: #fff;
}
.destaque-primario .stat-label, .destaque-primario .small { color: rgba(255, 255, 255, .8); }

.vazio { text-align: center; padding: 3rem 1rem; color: #6b7280; }
.vazio i { font-size: 2.2rem; color: #c7cad6; }
.vazio p { margin: .5rem 0 1rem; }

/* ---------- Filtros ---------- */
.filtros { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  padding: .35rem .85rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--fett-borda);
  color: #374151;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
}
.chip:hover { border-color: #a5b4fc; }
.chip.active { background: var(--fett-primary); border-color: var(--fett-primary); color: #fff; }

.filtros-barra {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .75rem;
  margin-bottom: 1rem;
  padding: .9rem 1rem;
  background: #fff;
  border: 1px solid var(--fett-borda);
  border-radius: 1rem;
}
.filtros-barra .form-label { font-size: .75rem; margin-bottom: .2rem; color: var(--fett-texto-suave); }
.filtro { flex: 1 1 150px; min-width: 140px; }
.filtro-busca { flex: 2 1 240px; }
.filtro-acoes { flex: 0 0 auto; min-width: 0; display: flex; gap: .25rem; }
.filtro-acoes .btn-link { color: var(--fett-texto-suave); }
.chip .contagem { opacity: .7; margin-left: .25rem; }

/* ---------- Status ---------- */
.badge { font-weight: 500; }
.status-ganho { background: #dcfce7; color: #166534; }
.status-perdido { background: #fee2e2; color: #991b1b; }

/* ---------- Formulário de orçamento ---------- */
.item-linha { padding: .6rem 0; border-bottom: 1px dashed var(--fett-campo-borda); }
.item-linha:last-child { border-bottom: 0; }
.previa {
  background: #eef2ff;
  border-radius: .6rem;
  padding: .45rem .9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #3730a3;
}
.previa strong { font-size: 1.15rem; }
.codigo {
  display: inline-block;
  min-width: 2rem;
  padding: .15rem .55rem;
  border-radius: .5rem;
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 700;
  font-size: .8rem;
  text-align: center;
}
.barra-acoes {
  position: sticky;
  bottom: 0;
  padding: 1rem 0;
  background: linear-gradient(to top, var(--fett-bg) 70%, transparent);
}
.resumo { top: 1.5rem; }

/* ---------- Login ---------- */
.tela-login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, #111827 0%, #312e81 100%); }
.login-caixa { width: 100%; max-width: 380px; }
.tela-login .brand { color: #fff; }
.usuario-logado { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: var(--fett-sidebar-text); font-size: .85rem; padding: 0 .25rem; }
.usuario-logado .btn-link { color: var(--fett-sidebar-text); text-decoration: none; padding: 0; }
.usuario-logado .btn-link:hover { color: #fff; }

/* ---------- Pregão ---------- */
.trilha { display: flex; align-items: center; gap: .4rem; font-size: .85rem; margin-bottom: .5rem; color: var(--fett-texto-suave); }
.trilha a { color: var(--fett-texto-suave); text-decoration: none; }
.trilha a:hover { color: var(--fett-primary); }
.trilha .bi { font-size: .7rem; }

.itens-pregao { display: flex; flex-direction: column; gap: .75rem; }
.item-card {
  background: #fff;
  border: 1px solid var(--fett-borda);
  border-radius: 1rem;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
}
.item-resumo {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  border-radius: 1rem;
}
.item-resumo:hover { background: #f8f9ff; }
.item-num {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 700;
}
.item-titulo { flex: 1 1 200px; min-width: 0; }
.item-metricas { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.item-metricas > div { display: flex; flex-direction: column; text-align: right; min-width: 5.5rem; }
@media (min-width: 1200px) {
  .item-resumo .item-metricas { flex-wrap: nowrap; gap: 1.25rem; }
}
.item-metricas span { font-size: .72rem; color: var(--fett-texto-suave); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.item-metricas strong { font-size: .95rem; white-space: nowrap; }
.item-totais {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.25rem;
  padding-right: 3.1rem;
  border-radius: 1rem;
  background: var(--fett-cabecalho);
  border: 1px dashed var(--fett-campo-borda);
}
.passos .sub dt, .passos .sub dd { color: #111827; font-weight: 600; }
.item-seta { color: var(--fett-texto-suave); transition: transform .2s ease; }
.item-resumo[aria-expanded="true"] .item-seta { transform: rotate(180deg); }
.item-resumo[aria-expanded="true"] { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: 1px solid var(--fett-borda); }
.item-detalhe { padding: 1.25rem; background: var(--fett-bg); border-bottom-left-radius: 1rem; border-bottom-right-radius: 1rem; }
button.badge.dropdown-toggle { cursor: pointer; padding: .4em .7em; }
.dropdown-menu { --bs-dropdown-link-active-bg: var(--fett-primary); }
.status-em_analise { background: #fef3c7; color: #92400e; }
@media (max-width: 767.98px) {
  .item-resumo { flex-wrap: wrap; }
  .item-metricas { width: 100%; gap: 1rem; }
  .item-metricas > div { text-align: left; }
}
@media print {
  .item-resumo .item-seta { display: none; }
  .collapse { display: block !important; }
}

/* ---------- Detalhe ---------- */
.linhas { margin: 0; }
.linhas > div { display: flex; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid #e4e8ef; }
.linhas > div:last-child { border-bottom: 0; }
.linhas dt { font-weight: 400; color: var(--fett-texto-suave); }
.linhas dd { margin: 0; font-weight: 600; }
.linhas .total dt, .linhas .total dd { color: #111827; font-size: 1.05rem; font-weight: 700; }
.barra-preco { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: #e4e8ef; }

/* ---------- Impressão ---------- */
@media print {
  body { background: #fff; font-size: 11pt; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .card-soft, .destaque { box-shadow: none; break-inside: avoid; }
  .destaque-primario { background: #fff; color: #000; border: 1px solid #000; }
  .destaque-primario .stat-label, .destaque-primario .small { color: #333; }
}
