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

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

:root {
  --primary: #ea580c;
  --primary-d: #c2410c;
  --primary-l: #fff7ed;
  --dark: #0b0f19;
  --dark2: #111827;
  --dark3: #1f2937;
  --green: #10b981;
  --green-l: #ecfdf5;
  --blue: #3b82f6;
  --blue-l: #eff6ff;
  --red: #ef4444;
  --red-l: #fef2f2;
  --amber: #f59e0b;
  --amber-l: #fef3c7;
  --purple: #8b5cf6;
  --purple-l: #f5f3ff;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text2: #475569;
  --text3: #64748b;
  --sidebar: 250px;
}

html, body {
  min-height: 100%;
  font-family: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar);
  background: var(--dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.slogo {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
}

.slogo img {
  max-width: 100%;
  max-height: 68px;
  width: auto;
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  object-fit: contain;
}

.snav {
  padding: 10px 8px;
  flex: 1;
}

.snav-sec {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.25);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 12px 10px 4px;
}

.snav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
  text-decoration: none;
  margin-bottom: 2px;
  transition: all 0.15s;
}

.snav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
}

.snav-item.active {
  background: rgba(37, 99, 235, 0.2);
  color: #fff;
  font-weight: 600;
}

.snav-item i {
  font-size: 17px;
  flex-shrink: 0;
}

.sfooter {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.svisita {
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(37, 99, 235, 0.35);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 11px;
  color: #bfdbfe;
  line-height: 1.4;
}

.svisita a {
  color: #fff;
  font-weight: 600;
  text-decoration: underline;
}

.suser {
  display: flex;
  align-items: center;
  gap: 9px;
}

.sav {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sname {
  flex: 1;
  overflow: hidden;
}

.sname .principal {
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.sname .secundario {
  color: rgba(255, 255, 255, 0.4);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.slogout {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.35);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.slogout:hover {
  background: rgba(239, 68, 68, 0.2);
  color: var(--red);
}

/* ── MAIN / TOPBAR / CONTENT ── */
.main {
  margin-left: var(--sidebar);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.content {
  flex: 1;
  padding: 24px;
  max-width: 1100px;
  width: 100%;
}

@media (max-width: 900px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
  }
  .main {
    margin-left: 0;
  }
}

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.card + .card {
  margin-top: 20px;
}

.card h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cabecalho-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.cabecalho-card h2 {
  margin-bottom: 0;
}

/* ── STAT CARDS ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.scard {
  background: var(--surface);
  border-radius: 11px;
  border: 1px solid var(--border);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.scard-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3);
  margin-bottom: 5px;
  font-weight: 600;
}

.scard-val {
  font-size: 24px;
  font-weight: 700;
  font-family: "Barlow Condensed", sans-serif;
  color: var(--text);
  line-height: 1.1;
}

/* ── FORM ELEMENTS ── */
.grade-campos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 16px;
}

.campo {
  margin-bottom: 16px;
}

.campo label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.campo input,
.campo textarea,
.campo select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border 0.15s;
}

.campo input:focus,
.campo textarea:focus,
.campo select:focus {
  border-color: var(--primary);
}

.campo textarea {
  resize: vertical;
  line-height: 1.5;
}

.campo .ajuda {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--text3);
}

/* ── BUTTONS ── */
.botao-primario {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.botao-primario:hover {
  background: var(--primary-d);
}

.botao-primario:disabled {
  opacity: 0.6;
  cursor: default;
}

.botao-secundario {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.15s;
}

.grupo-botoes-linha {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.grupo-botoes-final {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.botao-secundario:hover {
  background: var(--primary-l);
}

.botao-secundario:disabled {
  opacity: 0.6;
  cursor: default;
}

.link-acao {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
}

.link-acao.editar {
  color: var(--primary);
}

.link-acao.excluir {
  color: var(--red);
}

.link-cancelar {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
  color: var(--text3);
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  background: var(--blue-l);
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

/* ── TABLE ── */
.tabela-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
}

table.tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

table.tabela thead {
  background: var(--bg);
}

table.tabela th {
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

table.tabela td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.tabela tr:last-child td {
  border-bottom: none;
}

table.tabela tbody tr:hover {
  background: var(--bg);
}

table.tabela .acoes {
  display: flex;
  gap: 12px;
  white-space: nowrap;
}

.vazio-lista {
  color: var(--text3);
  font-size: 0.85rem;
  padding: 16px;
  text-align: center;
}

/* ── LINHA-PERFIL (par label/valor) ── */
.linha-perfil {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.linha-perfil:last-child {
  border-bottom: none;
}

.linha-perfil span:first-child {
  color: var(--text3);
}

/* ── MENSAGENS / ALERTAS ── */
.mensagem {
  margin: 0 0 16px;
  font-size: 0.85rem;
  padding: 10px 12px;
  border-radius: 8px;
  border-left: 4px solid var(--border);
}

.mensagem.erro {
  background: var(--red-l);
  color: #991b1b;
  border-left-color: var(--red);
}

.mensagem.sucesso {
  background: var(--green-l);
  color: #166534;
  border-left-color: var(--green);
}

.faixa-info {
  background: var(--blue-l);
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.oculto {
  display: none;
}

/* ── LOGO (Configurações) ── */
.logo-atual {
  margin-bottom: 10px;
}

.logo-preview {
  max-width: 200px;
  max-height: 80px;
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
}

/* ── VEÍCULOS (Clientes) ── */
.lista-veiculos {
  list-style: none;
  margin: 0 0 10px;
}

.lista-veiculos li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.linha-adicionar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.linha-adicionar input {
  flex: 1;
}

/* ── FOTOS (Orçamento) ── */
.grade-fotos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.foto-thumb {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
}

.foto-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.foto-thumb button {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.7rem;
  cursor: pointer;
}

/* ── CHECKLIST (Orçamento) ── */
.grade-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.item-checklist {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.item-checklist input {
  width: auto;
}

/* ── TOGGLE SWITCH (ativo/inativo) ── */
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
  vertical-align: middle;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cbd5e1;
  transition: 0.2s;
  border-radius: 20px;
}

.switch .slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: 0.2s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background-color: var(--green);
}

.switch input:checked + .slider:before {
  transform: translateX(18px);
}

.linha-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text3);
}

/* ── TABELA DENSA DE ITENS (linhas de orçamento) ── */
.items-tbl-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 16px;
}

table.items-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

table.items-tbl thead {
  background: var(--bg);
}

table.items-tbl th {
  padding: 8px 10px;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.items-tbl td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.items-tbl tr:last-child td {
  border-bottom: none;
}

table.items-tbl select,
table.items-tbl input[type="text"],
table.items-tbl input[type="number"] {
  width: 100%;
  padding: 5px 7px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  outline: none;
}

table.items-tbl select:focus,
table.items-tbl input:focus {
  border-color: var(--primary);
}

table.items-tbl .campo-linha {
  margin-bottom: 4px;
}

table.items-tbl .campo-linha:last-child {
  margin-bottom: 0;
}

table.items-tbl .linha-selects {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

table.items-tbl .nota-linha {
  font-size: 10.5px;
  color: var(--text3);
  margin-top: 4px;
  line-height: 1.4;
}

table.items-tbl .nota-linha.aviso {
  color: #b45309;
}

table.items-tbl .valor-calculado {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

table.items-tbl .rotulo-calculado {
  font-size: 9.5px;
  color: var(--text3);
  text-transform: uppercase;
  margin-top: 2px;
}

table.items-tbl .sugestao-hint {
  font-size: 10.5px;
  margin-top: 4px;
  line-height: 1.3;
}

table.items-tbl .margem-valor {
  font-weight: 700;
  white-space: nowrap;
}

.margem-positiva {
  color: var(--green);
}

.margem-negativa {
  color: var(--red);
}

.margem-neutra {
  color: var(--text);
}
