* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Varela Round', sans-serif;
}

body {
  background-color: #eef2f5;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  color: #000;
}

.toolbar {
  display: flex;
  flex-direction: column;
  width: 215.9mm;
  gap: 14px;
  margin-bottom: 20px;
  background: #ffffff;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.toolbar-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toolbar-group {
  display: flex;
  gap: 10px;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #333;
}

.toolbar-text-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid #e5e7eb;
  padding-top: 12px;
}

.text-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  color: #374151;
}

.text-input-wrapper textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.text-input-wrapper textarea:focus {
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.15);
}

.text-options {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #4b5563;
  font-weight: 500;
}

.offset-item {
  width: 100%;
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.offset-controls-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f3f4f6;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

.btn-step {
  padding: 5px 10px;
  font-size: 0.82rem;
  font-weight: bold;
  background: #0066cc;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-step:hover {
  background: #0052a3;
}

.control-range {
  width: 130px;
  cursor: pointer;
  accent-color: #0066cc;
}

.control-number {
  width: 55px;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  text-align: center;
  font-size: 0.88rem;
  font-weight: bold;
}

.unit-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #6b7280;
}

.control-select {
  padding: 6px 10px;
  border-radius: 5px;
  border: 1px solid #ccc;
  background-color: #fff;
  font-size: 0.88rem;
  cursor: pointer;
}

.control-checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.btn {
  padding: 9px 16px;
  font-size: 0.9rem;
  font-weight: bold;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary { background-color: #0066cc; color: #fff; }
.btn-success { background-color: #28a745; color: #fff; }
.btn-secondary { background-color: #333; color: #fff; }

/* Hoja Carta con Márgenes de Impresión Seguros */
.worksheet {
  width: 215.9mm;
  height: 279.4mm;
  background: #ffffff;
  border: 1.5px solid #d1d5db;
  border-radius: 4px;
  padding: 14.7mm 12.95mm; /* Márgenes seguros: ~1.47cm vertical y ~1.3cm horizontal */
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: center;
  align-items: center;
}

.grid-wrapper {
  position: relative;
  width: 190mm;  /* 38 columnas de 5mm */
  height: 250mm; /* 50 filas de 5mm */
}

.grid-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.text-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  padding-top: 5.5mm;
  padding-left: 10mm;
  padding-right: 10mm;
  font-family: 'Varela Round', sans-serif;
  color: #111827;
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: transparent;
  overflow: hidden;
}

.text-overlay:empty:before {
  content: attr(data-placeholder);
  color: #9ca3af;
  font-style: italic;
  font-size: 14px;
  line-height: 1.5;
  pointer-events: none;
}

.text-overlay:focus:empty:before {
  content: "";
}

@page {
  size: letter portrait;
  margin: 0;
}

@media print {
  body {
    background: none;
    padding: 0;
    margin: 0;
  }

  .no-print {
    display: none !important;
  }

  .worksheet {
    border: none;
    box-shadow: none;
    width: 215.9mm;
    height: 279.4mm;
    padding: 14.7mm 12.95mm;
    border-radius: 0;
    page-break-after: avoid;
    page-break-inside: avoid;
  }

  .text-overlay:empty:before {
    content: "" !important;
  }
}