:root {
  --azul: #2d2d2d;
  --azul-medio: #454545;
  --laranja: #e04820;
  --laranja-claro: #fff4ef;
  --cinza: #f5f5f5;
  --cinza-borda: #e0e0e0;
  --texto: #2d2d2d;
  --texto-leve: #6b7280;
  --branco: #ffffff;
  --verde: #1a7a4a;
  --sombra: 0 2px 12px rgba(0,0,0,0.09);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--cinza);
  color: var(--texto);
  min-height: 100vh;
}

/* ── HEADER ── */
header {
  background: var(--azul);
  color: white;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  position: sticky;
  top: 0;
  z-index: 100;
}
header .logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}
header .logo-area img {
  height: 38px;
  object-fit: contain;
}
header .logo-area .nome {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}
header .logo-area .subtitulo {
  font-size: 0.72rem;
  opacity: 0.7;
  margin-top: 1px;
}
header .header-acoes {
  display: flex;
  align-items: center;
  gap: 8px;
}
header .btn-gerar {
  background: var(--laranja);
  color: white;
  border: none;
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  letter-spacing: 0.2px;
}
header .btn-gerar:hover { background: #c8390f; transform: translateY(-1px); }
header .btn-sec {
  background: rgba(255,255,255,0.12);
  color: white;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
header .btn-sec:hover { background: rgba(255,255,255,0.22); }
header .btn-admin { text-decoration: none; display: inline-flex; align-items: center; }

/* ── LAYOUT PRINCIPAL ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 800px) { .container { grid-template-columns: 1fr; } }

/* ── CARD ── */
.card {
  background: var(--branco);
  border-radius: 12px;
  box-shadow: var(--sombra);
  overflow: hidden;
}
.card.full { grid-column: 1 / -1; }

.card-header {
  background: var(--azul);
  color: white;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.card-header .icone {
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}
.card-body { padding: 20px; }

/* ── GRUPOS DE CAMPOS ── */
.campo-grupo {
  display: grid;
  gap: 14px;
}
.campo-grupo.col2 { grid-template-columns: 1fr 1fr; }
.campo-grupo.col3 { grid-template-columns: 1fr 1fr 1fr; }

.campo {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.campo label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--texto-leve);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.campo input,
.campo select,
.campo textarea {
  border: 1.5px solid var(--cinza-borda);
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 0.9rem;
  color: var(--texto);
  background: white;
  transition: border-color 0.2s;
  width: 100%;
  font-family: inherit;
}
.campo input:focus,
.campo select:focus,
.campo textarea:focus {
  outline: none;
  border-color: var(--azul-medio);
  box-shadow: 0 0 0 3px rgba(26,74,122,0.1);
}
.campo textarea { resize: vertical; min-height: 70px; }
.campo .hint {
  font-size: 0.72rem;
  color: var(--texto-leve);
}

/* ── TABELA DE UCS ── */
.uc-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.uc-table th {
  background: #3a3a3a;
  color: rgba(255,255,255,0.85);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 9px 4px;
  text-align: center;
  border-bottom: 2px solid #555;
  white-space: nowrap;
}
.uc-table th:first-child { text-align: left; padding-left: 10px; min-width: 130px; }
.uc-table th:last-child { width: 30px; }
.uc-table td {
  padding: 6px 3px;
  border-bottom: 1px solid var(--cinza-borda);
  text-align: center;
  vertical-align: middle;
}
.uc-table td:first-child { padding: 6px 6px; text-align: left; }
.uc-table td:last-child { padding: 4px 2px; }
.uc-table tbody tr:nth-child(even) td { background: #fafafa; }
.uc-table tbody tr:hover td { background: #f0f4ff !important; }
.uc-table tr:last-child td { border-bottom: none; }
.uc-table input {
  border: 1px solid var(--cinza-borda);
  border-radius: 5px;
  padding: 4px 5px;
  font-size: 0.82rem;
  width: 100%;
  text-align: center;
  color: var(--texto);
}
.uc-table input[type="text"] { text-align: left; }
.uc-table input:focus {
  outline: none;
  border-color: var(--laranja);
  box-shadow: 0 0 0 2px rgba(224,72,32,0.15);
}
/* Coluna Média */
.uc-table td:nth-last-child(2) {
  font-weight: 700;
  background: rgba(224,72,32,0.06);
  color: var(--laranja);
  min-width: 58px;
}
.uc-table th:nth-last-child(2) { background: rgba(224,72,32,0.25); color: white; }
.uc-table .total-row td {
  background: var(--laranja-claro) !important;
  font-weight: 700;
  color: var(--texto);
  border-top: 2px solid var(--laranja);
  font-size: 0.82rem;
}

.btn-add-uc {
  background: none;
  border: 1.5px dashed var(--cinza-borda);
  border-radius: 7px;
  padding: 9px;
  width: 100%;
  color: var(--texto-leve);
  font-size: 0.83rem;
  cursor: pointer;
  margin-top: 12px;
  transition: all 0.2s;
}
.btn-add-uc:hover { border-color: var(--azul-medio); color: var(--azul-medio); }

.btn-del-uc {
  background: none;
  border: none;
  color: #c0392b;
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 4px;
}
.btn-del-uc:hover { background: #fde8e8; }

/* ── PAINEL DE RESULTADO RÁPIDO ── */
.resultado-rapido {
  background: linear-gradient(135deg, var(--azul) 0%, var(--azul-medio) 100%);
  border-radius: 12px;
  padding: 20px;
  color: white;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.res-item { text-align: center; }
.res-item .valor {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.res-item .label-res {
  font-size: 0.72rem;
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 2px;
}
.res-item .sublabel {
  font-size: 0.8rem;
  opacity: 0.9;
  font-weight: 600;
  margin-top: 1px;
}
.res-divider {
  width: 1px;
  background: rgba(255,255,255,0.2);
  align-self: stretch;
  margin: 0 -6px;
}

/* ── BADGE ── */
.badge {
  display: inline-block;
  background: var(--laranja-claro);
  color: var(--laranja);
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  margin-left: 6px;
}
.badge.verde { background: #e8f7ef; color: var(--verde); }

/* ── SEPARADOR ── */
.sep { height: 1px; background: var(--cinza-borda); margin: 16px 0; }

/* ── CUSTOS GD2 ── */
.gd2-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.gd2-item {
  background: var(--cinza);
  border-radius: 8px;
  padding: 12px;
}
.gd2-item label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--texto-leve);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: block;
  margin-bottom: 6px;
}
.gd2-item .row-input {
  display: flex;
  align-items: center;
  gap: 6px;
}
.gd2-item input {
  border: 1.5px solid var(--cinza-borda);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.88rem;
  width: 100%;
  color: var(--texto);
  background: white;
}
.gd2-item input:focus {
  outline: none;
  border-color: var(--azul-medio);
  box-shadow: 0 0 0 3px rgba(26,74,122,0.1);
}
.gd2-item .unidade { font-size: 0.78rem; color: var(--texto-leve); white-space: nowrap; }

/* ── CHECKBOX TOGGLE ── */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.toggle-row input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--azul-medio);
  flex-shrink: 0;
}
.toggle-row label { font-size: 0.88rem; color: var(--texto); cursor: pointer; }

/* ── NOTIFICAÇÃO ── */
.notif {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--verde);
  color: white;
  padding: 12px 20px;
  border-radius: 9px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  z-index: 999;
}
.notif.visivel { opacity: 1; transform: translateY(0); }

/* ── INVERSORES TABLE — header leve (não herda o dark do uc-table) ── */
#inv-table th {
  background: var(--cinza);
  color: var(--texto-leve);
  font-size: 0.72rem;
  padding: 8px 6px;
  text-align: center;
  border-bottom: 1.5px solid var(--cinza-borda);
}
#inv-table th:first-child { text-align: left; padding-left: 10px; }
#inv-table th:nth-last-child(2) { background: var(--cinza); color: var(--texto); font-weight: 700; }
#inv-table td { padding: 7px 6px; background: white; }
#inv-table td:nth-last-child(2) { background: transparent; color: var(--texto); font-weight: 700; }
#inv-table tbody tr:hover td { background: #fafafa !important; }

/* ── DECOMPOSIÇÃO DE PREÇO ── */
.decomp-box {
  background: var(--cinza);
  border-radius: 10px;
  padding: 16px;
  border: 1.5px solid var(--cinza-borda);
  margin-top: 4px;
}
.decomp-titulo {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--texto-leve);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}
.decomp-barra-vis {
  display: flex;
  width: 100%;
  height: 22px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 14px;
}
.decomp-seg { height: 100%; transition: width 0.4s ease; }
.decomp-custo-seg    { background: #3d4a5c; }
.decomp-overhead-seg { background: #7f8c9b; }
.decomp-imposto-seg  { background: var(--laranja); }
.decomp-lucro-seg    { background: var(--verde); }
.decomp-linhas { display: flex; flex-direction: column; gap: 8px; }
.decomp-linha {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}
.decomp-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.decomp-lbl { flex: 1; color: var(--texto); }
.decomp-val {
  font-weight: 700;
  color: var(--texto);
  min-width: 110px;
  text-align: right;
}
.decomp-pct {
  font-size: 0.75rem;
  color: var(--texto-leve);
  min-width: 46px;
  text-align: right;
  background: rgba(0,0,0,0.06);
  padding: 2px 6px;
  border-radius: 4px;
}
.destaque-lucro .decomp-val { color: var(--verde); }
.destaque-lucro .decomp-pct { background: #e8f7ef; color: var(--verde); font-weight: 700; }
