    .cd-btn-checkout:disabled,
    .cd-btn-checkout.is-disabled {
      background: #2a2820;
      color: #6e6858;
      pointer-events: none;
      cursor: not-allowed;
      box-shadow: none;
      transform: none;
      opacity: 1;
    }

/* ── Campos "Outro" — correção de layout, ícone e borda dourada ao focar ──
   Scoped: .scope-editor-prescricao (zero vazamento)
   ─────────────────────────────────────────────────────────────────────────── */

.scope-editor-prescricao .input-wrap.has-icon {
  position: relative;
}

.scope-editor-prescricao .input-wrap.has-icon .input-icon {
  z-index: 4 !important;
  pointer-events: none;
}

.scope-editor-prescricao #input-nacionalidade-outro-prescricao,
.scope-editor-prescricao #input-orgao-emissor-personalizado-prescricao,
.scope-editor-prescricao #input-profissao-outro-prescricao {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  height: 100% !important;
  padding: 0 14px 0 42px !important;
  border-radius: var(--radius-sm) !important;
  background: rgba(0,0,0,0.3) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
  font-size: 14px !important;
  font-family: inherit !important;
  z-index: 3 !important;
  box-sizing: border-box !important;
  -webkit-appearance: none;
  appearance: none;
}

.scope-editor-prescricao #input-nacionalidade-outro-prescricao:focus,
.scope-editor-prescricao #input-orgao-emissor-personalizado-prescricao:focus,
.scope-editor-prescricao #input-profissao-outro-prescricao:focus {
  border-color: var(--gold, #d4af37) !important;
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15) !important;
  background: rgba(0,0,0,0.3) !important;
  outline: none !important;
}

.scope-editor-prescricao #input-nacionalidade-outro-prescricao::placeholder,
.scope-editor-prescricao #input-orgao-emissor-personalizado-prescricao::placeholder,
.scope-editor-prescricao #input-profissao-outro-prescricao::placeholder {
  color: var(--text-muted, rgba(240,240,245,.4));
}

.scope-editor-prescricao #input-nacionalidade-outro-prescricao:-webkit-autofill,
.scope-editor-prescricao #input-orgao-emissor-personalizado-prescricao:-webkit-autofill,
.scope-editor-prescricao #input-profissao-outro-prescricao:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 30px #0d0d0d inset !important;
  -webkit-text-fill-color: var(--text-primary, #f0f0f5) !important;
  caret-color: var(--text-primary, #f0f0f5);
}

/* Fix mobile scroll */
@media (max-width: 768px) {
  .scope-editor-prescricao .form-panel {
    overflow: visible !important;
    max-height: none !important;
  }
}

/* Painel de Pré-visualização Estático e Instantâneo (Módulo Prescrição) */
.scope-editor-prescricao #previewPanel {
  opacity: 1 !important;
  visibility: visible !important;
  transition: none !important;
}




/* ================================================================ */
/* Extraído de prescricao.html (bloco inline linha 46)            */
/* ================================================================ */
    /* Responsividade equilibrada para tablet (inclui iPad Pro 13 1032px) */
    @media (max-width: 1040px) {
      .grid-3,
      .grid-4 {
        grid-template-columns: 1fr 1fr !important;
      }
    }

    @media (max-width: 850px) {

      /* Em telas menores, pega QUALQUER linha e força para 1 coluna (um embaixo do outro) */
      .form-row,
      .form-row-3,
      .form-row-4,
      .grid-2,
      .grid-3,
      .grid-4,
      .step-pane [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
      }
    }

    /* ============================================
   DESIGN TOKENS — DefesaExpress Premium
   (Mesmo padrão do editor-defesa.html)
   ============================================ */
    :root {
      --bg-primary: #0a0a0a;
      --bg-secondary: rgba(15, 15, 15, 0.6);
      --bg-tertiary: rgba(0, 0, 0, 0.3);
      --gold: #d4af37;
      --gold-light: #f4d03f;
      --gold-dark: #a88828;
      --text-primary: #ffffff;
      --text-secondary: #a0a0b0;
      --text-muted: #6b7280;
      --success: #f5c842;
      --danger: #ef4444;
      --warning: #f59e0b;
      --info: #3b82f6;
      --border: rgba(255, 255, 255, 0.1);
      --border-strong: rgba(255, 255, 255, 0.18);
      --glass: rgba(255, 255, 255, 0.05);
      --glass-strong: rgba(255, 255, 255, 0.08);
      --shadow-gold: 0 10px 30px -10px rgba(212, 175, 55, 0.45);
      --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.35);
      --radius: 16px;
      --radius-sm: 10px;
      --radius-xs: 8px;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    html,
    body {
      height: 100%;
    }

    body {
      font-family: var(--font-body);
      background: var(--bg-primary);
      color: var(--text-primary);
      font-size: 14px;
      line-height: 1.5;
      overflow-x: clip;
      background-image:
        radial-gradient(ellipse at 20% 0%, rgba(212, 175, 55, 0.08), transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(212, 175, 55, 0.04), transparent 50%);
      background-attachment: fixed;
    }

    ::-webkit-scrollbar {
      width: 8px;
      height: 8px;
    }

    ::-webkit-scrollbar-track {
      background: transparent;
      border-radius: 8px;
    }

    ::-webkit-scrollbar-thumb {
      background: transparent;
      border-radius: 8px;
    }

    .preview-frame:hover::-webkit-scrollbar-thumb,
    *:hover::-webkit-scrollbar-thumb {
      background: rgba(212, 175, 55, 0.3);
    }

    .preview-frame:hover::-webkit-scrollbar-thumb:hover,
    *:hover::-webkit-scrollbar-thumb:hover {
      background: rgba(212, 175, 55, 0.6);
    }

    @media (max-width: 768px) {
      ::-webkit-scrollbar {
        width: 3px;
        height: 3px;
        display: block;
      }

      html,
      body {
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
        -webkit-overflow-scrolling: touch;
      }

      html::-webkit-scrollbar,
      body::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
      }
    }

    i,
    svg {
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    .btn i,
    .btn svg,
    .icon-btn i,
    .icon-btn svg {
      width: 20px;
      height: 20px;
      margin: 0;
      padding: 0;
    }

    /* HEADER */
    .header {
      position: sticky;
      top: 0;
      z-index: 50;
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      background: rgba(10, 10, 15, 0.7);
      border-bottom: 1px solid var(--border);
      padding: 0;
      /* padding movido para .header-inner para alinhar com .main */
    }

    /* Layout inteligente: não esmaga o título! */
    .header-inner {
      max-width: 1600px;
      margin: 0 auto;
      padding: 14px 24px;
      /* mesmo padding do .main */
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 16px;
      flex-wrap: wrap;
    }

    /* O stepper flexível cai pra linha de baixo se não couber no meio */
    .stepper {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 4px;
      flex: 1 1 300px;
      /* Flex cresce, mas tem tamanho mínimo. Se não couber, ele quebra a linha */
    }

    /* Garante que o título nunca encolha e seja cortado */
    .brand {
      flex: 0 0 auto;
      display: flex;
      align-items: center;
      gap: 12px;
    }

    /* Segura os botões da direita sempre juntos */
    .header-inner>div:last-child {
      flex: 0 0 auto;
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .brand-icon {
      width: 40px;
      height: 40px;
      border-radius: 12px;
      background: linear-gradient(135deg, var(--gold), var(--gold-dark));
      display: grid;
      place-items: center;
      color: #1a1a24;
      box-shadow: var(--shadow-gold);
    }

    .brand-text h1 {
      font-size: 15px;
      font-weight: 700;
      letter-spacing: -0.01em;
    }

    .brand-text p {
      font-size: 11px;
      color: var(--text-muted);
    }

    .btn-back {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      background: transparent;
      border: 1px solid var(--border);
      color: var(--text-secondary);
      padding: 8px 14px;
      border-radius: 10px;
      cursor: pointer;
      font-size: 13px;
      font-weight: 500;
      transition: all .2s;
    }

    .btn-back:hover {
      color: var(--text-primary);
      border-color: var(--border-strong);
      background: var(--glass);
    }

    /* Padroniza altura de TODOS os botões de ação do header (Videoaulas, Voltar,
       Carrinho, Avatar) — usa !important para vencer qualquer estilo nativo de
       botão do navegador que ignore a altura declarada inline. */
    .header-action-btn {
      height: 40px !important;
      min-height: 40px !important;
      max-height: 40px !important;
      box-sizing: border-box !important;
      line-height: 1 !important;
      appearance: none !important;
      -webkit-appearance: none !important;
      -moz-appearance: none !important;
      font-family: inherit !important;
      vertical-align: middle !important;
    }

    #cart-drawer-trigger-desktop {
      width: 40px !important;
      height: 40px !important;
      min-width: 40px !important;
      min-height: 40px !important;
      max-width: 40px !important;
      max-height: 40px !important;
      padding: 0 !important;
      display: inline-flex !important;
      align-items: center !important;
      justify-content: center !important;
      border-radius: 12px !important;
      box-sizing: border-box !important;
    }

    #cart-drawer-trigger-desktop i,
    #cart-drawer-trigger-desktop svg {
      width: 20px !important;
      height: 20px !important;
      min-width: 20px !important;
      min-height: 20px !important;
      transform: none !important;
    }

    /* Stepper — flex: 1 1 300px definido acima */
    .step {
      display: flex;
      align-items: center;
      gap: 8px;
      cursor: pointer;
    }

    .step-circle {
      width: 32px !important;
      height: 32px !important;
      border-radius: 50% !important;
      display: grid !important;
      place-items: center !important;
      background: rgba(0, 0, 0, 0.5) !important;
      border: none !important;
      margin: 3px !important;
      box-shadow: 0 0 0 2.5px #5c4718 !important;
      color: var(--text-muted) !important;
      font-weight: 600 !important;
      font-size: 13px !important;
      transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease, background 0.25s ease, color 0.25s ease !important;
      box-sizing: border-box !important;
    }

    .step-label {
      font-size: 12px;
      color: var(--text-muted);
      font-weight: 500;
      transition: color 0.25s ease;
    }

    .step:hover .step-circle {
      transform: translateY(-2px) scale(1.08) !important;
      box-shadow: 0 0 0 3px #8a6d1b, 0 0 14px rgba(212, 175, 55, 0.4) !important;
    }

    .step:hover .step-label {
      color: var(--text-primary, #ffffff) !important;
    }

    .step.active .step-circle {
      background: linear-gradient(135deg, var(--gold), var(--gold-dark)) !important;
      border: none !important;
      color: #1a1a24 !important;
      box-shadow: 0 0 0 2.5px #5c4718, 0 0 12px rgba(212, 175, 55, 0.35) !important;
    }

    .step.active .step-label {
      color: var(--text-primary);
    }

    .step.done .step-circle {
      background: linear-gradient(135deg, #10B981, #059669) !important;
      border: none !important;
      box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35) !important;
      color: white !important;
    }

    .step.done.active .step-circle {
      background: linear-gradient(135deg, #10B981, #059669) !important;
      border: none !important;
      box-shadow: 0 0 0 2.5px #d4af37, 0 0 14px rgba(16, 185, 129, 0.45) !important;
      color: #ffffff !important;
      border-radius: 50% !important;
    }

    .step.done .step-label {
      color: var(--text-secondary);
    }

    .step.done.active .step-label {
      color: #10B981 !important;
    }

    .step-line {
      width: 28px;
      height: 2px;
      background: var(--border);
      border-radius: 2px;
      transition: background 0.3s;
    }

    .step-line.done {
      background: #10B981 !important;
    }

    .stepper-mobile {
      display: none;
      font-size: 13px;
      color: var(--text-secondary);
      font-weight: 600;
    }

    .user-avatar {
      width: 38px;
      height: 38px;
      border-radius: 6px;
      background: linear-gradient(135deg, #2a2a3a, #1a1a24);
      border: 1px solid var(--border);
      display: grid;
      place-items: center;
      color: var(--gold);
      font-weight: 600;
      font-size: 13px;
      cursor: pointer;
    }

    /* LAYOUT */
    .main {
      max-width: 1600px;
      margin: 0 auto;
      padding: 24px;
      display: grid;
      grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
      gap: 24px;
      align-items: stretch;
    }

    .glass-card {
      background: rgba(15, 15, 18, 0.95) !important;
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      box-shadow: var(--shadow-card);
    }

    /* Seletor Tipo de Requerente */
    .tipo-pessoa-selector-container {
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
      padding: 0;
      margin-bottom: 22px;
    }

    .tipo-pessoa-toggle-group {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      gap: 10px;
      background: rgba(255, 255, 255, 0.03);
      padding: 4px;
      border-radius: 12px;
      border: 1px solid var(--border);
      box-sizing: border-box;
      width: 100%;
    }

    .btn-tipo-pessoa {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 12px 14px;
      border-radius: 8px;
      border: 1px solid transparent;
      font-size: 14px;
      font-weight: 700;
      cursor: pointer;
      transition: all 0.2s ease;
      background: transparent;
      color: var(--text-muted);
      min-width: 0;
      box-sizing: border-box;
      white-space: nowrap;
    }

    .btn-tipo-pessoa.active {
      background: var(--gold, #d4af37) !important;
      color: #09090b !important;
      box-shadow: 0 2px 8px rgba(212, 175, 55, 0.25) !important;
    }

    .form-panel {
      grid-column: 1;
      padding: 28px !important;
      min-height: calc(100vh - 130px);
      max-height: calc(100vh - 130px);
      height: calc(100vh - 130px);
      overflow-y: auto !important;
      overflow-x: hidden !important;
      position: sticky;
      top: 90px;
      isolation: isolate;
      display: flex !important;
      flex-direction: column !important;
      justify-content: space-between !important;
      align-self: stretch;
    }

    .step-header {
      margin-bottom: 24px;
    }

    .step-eyebrow {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      font-size: 12px;
      text-transform: uppercase;
      letter-spacing: .12em;
      color: var(--gold);
      font-weight: 700;
      margin-bottom: 10px;
      background: linear-gradient(135deg, rgba(212, 175, 55, .12), rgba(212, 175, 55, .04));
      border: 1px solid rgba(212, 175, 55, .30);
      border-radius: 6px;
      padding: 6px 14px;
      box-shadow: 0 0 16px rgba(212, 175, 55, .10);
    }

    .step-title {
      font-family: var(--font-display);
      font-size: 26px;
      font-weight: 700;
      letter-spacing: -0.02em;
      margin-bottom: 6px;
    }

    .step-subtitle {
      color: var(--text-secondary);
      font-size: 14px;
    }

    .step-content {
      animation: fadeInUp 0.4s ease both;
      display: flex;
      flex-direction: column;
      flex: 1;
    }

    @keyframes fadeInUp {
      from {
        opacity: 0;
        transform: translateY(12px);
      }

      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .section {
      margin-bottom: 28px;
    }

    .section-title {
      display: flex;
      align-items: center;
      gap: 10px;
      font-size: 13px;
      font-weight: 700;
      color: var(--gold);
      text-transform: uppercase;
      letter-spacing: .08em;
      margin-bottom: 14px;
      padding-bottom: 10px;
      border-bottom: 1px solid rgba(212, 175, 55, .30);
    }

    .section-title svg,
    .section-title i {
      width: 20px !important;
      height: 20px !important;
      color: var(--gold) !important;
      background: linear-gradient(135deg, rgba(212, 175, 55, .15), rgba(212, 175, 55, .05)) !important;
      border: 1px solid rgba(212, 175, 55, .35) !important;
      border-radius: 8px !important;
      padding: 5px !important;
      box-sizing: content-box !important;
      display: inline-grid !important;
      place-items: center !important;
      box-shadow: 0 0 12px rgba(212, 175, 55, .12) !important
    }

    .section-title i svg {
      width: 20px !important;
      height: 20px !important;
      background: transparent !important;
      border: none !important;
      border-radius: 0 !important;
      padding: 0 !important;
      box-shadow: none !important;
      display: block !important;
    }

    .grid {
      display: grid;
      gap: 14px;
    }

    .grid-2 {
      grid-template-columns: 1fr 1fr;
    }

    .grid-3 {
      grid-template-columns: repeat(3, 1fr);
    }

    .col-span-2 {
      grid-column: span 2;
    }

    .col-span-3 {
      grid-column: span 3;
    }

    /* Quando Possui CNH for Sim, Telefone e Email ficam na mesma linha (1 coluna cada) */
    body.cnh-ativa #field-email-wrapper,
    .cnh-ativa #field-email-wrapper {
      grid-column: auto !important;
    }

    @media (max-width: 640px) {

      .grid-2,
      .grid-3 {
        grid-template-columns: 1fr;
      }

      .col-span-2,
      .col-span-3 {
        grid-column: auto;
      }
    }

    /* ============================================
   UPLOAD DE ANEXOS
   ============================================ */
    .anexos-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 12px;
    }

    @media (max-width: 768px) {
      .anexos-grid {
        grid-template-columns: repeat(2, 1fr);
      }
    }

    @media (max-width: 640px) {
      .anexos-grid {
        grid-template-columns: 1fr;
      }
    }

    .anexo-field label {
      font-size: 11px;
      color: var(--text-secondary);
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-bottom: 6px;
      display: block;
    }

    .anexo-preview {
      margin-top: 8px;
      display: none;
    }

    .anexo-preview.active {
      display: block;
    }

    .anexo-preview img {
      max-width: 100%;
      max-height: 120px;
      object-fit: cover;
      border-radius: 8px;
    }

    .anexo-preview .anexo-file-info {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 12px;
      background: var(--bg-2, rgba(10, 10, 15, 0.4));
      border-radius: 6px;
      border: 1px solid var(--border);
    }

    /* Fields */
    .field {
      display: flex;
      flex-direction: column;
      gap: 6px;
      position: relative;
      justify-content: flex-start;
      padding-bottom: 18px;
    }

    .field label {
      font-size: 12px;
      font-weight: 500;
      color: var(--text-secondary);
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .field label .req {
      color: var(--danger);
    }

    .field-hint {
      font-size: 11px;
      color: var(--text-muted);
      margin-top: -2px;
    }

    .tooltip-icon {
      width: 14px;
      height: 14px;
      border-radius: 6px;
      background: var(--bg-tertiary);
      display: inline-grid;
      place-items: center;
      font-size: 9px;
      color: var(--text-muted);
      cursor: help;
      position: relative;
    }

    .tooltip-icon:hover::after {
      content: attr(data-tip);
      position: absolute;
      bottom: 130%;
      left: 50%;
      transform: translateX(-50%);
      white-space: nowrap;
      background: var(--bg-tertiary);
      color: var(--text-primary);
      border: 1px solid var(--gold);
      padding: 6px 10px;
      border-radius: 6px;
      font-size: 11px;
      z-index: 100;
    }

    .input-wrap {
      position: relative;
    }

    .input-wrap .input-icon {
      position: absolute;
      left: 12px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-muted);
      width: 16px;
      height: 16px;
      pointer-events: none;
    }

    .input-wrap.has-icon input,
    .input-wrap.has-icon select {
      padding-left: 38px;
    }

    .input-wrap .input-action {
      position: absolute;
      right: 10px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-muted);
      cursor: pointer;
      padding: 4px;
      border-radius: 4px;
    }

    .field {
      display: flex;
      flex-direction: column;
      gap: 0px !important;
      position: relative;
    }

    .field label {
      font-size: 12px;
      font-weight: 500;
      color: var(--text-secondary);
      display: flex;
      align-items: center;
      gap: 4px;
      margin: 0 0 6px 0 !important;
      padding: 0 !important;
    }

    .field label .req {
      color: var(--accent-danger, #ef4444);
    }

    input,
    select,
    textarea,
    .custom-select-trigger,
    .input-field,
    .input-wrap input {
      width: 100%;
      background: #09090b !important;
      background-color: #09090b !important;
      border: 1px solid var(--border) !important;
      color: var(--text-primary) !important;
      padding: 0 14px !important;
      border-radius: var(--radius-sm) !important;
      font-size: 14px !important;
      font-family: inherit !important;
      transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.2s ease;
      outline: none !important;
      box-sizing: border-box !important;
      margin: 0 !important;
    }

    /* Bloquear fundo de autofill do navegador em inputs customizados (modo OUTRO) */
    .input-wrap input:-webkit-autofill,
    .input-wrap input:-webkit-autofill:hover,
    .input-wrap input:-webkit-autofill:focus,
    .input-wrap input:-webkit-autofill:active,
    .legal-input:-webkit-autofill,
    .legal-input:-webkit-autofill:hover,
    .legal-input:-webkit-autofill:focus,
    .legal-input:-webkit-autofill:active {
      -webkit-box-shadow: 0 0 0 30px #09090b inset !important;
      -webkit-text-fill-color: #e0e0e0 !important;
      transition: background-color 5000s ease-in-out 0s;
    }

    input,
    select,
    .custom-select-trigger,
    .input-field {
      height: 44px !important;
    }

    textarea {
      padding: 11px 14px !important;
      height: auto !important;
      min-height: 110px !important;
    }

    .input-wrap.has-icon input,
    .input-wrap.has-icon select,
    .input-wrap.has-icon .custom-select-trigger {
      padding-left: 38px !important;
    }

    input::placeholder,
    textarea::placeholder {
      color: var(--text-muted) !important;
    }

    input:focus,
    select:focus,
    textarea:focus,
    .custom-select-wrapper.open .custom-select-trigger {
      border-color: var(--gold) !important;
      box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12) !important;
      background: #09090b !important;
      background-color: #09090b !important;
    }

    .field.error input,
    .field.error select,
    .field.error textarea,
    .field.error .custom-select-trigger,
    .field.error .input-wrap input,
    input.error,
    select.error,
    textarea.error,
    input.campo-erro,
    select.campo-erro,
    textarea.campo-erro,
    .custom-select-trigger.campo-erro,
    .campo-erro-fici,
    .has-error input,
    .has-error select,
    .has-error textarea {
      border-color: var(--accent-danger, #ef4444) !important;
      background: #09090b !important;
      background-color: #09090b !important;
      box-shadow: none !important;
    }

    .error-msg,
    .field.error .error-msg,
    .field-error,
    .field.invalid .field-error {
      display: none !important;
    }

    #cep-field.error #cep-error-msg {
      display: block !important;
      color: #ef4444;
      font-size: 13px;
      margin-top: 5px !important;
    }

    /* Shake animation for invalid fields */
    @keyframes shake {

      0%,
      100% {
        transform: translateX(0);
      }

      10%,
      30%,
      50%,
      70%,
      90% {
        transform: translateX(-4px);
      }

      20%,
      40%,
      60%,
      80% {
        transform: translateX(4px);
      }
    }

    .field.shake {
      animation: shake 0.5s ease-in-out;
    }

    /* Checkbox row */
    .check-row {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 12px 14px;
      background: var(--bg-tertiary);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      cursor: pointer;
      transition: all 0.2s;
    }

    .check-row:hover {
      border-color: var(--border-strong);
    }

    .check-row input[type="checkbox"] {
      width: 16px;
      height: 16px;
      accent-color: var(--gold);
      margin: 0;
      flex-shrink: 0;
    }

    .check-row label {
      font-size: 13px;
      color: var(--text-secondary);
      cursor: pointer;
      margin: 0;
    }

    /* Buttons */
    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 11px 20px;
      border-radius: var(--radius-sm);
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
      border: none;
      font-family: inherit;
      transition: all 0.2s;
      white-space: nowrap;
    }

    .btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    .btn-primary {
      background: linear-gradient(135deg, var(--gold-light), var(--gold));
      color: #1a1a24;
      box-shadow: var(--shadow-gold);
    }

    .btn-primary:hover:not(:disabled) {
      transform: translateY(-1px) scale(1.01);
      box-shadow: 0 14px 36px -10px rgba(212, 175, 55, 0.6);
    }

    .btn-secondary {
      background: transparent;
      color: var(--text-primary);
      border: 1px solid var(--border-strong);
    }

    .btn-secondary:hover {
      background: var(--glass);
      border-color: var(--gold);
    }

    .btn-ghost {
      background: transparent;
      color: var(--text-secondary);
    }

    .btn-ghost:hover {
      color: var(--text-primary);
      background: var(--glass);
    }

    .btn-danger {
      background: var(--danger);
      color: white;
    }

    .btn-success {
      background: var(--success);
      color: white;
    }

    .btn-lg {
      padding: 14px 28px;
      font-size: 15px;
    }

    .btn-block {
      width: 100%;
    }

    .btn .spinner {
      width: 16px;
      height: 16px;
      border-radius: 6px;
      border: 2px solid currentColor;
      border-top-color: transparent;
      animation: spin 0.7s linear infinite;
    }

    @keyframes spin {
      to {
        transform: rotate(360deg);
      }
    }

    .actions,
    #form-navigation.actions {
      display: flex;
      justify-content: space-between !important;
      align-items: center !important;
      gap: 12px !important;
      margin-top: auto !important;
      padding-top: 20px !important;
      padding-bottom: 0 !important;
      padding-left: 0 !important;
      padding-right: 0 !important;
      border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
      background: transparent !important;
      backdrop-filter: none !important;
      -webkit-backdrop-filter: none !important;
      position: static !important;
      box-shadow: none !important;
      flex-shrink: 0 !important;
      z-index: auto !important;
    }

    /* ============================================
   STEP 1 — Cards de Tipo de Prescrição
   ============================================ */
    .tipo-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      align-items: stretch;
      gap: 20px;
      margin-bottom: 28px;
    }

    @media (max-width: 900px) {
      .tipo-grid {
        grid-template-columns: 1fr;
      }
    }

    .tipo-card {
      position: relative;
      padding: 26px 22px 22px;
      border-radius: 22px;
      cursor: pointer;
      transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
      overflow: hidden;
      display: flex;
      flex-direction: column;
      height: 100%;
      gap: 14px;
      min-height: 245px;
      animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
      outline: none !important;
      -webkit-tap-highlight-color: transparent;
      z-index: 1;
      box-sizing: border-box;
      background: linear-gradient(165deg, rgba(26, 26, 32, 0.92) 0%, rgba(18, 18, 22, 0.97) 100%);
      border: 1px solid #2a2a30;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 10px 28px rgba(0, 0, 0, 0.35);
      backdrop-filter: blur(14px);
      -webkit-backdrop-filter: blur(14px);
    }

    .tipo-card::before {
      content: '';
      position: absolute;
      top: 0;
      left: 10%;
      right: 10%;
      height: 3px;
      background: linear-gradient(90deg, transparent, var(--card-accent), transparent);
      opacity: 0.9;
      transition: all 0.35s ease;
      z-index: 2;
    }

    .tipo-card::after {
      content: '';
      position: absolute;
      top: -30px;
      left: -30px;
      width: 150px;
      height: 150px;
      border-radius: 50%;
      background: radial-gradient(circle, var(--card-glow) 0%, transparent 70%);
      opacity: 0.14;
      transition: all 0.4s ease;
      pointer-events: none;
      z-index: -1;
    }

    .tipo-card:focus,
    .tipo-card:active {
      outline: none !important;
    }

    /* CARD 1: INTERCORRENTE (BRONZE / COBRE SOFISTICADO) */
    .tipo-card[data-tipo="intercorrente"] {
      --card-accent: #cd7f32;
      --card-glow: rgba(205, 127, 50, 0.22);
      background: linear-gradient(165deg, #1b1b22 0%, #121216 100%);
      border: 1px solid #2a2a30;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 10px 28px rgba(0, 0, 0, 0.35);
    }

    .tipo-card[data-tipo="intercorrente"] .tipo-icon {
      background: rgba(205, 127, 50, 0.13);
      color: #d99a5b;
      box-shadow: none;
      border: 1px solid rgba(205, 127, 50, 0.25);
    }

    .tipo-card[data-tipo="intercorrente"] .tipo-subtitle {
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid rgba(255, 255, 255, 0.09);
      color: #e2b98a !important;
      font-weight: 600;
    }

    .tipo-card[data-tipo="intercorrente"] .tipo-prazo {
      background: rgba(205, 127, 50, 0.10);
      border: 1px solid rgba(205, 127, 50, 0.30);
      color: #ecc39a !important;
      box-shadow: none;
    }

    /* CARD 2: PUNITIVA (OURO / ÂMBAR IMPERIAL REFINADO - FEATURED CARD) */
    .tipo-card[data-tipo="punitiva"] {
      --card-accent: #f5c842;
      --card-glow: rgba(245, 200, 66, 0.26);
      background: linear-gradient(165deg, #1c1a20 0%, #121216 100%);
      border: 1px solid #2a2a30;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 10px 28px rgba(0, 0, 0, 0.35);
    }

    .tipo-card[data-tipo="punitiva"] .tipo-icon {
      background: rgba(245, 200, 66, 0.14);
      color: #f2c94c;
      box-shadow: none;
      border: 1px solid rgba(245, 200, 66, 0.28);
    }

    .tipo-card[data-tipo="punitiva"] .tipo-subtitle {
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid rgba(255, 255, 255, 0.09);
      color: #f5d97a !important;
      font-weight: 600;
    }

    .tipo-card[data-tipo="punitiva"] .tipo-prazo {
      background: rgba(245, 200, 66, 0.12);
      border: 1px solid rgba(245, 200, 66, 0.34);
      color: #f8e2a0 !important;
      box-shadow: none;
    }

    /* CARD 3: EXECUTÓRIA (PRATA / PLATINA ELEGANTE) */
    .tipo-card[data-tipo="executoria"] {
      --card-accent: #b0b8c8;
      --card-glow: rgba(176, 184, 200, 0.20);
      background: linear-gradient(165deg, #1a1b21 0%, #121216 100%);
      border: 1px solid #2a2a30;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 10px 28px rgba(0, 0, 0, 0.35);
    }

    .tipo-card[data-tipo="executoria"] .tipo-icon {
      background: rgba(176, 184, 200, 0.12);
      color: #aab4c6;
      box-shadow: none;
      border: 1px solid rgba(176, 184, 200, 0.22);
    }

    .tipo-card[data-tipo="executoria"] .tipo-subtitle {
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid rgba(255, 255, 255, 0.09);
      color: #c6cfdf !important;
      font-weight: 600;
    }

    .tipo-card[data-tipo="executoria"] .tipo-prazo {
      background: rgba(176, 184, 200, 0.10);
      border: 1px solid rgba(176, 184, 200, 0.28);
      color: #d3dae8 !important;
      box-shadow: none;
    }

    /* HOVER & SELECTED EFFECTS */
    .tipo-card:hover {
      transform: translateY(-5px) scale(1.015);
      border-color: #3a3a44 !important;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 18px 44px rgba(0, 0, 0, 0.5), 0 0 26px var(--card-glow);
    }

    .tipo-card:hover::before {
      left: 0%;
      right: 0%;
      height: 3px;
      box-shadow: 0 0 14px var(--card-accent);
    }

    .tipo-card.selected {
      border: 1.5px solid var(--card-accent) !important;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 34px var(--card-glow), 0 0 1px rgba(255, 255, 255, 0.08);
      transform: translateY(-5px) scale(1.015);
    }

    .tipo-card.selected::before {
      left: 0%;
      right: 0%;
      height: 3px;
      box-shadow: 0 0 16px var(--card-accent);
    }

    /* SHARED ELEMENTS */
    .tipo-icon {
      width: 50px;
      height: 50px;
      border-radius: 16px;
      display: grid;
      place-items: center;
      transition: all 0.35s ease;
    }

    .tipo-icon i,
    .tipo-icon svg {
      width: 24px !important;
      height: 24px !important;
    }

    .tipo-title {
      font-family: var(--font-display);
      font-size: 21px;
      font-weight: 800;
      letter-spacing: -0.025em;
      color: #ffffff !important;
      line-height: 1.2;
      margin-bottom: 6px;
      min-height: 52px;
      display: flex;
      align-items: center;
      text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    }

    .tipo-subtitle {
      display: inline-flex;
      align-items: center;
      box-sizing: border-box;
      min-height: 36px;
      font-size: 12px;
      line-height: 1.3;
      padding: 4px 12px;
      border-radius: 8px;
      letter-spacing: 0.01em;
    }

    .tipo-prazo {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      box-sizing: border-box;
      min-height: 30px;
      font-size: 12.5px;
      font-weight: 800;
      padding: 7px 16px;
      border-radius: 10px;
      align-self: flex-start;
      letter-spacing: 0.03em;
    }

    .tipo-prazo i,
    .tipo-prazo svg {
      width: 14px !important;
      height: 14px !important;
      opacity: 0.85;
    }

    .tipo-desc {
      font-size: 13.5px;
      color: rgba(232, 235, 242, 0.88) !important;
      line-height: 1.65;
      flex-grow: 1;
      font-weight: 400;
      letter-spacing: 0.01em;
    }

    .tipo-example {
      display: flex;
      align-items: center;
      box-sizing: border-box;
      min-height: 68px;
      font-size: 12px;
      color: rgba(226, 230, 238, 0.78) !important;
      font-style: italic;
      padding: 11px 14px;
      background: rgba(0, 0, 0, 0.28);
      border: 1px solid rgba(255, 255, 255, 0.08);
      border-left: 3px solid var(--card-accent);
      border-radius: 10px;
      margin-top: auto;
    }

    /* Badge "Selecionado" — reserva espaço fixo em todos os cards, some/aparece sem sobrepor nada */
    .tipo-selected-check {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      height: 30px;
      font-size: 11px;
      font-weight: 900;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      border-radius: 8px;
      background: transparent;
      border: 1px solid transparent;
      color: transparent;
      opacity: 0;
      transform: scale(0.94);
      transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
      pointer-events: none;
      box-sizing: border-box;
    }

    .tipo-selected-check i,
    .tipo-selected-check svg {
      width: 13px !important;
      height: 13px !important;
    }

    .tipo-card.selected .tipo-selected-check {
      opacity: 1;
      transform: scale(1);
      background: var(--card-accent);
      border-color: var(--card-accent);
      color: #04121f;
      box-shadow: 0 4px 14px var(--card-glow);
      pointer-events: auto;
    }

    .tipo-badge-top {
      position: absolute;
      top: 14px;
      right: 14px;
      font-size: 9.5px;
      font-weight: 800;
      letter-spacing: 0.12em;
      padding: 5px 12px;
      border-radius: 20px;
      background: rgba(245, 200, 66, 0.12);
      color: #f5d97a;
      text-transform: uppercase;
      border: 1px solid rgba(245, 200, 66, 0.32);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
      z-index: 3;
    }

    /* Botões de gravidade — padrão radio-card idêntico ao editor de defesa */
    .gravity-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 10px;
      margin-bottom: 16px;
    }

    @media(max-width:640px) {
      .gravity-grid {
        grid-template-columns: repeat(2, 1fr);
      }
    }

    .rc-gravity {
      position: relative;
      cursor: pointer;
      padding: 14px;
      border: 1px solid var(--border);
      background: var(--bg-tertiary);
      border-radius: var(--radius);
      display: flex;
      flex-direction: column;
      gap: 4px;
      transition: all .2s;
      font-family: inherit;
      text-align: left;
      color: inherit;
    }

    .rc-gravity .rc-title {
      font-weight: 600;
      font-size: 13px;
      color: var(--text-primary);
    }

    .rc-gravity .rc-desc {
      font-size: 11px;
      color: var(--text-muted);
    }

    .rc-gravity.active {
      border-color: var(--gold);
      background: linear-gradient(135deg, rgba(212, 175, 55, 0.08), rgba(212, 175, 55, 0.02));
      box-shadow: 0 0 0 3px rgba(212, 175, 55, .10);
    }

    .rc-gravity:hover {
      transform: translateY(-2px);
    }

    .help-link {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      background: none;
      border: none;
      color: var(--info);
      cursor: pointer;
      font-size: 13px;
      font-weight: 500;
      padding: 6px 0;
    }

    .help-link:hover {
      text-decoration: underline;
    }

    /* ============================================
   CARD RESULTADO PRESCRIÇÃO
   ============================================ */
    .result-card {
      margin-top: 20px;
      padding: 24px;
      background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
      border: 1px solid var(--border-strong);
      border-radius: var(--radius);
      box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
      animation: fadeInUp 0.4s ease both;
    }

    .result-card.prescrita {
      border-color: rgba(245, 200, 66, 0.45);
      background: linear-gradient(135deg, rgba(245, 200, 66, 0.06) 0%, rgba(12, 10, 4, 0.0) 100%);
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(245, 200, 66, 0.18), inset 0 1px 0 rgba(255, 240, 140, 0.08);
    }

    .result-card.pendente {
      border-color: rgba(245, 158, 11, 0.4);
      background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(245, 158, 11, 0.02));
    }

    .result-card.urgente {
      border-color: rgba(239, 68, 68, 0.4);
      background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.02));
    }

    .result-status {
      display: flex;
      align-items: center;
      gap: 12px;
      margin-bottom: 16px;
    }

    .result-status-icon {
      width: 48px;
      height: 48px;
      border-radius: 14px;
      display: grid;
      place-items: center;
      flex-shrink: 0;
    }

    .prescrita .result-status-icon {
      background: rgba(34, 197, 94, 0.15);
      color: #22c55e;
      border: 1px solid rgba(34, 197, 94, 0.35);
    }

    .prescrita .result-status-value {
      color: #22c55e;
    }

    .pendente .result-status-icon {
      background: rgba(239, 68, 68, 0.15);
      color: var(--danger);
      border: 1px solid rgba(239, 68, 68, 0.3);
    }

    .pendente .result-status-value {
      color: var(--danger);
    }

    .urgente .result-status-icon {
      background: rgba(239, 68, 68, 0.2);
      color: var(--danger);
    }

    .result-status-text {
      display: flex;
      flex-direction: column;
    }

    .result-status-label {
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--text-muted);
      font-weight: 600;
    }

    .result-status-value {
      font-size: 18px;
      font-weight: 700;
      font-family: var(--font-display);
    }

    .progress-wrap {
      margin: 14px 0 8px;
      height: 8px;
      background: rgba(0, 0, 0, 0.3);
      border-radius: 6px;
      overflow: hidden;
    }

    .progress-bar {
      height: 100%;
      border-radius: 6px;
      transition: width 0.5s ease;
      background: linear-gradient(90deg, var(--info), var(--gold));
    }

    .prescrita .progress-bar {
      background: linear-gradient(90deg, #b5651d, var(--success));
    }

    .urgente .progress-bar {
      background: linear-gradient(90deg, var(--warning), var(--danger));
    }

    .result-meta {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 10px;
      margin-top: 14px;
    }

    .result-stat {
      background: rgba(0, 0, 0, 0.25);
      padding: 10px 12px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
    }

    .result-stat-label {
      font-size: 10px;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.06em;
    }

    .result-stat-value {
      font-size: 14px;
      font-weight: 700;
      margin-top: 3px;
    }

    @media (max-width: 540px) {
      .result-meta {
        grid-template-columns: 1fr 1fr;
      }
    }

    /* ============================================
   PREVIEW PANEL (A4) — igual ao editor-defesa
   ============================================ */
    .preview-panel {
      position: sticky;
      top: 90px;
      padding: 18px;
      max-height: calc(100vh - 110px);
      display: flex;
      flex-direction: column;
    }

    .preview-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 14px;
    }

    .preview-header h3 {
      font-size: 13px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--text-secondary);
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .preview-actions {
      display: flex;
      gap: 6px;
    }

    .preview-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 12px;
      padding: 10px 12px;
      background: var(--bg-tertiary);
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
    }

    .preview-toolbar .left {
      display: flex;
      align-items: center;
      gap: 8px;
      color: var(--text-secondary);
      font-size: 12px;
      font-weight: 500
    }

    .preview-toolbar .right {
      display: flex;
      align-items: center;
      gap: 6px
    }


    .icon-btn {
      width: 32px;
      height: 32px;
      border-radius: 8px;
      background: var(--bg-tertiary);
      border: 1px solid var(--border);
      color: var(--text-secondary);
      cursor: pointer;
      display: grid;
      place-items: center;
      transition: all 0.2s;
    }

    .icon-btn:hover {
      color: var(--gold);
      border-color: var(--gold);
    }

    .preview-frame {
      flex: 1;
      overflow: auto;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
      background: transparent;
      padding: 24px 20px;
      display: flex;
      justify-content: center;
      align-items: flex-start;
      position: relative;
      background-clip: padding-box;
    }

    .folha-a4,
    .a4-page {
      background: #fff;
      color: #000;
      /* Proporção áurea nobre A4 para preview sem esticar na largura total */
      width: 100%;
      max-width: 760px;
      min-height: 297mm;
      margin: 0 auto;
      /* Margem nobre externa proporcional: espaço sacralizado nas laterais para ver a moldura inteira */
      padding: 18px 22px;
      box-sizing: border-box;
      font-family: var(--doc-font, 'Times New Roman', Times, serif);
      font-size: 11pt;
      line-height: 1.65;
      box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
      transform-origin: top center;
      transform: scale(1);
      -webkit-font-smoothing: antialiased !important;
      -moz-osx-font-smoothing: grayscale !important;
      text-rendering: optimizeLegibility !important;
      backface-visibility: hidden;
      -webkit-backface-visibility: hidden;
      overflow-wrap: break-word;
      word-break: normal;
    }

    .folha-a4 *,
    .a4-page * {
      max-width: 100%;
      box-sizing: border-box;
    }

    /* Quando houver template nobre/luxo com moldura externa própria, a folha mantém respiro lateral nobre */
    .folha-a4:has([class*="template-"]),
    .folha-a4:has([class*="container-"]),
    .folha-a4:has([class*="tpl-"]),
    .folha-a4.tem-template,
    .a4-page:has([class*="template-"]),
    .a4-page:has([class*="container-"]),
    .a4-page:has([class*="tpl-"]),
    .a4-page.tem-template {
      padding: 18px 22px !important;
    }

    /* Ajuste responsivo para telas menores */
    @media(max-width:1400px) {
      .folha-a4,
      .a4-page {
        width: 100%;
        max-width: 740px;
        padding: 16px 20px !important;
        font-size: 10.5pt;
        transform: scale(1);
      }
    }

    @media(max-width:1200px) {
      .folha-a4,
      .a4-page {
        width: 100%;
        max-width: 720px;
        padding: 14px 18px !important;
        font-size: 10pt;
        transform: scale(1);
      }
    }

    @media(max-width:1040px) {
      .folha-a4,
      .a4-page {
        width: 100%;
        max-width: 100%;
        padding: 12px 14px !important;
        font-size: 10pt;
        transform: scale(1);
      }
    }

    /* Estilos base para fallback inline (quando nenhum template premium carregou) */
    .a4-page.fallback-preview {
      font-size: 12pt;
      line-height: 1.58
    }

    .a4-page.fallback-preview h2 {
      font-size: 14pt;
      text-align: center;
      text-transform: uppercase;
      margin-bottom: 16pt;
      font-weight: 700;
      letter-spacing: .02em
    }

    .a4-page.fallback-preview h3 {
      font-size: 12pt;
      text-transform: uppercase;
      margin: 14pt 0 6pt;
      font-weight: 700;
      border-bottom: 1px solid #000;
      padding-bottom: 2pt
    }

    .a4-page.fallback-preview p {
      margin-bottom: 8pt;
      text-align: justify;
      text-indent: 2em
    }

    .a4-page.fallback-preview p.no-indent {
      text-indent: 0
    }

    .a4-page.fallback-preview .assinatura {
      margin-top: 36pt;
      text-align: center;
      text-indent: 0
    }

    .a4-page.fallback-preview .placeholder {
      color: #888;
      font-style: italic
    }

    .a4-page.fallback-preview .placeholder-line {
      background: #e5e0c5;
      color: #6b5618;
      padding: 0 4px;
      border-radius: 2px;
    }

    /* ==========================================================================
       DESIGN SYSTEM MOLDURAS NOBRES E VISUAL LAW - PRESCRIÇÃO
       Garante moldura dupla nobre completa (4 lados) e cantoneiras vetoriais
       ========================================================================== */
    .a4-page [class*="container-prescricao-"],
    [class*="container-prescricao-"] {
      display: block !important;
      position: relative !important;
      box-sizing: border-box !important;
      width: 100% !important;
      background: #ffffff !important;
    }

    /* 1. Tema Ouro Imperial */
    .a4-page .container-prescricao-ouro,
    .container-prescricao-ouro {
      border: 2px solid #8c6214 !important;
      padding: 6px !important;
      box-shadow: 0 4px 24px rgba(140, 98, 20, 0.08) !important;
      position: relative !important;
      background: #ffffff !important;
      box-sizing: border-box !important;
      margin-bottom: 24px !important;
    }
    .a4-page .container-prescricao-ouro .container-prescricao-inner,
    .container-prescricao-ouro .container-prescricao-inner {
      border: 1px solid #c5a059 !important;
    }

    /* 2. Tema Titanium Executive */
    .a4-page .container-prescricao-titanium,
    .container-prescricao-titanium {
      border: 2px solid #334155 !important;
      padding: 6px !important;
      box-shadow: 0 4px 24px rgba(51, 65, 85, 0.08) !important;
      position: relative !important;
      background: #ffffff !important;
      box-sizing: border-box !important;
      margin-bottom: 24px !important;
    }
    .a4-page .container-prescricao-titanium .container-prescricao-inner,
    .container-prescricao-titanium .container-prescricao-inner {
      border: 1px solid #64748b !important;
    }

    /* 3. Tema Imperial Blue */
    .a4-page .container-prescricao-imperial,
    .container-prescricao-imperial {
      border: 2px solid #1e3a8a !important;
      padding: 6px !important;
      box-shadow: 0 4px 24px rgba(30, 58, 138, 0.08) !important;
      position: relative !important;
      background: #ffffff !important;
      box-sizing: border-box !important;
      margin-bottom: 24px !important;
    }
    .a4-page .container-prescricao-imperial .container-prescricao-inner,
    .container-prescricao-imperial .container-prescricao-inner {
      border: 1px solid #3b82f6 !important;
    }

    /* 4. Tema Emerald Master */
    .a4-page .container-prescricao-emerald,
    .container-prescricao-emerald {
      border: 2px solid #065f46 !important;
      padding: 6px !important;
      box-shadow: 0 4px 24px rgba(6, 95, 70, 0.08) !important;
      position: relative !important;
      background: #ffffff !important;
      box-sizing: border-box !important;
      margin-bottom: 24px !important;
    }
    .a4-page .container-prescricao-emerald .container-prescricao-inner,
    .container-prescricao-emerald .container-prescricao-inner {
      border: 1px solid #10b981 !important;
    }

    /* 5. Tema Bordeaux Royal */
    .a4-page .container-prescricao-bordeaux,
    .container-prescricao-bordeaux {
      border: 2px solid #831843 !important;
      padding: 6px !important;
      box-shadow: 0 4px 24px rgba(131, 24, 67, 0.08) !important;
      position: relative !important;
      background: #ffffff !important;
      box-sizing: border-box !important;
      margin-bottom: 24px !important;
    }
    .a4-page .container-prescricao-bordeaux .container-prescricao-inner,
    .container-prescricao-bordeaux .container-prescricao-inner {
      border: 1px solid #ec4899 !important;
    }

    /* Container Interno Nobre Comum */
    .a4-page .container-prescricao-inner,
    .container-prescricao-inner {
      padding: 28px 30px !important;
      box-sizing: border-box !important;
      background: #ffffff !important;
      position: relative !important;
      width: 100% !important;
    }

    /* Cantoneiras Nobres Vetoriais de Filigrana (44px) */
    .a4-page .cantoneira-prescricao,
    .cantoneira-prescricao {
      position: absolute !important;
      width: 44px !important;
      height: 44px !important;
      pointer-events: none !important;
      z-index: 10 !important;
      background-repeat: no-repeat !important;
      background-size: contain !important;
    }
    .a4-page .canto-top-left, .canto-top-left { top: 4px !important; left: 4px !important; }
    .a4-page .canto-top-right, .canto-top-right { top: 4px !important; right: 4px !important; transform: scaleX(-1) !important; }
    .a4-page .canto-bottom-left, .canto-bottom-left { bottom: 4px !important; left: 4px !important; transform: scaleY(-1) !important; }
    .a4-page .canto-bottom-right, .canto-bottom-right { bottom: 4px !important; right: 4px !important; transform: scale(-1) !important; }

    /* Preservação Absoluta das Cores e Bordas dos Templates Nobres de Prescrição */
    .a4-page [class*="tpl-"],
    .a4-page [class*="tpl-"] * {
      box-sizing: border-box;
    }

    /* Regras legadas aplicadas SOMENTE a documentos puramente legados (sem tpl- e sem moldura) */
    .a4-page>div.template-legado-antigo:not([class*="tpl-"]):not([class*="container-"]) {
      width: 100% !important;
      max-width: none !important;
      padding: 0 !important;
      margin: 0 !important;
      background: #fff !important;
    }

    /* Ícones de calendário e relógio nos inputs nativos — forçar dourado */
    input[type="date"]::-webkit-calendar-picker-indicator,
    input[type="time"]::-webkit-calendar-picker-indicator {
      filter: invert(1) sepia(1) saturate(10) hue-rotate(0deg) brightness(0.8);
      cursor: pointer;
    }

    .preview-footer {
      display: flex;
      gap: 8px;
      margin-top: 14px;
    }

    .preview-footer .btn {
      flex: 1;
      padding: 10px;
      font-size: 12px;
    }

    .delivery-note {
      margin-top: 12px;
      padding: 12px;
      border: 1px solid rgba(212, 175, 55, .25);
      border-radius: 10px;
      background: rgba(212, 175, 55, .07);
      color: var(--text-secondary);
      font-size: 12px;
      line-height: 1.5;
    }

    /* Mobile preview */
    .preview-fab {
      display: none;
      position: fixed;
      bottom: 24px;
      right: 24px;
      z-index: 40;
      width: 56px;
      height: 56px;
      border-radius: 6px;
      background: linear-gradient(135deg, var(--gold), var(--gold-dark));
      color: #1a1a24;
      border: none;
      cursor: pointer;
      box-shadow: var(--shadow-gold);
      place-items: center;
    }

    .preview-drawer {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 60;
      background: rgba(0, 0, 0, 0.8);
      backdrop-filter: blur(8px);
    }

    .preview-drawer.open {
      display: block;
    }

    .preview-drawer .drawer-content {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      height: 85vh;
      background: var(--bg-secondary);
      border-radius: 6px 20px 0 0;
      padding: 20px;
      display: flex;
      flex-direction: column;
      animation: slideUp 0.3s ease;
    }

    @keyframes slideUp {
      from {
        transform: translateY(100%);
      }

      to {
        transform: translateY(0);
      }
    }

    /* TOAST */
    .toast-container {
      position: fixed;
      top: 20px;
      right: 20px;
      z-index: 100;
      display: flex;
      flex-direction: column;
      gap: 10px;
      max-width: 380px;
    }

    .toast {
      display: flex;
      align-items: flex-start;
      gap: 12px;
      padding: 14px 16px;
      background: var(--bg-secondary);
      border: 1px solid var(--border);
      border-left-width: 3px;
      border-radius: var(--radius-sm);
      box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
      backdrop-filter: blur(20px);
      animation: slideInRight 0.3s ease;
    }

    @keyframes slideInRight {
      from {
        transform: translateX(120%);
        opacity: 0;
      }

      to {
        transform: translateX(0);
        opacity: 1;
      }
    }

    .toast.success {
      border-left-color: var(--success);
    }

    .toast.error {
      border-left-color: var(--danger);
    }

    .toast.warning {
      border-left-color: var(--warning);
    }

    .toast.info {
      border-left-color: var(--info);
    }

    .toast-icon {
      flex-shrink: 0;
    }

    .toast.success .toast-icon {
      color: var(--success);
    }

    .toast.error .toast-icon {
      color: var(--danger);
    }

    .toast.warning .toast-icon {
      color: var(--warning);
    }

    .toast.info .toast-icon {
      color: var(--info);
    }

    .toast-content {
      flex: 1;
    }

    .toast-title {
      font-size: 13px;
      font-weight: 600;
    }

    .toast-msg {
      font-size: 12px;
      color: var(--text-secondary);
      margin-top: 2px;
    }

    .toast-close {
      background: none;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      padding: 0;
    }

    /* MODAL */
    .modal-backdrop {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 90;
      background: rgba(0, 0, 0, 0.8);
      backdrop-filter: blur(8px);
      align-items: center;
      justify-content: center;
      padding: 20px;
    }

    /* FORÇA OS MODAIS A FICAREM ESCONDIDOS SE NÃO FOREM CHAMADOS (EVITA O BUG DO CELULAR) */
    .modal-backdrop:not(.open) {
      display: none !important;
    }

    .modal-backdrop.open {
      display: flex !important;
    }

    .modal {
      background: var(--bg-secondary);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      max-width: 540px;
      width: 100%;
      padding: 24px;
      animation: modalIn 0.25s ease;
      max-height: 90vh;
      overflow-y: auto;
    }

    @keyframes modalIn {
      from {
        opacity: 0;
        transform: scale(0.95);
      }

      to {
        opacity: 1;
        transform: scale(1);
      }
    }

    .modal-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 16px;
    }

    .modal-header h3 {
      font-size: 17px;
      font-weight: 600;
    }

    .modal-body {
      color: var(--text-secondary);
      font-size: 14px;
      margin-bottom: 20px;
    }

    .modal-actions {
      display: flex;
      gap: 10px;
      justify-content: flex-end;
      flex-wrap: wrap;
    }

    /* Decision flow */
    .decision-step {
      padding: 14px;
      background: var(--bg-tertiary);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      margin-bottom: 10px;
    }

    /* Ajuste dos botões de decisão do Modal (Responsivo) */
    .decision-opts {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }

    .decision-opts button {
      width: 100%;
      padding: 12px;
      /* Deixei mais gordinho pro toque do dedo */
      background: var(--bg-secondary);
      border: 1px solid var(--border);
      color: var(--text-secondary);
      border-radius: 8px;
      cursor: pointer;
      font-size: 13px;
      font-family: inherit;
      transition: all 0.2s;
    }

    .decision-opts button:hover {
      border-color: var(--gold);
      color: var(--text-primary);
    }

    /* Quando for celular, empilha um botão embaixo do outro */
    @media (max-width: 480px) {
      .decision-opts {
        grid-template-columns: 1fr;
      }
    }

    /* Tips box */
    .tips-box {
      margin-top: 12px;
      padding: 14px;
      background: rgba(59, 130, 246, 0.06);
      border-left: 3px solid var(--info);
      border-radius: var(--radius-xs);
      font-size: 12px;
      color: var(--text-secondary);
      line-height: 1.6;
    }

    .tips-box strong {
      color: var(--info);
      display: block;
      margin-bottom: 4px;
    }

    /* Review */
    .review-section {
      padding: 16px;
      background: var(--bg-tertiary);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      margin-bottom: 12px;
    }

    .review-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 12px;
      padding-bottom: 10px;
      border-bottom: 1px solid var(--border);
    }

    .review-head h4 {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 13px;
      font-weight: 600;
      color: var(--gold);
      text-transform: uppercase;
      letter-spacing: 0.06em;
    }

    .btn-edit-mini {
      background: transparent;
      border: 1px solid var(--border);
      color: var(--text-secondary);
      padding: 4px 10px;
      border-radius: 6px;
      font-size: 11px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 4px;
    }

    .btn-edit-mini:hover {
      color: var(--gold);
      border-color: var(--gold);
    }

    .review-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 10px 16px;
      font-size: 13px;
    }

    .review-grid .lbl {
      color: var(--text-muted);
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }

    .review-grid .val {
      color: var(--text-primary);
      font-weight: 500;
    }

    @media (max-width: 600px) {
      .review-grid {
        grid-template-columns: 1fr;
      }
    }

    /* Tipo badge */
    .tipo-badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 4px 10px;
      border-radius: 6px;
      font-size: 11px;
      font-weight: 600;
    }

    .tipo-badge.intercorrente {
      background: rgba(59, 130, 246, 0.2);
      color: #60a5fa;
      border: 1px solid rgba(59, 130, 246, 0.5);
    }

    .tipo-badge.punitiva {
      background: rgba(245, 158, 11, 0.2);
      color: #fbbf24;
      border: 1px solid rgba(245, 158, 11, 0.5);
    }

    .tipo-badge.executoria {
      background: rgba(239, 68, 68, 0.2);
      color: #f87171;
      border: 1px solid rgba(239, 68, 68, 0.5);
    }

    /* Autocomplete */
    .autocomplete-list {
      position: absolute;
      top: 100%;
      left: 0;
      right: 0;
      z-index: 30;
      background: var(--bg-secondary);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      margin-top: 4px;
      max-height: 220px;
      overflow-y: auto;
      box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
    }

    .autocomplete-item {
      padding: 10px 12px;
      cursor: pointer;
      font-size: 13px;
      border-bottom: 1px solid var(--border);
    }

    .autocomplete-item:hover {
      background: var(--bg-tertiary);
      color: var(--gold);
    }

    .autocomplete-item:last-child {
      border-bottom: none;
    }

    .autocomplete-item .ac-code {
      color: var(--gold);
      font-weight: 600;
      font-size: 11px;
    }

    .autocomplete-item .ac-desc {
      color: var(--text-secondary);
      font-size: 12px;
      margin-top: 2px;
    }

    /* RESPONSIVE */
    @media (max-width: 1200px) {
      .step-label {
        display: none;
      }

      .step-line {
        width: 16px;
      }
    }

    @media (max-width: 1040px) {
      html, body {
        height: auto !important;
        min-height: 100% !important;
        overflow-y: auto !important;
      }

      .main {
        grid-template-columns: 1fr !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        overflow: visible !important;
      }

      .form-panel {
        grid-column: 1 !important;
        position: static !important;
        max-height: none !important;
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
        overflow-y: visible !important;
        width: 100% !important;
      }

      .preview-panel {
        grid-column: 1 !important;
        position: static !important;
        max-height: none !important;
        height: auto !important;
        min-height: auto !important;
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        margin-top: 24px !important;
      }

      .preview-fab {
        display: none !important;
      }
    }

    /* regras mobile unificadas no bloco abaixo */

    @media (max-width: 768px) {

      html,
      body {
        width: 100%;
        max-width: 100%;
        overflow-x: clip;
      }

      .header {
        padding: 0;
        /* padding movido para .header-inner */
        width: 100%;
        max-width: 100vw;
      }

      .header-inner {
        padding: 10px 12px;
        /* mesmo padding lateral da .main no mobile */
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 15px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
      }

      .header-inner>div:first-child,
      .brand {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
      }

      .brand-icon,
      .user-avatar {
        width: 38px;
        height: 38px;
        border-radius: 6px;
        background: linear-gradient(135deg, #2a2a3a, #1a1a24);
        border: 1px solid var(--border);
        display: grid;
        place-items: center;
        color: var(--gold);
        font-weight: 600;
        font-size: 13px;
        cursor: pointer;
      }

      .brand-text h1 {
        font-size: 15px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin: 0;
      }

      .brand-text p {
        display: none !important;
      }

      .stepper {
        display: none !important;
      }

      .btn-back span {
        display: none !important;
      }

      .btn-back {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: transparent;
        border: 1px solid var(--border);
        color: var(--text-secondary);
        padding: 8px 14px;
        border-radius: 10px;
        cursor: pointer;
        font-size: 13px;
        font-weight: 500;
        transition: all .2s;
      }

      .header-inner>div:last-child {
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
      }


      .stepper-mobile {
        display: block;
        white-space: nowrap;
        font-size: 13px;
        color: var(--text-secondary);
        font-weight: 600;
        text-align: center;
      }

      .main {
        display: block;
        width: 100%;
        max-width: 100vw;
        min-width: 0;
        padding: 14px 12px 14px !important;
        margin: 0;
      }

      .glass-card,
      .form-panel,
      .step-pane,
      .step-content,
      .section,
      .tipo-grid,
      .tipo-card,
      .result-card {
        width: 100%;
        max-width: 100%;
        min-width: 0;
      }

      .form-panel {
        padding: 18px 14px;
        min-height: auto;
        position: static;
        max-height: none;
        overflow: visible;
      }

      .step-header {
        margin-bottom: 18px;
      }

      .step-title {
        font-size: clamp(25px, 9.5vw, 34px) !important;
        line-height: 1.05;
        max-width: 100%;
        overflow-wrap: break-word;
        word-break: normal;
      }

      .step-subtitle {
        font-size: 14px;
        line-height: 1.55;
        max-width: 100%;
      }

      .tipo-grid,
      .grid,
      .grid-2,
      .grid-3,
      .result-meta,
      .review-grid {
        grid-template-columns: 1fr !important;
      }

      /* Campos de formulário: nunca deixar espremidos */
      .field {
        width: 100% !important;
        min-width: 0 !important;
      }

      /* Grupos de campos lado a lado → 1 coluna */
      .form-row,
      .form-row-3,
      .form-row-4,
      [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
      }

      .actions {
        display: flex !important;
        flex-wrap: wrap !important;
        flex-direction: row !important;
        gap: 12px !important;
        align-items: stretch !important;
      }

      #form-navigation.actions {
        position: static !important;
        background: transparent !important;
        padding: 16px 0 calc(56px + env(safe-area-inset-bottom, 0px)) !important;
        box-shadow: none !important;
      }

      .actions>div[style*="display:flex"] {
        display: contents !important;
      }

      .actions .btn-primary {
        order: 1 !important;
        flex: 0 0 100% !important;
        width: 100% !important;
        justify-content: center !important;
        min-height: 48px !important;
      }

      .actions .btn:not(.btn-primary) {
        order: 2 !important;
        flex: 1 1 0% !important;
        min-width: 40% !important;
        width: auto !important;
        justify-content: center !important;
        min-height: 48px !important;
        background: rgba(255, 255, 255, 0.05) !important;
        border: 1px solid rgba(255, 255, 255, 0.15) !important;
        color: var(--text-primary, #e5e7eb) !important;
        border-radius: 10px !important;
        padding: 10px 14px !important;
        font-weight: 600 !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
      }

      .tipo-card {
        padding: 20px 16px 18px;
      }

      .tipo-title {
        font-size: 17px;
        line-height: 1.15;
      }

      .result-status {
        align-items: flex-start;
      }

      /* Removed conflicting .stepper mobile flex rule */

      .preview-panel {
        display: none !important;
      }

      .preview-fab {
        display: grid;
        right: 16px;
        bottom: 16px;
      }

      .preview-drawer .drawer-content {
        height: min(92vh, 100dvh - 18px);
        padding: 14px;
      }

      .preview-drawer .preview-frame {
        min-height: 0;
        padding: 12px;
        overflow: auto;
      }

      .preview-drawer .a4-page {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        min-height: auto;
        aspect-ratio: auto;
        padding: 22px 18px;
        font-size: 10pt;
        transform: none !important;
      }

      .modal {
        width: 100%;
        max-width: calc(100vw - 24px);
      }
    }

    @media (max-width: 480px) {
      .step-eyebrow {
        font-size: 10px !important;
        padding: 4px 10px !important;
        letter-spacing: .08em !important;
      }

      .step-title {
        font-size: clamp(22px, 8.5vw, 28px) !important;
      }

      .section-title {
        font-size: 11px !important;
      }

      .form-panel {
        padding: 16px 12px !important;
      }

      /* Botões de escolha (tipo-card) não ficam truncados */
      .tipo-card {
        padding: 16px 14px !important;
      }

      .tipo-title {
        font-size: 15px !important;
      }

      .tipo-desc {
        font-size: 12px !important;
      }
    }

    @media (max-width: 360px) {
      .main {
        padding-left: 10px !important;
        padding-right: 10px !important;
      }

      .form-panel {
        padding: 14px 10px !important;
      }

      .step-title {
        font-size: clamp(20px, 10vw, 26px) !important;
      }

      .tipo-card {
        padding: 14px 12px !important;
      }
    }

    .step-pane {
      display: none !important;
    }

    .step-pane.active {
      display: flex !important;
      flex-direction: column !important;
      flex: 1 0 auto !important;
      animation: fadeInUp 0.3s ease both;
    }

    /* ── Overlay Gerando Petição — CLONE EXATO do Defesa ────────────────── */
    .gerando-overlay {
      /* Injetado diretamente no #form-panel como filho absolute */
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      width: 100%;
      height: 100%;
      min-height: 100%;
      z-index: 9999;
      background: rgba(15, 15, 18, 0.98) !important;
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 16px;
      padding: 30px;
      text-align: center;
      pointer-events: auto;
      border-radius: 16px; /* --radius do prescricao.html */
      box-sizing: border-box;
    }


    .gerando-overlay.gerando-overlay--entrada {
      animation: gerandoOverlayFadeIn 0.3s ease-out forwards;
    }

    @keyframes gerandoOverlayFadeIn {
      from { opacity: 0; }
      to   { opacity: 1; }
    }

    .gerando-overlay .cadeado {
      width: 60px;
      height: 60px;
      flex-shrink: 0;
      border: 2px solid var(--gold);
      border-radius: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 10px;
      animation: pulse-lock 2s infinite ease-in-out;
    }

    .gerando-overlay .cadeado svg {
      color: var(--gold);
      width: 30px;
      height: 30px;
    }

    .gerando-overlay .gerando-overlay-texto {
      flex: none;
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 100%;
    }

    .gerando-overlay h2 {
      color: var(--gold);
      font-family: var(--font-display, 'Plus Jakarta Sans', system-ui, sans-serif);
      font-size: 1.25rem;
      font-weight: 700;
      margin: 0 0 8px;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      line-height: 1.2;
    }

    .gerando-overlay p {
      color: var(--text-secondary);
      font-size: 0.9rem;
      margin: 0 0 20px;
      line-height: 1.5;
      max-width: 80%;
    }

    .gerando-barra {
      width: 100%;
      max-width: 260px;
      height: 3px;
      background: rgba(212, 175, 55, 0.15);
      border-radius: 2px;
      overflow: hidden;
    }

    .gerando-barra::after {
      content: '';
      display: block;
      width: 40%;
      height: 100%;
      background: linear-gradient(90deg, var(--gold), var(--gold-light, #f4d03f));
      border-radius: 2px;
      animation: slideBarra 1.2s ease-in-out infinite;
    }

    @keyframes pulse-lock {
      0%, 100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(212, 175, 55, .3); }
      50%       { transform: scale(1.06); box-shadow: 0 0 20px 6px rgba(212, 175, 55, .12); }
    }

    @keyframes slideBarra {
      0%   { transform: translateX(-100%); }
      100% { transform: translateX(250%); }
    }

    @media (max-width: 768px) {
      .gerando-overlay {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 16px;
      }
      .gerando-overlay .gerando-overlay-texto { width: 100%; }
      .gerando-barra { max-width: 100%; margin: 0 auto; }
    }

    /* ─────────────────────────────────────────────────── */
    /* =======================================================
   CORREÇÃO DE CAMPOS ESPREMIDOS NO TABLET (GRID)
   ======================================================= */
    @media (max-width: 1040px) {

      /* No Tablet em pé ou deitado: força os blocos de 3/4 colunas a virarem 2 colunas */
      .form-row-3,
      .form-row-4,
      .grid-3,
      .grid-4,
      [style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr 1fr !important;
      }
    }

    @media (max-width: 850px) {

      /* Num Tablet um pouco menor: já quebra tudo para 1 coluna (um embaixo do outro) para não arriscar amassar */
      .form-row,
      .form-row-3,
      .form-row-4,
      .field-row-3,
      #wrap-cnh,
      .grid-2,
      .grid-3,
      .grid-4,
      [style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
      }
    }

    @media (max-width: 768px) {
      .close-preview-mobile {
        display: flex !important;
      }
    }

    /* Efeito de Validação (Erro) para os botões da grade de Gravidade (Estilo Defesa) */
    .gravity-grid.campo-erro-fici .btn-gravity {
      border-color: #ef4444 !important;
      box-shadow: 0 0 0 1px #ef4444 !important;
    }

    /* Efeito de Validação (Erro) para os cards de Tipo de Prescrição */
    .tipo-grid.campo-erro-fici .tipo-card {
      border-color: #ef4444 !important;
      box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.4) !important;
    }

/* ================================================================ */
/* Extraído de prescricao.html (bloco inline linha 2960)            */
/* ================================================================ */
/* --- NOVO MOBILE UI --- */
    @media (max-width: 768px) {

      /* Rolagem normal do documento no mobile — NÃO travar o body
         (overflow:hidden + altura fixa do .main congelava a página inteira) */
      body {
        overflow-y: auto !important;
        height: auto !important;
      }

      .main {
        height: auto !important;
        overflow: visible !important;
      }

      /* Header opaco para conteúdo não vazar no scroll transparente */
      .header {
        background: #0a0a0f !important;
        backdrop-filter: none !important;
        padding: 0 !important;
      }

      .header-inner {
        padding: 6px 12px !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
      }

      /* Esconder elementos puramente desktop do header */
      .header-inner .brand,
      .header-inner .stepper,
      .header-inner > div[style*="display:flex"],
      .header-inner > div[style*="display: flex"] {
        display: none !important;
      }

      /* Ajustar o padding do main e preview-panel */
      .preview-panel {
        z-index: 50;
        position: fixed;
        top: 130px !important;
        left: 0;
        width: 100%;
        height: calc(100dvh - 130px) !important;
        height: calc(100vh - 130px) !important;
        background: var(--bg-primary);
        overflow-y: auto;
        padding: 12px 16px 24px;
        display: none;
      }

      .preview-panel.mobile-active {
        display: flex !important;
      }

      .preview-toolbar {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 8px !important;
        width: 100% !important;
        padding: 4px 8px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none !important;
      }

      .preview-toolbar::-webkit-scrollbar {
        display: none !important;
      }

      .preview-toolbar .left {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 8px !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        padding-left: 2px !important;
        margin-right: 4px !important;
        font-size: 11px !important;
        margin-bottom: 0 !important;
      }

      .preview-toolbar .left span {
        white-space: nowrap !important;
        overflow: visible !important;
        text-overflow: clip !important;
        font-size: 11px !important;
      }

      .preview-toolbar .right {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 6px !important;
        flex-shrink: 0 !important;
        margin-left: 0 !important;
        width: auto !important;
      }

      .preview-toolbar button, .preview-toolbar .btn, .preview-toolbar .icon-btn {
        flex-shrink: 0 !important;
        min-width: 34px !important;
        height: 34px !important;
        min-height: 34px !important;
        max-height: 34px !important;
        padding: 0 8px !important;
        font-size: 13px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
      }

      .preview-frame {
        width: 100% !important;
        overflow: hidden !important;
        display: flex !important;
        justify-content: center !important;
        align-items: flex-start !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 auto !important;
      }

      .folha-a4, #a4Preview {
        width: 800px !important;
        min-width: 800px !important;
        max-width: 800px !important;
        transform-origin: top center !important;
        margin-top: 20px !important;
        margin-bottom: 20px !important;
        margin-left: auto !important;
        margin-right: auto !important;
        box-sizing: border-box !important;
        box-shadow: 0 4px 15px rgba(0,0,0,0.15) !important;
      }

      .form-panel.hidden-mobile {
        display: none !important;
        /* Se ainda for usado */
      }
    }

    /* Novo Header Mobile */
    .mobile-header-custom {
      display: none;
    }

    .field.error input,
    .field.error select,
    .field.error #displayDataStep4 {
      border-color: #ef4444 !important;
      background: #09090b !important;
    }

    /* Campo valor da multa: fundo preto sólido sempre */
    #valorAtualMulta {
      background: #09090b !important;
    }

    #valorAtualMulta.campo-erro,
    .field.error #valorAtualMulta {
      background: #09090b !important;
      border-color: #ef4444 !important;
      box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25) !important;
    }

    .mobile-drawer-overlay,
    .mobile-drawer {
      display: none !important;
    }

    .progress-modal-overlay {
      position: fixed !important;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.75) !important;
      backdrop-filter: blur(4px) !important;
      z-index: 2000;
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.3s ease;
    }

    .progress-modal-overlay.open {
      opacity: 1;
      pointer-events: all;
    }

    @media (min-width: 769px) {
      .progress-modal-overlay {
        display: none !important;
      }
    }

    @media (max-width: 768px) {
      .mobile-drawer-overlay {
        display: block !important;
      }

      .mobile-drawer {
        display: flex !important;
      }
    }

    @media (max-width: 768px) {
      .mobile-header-custom {
        display: flex;
        width: 100%;
        align-items: center;
        justify-content: space-between;
        position: relative;
        /* added */
      }

      .mobile-header-custom .mh-left {
        display: flex;
        align-items: center;
        gap: 12px;
      }

      .mobile-header-custom .mh-logo {
        font-size: 16px;
        font-weight: 700;
        color: var(--text-primary);
        white-space: nowrap;
        flex-shrink: 1;
        text-overflow: ellipsis;
        overflow: hidden;
        text-align: center;
      }

      .mobile-header-custom .mh-logo span {
        color: var(--gold);
      }

      .mobile-header-custom .user-avatar {
        position: relative;
        z-index: 2;
        width: 28px !important;
        height: 28px !important;
        font-size: 10px !important;
        border-radius: 6px !important;
      }

      .mh-menu-btn {
        background: transparent;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 4px;
      }

      /* Hamburger Menu Overlay */
      .mobile-drawer-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        z-index: 1000;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
      }

      .mobile-drawer-overlay.open {
        opacity: 1;
        pointer-events: auto;
      }

      .mobile-drawer {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100%;
        background: #12121a;
        z-index: 1001;
        transition: left 0.3s ease;
        display: flex;
        flex-direction: column;
        border-right: 1px solid var(--border);
      }

      .mobile-drawer.open {
        left: 0;
      }

      .md-header {
        padding: 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid var(--border);
      }

      .md-close {
        background: transparent;
        border: none;
        color: var(--text-secondary);
        padding: 4px;
        cursor: pointer;
      }

      .md-body {
        padding: 20px;
        display: flex;
        flex-direction: column;
        gap: 4px;
      }

      .md-btn {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        text-align: left;
        gap: 12px;
        padding: 10px 16px;
        border-radius: 8px;
        background: transparent;
        border: none;
        color: var(--text-secondary);
        font-size: 14px;
        font-weight: 500;
        line-height: 1.3;
        text-decoration: none;
        cursor: pointer;
        transition: all 0.3s ease;
      }

      .md-btn:hover {
        background: rgba(255, 255, 255, 0.05);
        color: var(--text-primary);
      }

      .md-btn i {
        width: 18px;
        height: 18px;
        color: var(--text-secondary);
        transition: color 0.3s ease;
      }

      .md-btn.videoaulas {
        color: var(--gold);
      }

      .md-btn.videoaulas i {
        color: var(--gold);
      }

      .md-btn.preview {
        color: var(--gold);
      }

      .md-btn.preview i {
        color: var(--gold);
      }

      /* Modal Progresso */
      .progress-modal-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.7);
        z-index: 2000;
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s;
      }

      .progress-modal-overlay.open {
        opacity: 1;
        pointer-events: auto;
      }

      .progress-modal {
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: 16px;
        padding: 24px;
        width: 90%;
        max-width: 320px;
        text-align: center;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
        transform: translateY(20px);
        transition: transform 0.3s;
      }

      .progress-modal-overlay.open .progress-modal {
        transform: translateY(0);
      }

      .pm-icon {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: rgba(16, 185, 129, 0.1);
        color: #10B981;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto 16px;
      }

      .pm-title {
        font-size: 18px;
        font-weight: 700;
        color: var(--text-primary);
        margin-bottom: 8px;
      }

      .pm-subtitle {
        font-size: 14px;
        color: var(--text-secondary);
        margin-bottom: 20px;
      }

      .pm-bar-bg {
        width: 100%;
        height: 8px;
        background: var(--bg-tertiary);
        border-radius: 4px;
        overflow: hidden;
        margin-bottom: 20px;
      }

      .pm-bar-fill {
        height: 100%;
        background: linear-gradient(90deg, var(--gold), #fbbf24);
        width: 0%;
        transition: width 0.5s ease;
      }

      .pm-btn {
        width: 100%;
        padding: 12px;
        background: var(--gold);
        color: #1a1a24;
        border: none;
        border-radius: 8px;
        font-weight: 600;
        cursor: pointer;
        font-size: 14px;
      }
    }

/* ================================================================ */
/* Extraído de prescricao.html (bloco inline linha 3375)            */
/* ================================================================ */
@media (max-width: 768px) {

      .preview-fab,
      #previewFab {
        display: none !important;
      }

      .preview-drawer,
      #previewDrawer {
        display: none !important;
      }

      .preview-fade-bottom,
      .scroll-fade,
      .fade-bottom,
      .bottom-blur {
        display: none !important;
      }
    }

/* ================================================================ */
/* Extraído de prescricao.html (bloco inline linha 4836)            */
/* ================================================================ */
/* ============================================================
   CART DRAWER (CARRINHO LATERAL) — mesma definição de defesa.css
   Sem isso, o drawer renderiza como bloco normal no fim da página
   (aparecendo "embaixo do editor") em vez de painel fixo lateral.
   ============================================================ */
    .cart-drawer-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.65);
      z-index: 1000;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.3s ease;
    }

    .cart-drawer-overlay.open {
      opacity: 1;
      pointer-events: auto;
    }

    .cart-drawer {
      position: fixed;
      top: 0;
      right: -320px;
      width: 320px;
      height: 100%;
      max-width: 100vw;
      background: #12121a;
      z-index: 1001;
      transition: right 0.3s ease;
      display: flex;
      flex-direction: column;
      border-left: 1px solid rgba(255, 255, 255, 0.08);
      box-shadow: -8px 0 32px rgba(0, 0, 0, 0.45);
    }

    .cart-drawer.open {
      right: 0;
    }

    .cd-header {
      padding: 20px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-bottom: 1px solid rgba(255, 255, 255, 0.08);
      background: #12121a;
    }

    .cd-title {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 16px;
      font-weight: 700;
      color: var(--gold);
    }

    .cd-title i {
      width: 18px;
      height: 18px;
    }

    .cd-close {
      background: transparent;
      border: none;
      color: var(--text-secondary);
      padding: 4px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .cd-close:hover {
      color: var(--danger);
    }

    .cd-body {
      flex: 1;
      padding: 20px;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 12px;
      background: #12121a;
    }

    .cd-empty {
      text-align: center;
      color: var(--text-muted, var(--text-secondary));
      font-size: 13px;
      margin-top: 40px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 12px;
    }

    .cd-item {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      background: #1a1a24;
      border: 1px solid rgba(255, 255, 255, 0.08);
      padding: 12px;
      border-radius: 8px;
      gap: 10px;
    }

    .cd-item-info {
      flex: 1;
      min-width: 0;
    }

    .cd-item-title {
      font-size: 13px;
      font-weight: 600;
      color: var(--text-primary);
      line-height: 1.4;
      margin-bottom: 4px;
      word-break: break-word;
    }

    .cd-item-price {
      font-size: 13px;
      color: var(--gold);
      font-weight: 700;
    }

    .cd-item-remove {
      background: transparent;
      border: none;
      color: var(--text-muted, var(--text-secondary));
      cursor: pointer;
      padding: 4px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: color 0.2s;
    }

    .cd-item-remove:hover {
      color: var(--danger);
    }

    .cd-footer {
      padding: 20px;
      border-top: 1px solid rgba(255, 255, 255, 0.08);
      background: #16161f;
      display: flex;
      flex-direction: column;
      gap: 14px;
    }

    .cd-subtotal {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 14px;
      color: var(--text-primary);
    }

    .cd-subtotal strong {
      font-size: 18px;
      color: var(--gold);
    }

    .cd-btn-checkout {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      width: 100%;
      padding: 14px;
      background: linear-gradient(135deg, var(--gold), #c5a059);
      color: #0a0a0a;
      border: none;
      border-radius: 10px;
      font-weight: 700;
      font-size: 14px;
      cursor: pointer;
      transition: transform 0.2s, box-shadow 0.2s;
      text-decoration: none;
    }

    .cd-btn-checkout:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 24px -8px rgba(212, 175, 55, 0.5);
      color: #0a0a0a !important;
    }

    .cd-btn-checkout:disabled,
    .cd-btn-checkout.is-disabled {
      background: #2a2820;
      color: #6e6858;
      pointer-events: none;
      cursor: not-allowed;
      box-shadow: none;
      transform: none;
      opacity: 1;
    }

    /* ==========================================================================
       PROTEÇÃO VISUAL LAW — Painéis e Métricas de Prescrição (Sem Vazamento)
       ========================================================================== */
    .a4-page [class*="resumo-grid"],
    .a4-page [class*="grid-metrics"],
    .a4-page [class*="metrics"] {
      overflow: visible !important;
    }

    .a4-page [class*="resumo-item"],
    .a4-page [class*="grid-metric"],
    .a4-page [class*="metric-box"] {
      min-width: 0 !important;
      box-sizing: border-box !important;
      word-break: normal !important;
      overflow-wrap: normal !important;
      hyphens: none !important;
    }

    .a4-page [class*="resumo-item"] strong,
    .a4-page [class*="grid-metric"] strong,
    .a4-page [class*="metric-box"] strong,
    .a4-page [class*="metric-label"] {
      word-break: keep-all !important;
      overflow-wrap: normal !important;
      hyphens: none !important;
      letter-spacing: 0.3px !important;
    }

    .a4-page #prev-ait,
    .a4-page #prev-data_vencimento,
    .a4-page #prev-data_infracao {
      white-space: nowrap !important;
      display: inline-block !important;
    }

/* ================================================================
   SCROLL NATURAL — PRESCRICAO.HTML MOBILE
   O usuário reportou que a barra de botões fixada no rodapé
   cobria campos (ex: data) ao rolar. Solução: página rola
   inteira — sem overflow:hidden no body, sem cadeia flex fechada,
   sem .actions fixado. Tudo flui no documento normalmente.
   ================================================================ */

@media (max-width: 768px) {

  /* Rola livremente a página inteira no mobile */
  html {
    height: auto !important;
    min-height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  body.scope-editor-prescricao {
    display: block !important;
    height: auto !important;
    min-height: 100dvh !important;
    overflow-x: hidden !important;
    overflow-y: visible !important;
  }

  /* Header sticky no topo — mas a página que rola por baixo */
  body.scope-editor-prescricao .header {
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    width: 100% !important;
  }

  /* Main e form-panel: sem altura fixa — crescem com o conteúdo */
  body.scope-editor-prescricao .main,
  body.scope-editor-prescricao .form-panel {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* step-content: sem scroll interno — rola com a página, sem buraco no final */
  body.scope-editor-prescricao .step-content:not(.hidden) {
    overflow: visible !important;
    height: auto !important;
    min-height: auto !important;
    padding-bottom: 16px !important;
  }

  /* Actions: ajustado no fim do formulário, SEM posição fixada/sticky e sem buraco */
  body.scope-editor-prescricao .actions {
    position: static !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
    flex-shrink: 0 !important;
    margin-top: 16px !important;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px)) !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Garante que títulos, subtítulos e textos quebrem linha normalmente no mobile */
  body.scope-editor-prescricao .step-header,
  body.scope-editor-prescricao .step-title,
  body.scope-editor-prescricao .step-subtitle,
  body.scope-editor-prescricao [class*="step-subtitle"],
  body.scope-editor-prescricao .card-sub,
  body.scope-editor-prescricao .step-eyebrow,
  body.scope-editor-prescricao p {
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    max-width: 100% !important;
  }

  /* Inputs font-size 16px no mobile para prevenir auto-zoom no iOS */
  body.scope-editor-prescricao input:not([type="checkbox"]):not([type="radio"]),
  body.scope-editor-prescricao select,
  body.scope-editor-prescricao textarea {
    font-size: 16px !important;
  }

  /* Área de data para análise no mobile — remove paddings residuais */
  body.scope-editor-prescricao #areaDataAnalise {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  body.scope-editor-prescricao #areaDataAnalise > .section {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Botões de Ação internos ("Analisar Prazo" e "Confirmar Valor") e barra inferior alinhados com margem do formulário */
  body.scope-editor-prescricao #btnAnalisarPrazo,
  body.scope-editor-prescricao #btnConfirmarValor {
    margin: 0 !important;
    width: 100% !important;
    min-height: 50px !important;
    height: 50px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    padding: 14px 20px !important;
    border-radius: 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    box-sizing: border-box !important;
  }

  /* Barra de navegação inferior (.actions) alinhada rigorosamente (24px) com a largura dos campos internos */
  body.scope-editor-prescricao .actions,
  body.scope-editor-prescricao #form-navigation {
    padding-left: 24px !important;
    padding-right: 24px !important;
    box-sizing: border-box !important;
  }

  body.scope-editor-prescricao #btn-next {
    min-height: 50px !important;
    height: 50px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    box-sizing: border-box !important;
  }

  /* Selo de Serviço — padrão dourado (igual Cassação) */
  #stepperMobile .service-badge,
  body.scope-editor-prescricao #stepperMobile .service-badge {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.16), rgba(212, 175, 55, 0.05)) !important;
    border: 1px solid rgba(212, 175, 55, 0.45) !important;
    color: var(--gold, #D4AF37) !important;
  }

  #stepperMobile .service-badge i,
  #stepperMobile .service-badge svg,
  #stepperMobile .service-badge [data-lucide],
  body.scope-editor-prescricao #stepperMobile .service-badge i {
    color: var(--gold, #D4AF37) !important;
  }

  #stepperMobile .service-badge .service-badge-label,
  body.scope-editor-prescricao #stepperMobile .service-badge .service-badge-label {
    color: var(--gold, #D4AF37) !important;
  }
}

/* =========================================================================
   MINI PLACA MERCOSUL OFICIAL (VISUAL LAW FORENSE) - MÓDULO PRESCRIÇÃO
   ========================================================================= */
.mini-placa-mercosul {
  display: inline-flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  align-items: stretch !important;
  width: 124px !important;
  min-width: 124px !important;
  max-width: 124px !important;
  flex-shrink: 0 !important;
  height: 30px !important;
  min-height: 30px !important;
  max-height: 30px !important;
  border: 1.5px solid #002b7a !important;
  border-radius: 4px !important;
  background: #ffffff !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15) !important;
  overflow: hidden !important;
  vertical-align: middle !important;
  box-sizing: border-box !important;
  line-height: 1 !important;
  margin: 0 4px !important;
  padding: 0 !important;
  white-space: nowrap !important;
}
.mini-placa-mercosul .mini-placa-header {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 9.5px !important;
  min-height: 9.5px !important;
  max-height: 9.5px !important;
  background: #002b7a !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  font-size: 5pt !important;
  font-weight: 800 !important;
  letter-spacing: 1px !important;
  text-align: center !important;
  padding: 0 !important;
  line-height: 9.5px !important;
  text-transform: uppercase !important;
  box-sizing: border-box !important;
  white-space: nowrap !important;
}
.mini-placa-mercosul .mini-placa-corpo {
  flex: 1 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #ffffff !important;
  height: 18.5px !important;
  line-height: 18.5px !important;
  padding: 0 4px !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  white-space: nowrap !important;
}
.mini-placa-mercosul .mini-placa-corpo span,
.mini-placa-mercosul .mini-placa-corpo .prev-placa,
.mini-placa-mercosul span.prev-placa,
.mini-placa-mercosul #prev-placa {
  display: inline-block !important;
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
  font-size: 9.5pt !important;
  font-weight: normal !important;
  letter-spacing: 0.6px !important;
  color: #000000 !important;
  -webkit-text-fill-color: #000000 !important;
  line-height: 1 !important;
  text-transform: uppercase !important;
  vertical-align: middle !important;
  white-space: nowrap !important;
}
/* No Modo YouTube, garantir contraste impecável sobre a placa branca (preto nítido) */
.modo-gravacao-yt-ativo .mini-placa-mercosul #prev-placa,
.modo-gravacao-yt-ativo .mini-placa-mercosul .prev-placa,
.modo-gravacao-yt-ativo .mini-placa-mercosul span {
  color: #000000 !important;
  font-weight: normal !important;
}

/* ============================================================
   COMBOBOX INTELIGENTE DE ÓRGÃOS AUTUADORES — PRESCRIÇÃO
   Idêntico ao seletor de Órgãos Autuadores do DefesaExpress
   ============================================================ */
.combobox-orgao-wrap {
  position: relative !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  padding: 0 !important;
  display: block !important;
  user-select: none;
}

.combobox-orgao-input {
  position: relative !important;
  z-index: 2 !important;
  cursor: text !important;
  pointer-events: auto !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 44px !important;
  padding-left: 42px !important;
  padding-right: 38px !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  color: var(--text-primary) !important;
  background: rgba(0, 0, 0, 0.3) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm, 10px) !important;
  font-family: inherit !important;
  font-size: 14px !important;
  font-weight: 400 !important;
  letter-spacing: normal !important;
  outline: none !important;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.2s ease !important;
}

.combobox-orgao-input:hover:not(:focus) {
  border-color: rgba(212, 175, 55, 0.5) !important;
}

.combobox-orgao-input::placeholder {
  color: var(--text-muted) !important;
  font-weight: 400 !important;
}

.combobox-orgao-input:focus {
  border-color: var(--gold, #d4af37) !important;
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12) !important;
  background: #0a0a0f !important;
  outline: none !important;
}

.combobox-arrow-btn {
  position: absolute !important;
  right: 14px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  background: transparent !important;
  border: none !important;
  color: #a0a0b0 !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  margin: 0 !important;
  width: 16px !important;
  height: 16px !important;
  z-index: 5 !important;
  transition: color 0.25s ease, transform 0.3s ease !important;
}

.combobox-arrow-btn:hover {
  color: var(--gold, #d4af37) !important;
}

.combobox-orgao-wrap.open .combobox-arrow-btn i,
.combobox-arrow-btn.open i {
  transform: rotate(180deg) !important;
}

.combobox-orgao-wrap .input-icon {
  position: absolute !important;
  left: 14px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  color: var(--text-muted) !important;
  width: 16px !important;
  height: 16px !important;
  pointer-events: none !important;
  z-index: 5 !important;
  transition: color 0.25s ease !important;
}

.combobox-orgao-wrap:focus-within .input-icon {
  color: var(--gold, #d4af37) !important;
}

/* Dropdown flutuante */
.combobox-orgao-dropdown {
  position: absolute !important;
  top: calc(100% + 4px) !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  max-height: 330px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  background: #0a0a0f !important;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12)) !important;
  border-radius: 8px !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65) !important;
  z-index: 1050 !important;
  padding: 0 !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 175, 55, 0.4) rgba(0, 0, 0, 0.2);
}

.combobox-orgao-dropdown::-webkit-scrollbar {
  width: 6px;
}
.combobox-orgao-dropdown::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
.combobox-orgao-dropdown::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.4);
  border-radius: 6px;
}
.combobox-orgao-dropdown::-webkit-scrollbar-thumb:hover {
  background: rgba(212, 175, 55, 0.7);
}

.combobox-group-header {
  position: relative !important;
  background: #12121c !important;
  color: var(--gold, #d4af37) !important;
  font-size: 10.5px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.6px !important;
  padding: 6px 12px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.04) !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  margin: 0 !important;
  user-select: none !important;
}

.combobox-item {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 7px 12px !important;
  min-height: 34px !important;
  box-sizing: border-box !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04) !important;
  cursor: pointer !important;
  transition: background 0.15s ease, color 0.15s ease !important;
  gap: 8px !important;
  background: transparent;
  color: var(--text-primary, #f1f5f9) !important;
}

.combobox-item:hover,
.combobox-item.is-focused {
  background: var(--gold, #d4af37) !important;
  color: #1a1a24 !important;
}

.combobox-item-main {
  flex: 1 !important;
  min-width: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 1px !important;
}

.combobox-item-nome {
  font-size: 12.5px !important;
  font-weight: 500 !important;
  color: var(--text-primary, #f1f5f9) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  line-height: 1.25 !important;
  transition: color 0.15s ease !important;
}

.combobox-item-nome strong {
  color: #ffffff !important;
  font-weight: 700 !important;
  transition: color 0.15s ease !important;
}

.combobox-item-sub {
  font-size: 10.5px !important;
  color: var(--text-muted, #94a3b8) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  line-height: 1.15 !important;
  transition: color 0.15s ease !important;
}

.combobox-item:hover .combobox-item-nome,
.combobox-item.is-focused .combobox-item-nome {
  color: #1a1a24 !important;
}

.combobox-item:hover .combobox-item-nome strong,
.combobox-item.is-focused .combobox-item-nome strong {
  color: #0c0a09 !important;
}

.combobox-item:hover .combobox-item-sub,
.combobox-item.is-focused .combobox-item-sub {
  color: #383844 !important;
}

.combobox-badge {
  font-size: 9px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.4px !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  flex-shrink: 0 !important;
  line-height: 1.2 !important;
  transition: all 0.15s ease !important;
}

.combobox-badge.federal {
  background: rgba(14, 165, 233, 0.15) !important;
  color: #38bdf8 !important;
  border: 1px solid rgba(14, 165, 233, 0.35) !important;
}

.combobox-badge.estadual {
  background: rgba(168, 85, 247, 0.15) !important;
  color: #c084fc !important;
  border: 1px solid rgba(168, 85, 247, 0.35) !important;
}

.combobox-badge.municipal {
  background: rgba(34, 197, 94, 0.15) !important;
  color: #4ade80 !important;
  border: 1px solid rgba(34, 197, 94, 0.35) !important;
}

.combobox-badge.outro {
  background: rgba(234, 179, 8, 0.15) !important;
  color: #facc15 !important;
  border: 1px solid rgba(234, 179, 8, 0.35) !important;
}

.combobox-item:hover .combobox-badge,
.combobox-item.is-focused .combobox-badge {
  background: rgba(0, 0, 0, 0.2) !important;
  color: #1a1a24 !important;
  border-color: rgba(0, 0, 0, 0.35) !important;
}

.item-orgao-livre {
  position: sticky !important;
  bottom: 0 !important;
  background: #0e0e16 !important;
  border-top: 1px dashed rgba(212, 175, 55, 0.4) !important;
  z-index: 15 !important;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.6) !important;
}

.item-orgao-livre:hover {
  background: var(--gold, #d4af37) !important;
  color: #1a1a24 !important;
}

.item-orgao-livre:hover .combobox-item-nome {
  color: #1a1a24 !important;
}

.item-orgao-livre:hover .combobox-item-sub {
  color: #383844 !important;
}

.combobox-empty {
  padding: 18px 16px !important;
  text-align: center !important;
  font-size: 12.5px !important;
  color: #94a3b8 !important;
}


