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

    body {
      font-family: Arial, sans-serif;
      background: #f0f0f0;
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 30px;
      min-height: 100vh;
    }

    /* ─── TABS ─── */
    .tab-row {
      display: flex;
      width: 100%;
      max-width: 210mm;
      border-radius: 8px 8px 0 0;
      overflow: hidden;
      margin-bottom: 0;
      box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
    }

    .tab-btn {
      flex: 1;
      padding: 13px 20px;
      border: none;
      font-size: 13px;
      font-family: Arial, sans-serif;
      cursor: pointer;
      background: #cbd5e0;
      color: #4a5568;
      font-weight: normal;
      transition: background 0.2s, color 0.2s;
      letter-spacing: 0.5px;
    }

    .tab-btn.activo {
      background: #2c5282;
      color: white;
      font-weight: bold;
    }

    /* ─── TÍTULO DEL DOCUMENTO ─── */
    .doc-title {
      text-align: center;
      font-size: 13px;
      font-weight: bold;
      color: #2c5282;
      letter-spacing: 3px;
      text-transform: uppercase;
      margin-bottom: 8mm;
      padding: 3mm 0;
      border-top: 1px solid #e0e0e0;
      border-bottom: 1px solid #e0e0e0;
    }

    .page {
      width: 100%;
      max-width: 210mm;
      min-height: 297mm;
      background: white;
      padding: 20mm 18mm 10mm 18mm;
      box-shadow: 0 4px 20px rgba(0,0,0,0.15);
      display: flex;
      flex-direction: column;
      position: relative;
    }

    /* ─── HEADER ─── */
    .header {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      margin-bottom: 14mm;
      border-bottom: none;
    }

    .logo-area {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .logo-area img {
      height: 80px;
      width: auto;
    }

    .clinica-name {
      font-size: 22px;
      font-weight: bold;
      color: #1a1a1a;
      line-height: 1.1;
    }

    .clinica-sub {
      font-size: 14px;
      color: #2c5282;
      line-height: 1.2;
    }

    .doctor-info {
      text-align: right;
      border-left: 3px solid #4caf50;
      padding-left: 12px;
    }

    .doctor-name {
      font-size: 15px;
      font-weight: bold;
      color: #1a1a1a;
      text-transform: uppercase;
    }

    .doctor-specialty {
      font-size: 12px;
      color: #333;
      margin-top: 2px;
    }

    .doctor-rut {
      font-size: 12px;
      color: #333;
      margin-top: 2px;
    }

    .doctor-address {
      font-size: 11px;
      color: #555;
      margin-top: 6px;
      line-height: 1.5;
    }

    /* ─── FECHA ─── */
    .fecha-box {
      display: inline-flex;
      align-items: center;
      border: 1px solid #aaa;
      border-radius: 3px;
      padding: 5px 14px;
      margin-bottom: 8mm;
      font-size: 13px;
      gap: 6px;
    }

    .fecha-box input[type="date"],
    .fecha-box .fecha-manual {
      border: none;
      outline: none;
      font-size: 13px;
      font-family: Arial, sans-serif;
      color: #333;
      background: transparent;
      min-width: 120px;
    }

    /* ─── CAMPOS PACIENTE ─── */
    .fields {
      margin-bottom: 8mm;
    }

    .field-row {
      display: flex;
      align-items: flex-end;
      margin-bottom: 7mm;
      gap: 6px;
    }

    .field-label {
      font-size: 13px;
      color: #333;
      white-space: nowrap;
      flex-shrink: 0;
    }

    .field-line {
      flex: 1;
      border: none;
      border-bottom: 1px solid #555;
      outline: none;
      font-size: 13px;
      font-family: Arial, sans-serif;
      color: #111;
      padding: 0 4px 2px 4px;
      background: transparent;
    }

    .field-rut {
      flex: 2;
    }

    .field-edad {
      flex: 1;
    }

    /* ─── ÁREA DE INDICACIONES / RECETA ─── */
    .receta-area {
      flex: 1;
      border: none;
      border-bottom: 1px solid #bbb;
      min-height: 110mm;
      margin-bottom: 10mm;
      padding: 4px;
    }

    .receta-area div[contenteditable] {
      width: 100%;
      min-height: 110mm;
      border: none;
      outline: none;
      font-family: Arial, sans-serif;
      font-size: 13px;
      color: #111;
      line-height: 1.8;
      background: transparent;
      white-space: pre-wrap;
      word-wrap: break-word;
    }

    .receta-area div[contenteditable]:empty::before {
      content: attr(data-placeholder);
      color: #aaa;
    }

    /* ─── EXPORTACIÓN COMPACTA RECETA / CERTIFICADO ─── */
    .page.export-mode.export-receta,
    .page.export-mode.export-certificado {
      padding-top: 14mm;
    }

    .page.export-mode.export-receta .header,
    .page.export-mode.export-certificado .header {
      margin-bottom: 5mm;
    }

    .page.export-mode.export-receta .logo-area img,
    .page.export-mode.export-certificado .logo-area img {
      height: 58px;
    }

    .page.export-mode.export-receta .doctor-name,
    .page.export-mode.export-certificado .doctor-name {
      font-size: 13px;
    }

    .page.export-mode.export-receta .doctor-specialty,
    .page.export-mode.export-receta .doctor-rut,
    .page.export-mode.export-certificado .doctor-specialty,
    .page.export-mode.export-certificado .doctor-rut {
      font-size: 11px;
    }

    .page.export-mode.export-receta .doctor-address,
    .page.export-mode.export-certificado .doctor-address {
      font-size: 10px;
      margin-top: 3px;
      line-height: 1.25;
    }

    .page.export-mode.export-receta .doc-title,
    .page.export-mode.export-certificado .doc-title {
      margin-bottom: 4mm;
      padding: 2mm 0;
    }

    .page.export-mode.export-receta .fecha-box,
    .page.export-mode.export-certificado .fecha-box,
    .page.export-mode.export-receta .fields,
    .page.export-mode.export-certificado .fields {
      margin-bottom: 4mm;
    }

    .page.export-mode.export-receta .field-row,
    .page.export-mode.export-certificado .field-row {
      margin-bottom: 3mm;
    }

    /* ─── ÁREA DE EXÁMENES ─── */
    .examen-area {
      display: none;
      flex: 1;
      margin-bottom: 10mm;
    }

    .examen-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 5px 16px;
      padding: 4px 0;
    }

    .examen-item {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 12.5px;
      color: #111;
      line-height: 1.7;
      cursor: pointer;
    }

    .examen-item input[type="checkbox"] {
      width: 14px;
      height: 14px;
      border: 1.5px solid #666;
      border-radius: 3px;
      appearance: none;
      -webkit-appearance: none;
      flex-shrink: 0;
      cursor: pointer;
      position: relative;
      background: white;
    }

    .examen-item input[type="checkbox"]:checked {
      background: #2c5282;
      border-color: #2c5282;
    }

    .examen-item input[type="checkbox"]:checked::after {
      content: '✓';
      color: white;
      font-size: 10px;
      font-weight: bold;
      position: absolute;
      top: -2px;
      left: 1px;
    }

    .examen-otros {
      margin-top: 6mm;
      border-top: 1px solid #ddd;
      padding-top: 4mm;
    }

    .examen-otros label {
      font-size: 12px;
      color: #555;
      display: block;
      margin-bottom: 4px;
    }

    .examen-otros div[contenteditable] {
      width: 100%;
      min-height: 18mm;
      border: none;
      outline: none;
      font-family: Arial, sans-serif;
      font-size: 12.5px;
      color: #111;
      line-height: 1.8;
      background: transparent;
      white-space: pre-wrap;
      word-wrap: break-word;
    }

    .examen-otros div[contenteditable]:empty::before {
      content: attr(data-placeholder);
      color: #aaa;
    }

    /* ─── FIRMA ─── */
    .firma-section {
      display: flex;
      flex-direction: column;
      align-items: center;
      margin-top: auto;
      padding-top: 3mm;
    }

    .firma-img {
      height: 160px;
      width: auto;
      max-width: 360px;
      object-fit: contain;
      margin-bottom: 0;
      filter: grayscale(1) contrast(4);
      mix-blend-mode: multiply;
    }

    /* ─── QR CODE ─── */
    #qr-wrapper {
      position: absolute;
      left: 9mm;
      bottom: 14mm;
      text-align: center;
    }

    #qr-wrapper img {
      display: block;
      width: 44px;
      height: 44px;
      image-rendering: pixelated;
    }

    #qr-wrapper p {
      font-size: 7px;
      color: #777;
      margin: 2px 0 0;
      font-family: Arial, sans-serif;
    }

    /* ─── BARRA VERDE INFERIOR ─── */
    .bottom-bar {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      height: 12px;
      background: #4caf50;
      border-radius: 0 0 2px 2px;
    }

    /* ─── BARRA PACIENTE ACTIVO ─── */
    .paciente-activo-bar {
      display: none;
      width: 100%;
      max-width: 210mm;
      background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
      border: 1.5px solid #4caf50;
      border-radius: 0;
      padding: 8px 16px;
      font-size: 13px;
      font-family: Arial, sans-serif;
      color: #2e7d32;
      align-items: center;
      gap: 10px;
      box-shadow: 0 2px 6px rgba(76,175,80,0.15);
    }

    .paciente-activo-bar.visible {
      display: flex;
    }

    .paciente-activo-bar .pa-icon {
      font-size: 16px;
      flex-shrink: 0;
    }

    .paciente-activo-bar .pa-datos {
      flex: 1;
      font-weight: bold;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .paciente-activo-bar .pa-datos span {
      font-weight: normal;
      color: #555;
      margin-left: 8px;
      font-size: 12px;
    }

    .paciente-activo-bar .pa-btn-cambiar {
      background: none;
      border: 1px solid #4caf50;
      border-radius: 4px;
      color: #2e7d32;
      font-size: 11px;
      padding: 4px 10px;
      cursor: pointer;
      font-family: Arial, sans-serif;
      white-space: nowrap;
      flex-shrink: 0;
    }

    .paciente-activo-bar .pa-btn-cambiar:hover {
      background: #4caf50;
      color: white;
    }

    /* ─── BOTONES (solo pantalla, no en impresión) ─── */
    .btn-row {
      display: flex;
      gap: 12px;
      justify-content: center;
      margin-top: 24px;
    }

    .btn {
      padding: 10px 28px;
      border: none;
      border-radius: 6px;
      font-size: 14px;
      cursor: pointer;
      font-family: Arial, sans-serif;
    }

    .btn-pdf {
      background: #2c5282;
      color: white;
    }

    .btn-img {
      background: #4caf50;
      color: white;
    }

    .btn-print {
      background: #718096;
      color: white;
    }

    .btn-clear {
      background: #e53e3e;
      color: white;
    }

    /* ─── LOGIN ─── */
    #login-screen {
      position: fixed;
      inset: 0;
      background: #f0f0f0;
      display: flex;
      justify-content: center;
      align-items: center;
      z-index: 9999;
    }

    .login-card {
      background: white;
      border-radius: 12px;
      box-shadow: 0 8px 32px rgba(0,0,0,0.15);
      padding: 48px 40px;
      width: 340px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 24px;
    }

    .login-card img {
      height: 70px;
      width: auto;
    }

    .login-card h2 {
      font-size: 15px;
      color: #1a1a1a;
      text-align: center;
      font-weight: bold;
      line-height: 1.4;
    }

    .login-card input[type="password"] {
      width: 100%;
      padding: 12px 16px;
      border: 1.5px solid #ccc;
      border-radius: 8px;
      font-size: 22px;
      text-align: center;
      letter-spacing: 8px;
      outline: none;
      font-family: Arial, sans-serif;
      color: #1a1a1a;
      transition: border-color 0.2s;
    }

    .login-card input[type="password"]:focus {
      border-color: #4caf50;
    }

    .login-card button {
      width: 100%;
      padding: 13px;
      background: #4caf50;
      color: white;
      border: none;
      border-radius: 8px;
      font-size: 15px;
      font-weight: bold;
      cursor: pointer;
      font-family: Arial, sans-serif;
      transition: background 0.2s;
    }

    .login-card button:hover {
      background: #43a047;
    }

    .login-error {
      color: #e53e3e;
      font-size: 13px;
      display: none;
    }

    .login-bar {
      width: 100%;
      height: 6px;
      background: #4caf50;
      border-radius: 0 0 12px 12px;
      position: absolute;
      bottom: 0;
      left: 0;
    }

    /* ─── CABECERA CONTINUACIÓN (solo impresión) ─── */
    #print-cont-header {
      display: none;
    }

    /* ─── IMPRESIÓN ─── */
    @media print {
      body {
        background: white;
        padding: 0;
      }

      .page {
        box-shadow: none;
        margin: 0;
        padding: 15mm 18mm 80mm 18mm;
        min-height: 297mm;
      }

      .tab-row {
        display: none;
      }

      .paciente-activo-bar {
        display: none !important;
      }

      .btn-row {
        display: none;
      }

      .firma-section {
        position: fixed;
        bottom: 14mm;
        left: 0;
        right: 0;
        display: flex;
        justify-content: center;
        margin-top: 0;
        padding-top: 0;
      }

      .bottom-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
      }

      #qr-wrapper {
        position: fixed;
        left: 9mm;
        bottom: 14mm;
      }

      .field-line {
        border-bottom-color: transparent;
      }

      /* Cabecera de continuación: aparece en TODAS las páginas impresas */
      #print-cont-header {
        display: flex;
        position: fixed;
        top: 1mm;
        left: 18mm;
        right: 18mm;
        height: 11mm;
        background: white;
        border-left: 3px solid #4caf50;
        border-bottom: 1px solid #2c5282;
        align-items: center;
        padding: 0 8px;
        gap: 14px;
        font-family: Arial, sans-serif;
      }

      #print-cont-header .pch-name {
        font-size: 11px;
        font-weight: bold;
        color: #1a1a1a;
      }

      #print-cont-header .pch-info {
        font-size: 10px;
        color: #555;
      }

      #print-cont-header .pch-titulo {
        margin-left: auto;
        font-size: 10px;
        font-weight: bold;
        color: #2c5282;
        letter-spacing: 0.5px;
      }
    }

    /* Margen superior en impresión: reserva espacio para la cabecera fija */
    @page {
      margin-top: 14mm;
    }

    /* ─── RESPONSIVO MÓVIL ─── */
    @media (max-width: 640px) {
      body {
        padding: 10px 6px;
      }

      /* LOGIN */
      .login-card {
        width: 92vw;
        padding: 28px 20px;
      }

      /* BARRA PACIENTE ACTIVO */
      .paciente-activo-bar {
        padding: 6px 10px;
        font-size: 12px;
        gap: 6px;
      }
      .paciente-activo-bar .pa-datos { font-size: 12px; }
      .paciente-activo-bar .pa-datos span { font-size: 11px; margin-left: 4px; }

      /* TABS — scroll horizontal con indicador visual */
      .tab-row {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;          /* Firefox */
        border-radius: 8px 8px 0 0;
        gap: 0;
      }
      .tab-row::-webkit-scrollbar { display: none; }

      .tab-btn {
        min-width: max-content;
        white-space: nowrap;
        font-size: 13px;
        padding: 11px 14px;
        touch-action: manipulation;
        flex-shrink: 0;
      }

      /* PÁGINA */
      .page {
        padding: 14px 12px 16px 12px;
        min-height: unset;
        border-radius: 0 0 4px 4px;
      }

      /* HEADER: logo arriba, datos doctora abajo */
      .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 10px;
      }

      .clinica-name {
        font-size: clamp(16px, 5vw, 22px);
      }

      .logo-area img {
        height: 48px;
      }

      .doctor-info {
        border-left: 3px solid #4caf50;
        padding-left: 10px;
        width: 100%;
        text-align: left;
      }

      .doctor-name   { font-size: 13px; }
      .doctor-specialty,
      .doctor-rut    { font-size: 12px; }
      .doctor-address { font-size: 11px; margin-top: 3px; }

      /* TÍTULO DOCUMENTO */
      .doc-title {
        font-size: 11px;
        letter-spacing: 1.5px;
        margin-bottom: 10px;
        padding: 6px 0;
      }

      /* FECHA — iOS Safari: 16px evita zoom automático */
      .fecha-box {
        width: 100%;
        padding: 8px 10px;
        margin-bottom: 10px;
        font-size: 16px;
      }

      .fecha-box input[type="date"],
      .fecha-box .fecha-manual {
        font-size: 16px;
      }

      /* CAMPOS PACIENTE — 16px evita zoom automático en iOS */
      .field-row {
        margin-bottom: 10px;
        gap: 4px;
        flex-wrap: wrap;
      }
      .field-label { font-size: 13px; }
      .field-line  { font-size: 16px; padding-bottom: 3px; min-width: 0; }

      /* Rut + Edad: cada par label+input en su propia línea */
      .field-row-rut-edad {
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 4px 6px;
      }
      .field-label-edad {
        margin-left: 0 !important;
      }

      /* ÁREA RECETA */
      .receta-area { min-height: unset; margin-bottom: 12px; }
      .receta-area div[contenteditable] {
        min-height: 120px;
        font-size: 16px;
      }

      /* EXÁMENES — 1 columna, checkboxes más grandes para dedo */
      .examen-grid {
        grid-template-columns: 1fr;
        gap: 4px;
      }

      .examen-item {
        font-size: 14px;
        line-height: 1.6;
        touch-action: manipulation;
        padding: 6px 4px;
        border-radius: 4px;
      }

      .examen-item:active {
        background: #edf2f7;
      }

      .examen-item input[type="checkbox"] {
        width: 24px;
        height: 24px;
        flex-shrink: 0;
      }

      .examen-item input[type="checkbox"]:checked::after {
        font-size: 13px;
        top: 0;
        left: 3px;
      }

      .examen-otros div[contenteditable] {
        font-size: 16px;
        min-height: 60px;
      }

      /* Diagnóstico inputs en áreas especiales */
      .examen-area .field-line {
        font-size: 16px;
      }

      /* QR — flujo normal en móvil, no absoluto */
      #qr-wrapper {
        position: relative;
        left: auto;
        bottom: auto;
        margin: 16px auto 8px;
      }

      /* FIRMA — más compacta */
      .firma-section {
        padding-top: 8px;
      }

      .firma-img {
        height: 110px;
        max-width: 80%;
      }

      /* BARRA VERDE — relativa al flujo en móvil */
      .bottom-bar {
        position: relative;
        left: auto;
        right: auto;
        bottom: auto;
        margin: 0 -12px;
        width: calc(100% + 24px);
        border-radius: 0 0 4px 4px;
      }

      /* BOTONES: 2 columnas, touch-friendly */
      .btn-row {
        flex-wrap: wrap;
        gap: 10px;
        margin-top: 16px;
        padding: 0 2px;
      }

      .btn {
        padding: 14px 10px;
        font-size: 15px;
        flex: 1 1 calc(50% - 5px);
        touch-action: manipulation;
        border-radius: 8px;
      }
    }

    /* ─── MODO CAPTURA: fuerza layout desktop para PDF/imagen ─── */
    .page.capture-mode {
      width: 210mm !important;
      max-width: 210mm !important;
      padding: 20mm 18mm 10mm 18mm !important;
      min-height: 297mm !important;
      border-radius: 0 !important;
    }
    .page.capture-mode .header {
      flex-direction: row !important;
      align-items: flex-start !important;
      gap: 0 !important;
      margin-bottom: 4mm !important;
    }
    .page.capture-mode .clinica-name {
      font-size: 22px !important;
    }
    .page.capture-mode .logo-area img {
      height: auto !important;
    }
    .page.capture-mode .doctor-info {
      border-left: 3px solid #4caf50 !important;
      padding-left: 12px !important;
      width: auto !important;
      text-align: left !important;
    }
    .page.capture-mode .doctor-name   { font-size: 15px !important; }
    .page.capture-mode .doctor-specialty,
    .page.capture-mode .doctor-rut    { font-size: 13px !important; }
    .page.capture-mode .doctor-address { font-size: 11px !important; }
    .page.capture-mode .doc-title {
      font-size: 13px !important;
      letter-spacing: 3px !important;
      margin-bottom: 8mm !important;
      padding: 3mm 0 !important;
    }
    .page.capture-mode .fecha-box {
      width: 50% !important;
      padding: 4px 8px !important;
      margin-bottom: 6mm !important;
      font-size: 13px !important;
    }
    .page.capture-mode .fecha-box input[type="date"],
    .page.capture-mode .fecha-box .fecha-manual {
      font-size: 13px !important;
    }
    .page.capture-mode .field-row {
      margin-bottom: 4mm !important;
      gap: 0 !important;
      flex-wrap: nowrap !important;
    }
    .page.capture-mode .field-label { font-size: 13px !important; }
    .page.capture-mode .field-line  { font-size: 13px !important; }
    .page.capture-mode .field-row-rut-edad {
      display: flex !important;
      grid-template-columns: unset !important;
    }
    .page.capture-mode .field-label-edad {
      margin-left: 16px !important;
    }
    .page.capture-mode .receta-area {
      min-height: 100px !important;
    }
    .page.capture-mode .receta-area div[contenteditable] {
      font-size: 13px !important;
    }
    .page.capture-mode .examen-grid {
      grid-template-columns: 1fr 1fr !important;
    }
    .page.capture-mode .examen-item {
      font-size: 11px !important;
      padding: 2px 4px !important;
    }
    .page.capture-mode .examen-item input[type="checkbox"] {
      width: 14px !important;
      height: 14px !important;
    }
    .page.capture-mode .examen-otros div[contenteditable] {
      font-size: 13px !important;
    }
    .page.capture-mode .examen-area .field-line {
      font-size: 13px !important;
    }
    .page.capture-mode #qr-wrapper {
      position: absolute !important;
      left: 9mm !important;
      bottom: 14mm !important;
      margin: 0 !important;
    }
    .page.capture-mode .firma-section {
      padding-top: 4px !important;
    }
    .page.capture-mode .firma-img {
      height: 160px !important;
      max-width: 360px !important;
    }
    .page.capture-mode .bottom-bar {
      position: absolute !important;
      bottom: 0 !important;
      left: 0 !important;
      right: 0 !important;
      width: 100% !important;
      margin: 0 !important;
      border-radius: 0 !important;
    }
    .page.capture-mode.export-receta,
    .page.capture-mode.export-certificado {
      padding-top: 14mm !important;
    }
    .page.capture-mode.export-receta .header,
    .page.capture-mode.export-certificado .header {
      margin-bottom: 5mm !important;
    }
    .page.capture-mode.export-receta .logo-area img,
    .page.capture-mode.export-certificado .logo-area img {
      height: 58px !important;
      width: auto !important;
    }
    .page.capture-mode.export-receta .doctor-name,
    .page.capture-mode.export-certificado .doctor-name {
      font-size: 13px !important;
    }
    .page.capture-mode.export-receta .doctor-specialty,
    .page.capture-mode.export-receta .doctor-rut,
    .page.capture-mode.export-certificado .doctor-specialty,
    .page.capture-mode.export-certificado .doctor-rut {
      font-size: 11px !important;
    }
    .page.capture-mode.export-receta .doctor-address,
    .page.capture-mode.export-certificado .doctor-address {
      font-size: 10px !important;
      margin-top: 3px !important;
      line-height: 1.25 !important;
    }
    .page.capture-mode.export-receta .doc-title,
    .page.capture-mode.export-certificado .doc-title {
      margin-bottom: 4mm !important;
      padding: 2mm 0 !important;
    }
    .page.capture-mode.export-receta .fecha-box,
    .page.capture-mode.export-certificado .fecha-box,
    .page.capture-mode.export-receta .fields,
    .page.capture-mode.export-certificado .fields {
      margin-bottom: 4mm !important;
    }
    .page.capture-mode.export-receta .field-row,
    .page.capture-mode.export-certificado .field-row {
      margin-bottom: 3mm !important;
    }
    /* Ocultar repositorio en captura PDF/imagen */
    .page.capture-mode .receta-repo { display: none !important; }
    .page.capture-mode.capture-receta #receta-mode { display: block !important; }
    .page.capture-mode .btn-repo-toggle { display: none !important; }

    /* ====== REPOSITORIO MEDICAMENTOS ====== */
    #receta-mode.repo-abierto { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
    .receta-repo { display: none; border: 2px solid #e2e8f0; border-radius: 10px; padding: 14px; max-height: 480px; overflow-y: auto; background: #fafcff; }
    #receta-mode.repo-abierto .receta-repo { display: block; }
    .receta-repo h4 { color: #2c5282; font-size: 14px; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 2px solid #edf2f7; }
    .receta-repo input[type="text"] { width: 100%; padding: 7px 10px; border: 1.5px solid #e2e8f0; border-radius: 7px; font-size: 13px; outline: none; margin-bottom: 8px; font-family: Arial, sans-serif; box-sizing: border-box; }
    .receta-repo input[type="text"]:focus { border-color: #2c5282; }
    .med-cat { font-size: 11px; font-weight: 700; color: #718096; text-transform: uppercase; letter-spacing: 1px; padding: 8px 0 3px; margin-top: 4px; }
    .med-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; margin-bottom: 4px; border: 1px solid #e2e8f0; transition: all 0.15s; background: #fff; }
    .med-item:hover { background: #ebf4ff; border-color: #2c5282; }
    .med-item .med-nombre { font-weight: 600; font-size: 13px; color: #2d3748; }
    .med-item .med-preview { color: #718096; font-size: 11px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .btn-repo-toggle { display: block; width: 100%; max-width: 210mm; margin: 0 auto 0; background: #edf2f7; border: 1.5px solid #cbd5e0; border-radius: 0; padding: 8px 14px; font-size: 12px; cursor: pointer; font-family: Arial, sans-serif; color: #4a5568; transition: all 0.15s; box-sizing: border-box; }
    .btn-repo-toggle:hover { background: #e2e8f0; border-color: #2c5282; color: #2c5282; }
    .btn-repo-toggle.activo { background: #ebf4ff; border-color: #2c5282; color: #2c5282; font-weight: 600; }
    @media (max-width: 900px) { #receta-mode.repo-abierto { grid-template-columns: 1fr; } .receta-repo { max-height: 260px; } }
    @media print { #receta-mode { display: block !important; } .receta-repo { display: none !important; } .btn-repo-toggle { display: none !important; } }
  
