/* =====================================================================
   Squad MMGD - Interface Web
   Paleta premium: navy, black, orange
   ===================================================================== */

:root {
  /* Paleta principal */
  --navy: #0A1628;
  --navy-soft: #1B2B47;
  --navy-light: #2A3F5F;
  --orange: #F26822;
  --orange-soft: #FFA268;
  --orange-bg: #FEF3EC;

  /* Neutros */
  --black: #0D0D0D;
  --gray-900: #1A1A1A;
  --gray-700: #4A4A4A;
  --gray-500: #888888;
  --gray-300: #D1D5DB;
  --gray-100: #F3F4F6;
  --gray-50: #F9FAFB;
  --white: #FFFFFF;

  /* Funcionais */
  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;

  /* Tipografia */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  --font-display: "Inter", -apple-system, sans-serif;

  /* Sombras */
  --shadow-sm: 0 1px 2px rgba(10, 22, 40, 0.05);
  --shadow-md: 0 4px 12px rgba(10, 22, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(10, 22, 40, 0.12);

  /* Raios */
  --radius: 10px;
  --radius-lg: 16px;
}

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

html, body {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.55;
  min-height: 100vh;
}

/* ============== LAYOUT BASE ============== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.content {
  padding: 32px 24px 80px;
}

/* ============== TOPBAR ============== */
.topbar {
  background: var(--navy);
  color: var(--white);
  padding: 20px 0;
  border-bottom: 3px solid var(--orange);
  box-shadow: var(--shadow-md);
}

.topbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  width: 56px;
  height: 56px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.brand-text h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 2px;
}

.brand-text p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 400;
}

/* ============== BUTTONS ============== */
.btn {
  display: inline-block;
  padding: 11px 22px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--orange);
  color: var(--white);
  box-shadow: 0 4px 14px rgba(242, 104, 34, 0.32);
}

.btn-primary:hover {
  background: #DC5A18;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(242, 104, 34, 0.42);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.15);
}

.content .btn-ghost {
  background: var(--white);
  color: var(--navy);
  border: 1px solid var(--gray-300);
}

.content .btn-ghost:hover {
  background: var(--gray-100);
  border-color: var(--navy);
}

.btn-large {
  padding: 16px 32px;
  font-size: 16px;
}

/* ============== KPI CARDS (HOME) ============== */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
}

.kpi-card-accent {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-soft) 100%);
  color: var(--white);
  border-color: var(--navy);
}

.kpi-card-accent .kpi-label {
  color: rgba(255, 255, 255, 0.7);
}

.kpi-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -1px;
  margin-bottom: 4px;
}

.kpi-card-accent .kpi-value {
  color: var(--orange-soft);
}

.kpi-label {
  font-size: 13px;
  color: var(--gray-500);
}

/* ============== PROJECTS LIST ============== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
}

.muted {
  font-size: 13px;
  color: var(--gray-500);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
  display: block;
}

.project-card:hover {
  border-color: var(--orange);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.project-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--navy);
  color: var(--white);
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.project-power {
  font-size: 18px;
  font-weight: 700;
  color: var(--orange);
}

.project-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--navy);
}

.project-meta {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.project-footer {
  border-top: 1px solid var(--gray-100);
  padding-top: 12px;
}

.project-id {
  font-family: "SF Mono", "Consolas", monospace;
  font-size: 11px;
  color: var(--gray-500);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 2px dashed var(--gray-300);
}

.empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 22px;
  color: var(--navy);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--gray-500);
  margin-bottom: 20px;
}

/* ============== STEPS INDICATOR ============== */
.steps-indicator {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  background: var(--white);
  padding: 18px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  flex: 1;
  position: relative;
}

.step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 36px;
  right: -8px;
  top: 50%;
  height: 2px;
  background: var(--gray-300);
  z-index: 0;
}

.step span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gray-300);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.step.active {
  color: var(--navy);
  font-weight: 700;
}

.step.active span {
  background: var(--orange);
}

.step.completed span {
  background: var(--success);
}

/* ============== FORM ============== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px;
}

.form-step {
  border: none;
  display: none;
}

.form-step.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

legend {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 20px;
  letter-spacing: -0.3px;
}

.subsection {
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
  margin-top: 24px;
  margin-bottom: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-100);
}

.help-text {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 16px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
}

.field input,
.field select {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: 8px;
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(242, 104, 34, 0.15);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.form-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--gray-100);
}

.form-nav .btn-primary {
  margin-left: auto;
}

/* ============== TABELA DE COORDENADAS ============== */
.coord-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.coord-table th {
  background: var(--gray-50);
  font-weight: 600;
  font-size: 13px;
  padding: 10px;
  border: 1px solid var(--gray-300);
  color: var(--navy);
  text-align: center;
}

.coord-table td {
  padding: 6px;
  border: 1px solid var(--gray-300);
}

.coord-table input {
  border: none;
  padding: 6px 10px;
  width: 100%;
  text-align: center;
}

/* ============== TABELAS DINÂMICAS (módulos/inversores) ============== */
.dynamic-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 16px;
}

.dynamic-table th {
  background: var(--navy);
  color: var(--white);
  padding: 10px 8px;
  font-weight: 600;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.dynamic-table th:first-child { border-radius: 8px 0 0 0; }
.dynamic-table th:last-child { border-radius: 0 8px 0 0; }

.dynamic-table td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.dynamic-table tbody tr:hover {
  background: var(--gray-50);
}

.dynamic-table input,
.dynamic-table select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
}

.dynamic-table input:focus {
  outline: none;
  border-color: var(--orange);
}

.dynamic-table tfoot td {
  background: var(--orange-bg);
  border-top: 2px solid var(--orange);
  padding: 12px 8px;
  font-size: 14px;
}

.row-num {
  text-align: center;
  font-weight: 600;
  color: var(--gray-500);
}

.btn-remove-row {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--danger);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.btn-remove-row:hover {
  background: var(--danger);
  color: var(--white);
}

/* ============== RESUMO BOX ============== */
.resumo-box {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-soft) 100%);
  color: var(--white);
  padding: 20px 24px;
  border-radius: var(--radius);
  margin-top: 24px;
  border-left: 4px solid var(--orange);
}

.resumo-box h4 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--orange-soft);
  margin-bottom: 12px;
}

.resumo-box ul {
  list-style: none;
}

.resumo-box li {
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.resumo-box li:last-child { border-bottom: none; }

.resumo-box strong {
  color: var(--orange-soft);
  font-weight: 600;
}

/* ============== RESULT PAGE ============== */
.success-banner {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-soft) 100%);
  color: var(--white);
  padding: 28px 32px;
  border-radius: var(--radius-lg);
  margin-bottom: 32px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
  border-left: 6px solid var(--success);
}

.success-icon {
  font-size: 48px;
  line-height: 1;
}

.success-banner h2 {
  font-size: 22px;
  margin-bottom: 4px;
}

.success-banner p {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
}

.docs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.doc-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
}

.doc-card:hover {
  border-color: var(--orange);
  box-shadow: var(--shadow-md);
  transform: translateX(2px);
}

.doc-icon {
  width: 60px;
  height: 60px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}

.doc-icon-1 { background: #FEF3EC; }
.doc-icon-2 { background: #ECF4FE; }
.doc-icon-3 { background: #EBFAEF; }
.doc-icon-4 { background: #FEFAEB; }

.doc-info { flex: 1; }

.doc-info h3 {
  font-size: 16px;
  color: var(--navy);
  margin-bottom: 2px;
}

.doc-info p {
  font-size: 13px;
  color: var(--gray-500);
}

.doc-action {
  font-weight: 600;
  color: var(--orange);
  font-size: 14px;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.info-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--gray-100);
}

.info-card h4 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--orange);
  margin-bottom: 16px;
}

.kv-list {
  list-style: none;
}

.kv-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
}

.kv-list li:last-child { border-bottom: none; }

.kv-list span { color: var(--gray-500); }

.next-steps {
  padding-left: 20px;
  font-size: 14px;
  color: var(--gray-700);
}

.next-steps li {
  padding: 6px 0;
}

/* ============== OVERLAY DE LOADING ============== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.overlay.hidden { display: none; }

.overlay-content {
  text-align: center;
  color: var(--white);
}

.overlay-content h3 {
  font-size: 22px;
  margin: 20px 0 8px;
}

.overlay-content p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
}

.spinner {
  width: 56px;
  height: 56px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============== FOOTER ============== */
.footer {
  background: var(--navy);
  color: rgba(255, 255, 255, 0.5);
  padding: 24px 0;
  text-align: center;
  font-size: 13px;
  margin-top: 60px;
}

/* ============== RESPONSIVE ============== */
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .docs-grid, .info-grid { grid-template-columns: 1fr; }
  .success-banner { grid-template-columns: 1fr; text-align: center; }
  .topbar .container { flex-direction: column; gap: 16px; }
  .steps-indicator { flex-wrap: wrap; gap: 12px; }
}

/* =====================================================================
   ZONA DE UPLOAD OCR (FATURA)
   ===================================================================== */
.ocr-zone {
  display: flex;
  align-items: center;
  gap: 20px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-soft) 100%);
  color: var(--white);
  padding: 24px;
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
  border-left: 4px solid var(--orange);
}

.ocr-icon {
  font-size: 36px;
  flex-shrink: 0;
  background: rgba(242, 104, 34, 0.18);
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ocr-content {
  flex: 1;
}

.ocr-content h4 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--orange-soft);
}

.ocr-content p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.5;
  margin-bottom: 12px;
}

.ocr-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.btn-ocr {
  background: var(--orange);
  color: var(--white);
  cursor: pointer;
  border: none;
  font-weight: 600;
}

.btn-ocr:hover {
  background: #DC5A18;
}

.ocr-status {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

.ocr-status.status-uploading {
  color: var(--orange-soft);
}

.ocr-status.status-success {
  color: #6EE7B7;
}

.ocr-status.status-success strong {
  color: var(--white);
}

.ocr-status.status-error {
  color: #FCA5A5;
}

/* Destaque dos campos preenchidos por OCR */
.ocr-filled {
  background: linear-gradient(to right, rgba(242, 104, 34, 0.06) 0%, transparent 100%) !important;
  border-color: var(--orange) !important;
  box-shadow: 0 0 0 2px rgba(242, 104, 34, 0.1) !important;
  animation: ocrFilledFlash 0.6s ease;
}

@keyframes ocrFilledFlash {
  0% { background-color: rgba(242, 104, 34, 0.3); }
  100% { background-color: rgba(242, 104, 34, 0.06); }
}

/* =====================================================================
   ANÁLISE TÉCNICA (VALIDATOR)
   ===================================================================== */
.validation-box {
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-top: 16px;
}

.validation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.validation-header h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
}

.btn-validar {
  background: var(--navy);
  color: var(--white);
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-validar:hover {
  background: var(--navy-soft);
  transform: translateY(-1px);
}

.validation-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.vbadge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.vbadge-bloqueio {
  background: #FEE2E2;
  color: #991B1B;
}

.vbadge-aviso {
  background: #FEF3C7;
  color: #92400E;
}

.vbadge-info {
  background: #DBEAFE;
  color: #1E40AF;
}

.vbadge-ok {
  background: #D1FAE5;
  color: #065F46;
}

.validation-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.vitem {
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: 8px;
  border-left: 3px solid var(--gray-300);
  background: var(--gray-50);
  font-size: 13.5px;
  line-height: 1.5;
}

.vitem-bloqueio {
  background: #FEF2F2;
  border-left-color: #DC2626;
}

.vitem-aviso {
  background: #FFFBEB;
  border-left-color: #D97706;
}

.vitem-info {
  background: #EFF6FF;
  border-left-color: #2563EB;
}

.vitem-header {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}

.vcodigo {
  font-family: "SF Mono", "Consolas", monospace;
  font-size: 11px;
  color: var(--gray-500);
  background: var(--white);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: auto;
}

.vitem-sugestao {
  margin-top: 6px;
  padding-left: 22px;
  color: var(--gray-700);
  font-style: italic;
}

.vitem-ref {
  margin-top: 4px;
  padding-left: 22px;
  font-size: 11px;
  color: var(--gray-500);
}

.status-error {
  color: #DC2626;
}

/* =====================================================================
   PROCURAÇÃO + EDIÇÃO + CNH
   ===================================================================== */
.doc-icon-0 {
  background: linear-gradient(135deg, #FFB347 0%, #FF8C00 100%);
}

.subsection-soft {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin: 18px 0 8px 0;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--gray-300);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ocr-zone-cnh {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-color: #0ea5e9;
  margin-top: 12px;
}

.ocr-zone-cnh .ocr-icon {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
}
