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

/* ─── Base ───────────────────────────────────────────────────── */
html, body {
  font-family: Poppins, system-ui, sans-serif;
  background: transparent;
  overflow: hidden;
  height: auto;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ─── Inputs: hide spinners ──────────────────────────────────── */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}
input[type="number"] {
  -moz-appearance: textfield;
}
input:focus, textarea:focus, select:focus {
  outline: none;
}

/* ─── Layout ─────────────────────────────────────────────────── */
.cot-app {
  width: 100%;
  background: transparent;
}

.cot-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px 48px;
  gap: 14px;
}

/* ─── Tool header ────────────────────────────────────────────── */
.cot-tool-header {
  width: 100%;
  max-width: 820px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── Document card ──────────────────────────────────────────── */
.cot-doc {
  width: 100%;
  max-width: 820px;
  background:
    radial-gradient(400px 300px at 10% 8%, rgba(167, 139, 250, .15), transparent 55%),
    radial-gradient(350px 300px at 88% 90%, rgba(167, 139, 250, .08), transparent 55%),
    rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .10);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 24px 18px;
}

/* ─── Inline input ───────────────────────────────────────────── */
.di {
  background: rgba(255, 255, 255, .04);
  border: none;
  border-bottom: 1.5px solid rgba(255, 255, 255, .12);
  color: #fff;
  font-family: Poppins, sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 8px;
  width: 100%;
  border-radius: 6px 6px 0 0;
  transition: border-color .15s, background .15s;
}
.di:focus {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, .08);
}
.di::placeholder {
  color: rgba(255, 255, 255, .28);
  font-weight: 500;
}
.di-lg {
  font-size: 16px;
  font-weight: 800;
  padding: 8px 8px;
}
.di-sm {
  font-size: 12px;
  padding: 6px 8px;
}
textarea.di {
  resize: vertical;
  min-height: 48px;
  border-radius: 6px;
  border: 1.5px solid rgba(255, 255, 255, .12);
}
textarea.di:focus {
  border-color: #8b5cf6;
}

/* ─── Section label ──────────────────────────────────────────── */
.sl {
  color: rgba(255, 255, 255, .50);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 3px;
  white-space: nowrap;
}

/* ─── Logo area ──────────────────────────────────────────────── */
.logo-area {
  margin-bottom: 8px;
}
.logo-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1.5px dashed rgba(139, 92, 246, .25);
  border-radius: 10px;
  padding: 10px 16px;
  min-width: 120px;
  min-height: 50px;
  transition: border-color .15s, background .15s;
}
.logo-upload:hover {
  border-color: rgba(139, 92, 246, .45);
  background: rgba(139, 92, 246, .04);
}
.logo-upload.has-logo {
  border: none;
  padding: 0;
  min-width: auto;
  min-height: auto;
}
.logo-placeholder {
  color: rgba(255, 255, 255, .35);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  line-height: 1.5;
}
.logo-change {
  color: rgba(139, 92, 246, .6);
  font-size: 10px;
  font-weight: 600;
  padding: 4px 10px;
  border: 1px solid rgba(139, 92, 246, .2);
  border-radius: 6px;
  transition: all .15s;
}
.logo-change:hover {
  color: #a78bfa;
  border-color: rgba(139, 92, 246, .4);
}
.logo-preview {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 6px;
}
.logo-preview img {
  border-radius: 6px;
  object-fit: contain;
  max-width: 160px;
  max-height: 60px;
}
.logo-rm {
  background: rgba(248, 113, 113, .1);
  border: 1px solid rgba(248, 113, 113, .2);
  color: rgba(248, 113, 113, .6);
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  transition: all .15s;
  flex-shrink: 0;
}
.logo-rm:hover {
  background: rgba(248, 113, 113, .15);
  color: #f87171;
}
.logo-err {
  color: #f87171;
  font-size: 11px;
  margin-top: 4px;
}

/* ─── Moneda selector ────────────────────────────────────────── */
.moneda-sel {
  display: inline-flex;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 10px;
  overflow: hidden;
}
.moneda-opt {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, .35);
  font-family: Poppins, sans-serif;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px;
  cursor: pointer;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.moneda-opt.on {
  background: rgba(139, 92, 246, .15);
  color: #c4b5fd;
  border-bottom: 2px solid #8b5cf6;
}

/* ─── Doc header ─────────────────────────────────────────────── */
.doc-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1.5px solid rgba(255, 255, 255, .10);
}
.doc-header-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.doc-header-left .di-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.doc-header-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}
.doc-header-right .meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Para + Enviar ──────────────────────────────────────────── */
.doc-para {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1.5px solid rgba(255, 255, 255, .10);
}
.doc-para-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.doc-para-col .di-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* ─── Comentarios ────────────────────────────────────────────── */
.doc-comments {
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1.5px solid rgba(255, 255, 255, .10);
}

/* ─── Items table ────────────────────────────────────────────── */
.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
}
.items-table th {
  background: rgba(139, 92, 246, .08);
  color: rgba(255, 255, 255, .55);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1.5px solid rgba(139, 92, 246, .15);
}
.items-table th:nth-child(4),
.items-table th:nth-child(5) {
  text-align: right;
}
.items-table td {
  padding: 4px;
  vertical-align: top;
  border-bottom: 1px solid rgba(255, 255, 255, .05);
}
.items-table .item-input {
  width: 100%;
  background: rgba(255, 255, 255, .03);
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, .10);
  color: #fff;
  font-family: Poppins, sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 8px;
  border-radius: 4px 4px 0 0;
}
.items-table .item-input:focus {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, .06);
  outline: none;
}
.items-table .item-input::placeholder {
  color: rgba(255, 255, 255, .25);
}
.items-table .item-detail {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, .55);
  padding: 5px 8px;
  margin-top: 2px;
  border-bottom-color: rgba(255, 255, 255, .06);
}
.items-table .item-detail::placeholder {
  color: rgba(255, 255, 255, .18);
  font-style: italic;
}
.items-table .item-autosize {
  resize: none;
  overflow: hidden;
  min-height: 36px;
  line-height: 1.4;
  display: block;
  width: 100%;
}
.items-table .item-total {
  text-align: right;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding-right: 8px;
  white-space: nowrap;
  vertical-align: middle;
}

/* ─── Remove row ─────────────────────────────────────────────── */
.rm-row {
  background: transparent;
  border: none;
  color: rgba(248, 113, 113, .4);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.rm-row:hover {
  color: #f87171;
}

/* ─── Totals ─────────────────────────────────────────────────── */
.cot-totals {
  margin-left: auto;
  max-width: 300px;
  margin-top: 14px;
}
.cot-totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  gap: 20px;
}
.cot-totals-label {
  color: rgba(255, 255, 255, .55);
  font-size: 12px;
  font-weight: 700;
}
.cot-totals-val {
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  text-align: right;
}
.cot-totals-row.total {
  border-top: 2px solid rgba(139, 92, 246, .30);
  margin-top: 6px;
  padding-top: 10px;
}
.cot-totals-row.total .cot-totals-label {
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}
.cot-totals-row.total .cot-totals-val {
  color: #c4b5fd;
  font-size: 20px;
  font-weight: 900;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.cot-btn {
  border: none;
  cursor: pointer;
  font-family: Poppins, sans-serif;
  font-weight: 700;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 11px;
  transition: all .18s;
  -webkit-tap-highlight-color: transparent;
}
.cot-btn-outline {
  background: rgba(139, 92, 246, .08);
  border: 1px solid rgba(139, 92, 246, .25);
  color: #c4b5fd;
}
.cot-btn-outline:hover {
  background: rgba(139, 92, 246, .14);
}
.cot-btn-primary {
  background: #8b5cf6;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  padding: 14px 28px;
  border-radius: 14px;
  width: 100%;
}
.cot-btn-primary:hover {
  background: #7c3aed;
}

/* ─── Imp. adicional inline ──────────────────────────────────── */
.imp-ad-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}
.imp-ad-row .sl {
  margin-bottom: 0;
}
.imp-ad-row .di {
  width: 65px;
  text-align: right;
}

/* ─── Utility ────────────────────────────────────────────────── */
.hide { display: none !important; }

/* ─── Footer card ────────────────────────────────────────────── */
.cot-footer {
  width: 100%;
  max-width: 820px;
}

/* ─── CTA block ──────────────────────────────────────────────── */
.cta {
  margin-top: 4px;
  position: relative;
}
.cta::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 16px;
  padding: 1px;
  background: linear-gradient(135deg,
    rgba(139, 92, 246, .5),
    rgba(167, 139, 250, .12),
    rgba(255, 255, 255, .08)
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.cta-in {
  background: rgba(255, 255, 255, .04);
  border-radius: 16px;
  padding: 16px;
  position: relative;
}

.cot-note strong { color: rgba(255, 255, 255, .6); }
.cot-note em     { font-style: normal; color: rgba(255, 255, 255, .45); }

/* ─── Mobile: evitar auto-zoom iOS en inputs ────────────────── */
@media (max-width: 519px) {
  .di, textarea.di, .di-sm, .item-input, select {
    font-size: 16px !important;
  }
}

/* ─── Preview modal ──────────────────────────────────────────── */
.cot-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 16px;
}
.cot-preview-modal {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  min-height: calc(100vh - 32px);
}
.cot-preview-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 10px;
  background: rgba(20, 22, 30, .92);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  padding: 10px;
  backdrop-filter: blur(10px);
}
.cot-preview-toolbar .cot-btn { flex: 1; padding: 10px 14px; font-size: 13px; }
.cot-preview-body {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  flex: 1;
  min-height: 70vh;
  display: flex;
}
.cot-preview-frame {
  width: 100%;
  height: 100%;
  min-height: 70vh;
  border: none;
  display: block;
  background: #fff;
}

/* ─── Tablet+ ────────────────────────────────────────────────── */
@media (min-width: 520px) {
  .cot-wrap {
    padding: 20px 16px 72px;
  }
  .cot-doc {
    border-radius: 24px;
    padding: 28px 26px;
  }
  .doc-header {
    grid-template-columns: 1.2fr 1fr;
  }
  .doc-para {
    grid-template-columns: 1.2fr 1fr;
  }
}

@media (min-width: 768px) {
  .cot-wrap {
    padding: 24px 20px 100px;
  }
  .cot-doc {
    border-radius: 28px;
    padding: 32px 30px;
  }
  .cta-in {
    padding: 18px;
  }
}
