/* ══════════════════════════════════════════════════════════════════════════════
   Orçamentos Valorize — UI inspirada no Manual de Marca Valorize 2026
   Paleta: Índigo #393883, Roxo #8615D4, Verde #10CCAE, Azul-céu #38ACF7,
   Navy #333366, Névoa #F3F4FB, Branco #FFFFFF.
   ══════════════════════════════════════════════════════════════════════════════ */

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

:root {
  --indigo: #393883;
  --purple: #8615D4;
  --green: #10CCAE;
  --sky: #38ACF7;
  --navy: #333366;
  --fog: #F3F4FB;
  --white: #FFFFFF;
  --text: #22224A;
  --muted: #8587A5;
  --line: #E5E7F4;
  --soft-indigo: rgba(57, 56, 131, .09);
  --soft-green: rgba(16, 204, 174, .14);
  --soft-sky: rgba(56, 172, 247, .16);
  --soft-purple: rgba(134, 21, 212, .12);
  --danger: #EF4444;
  --warning: #F59E0B;
  --success: #10A873;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 18px 45px rgba(51, 51, 102, .08);
  --shadow-sm: 0 8px 22px rgba(51, 51, 102, .07);
}

html { min-height: 100%; }
body {
  min-height: 100vh;
  font-family: 'Poppins', 'Segoe UI', system-ui, sans-serif;
  background:
    radial-gradient(circle at 105% -8%, rgba(16, 204, 174, .28) 0 7%, transparent 7.2% 100%),
    radial-gradient(circle at -5% 92%, rgba(134, 21, 212, .18) 0 8%, transparent 8.2% 100%),
    var(--fog);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

button, input, textarea, select { font: inherit; }
a { color: inherit; }

/* ── Estrutura principal ─────────────────────────────────────────────────── */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 20px;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(18px);
  border-right: 1px solid rgba(57,56,131,.10);
  display: flex;
  flex-direction: column;
  gap: 22px;
  z-index: 20;
}

.brand-card {
  position: relative;
  border: 0;
  background: var(--white);
  border-radius: 24px;
  min-height: 142px;
  padding: 20px 18px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.brand-card::before,
.brand-card::after {
  content: '';
  position: absolute;
  width: 120px;
  height: 120px;
  border: 18px solid var(--green);
  border-radius: 50%;
  opacity: .18;
}
.brand-card::before { top: -66px; right: -46px; }
.brand-card::after { left: -76px; bottom: -76px; border-color: var(--purple); opacity: .14; }
.brand-logo { position: relative; width: 138px; height: auto; object-fit: contain; z-index: 1; }
.brand-product {
  position: relative;
  z-index: 1;
  color: var(--indigo);
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-size: 12px;
}

.side-nav { display: flex; flex-direction: column; gap: 10px; }
.side-link {
  width: 100%;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  border-radius: 18px;
  color: var(--navy);
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, color .15s ease, box-shadow .15s ease;
  text-align: left;
}
.side-link span {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--soft-indigo);
  color: var(--indigo);
  font-weight: 800;
}
.side-link strong { font-size: 14px; font-weight: 700; }
.side-link:hover { background: rgba(57,56,131,.06); transform: translateX(2px); }
.side-link.active {
  color: #fff;
  background: linear-gradient(135deg, var(--indigo), var(--purple));
  box-shadow: 0 12px 26px rgba(57,56,131,.22);
}
.side-link.active span { background: rgba(255,255,255,.18); color: #fff; }

.help-card {
  margin-top: auto;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  background: var(--white);
  border: 1px solid rgba(57,56,131,.09);
  box-shadow: var(--shadow-sm);
}
.help-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--sky);
  color: #fff;
  font-weight: 800;
}
.help-card small { display: block; color: var(--muted); font-size: 11px; }
.help-card strong { color: var(--indigo); font-size: 12px; }
.help-arrow { margin-left: auto; color: var(--indigo); font-weight: 800; }

.workspace { min-width: 0; }
.topbar {
  height: 78px;
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 28px;
  background: rgba(243,244,251,.82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(57,56,131,.08);
}
.search-wrap {
  width: min(560px, 48vw);
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-radius: 16px;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  color: var(--muted);
  box-shadow: 0 8px 20px rgba(51,51,102,.04);
}
.search-wrap input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-wrap input::placeholder { color: #A4A6BD; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 999px;
  background: rgba(16, 204, 174, .12);
  color: var(--navy);
  font-weight: 700;
  border: 1px solid rgba(16,204,174,.28);
  white-space: nowrap;
}
.status-chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(16,204,174,.14); }
.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px 7px 7px;
  border-radius: 999px;
  background: var(--white);
  border: 1px solid var(--line);
}
.user-pill span {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--indigo);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.user-pill strong { color: var(--navy); font-size: 13px; }
.content-area { padding: 26px 28px 58px; max-width: 1600px; margin: 0 auto; }

/* ── Tipografia e utilitários ─────────────────────────────────────────────── */
h1 { font-size: clamp(28px, 3vw, 48px); line-height: 1.04; font-weight: 800; color: var(--indigo); letter-spacing: -.04em; }
h2 { font-size: 21px; line-height: 1.18; font-weight: 800; color: var(--navy); }
h3 { font-size: 15px; font-weight: 800; color: var(--navy); }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--purple);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.eyebrow::before { content: ''; width: 34px; height: 3px; background: currentColor; border-radius: 10px; }

/* ── Cards e blocos ──────────────────────────────────────────────────────── */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 22px;
}
.page-head p { color: var(--muted); max-width: 620px; margin-top: 8px; }
.card {
  position: relative;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(57,56,131,.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-body { padding: 22px; }
.card-header {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.valorize-ring::after {
  content: '';
  position: absolute;
  width: 190px;
  height: 190px;
  border: 30px solid var(--green);
  border-radius: 50%;
  right: -112px;
  top: -112px;
  opacity: .16;
  pointer-events: none;
}

/* ── Botões ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  font-weight: 800;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--indigo), var(--purple)); box-shadow: 0 16px 28px rgba(57,56,131,.24); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 20px 36px rgba(57,56,131,.28); }
.btn-success { color: #fff; background: var(--success); box-shadow: 0 10px 20px rgba(16,168,115,.22); }
.btn-warning { color: #fff; background: var(--warning); box-shadow: 0 10px 20px rgba(245,158,11,.18); }
.btn-perigo { color: #fff; background: var(--danger); box-shadow: 0 10px 20px rgba(239,68,68,.18); }
.btn-outline { color: var(--navy); background: #fff; border: 1px solid var(--line); box-shadow: none; }
.btn-outline:hover:not(:disabled) { background: var(--fog); }
.btn-sky { color: #fff; background: var(--sky); }
.btn-sm { min-height: 34px; padding: 7px 11px; border-radius: 11px; font-size: 12px; }
.btn-lg { min-height: 60px; padding: 14px 24px; border-radius: 18px; font-size: 16px; }
.btn-block { width: 100%; }
.arrow-btn::after { content: '→'; font-size: 18px; line-height: 1; }

/* ── Badges / chips ──────────────────────────────────────────────────────── */
.badge, .chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.badge-criada, .badge-pendente { background: var(--soft-indigo); color: var(--indigo); }
.badge-em_busca { background: rgba(56,172,247,.15); color: #1474B8; }
.badge-aguardando_intervencao { background: rgba(245,158,11,.15); color: #B45309; }
.badge-concluida, .badge-valido, .badge-aprovado { background: var(--soft-green); color: #087B65; }
.badge-erro, .badge-invalido, .badge-reprovado, .badge-erro-orc { background: rgba(239,68,68,.12); color: #B91C1C; }
.badge-status { text-transform: uppercase; letter-spacing: .04em; }
.chip-ok { background: var(--soft-green); color: #087B65; }
.chip-info { background: var(--soft-sky); color: #146DA0; }
.chip-alert { background: rgba(245,158,11,.14); color: #B45309; }
.chip-danger { background: rgba(239,68,68,.12); color: #B91C1C; }

/* ── Formulário nova cotação ─────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr);
  gap: 18px;
  align-items: stretch;
}
.form-steps {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(210px, .72fr);
  gap: 16px;
  margin-top: 20px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label { font-size: 12px; color: var(--navy); font-weight: 800; }
.form-control {
  min-height: 50px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  transition: box-shadow .15s, border-color .15s;
}
.form-control:focus { border-color: var(--sky); box-shadow: 0 0 0 4px rgba(56,172,247,.15); }
textarea.form-control { min-height: 74px; resize: vertical; }
.input-icon-row { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 10px; align-items: end; }
.input-icon {
  min-height: 50px;
  border-radius: 15px;
  background: var(--soft-sky);
  color: var(--indigo);
  display: grid;
  place-items: center;
  font-size: 22px;
}
.step-label { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--navy); font-weight: 800; margin-bottom: 8px; }
.step-dot { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; background: var(--indigo); color: #fff; font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ── Automação / progresso ───────────────────────────────────────────────── */
.process-card { min-height: 100%; }
.process-title { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.process-icon { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: var(--soft-purple); color: var(--purple); font-size: 24px; }
.steps-line { position: relative; display: flex; flex-direction: column; gap: 18px; margin-left: 12px; }
.steps-line::before { content: ''; position: absolute; left: 16px; top: 20px; bottom: 22px; width: 2px; background: var(--line); }
.process-step { position: relative; display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 12px; align-items: center; }
.step-circle { position: relative; z-index: 1; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: #DCE0F1; color: var(--navy); }
.step-circle.done { background: var(--green); color: #fff; }
.step-circle.active { background: var(--sky); color: #fff; box-shadow: 0 0 0 7px rgba(56,172,247,.14); }
.process-step strong { color: var(--navy); font-size: 13px; }
.process-step small { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
.step-state { color: var(--muted); font-size: 11px; font-weight: 700; }
.progress-wrap { margin-top: 20px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 14px; align-items: center; }
.progress-bar { height: 12px; border-radius: 999px; background: #E2E6F5; overflow: hidden; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--sky), var(--purple)); transition: width .25s ease; }
.progress-number { font-weight: 800; color: var(--navy); }

/* ── Lista / tabelas ─────────────────────────────────────────────────────── */
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { padding: 18px; min-height: 126px; display: flex; flex-direction: column; justify-content: space-between; }
.metric-card small { color: var(--muted); font-weight: 700; }
.metric-card strong { font-size: 28px; color: var(--indigo); line-height: 1; }
.metric-card span { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0 10px; }
th { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 800; text-align: left; padding: 0 14px 6px; }
td { background: #fff; padding: 15px 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 13px; }
td:first-child { border-left: 1px solid var(--line); border-radius: 16px 0 0 16px; }
td:last-child { border-right: 1px solid var(--line); border-radius: 0 16px 16px 0; }
tr.cotacao-row { cursor: pointer; transition: transform .15s; }
tr.cotacao-row:hover { transform: translateY(-1px); }
tr.cotacao-row:hover td { border-color: rgba(56,172,247,.36); background: #FCFDFF; }

/* ── Detalhe de cotação ──────────────────────────────────────────────────── */
.detalhe-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.hero-panel { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); gap: 18px; margin-bottom: 18px; }
.info-summary { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-top: 16px; }
.info-tile { padding: 14px; border-radius: 16px; background: var(--fog); border: 1px solid rgba(57,56,131,.06); }
.info-tile small { color: var(--muted); display: block; font-weight: 700; margin-bottom: 4px; }
.info-tile strong { color: var(--navy); }
.summary-panel { position: sticky; top: 98px; }
.summary-item { display: grid; grid-template-columns: 44px minmax(0,1fr); gap: 12px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.summary-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: var(--indigo); background: var(--soft-sky); font-size: 20px; }
.summary-item small { display: block; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.summary-item strong { color: var(--navy); font-size: 13px; }
.donut { width: 124px; height: 124px; border-radius: 50%; margin: 16px auto; display: grid; place-items: center; background: conic-gradient(var(--green) 0 var(--pct), var(--warning) var(--pct) 75%, #E1E4F0 75% 100%); }
.donut-inner { width: 84px; height: 84px; border-radius: 50%; background: #fff; display: grid; place-items: center; text-align: center; color: var(--navy); font-size: 11px; }
.donut-inner strong { display: block; font-size: 20px; }
.legend { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.legend-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); }
.legend-row span { display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.green { background: var(--green); }
.dot.warning { background: var(--warning); }
.dot.red { background: var(--danger); }
.tip-box { display: flex; gap: 10px; align-items: flex-start; background: rgba(56,172,247,.12); border: 1px solid rgba(56,172,247,.20); color: var(--navy); padding: 14px; border-radius: 16px; font-size: 12px; margin-bottom: 14px; }
.tip-box span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--sky); color: #fff; flex: 0 0 auto; }

.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.orc-list { display: flex; flex-direction: column; gap: 12px; }
.orc-row {
  position: relative;
  display: grid;
  grid-template-columns: 74px 170px minmax(190px, 1.1fr) 132px 166px 154px 138px;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 10px 24px rgba(51,51,102,.045);
  overflow: hidden;
}
.orc-row::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: #CBD2E5; }
.orc-row.aprovado::before { background: var(--green); }
.orc-row.reprovado::before { background: var(--danger); }
.orc-row.best::before { background: linear-gradient(180deg, var(--green), var(--sky)); }
.orc-medal { width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; background: var(--fog); color: var(--indigo); font-weight: 800; text-align: center; font-size: 22px; }
.orc-row.best .orc-medal { color: #087B65; background: var(--soft-green); }
.orc-store strong { display: block; color: var(--indigo); font-size: 15px; line-height: 1.1; }
.orc-store small, .orc-product small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; word-break: break-all; }
.orc-product strong { color: var(--navy); }
.orc-price { color: #078653; font-size: 20px; font-weight: 800; white-space: nowrap; }
.orc-checks { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.orc-previews { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preview-box { display: flex; flex-direction: column; gap: 5px; align-items: center; color: var(--muted); font-size: 10px; font-weight: 700; }
.preview-thumb { width: 64px; height: 46px; border: 1px solid var(--line); border-radius: 10px; object-fit: cover; background: var(--fog); cursor: pointer; }
.preview-empty { width: 64px; height: 46px; border-radius: 10px; background: var(--fog); border: 1px dashed #C8CDE1; display: grid; place-items: center; color: var(--muted); }
.orc-actions { display: flex; flex-direction: column; gap: 8px; }
.orc-evidence { color: var(--indigo); font-size: 12px; font-weight: 800; text-decoration: none; }

/* ── Automação/log ───────────────────────────────────────────────────────── */
.automation-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.intervencao-alerta { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.28); border-radius: 18px; padding: 14px; margin-top: 14px; color: #92400E; font-size: 13px; }
.intervencao-alerta strong { display: block; margin-bottom: 4px; }
.log-box { max-height: 240px; overflow-y: auto; border-radius: 18px; padding: 14px 16px; background: var(--navy); font-family: 'Consolas', monospace; font-size: 12px; line-height: 1.6; }
.log-linha { margin: 0; }
.log-INFO { color: #9CF2DE; }
.log-AVISO { color: #FDE68A; }
.log-ERRO { color: #FCA5A5; }

/* ── Lightbox / modal / toast / estados ──────────────────────────────────── */
.imagem-preview { width: 100%; border: 1px solid var(--line); border-radius: 18px; cursor: pointer; transition: opacity .15s; }
.imagem-preview:hover { opacity: .86; }
.lightbox-overlay { position: fixed; inset: 0; background: rgba(19,19,46,.86); z-index: 200; display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 24px; }
.lightbox-overlay img { max-width: 94vw; max-height: 94vh; border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.empty { min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; color: var(--muted); padding: 32px; }
.empty-icon { font-size: 42px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-dark { border-color: rgba(57,56,131,.16); border-top-color: var(--indigo); }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 9px; }
.toast { background: var(--navy); color: #fff; border-left: 5px solid var(--sky); padding: 13px 17px; border-radius: 16px; font-size: 13px; box-shadow: 0 16px 35px rgba(51,51,102,.25); max-width: 360px; animation: slideIn .2s ease; }
.toast-success { border-left-color: var(--green); }
.toast-erro { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--sky); }
@keyframes slideIn { from { transform: translateX(22px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-overlay { position: fixed; inset: 0; background: rgba(19,19,46,.55); z-index: 400; display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal-overlay.hidden { display: none; }
.modal { background: #fff; border-radius: 24px; padding: 24px; width: 420px; max-width: 96vw; box-shadow: 0 30px 80px rgba(19,19,46,.25); }
.modal-titulo { font-size: 18px; font-weight: 800; color: var(--navy); margin-bottom: 8px; }
.modal-corpo { color: var(--muted); margin-bottom: 22px; }
.modal-acoes { display: flex; justify-content: flex-end; gap: 10px; }

/* ── Responsivo ──────────────────────────────────────────────────────────── */
@media (max-width: 1320px) {
  .orc-row { grid-template-columns: 54px 150px minmax(180px,1fr) 126px 150px 130px; }
  .orc-previews { display: none; }
}
@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 14px; }
  .brand-card { min-height: 74px; min-width: 176px; flex-direction: row; justify-content: flex-start; }
  .brand-logo { width: 76px; }
  .brand-product { display: none; }
  .side-nav { flex-direction: row; }
  .side-link { min-width: max-content; }
  .help-card { display: none; }
  .topbar { top: 0; }
  .dashboard-grid, .hero-panel, .detalhe-layout { grid-template-columns: 1fr; }
  .summary-panel { position: static; }
}
@media (max-width: 780px) {
  .topbar { height: auto; align-items: stretch; flex-direction: column; padding: 12px 14px; }
  .search-wrap { width: 100%; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .content-area { padding: 18px 14px 44px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .metrics-grid, .form-steps, .info-summary { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .orc-row { grid-template-columns: 1fr; }
  .orc-medal { width: 46px; height: 46px; }
}

/* ── v3: Lotes, fila, conformidade e aprovação ─────────────────────────── */
.page-title { margin-bottom: 20px; }
.page-title h1 { font-size: clamp(28px, 3vw, 44px); line-height: 1.05; color: var(--indigo); margin: 6px 0; font-weight: 800; }
.page-title p { color: var(--muted); max-width: 760px; font-size: 15px; }
.back-link { border: 0; background: transparent; color: var(--indigo); font-weight: 800; cursor: pointer; padding: 0; margin-bottom: 6px; }

.section-card { background: rgba(255,255,255,.94); border: 1px solid rgba(57,56,131,.08); border-radius: 28px; box-shadow: var(--shadow); padding: 24px; margin-bottom: 22px; position: relative; overflow: hidden; }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-header.compact { margin-top: 24px; }
.section-header h2 { color: var(--indigo); font-size: 22px; margin-bottom: 3px; }
.section-header p { color: var(--muted); }
.loading-card { padding: 28px; color: var(--muted); }

.hero-panel { background: linear-gradient(135deg, var(--indigo), var(--navy)); color: #fff; border-radius: 32px; padding: 34px; min-height: 240px; display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; box-shadow: 0 24px 54px rgba(57,56,131,.22); margin-bottom: 22px; overflow: hidden; position: relative; }
.hero-panel h1 { max-width: 720px; font-size: clamp(34px, 4vw, 58px); line-height: .98; font-weight: 800; margin: 8px 0 12px; }
.hero-panel p { max-width: 720px; color: rgba(255,255,255,.78); font-size: 16px; }
.eyebrow { color: var(--green); font-weight: 800; letter-spacing: .15em; text-transform: uppercase; font-size: 12px; }
.hero-actions { display: flex; flex-direction: column; gap: 10px; min-width: 260px; position: relative; z-index: 1; }
.valorize-rings::before, .valorize-rings::after { content: ''; position: absolute; border-radius: 50%; pointer-events: none; opacity: .24; }
.valorize-rings::before { width: 260px; height: 260px; border: 34px solid var(--green); right: -92px; top: -110px; }
.valorize-rings::after { width: 240px; height: 240px; border: 34px solid var(--purple); left: -140px; bottom: -150px; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 22px; }
.metric-card { background: rgba(255,255,255,.94); border: 1px solid rgba(57,56,131,.08); border-radius: 24px; box-shadow: var(--shadow-sm); padding: 20px; display: flex; flex-direction: column; gap: 8px; min-height: 140px; }
.metric-card span { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 15px; background: var(--soft-sky); color: var(--indigo); font-weight: 800; }
.metric-card strong { color: var(--indigo); font-size: 34px; line-height: 1; }
.metric-card small { color: var(--muted); font-weight: 600; }
.metric-card.skeleton { color: var(--muted); }

.lote-list { display: flex; flex-direction: column; gap: 12px; }
.lote-row, .item-row { display: grid; grid-template-columns: minmax(260px,1.2fr) minmax(200px,.9fr) auto auto; align-items: center; gap: 16px; padding: 16px; border: 1px solid rgba(57,56,131,.08); background: #fff; border-radius: 20px; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; }
.lote-row:hover, .item-row:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); border-color: rgba(56,172,247,.35); }
.lote-main { display: flex; align-items: center; gap: 14px; }
.lote-main strong, .item-row strong { color: var(--indigo); font-size: 15px; }
.lote-main p, .item-row p { color: var(--muted); font-size: 12px; margin-top: 3px; }
.lote-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 16px; background: var(--soft-indigo); color: var(--indigo); font-weight: 800; }
.lote-progress, .mini-progress { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
.progress-bar { width: 100%; height: 9px; background: #E8EAF6; border-radius: 99px; overflow: hidden; }
.progress-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), var(--sky)); }
.progress-big { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; margin: 20px 0; }
.progress-big strong { color: var(--indigo); font-size: 22px; }
.lote-actions { display: flex; flex-wrap: wrap; gap: 12px; position: relative; z-index: 1; }
.queue-status { margin-top: 14px; padding: 14px; border-radius: 18px; background: var(--fog); color: var(--indigo); font-weight: 700; position: relative; z-index: 1; }
.lote-detail-grid { display: grid; grid-template-columns: minmax(0,1fr) 330px; gap: 18px; }
.summary-list { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.summary-list span { display: flex; justify-content: space-between; padding: 12px; border-radius: 16px; background: var(--fog); color: var(--muted); }
.summary-list strong { color: var(--indigo); }

.form-grid-wide { grid-template-columns: 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-group label { font-size: 12px; font-weight: 800; color: var(--indigo); }
.form-group input, .form-group select, .form-group textarea, .inline-add input, .inline-add select { width: 100%; border: 1px solid var(--line); border-radius: 15px; background: #fff; min-height: 44px; padding: 10px 13px; outline: none; color: var(--text); }
.form-group input:focus, .form-group select:focus, .inline-add input:focus { border-color: var(--sky); box-shadow: 0 0 0 4px rgba(56,172,247,.13); }
.itens-form { display: flex; flex-direction: column; gap: 14px; }
.item-line { display: grid; grid-template-columns: 42px 1.15fr 1fr 110px 110px 74px 150px 38px; gap: 10px; align-items: end; padding: 14px; border-radius: 22px; background: var(--fog); border: 1px solid rgba(57,56,131,.08); }
.item-line-number { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; background: var(--indigo); color: #fff; font-weight: 800; align-self: center; }
.btn-icon-danger { width: 36px; height: 36px; border-radius: 12px; border: 0; background: #FEE2E2; color: var(--danger); font-size: 22px; cursor: pointer; margin-bottom: 4px; }
.reuso-box { grid-column: 2 / -2; padding: 10px 12px; background: rgba(56,172,247,.12); color: var(--indigo); border-radius: 14px; font-size: 12px; font-weight: 700; }
.hidden { display: none !important; }
.form-actions-sticky { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.inline-add { display: grid; grid-template-columns: 1fr 1fr 130px 130px 150px auto; gap: 10px; margin-bottom: 16px; padding: 14px; border-radius: 20px; background: var(--fog); }

.item-table { display: flex; flex-direction: column; gap: 10px; }
.price-range { color: var(--indigo); font-weight: 800; }
.approval-summary { position: relative; overflow: hidden; background: #fff; border-radius: 28px; border: 1px solid rgba(57,56,131,.08); box-shadow: var(--shadow); padding: 22px; display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center; margin-bottom: 18px; }
.approval-summary h2 { color: var(--indigo); }
.approval-summary p { color: var(--muted); }
.approval-counter { width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; text-align: center; background: conic-gradient(var(--green) 0 66%, #EBEDF8 66%); color: var(--indigo); position: relative; }
.approval-counter::before { content: ''; position: absolute; inset: 12px; background: #fff; border-radius: 50%; }
.approval-counter strong, .approval-counter span { position: relative; z-index: 1; display: block; }
.approval-counter strong { font-size: 22px; }
.approval-counter span { font-size: 12px; color: var(--muted); }

.quote-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; margin-bottom: 20px; }
.quote-card { background: #fff; border: 1px solid rgba(57,56,131,.08); border-radius: 26px; padding: 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 14px; }
.quote-card.approved { border-color: rgba(16,204,174,.6); box-shadow: 0 14px 34px rgba(16,204,174,.12); }
.quote-card.rejected { opacity: .68; border-color: rgba(239,68,68,.35); }
.quote-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.quote-head strong { color: var(--indigo); font-size: 17px; }
.quote-head small { display: block; color: var(--muted); margin-top: 2px; }
.quote-price { color: var(--success); font-weight: 800; font-size: 22px; white-space: nowrap; }
.score-box { display: flex; align-items: center; justify-content: space-between; padding: 12px; background: var(--fog); border-radius: 16px; color: var(--muted); }
.score-box strong { color: var(--indigo); font-size: 24px; }
.cnpj-line { color: var(--muted); }
.cnpj-line strong { color: var(--indigo); }
.checklist-simple { display: grid; gap: 6px; }
.checklist-simple span { padding: 8px 10px; border-radius: 12px; font-size: 12px; font-weight: 800; }
.checklist-simple .ok { background: rgba(16,204,174,.14); color: #087F6D; }
.checklist-simple .bad { background: rgba(239,68,68,.10); color: #B91C1C; }
.preview-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.preview-pair button { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 8px; cursor: zoom-in; }
.preview-pair span { display: block; font-size: 11px; color: var(--muted); font-weight: 800; margin-bottom: 6px; }
.preview-pair img { width: 100%; height: 86px; object-fit: cover; border-radius: 10px; }
.quote-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.warn-text { color: var(--danger); font-size: 12px; font-weight: 700; }
.log-box { max-height: 260px; overflow: auto; background: #111332; border-radius: 18px; padding: 14px; color: #fff; font-family: Consolas, monospace; font-size: 12px; }

.supplier-table { display: flex; flex-direction: column; gap: 10px; }
.supplier-table article { display: grid; grid-template-columns: 1fr 110px 110px 110px 90px; gap: 12px; align-items: center; padding: 14px; border-radius: 18px; background: var(--fog); }
.supplier-table strong { color: var(--indigo); }
.empty-state { display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; padding: 34px; color: var(--muted); }
.empty-state strong { color: var(--indigo); font-size: 18px; }

.badge-rascunho, .badge-criada { background: var(--soft-indigo); color: var(--indigo); }
.badge-em_fila, .badge-em_execucao, .badge-em_busca { background: var(--soft-sky); color: var(--indigo); }
.badge-pendente_aprovacao, .badge-concluida_com_pendencia, .badge-pendente_orcamento_formal { background: rgba(245,158,11,.14); color: #A16207; }
.badge-concluida, .badge-concluido { background: rgba(16,204,174,.16); color: #087F6D; }
.badge-erro { background: rgba(239,68,68,.14); color: #B91C1C; }

.btn-xl { min-height: 52px; padding-inline: 22px; font-weight: 800; }
.btn-success { background: var(--green); color: var(--navy); }
.btn-success:hover:not(:disabled) { filter: brightness(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 1180px) {
  .metrics-grid, .quote-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .lote-detail-grid { grid-template-columns: 1fr; }
  .item-line { grid-template-columns: 42px 1fr 1fr; }
  .item-line .small, .item-line .tiny, .item-line .tipo { grid-column: auto; }
  .btn-icon-danger { align-self: center; }
  .inline-add { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .side-nav { flex-direction: row; overflow-x: auto; }
  .brand-card { min-height: 100px; }
  .topbar { flex-direction: column; align-items: stretch; height: auto; }
  .search-wrap { width: 100%; }
  .hero-panel, .approval-summary { grid-template-columns: 1fr; display: grid; }
  .metrics-grid, .quote-grid { grid-template-columns: 1fr; }
  .lote-row, .item-row { grid-template-columns: 1fr; }
  .item-line { grid-template-columns: 1fr; }
  .item-line-number { align-self: start; }
}

/* ── Operação 24/7 ───────────────────────────────────────────────────────── */
.operation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr);
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}
.operation-hero .worker-hint {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(57,56,131,.08);
  color: var(--navy);
  font-size: 13px;
}
.operation-hero code {
  background: #fff;
  border: 1px solid rgba(57,56,131,.15);
  border-radius: 8px;
  padding: 2px 6px;
  font-family: Consolas, monospace;
}
.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.config-grid .toggle-line {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(57,56,131,.14);
  border-radius: 14px;
  background: #fff;
  font-weight: 600;
  color: var(--navy);
}
.config-grid button { grid-column: 1 / -1; }
.worker-list, .event-list { display: flex; flex-direction: column; gap: 10px; }
.worker-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(57,56,131,.12);
  border-radius: 16px;
  background: #fff;
}
.worker-row p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.worker-row small { color: var(--muted); }
.event-list p {
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--mist);
  color: var(--navy);
  margin: 0;
}
.event-list small { display: block; color: var(--muted); margin-top: 4px; }
@media (max-width: 980px) { .operation-grid { grid-template-columns: 1fr; } .config-grid { grid-template-columns: 1fr; } }
.badge-fila_24x7, .badge-fila_noturna, .badge-online, .badge-processando { background: rgba(16,204,174,.16); color: #087F6D; }
.badge-pausado, .badge-sugestao_reaproveitamento { background: rgba(245,158,11,.14); color: #A16207; }

/* Correção v4.1 — painel de intervenção/captcha */
.intervention-panel {
  background: linear-gradient(135deg, #FFF7E8, #FFFFFF);
  border: 1px solid rgba(217,119,6,.28);
  border-radius: 26px;
  box-shadow: 0 18px 42px rgba(217,119,6,.12);
  padding: 22px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.intervention-panel > div {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.intervention-panel h2 { color: #92400E; margin-bottom: 4px; }
.intervention-panel p { color: #7C2D12; margin-bottom: 4px; font-weight: 700; }
.intervention-panel small { color: #92400E; }
.intervention-icon {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #FEF3C7;
  font-size: 24px;
  flex: 0 0 auto;
}
.intervention-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}
.intervention-inline div:first-child {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.intervention-inline strong { color: #92400E; }
.intervention-inline span { color: #7C2D12; font-weight: 600; }
.intervention-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn-warning {
  background: #D97706;
  color: #fff;
  border-color: #D97706;
}
.btn-warning:hover { filter: brightness(.96); }
@media (max-width: 760px) {
  .intervention-panel, .intervention-inline { flex-direction: column; align-items: stretch; }
}
