    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    :root {
      --verde: #1D9E75;
      --verde-oscuro: #085041;
      --verde-medio: #0F6E56;
      --verde-claro: #E1F5EE;
      --verde-menta: #9FE1CB;
      --sidebar-w: 280px;
      --header-h: 88px;
    }

    html, body { height: 100%; font-family: system-ui, -apple-system, sans-serif; }

    body {
      display: flex;
      flex-direction: column;
      height: 100vh;
      background: #f0f4f2;
      overflow: hidden;
    }

    /* ---- Header ---- */
    header {
      background: var(--verde-oscuro);
      flex-shrink: 0;
    }

    .header-top {
      padding: 10px 20px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }

    .header-brand {
      display: flex;
      align-items: center;
      gap: 10px;
      color: white;
    }

    .header-brand i { color: var(--verde-menta); font-size: 22px; }
    .header-brand span { font-size: 16px; font-weight: 600; }

    .header-actions { display: flex; align-items: center; gap: 12px; }

    #conn-status {
      font-size: 12px;
      padding: 3px 10px;
      border-radius: 12px;
      display: flex;
      align-items: center;
      gap: 5px;
    }

    .conn-ok  { background: rgba(29,158,117,.2); color: var(--verde-menta); }
    .conn-err { background: rgba(220,80,80,.2);  color: #f99; }

    .btn-sound {
      background: transparent;
      border: 1px solid rgba(159,225,203,.35);
      color: var(--verde-menta);
      padding: 5px 12px;
      border-radius: 6px;
      font-size: 12px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 5px;
      transition: opacity .2s;
    }
    .btn-sound.muted { opacity: .45; }

    .header-stats {
      padding: 0 20px 8px;
      display: flex;
      gap: 20px;
      border-top: 1px solid var(--verde-medio);
    }

    .stat { color: var(--verde-menta); font-size: 12px; }
    .stat strong { color: white; }
    .stat.warn strong { color: #FAC775; }

    /* ---- Layout principal ---- */
    .main {
      display: flex;
      flex: 1;
      overflow: hidden;
    }

    /* ---- Sidebar ---- */
    .sidebar {
      width: var(--sidebar-w);
      background: #f7faf8;
      border-right: 1px solid #d4e6dd;
      display: flex;
      flex-direction: column;
      flex-shrink: 0;
    }

    .filters {
      padding: 10px;
      border-bottom: 1px solid #d4e6dd;
      display: flex;
      gap: 6px;
    }

    .flt {
      flex: 1;
      padding: 6px 4px;
      font-size: 12px;
      cursor: pointer;
      border: 1px solid #c5ddd4;
      border-radius: 6px;
      background: transparent;
      color: #6b8f7e;
      transition: all .15s;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 5px;
    }
    .flt.active {
      background: white;
      color: #1a3d30;
      border-color: #85c4aa;
      font-weight: 500;
    }
    .flt:hover:not(.active) { background: #edf5f0; }

    .flt-badge {
      background: var(--verde);
      color: white;
      font-size: 10px;
      font-weight: 600;
      border-radius: 9px;
      min-width: 18px;
      height: 18px;
      line-height: 18px;
      padding: 0 5px;
      display: inline-block;
      text-align: center;
    }

    .search-bar {
      padding: 6px 10px;
      display: flex;
      align-items: center;
      gap: 6px;
      border-bottom: 1px solid #d4e6dd;
      background: #f7faf8;
    }
    .search-bar i { color: #6b8f7e; font-size: 14px; }
    .search-bar input {
      width: 100%;
      border: 1px solid #d4e6dd;
      border-radius: 6px;
      padding: 6px 8px;
      font-size: 12px;
      background: white;
      color: #1a3d30;
      outline: none;
      transition: border-color .15s;
    }
    .search-bar input:focus { border-color: var(--verde); }
    .search-bar input::placeholder { color: #a3c0b2; }

    .receta-list {
      overflow-y: auto;
      flex: 1;
      padding: 8px;
    }

    .receta-item {
      padding: 10px 10px;
      border-radius: 8px;
      margin-bottom: 6px;
      cursor: pointer;
      border: 1px solid #dceae2;
      background: white;
      transition: border-color .15s, background .15s;
    }
    .receta-item:hover { border-color: #85c4aa; }
    .receta-item.selected { border-color: var(--verde); background: var(--verde-claro); }
    .receta-item.nueva:not(.selected) { border-left: 3px solid #EF9F27; padding-left: 8px; }

    .item-top {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 6px;
    }
    .item-phone { font-size: 13px; font-weight: 500; color: #1a3d30; display:flex;align-items:center;gap:5px; }
    .item-hora  { font-size: 11px; color: #6b8f7e; }
    .item-badges { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }

    .badge {
      font-size: 11px;
      padding: 2px 7px;
      border-radius: 4px;
      display: flex;
      align-items: center;
      gap: 3px;
    }
    .badge-img   { background: #E6F1FB; color: #185FA5; }
    .badge-pdf   { background: #FAECE7; color: #993C1D; }
    .badge-link  { background: #EAF3DE; color: #3B6D11; }
    .badge-grupo { background: #EDE7FA; color: #5B3D8A; }
    .badge-nueva   { background: #FAEEDA; color: #BA7517; }
    .badge-vista   { background: #E6F1FB; color: #185FA5; }
    .badge-impresa { background: #EAF3DE; color: #3B6D11; }

    .new-tag { font-size: 10px; color: #BA7517; font-weight: 600; margin-left: auto; }

    .empty-msg {
      text-align: center;
      color: #6b8f7e;
      font-size: 13px;
      padding: 32px 0;
    }

    /* ---- Preview ---- */
    .preview {
      flex: 1;
      background: white;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      overflow: hidden;
    }

    .preview-placeholder {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 10px;
      color: #6b8f7e;
    }
    .preview-placeholder i { font-size: 52px; }
    .preview-placeholder p { font-size: 14px; }

    .preview-content {
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 100%;
      height: 100%;
      overflow-y: auto;
      padding: 20px;
      gap: 16px;
    }

    .preview-meta {
      display: flex;
      gap: 8px;
      align-items: center;
      width: 100%;
      max-width: 520px;
      flex-wrap: wrap;
    }
    .preview-meta .meta-phone { font-size: 13px; color: #6b8f7e; display:flex;align-items:center;gap:4px; }
    .preview-meta .meta-hora  { font-size: 12px; color: #6b8f7e; }

    /* Imagen real */
    .preview-img-wrap {
      width: 100%;
      max-width: 420px;
      border: 1px solid #dceae2;
      border-radius: 10px;
      overflow: hidden;
      background: #f7faf8;
      flex-shrink: 0;
    }
    .preview-img-wrap img {
      width: 100%;
      height: auto;
      display: block;
    }

    /* PDF embed */
    .preview-pdf-wrap {
      width: 100%;
      max-width: 520px;
      height: 80vh;
      max-height: 700px;
      border: 1px solid #dceae2;
      border-radius: 10px;
      overflow: hidden;
      flex-shrink: 0;
    }
    .preview-pdf-wrap iframe {
      width: 100%;
      height: 100%;
      border: none;
    }

    /* PDF item con checkbox */
    .pdf-item {
      width: 100%;
      max-width: 520px;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .pdf-check-row {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 8px;
    }

    .pdf-label {
      font-size: 13px;
      color: #6b8f7e;
    }

    .chk {
      display: inline-flex;
      align-items: center;
      cursor: pointer;
      width: 22px;
      height: 22px;
      position: relative;
    }

    .chk input {
      position: absolute;
      opacity: 0;
      width: 0;
      height: 0;
    }

    .chk-mark {
      width: 22px;
      height: 22px;
      border: 2px solid #c5ddd4;
      border-radius: 4px;
      background: white;
      transition: all 0.15s;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .chk:hover .chk-mark {
      border-color: var(--verde);
      background: #f0faf6;
    }

    .chk input:checked + .chk-mark {
      background: var(--verde);
      border-color: var(--verde);
    }

    .chk input:checked + .chk-mark::after {
      content: '';
      display: block;
      width: 6px;
      height: 10px;
      border: solid white;
      border-width: 0 2px 2px 0;
      transform: rotate(45deg);
      margin-top: -2px;
    }

    .chk input:disabled {
      pointer-events: none;
    }

    .chk input:disabled + .chk-mark {
      opacity: 1;
    }

    /* Link */
    .preview-link-card {
      width: 100%;
      max-width: 420px;
      background: #f7faf8;
      border: 1px solid #dceae2;
      border-radius: 10px;
      padding: 24px;
      text-align: center;
    }
    .preview-link-card i { font-size: 36px; color: var(--verde); margin-bottom: 10px; display:block; }
    .preview-link-card .link-url {
      font-size: 12px;
      color: #185FA5;
      word-break: break-all;
      margin: 10px 0 16px;
    }
    .btn-open-link {
      background: #E6F1FB;
      color: #185FA5;
      border: 1px solid #B5D4F4;
      padding: 8px 18px;
      border-radius: 6px;
      cursor: pointer;
      font-size: 13px;
      display: inline-flex;
      align-items: center;
      gap: 5px;
    }
    .btn-open-link:hover { background: #d0e8f8; }

    /* Acciones */
    .preview-actions {
      display: flex;
      justify-content: center;
      gap: 10px;
      width: 100%;
      max-width: 420px;
    }

    .btn-print {
      flex: 1;
      background: var(--verde);
      color: white;
      border: none;
      padding: 11px 16px;
      border-radius: 8px;
      cursor: pointer;
      font-size: 14px;
      font-weight: 500;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      transition: background .15s;
    }
    .btn-print:hover { background: var(--verde-medio); }

    .btn-download {
      flex: 1;
      justify-content: center;
      background: transparent;
      color: #6b8f7e;
      border: 1px solid #c5ddd4;
      padding: 11px 14px;
      border-radius: 8px;
      cursor: pointer;
      font-size: 13px;
      display: flex;
      align-items: center;
      gap: 5px;
    }
    .btn-download:hover { background: #edf5f0; }

    .done-badge {
      display: flex;
      align-items: center;
      gap: 8px;
      color: #3B6D11;
      background: #EAF3DE;
      padding: 11px 20px;
      border-radius: 8px;
      font-size: 14px;
      font-weight: 500;
    }

    /* ---- Toast ---- */
    #toast {
      position: fixed;
      bottom: 20px;
      right: 20px;
      background: var(--verde-oscuro);
      color: white;
      padding: 11px 16px;
      border-radius: 10px;
      font-size: 13px;
      display: none;
      align-items: center;
      gap: 8px;
      border: 1px solid var(--verde);
      animation: slidein .3s ease;
      z-index: 100;
      max-width: 300px;
    }

    .toast-error {
      background: #C53030 !important;
      border-color: #E53E3E !important;
    }

    /* ---- Animaciones ---- */
    @keyframes blink   { 0%,100%{opacity:1} 50%{opacity:.25} }
    @keyframes slidein { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

    /* ---- Print ---- */
    @media print {
      @page {
        margin: 0;
      }

      html, body { height: 100%; margin: 0; padding: 0; overflow: visible; }

      header, .sidebar, .preview-meta, .preview-actions, #toast,
      .preview-placeholder, .preview-link-card,
      .pdf-item, .preview-pdf-wrap,
      .preview > *:not(.preview-content) {
        display: none !important;
      }

      .main {
        display: block !important;
        overflow: visible;
        flex: none;
      }

      .preview {
        display: block !important;
        overflow: visible;
      }

      .preview-content {
        display: block;
        overflow: visible;
        padding: 0;
        gap: 0;
      }

      .preview-img-wrap {
        display: flex;
        align-items: center;
        justify-content: center;
        max-width: 100%;
        border: none;
        border-radius: 0;
        page-break-after: always;
        padding-top: 1cm;
      }
      .preview-img-wrap:last-child { page-break-after: auto; }
      .preview-img-wrap img {
        max-width: 100%;
        max-height: 100vh;
        object-fit: contain;
      }
    }