/* Preventivi: layout originale + palette Binary Edge (#111, #666, #e5e5e5) */

*,
*::before,
*::after {
  box-sizing: border-box;
}

.preventivi-app {
  margin: 0;
  min-height: 100vh;
  font-family: "Open Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: #111;
  background: linear-gradient(165deg, #f5f5f5 0%, #e5e5e5 100%);
}

.preventivi-header {
  background: #111;
  color: #fff;
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preventivi-header h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.preventivi-header p {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: #999;
}

.preventivi-header a {
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  opacity: 0.85;
}

.preventivi-header a:hover {
  opacity: 1;
  text-decoration: underline;
}

.preventivi-header-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.preventivi-layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 992px) {
  .preventivi-layout {
    grid-template-columns: 1fr 340px;
    align-items: start;
  }
}

.preventivi-card {
  background: #fff;
  border-radius: 8px;
  padding: 22px 24px;
  margin-bottom: 20px;
  border: 1px solid #e5e5e5;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.preventivi-card h2 {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #111;
}

.preventivi-card-lead {
  margin: 0 0 18px;
  font-size: 13px;
  color: #666;
}

.preventivi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 600px) {
  .preventivi-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.preventivi-field.full {
  grid-column: 1 / -1;
}

.preventivi-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  margin-bottom: 6px;
}

.preventivi-field input,
.preventivi-field textarea,
.preventivi-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  font: inherit;
  color: #111;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.preventivi-field input:focus,
.preventivi-field textarea:focus,
.preventivi-field select:focus {
  outline: none;
  border-color: #111;
  box-shadow: 0 0 0 2px rgba(17, 17, 17, 0.08);
}

.preventivi-field textarea {
  min-height: 100px;
  resize: vertical;
}

.preventivi-input-group {
  display: flex;
  gap: 8px;
}

.preventivi-input-group input {
  flex: 1;
}

.preventivi-lines {
  overflow-x: auto;
  margin: 0 -4px 8px;
}

.preventivi-lines table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

.preventivi-lines th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
  padding: 10px 8px;
  border-bottom: 2px solid #e5e5e5;
  background: #f5f5f5;
}

.preventivi-lines td {
  padding: 8px 6px;
  vertical-align: middle;
  border-bottom: 1px solid #f0f0f0;
}

.preventivi-lines input,
.preventivi-lines select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  font: inherit;
  color: #111;
  background: #fff;
}

.preventivi-lines input[type="number"] {
  text-align: right;
}

.preventivi-lines select.line-unit {
  appearance: none;
  -webkit-appearance: none;
  padding: 8px 30px 8px 10px;
  font-weight: 600;
  cursor: pointer;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23111' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 6px;
}

.preventivi-lines select.line-unit:hover {
  border-color: #999;
}

.preventivi-lines select.line-unit:focus {
  border-color: #111;
  outline: none;
}

.preventivi-line-total {
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  color: #111;
}

.preventivi-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.preventivi-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: none;
  border-radius: 4px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.preventivi-btn-primary {
  background: #111;
  color: #fff;
}

.preventivi-btn-primary:hover {
  background: #333;
}

.preventivi-btn-secondary {
  background: #fff;
  color: #111;
  border: 1px solid #e5e5e5;
}

.preventivi-btn-secondary:hover {
  background: #f5f5f5;
  border-color: #111;
}

.preventivi-btn-danger {
  background: #fff;
  color: #666;
  border: 1px solid #e5e5e5;
  padding: 6px 12px;
  font-size: 18px;
  line-height: 1;
}

.preventivi-btn-danger:hover {
  color: #111;
  border-color: #111;
}

.preventivi-totals {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 2px solid #e5e5e5;
  max-width: 320px;
  margin-left: auto;
}

.preventivi-totals-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
  color: #666;
}

.preventivi-totals-row.grand {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 2px solid #111;
}

.preventivi-sidebar {
  position: sticky;
  top: 16px;
}

.preventivi-preview-box {
  background: #fff;
  border-radius: 8px;
  padding: 22px 20px;
  border: 1px solid #e5e5e5;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.preventivi-preview-box h2 {
  margin: 0 0 16px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #111;
}

.preventivi-preview {
  font-size: 13px;
  line-height: 1.5;
  color: #666;
}

.preventivi-preview h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 700;
  color: #111;
}

.preventivi-preview-meta {
  margin-bottom: 14px;
  line-height: 1.45;
}

.preventivi-preview table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
  margin: 12px 0;
}

.preventivi-preview th,
.preventivi-preview td {
  border: 1px solid #e5e5e5;
  padding: 6px 8px;
}

.preventivi-preview th {
  background: #f5f5f5;
  color: #666;
}

.preventivi-preview .text-right {
  text-align: right;
}

.preventivi-preview .preventivi-totals {
  max-width: 100%;
  margin-left: 0;
}

.preventivi-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.preventivi-actions .preventivi-btn {
  width: 100%;
}

.preventivi-hint {
  font-size: 12px;
  color: #999;
  margin-top: 14px;
  line-height: 1.45;
}

.preventivi-preview-notes {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #e5e5e5;
  font-size: 12px;
  color: #666;
  white-space: pre-wrap;
}

.preventivi-preview-notes strong {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #111;
}

.preventivi-empty-msg {
  color: #999;
  font-style: italic;
}

@media (max-width: 991px) {
  .preventivi-sidebar {
    position: static;
  }
}

/* Modal piani prima del download PDF */
.preventivi-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.preventivi-modal[hidden] {
  display: none;
}

.preventivi-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 17, 17, 0.55);
}

.preventivi-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e5e5e5;
  padding: 24px 22px 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.preventivi-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  color: #666;
  cursor: pointer;
  padding: 0 4px;
}

.preventivi-modal-close:hover {
  color: #111;
}

.preventivi-modal-title {
  margin: 0 32px 10px 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #111;
  line-height: 1.3;
}

.preventivi-modal-lead {
  margin: 0 0 18px;
  font-size: 14px;
  color: #666;
  line-height: 1.5;
}

.preventivi-plans {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.preventivi-plan {
  display: block;
  padding: 12px 14px;
  border: 2px solid #e5e5e5;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  position: relative;
}

.preventivi-plan:hover {
  border-color: #999;
  background: #fafafa;
}

.preventivi-plan.is-selected {
  border-color: #111;
  background: #f5f5f5;
}

.preventivi-plan input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.preventivi-plan-badge {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #111;
  color: #fff;
  padding: 4px 8px;
  border-radius: 3px;
}

.preventivi-plan-price {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: #111;
}

.preventivi-plan-price small {
  font-size: 11px;
  font-weight: 600;
  color: #666;
}

.preventivi-plan-name {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 700;
  color: #111;
}

.preventivi-plan-desc {
  display: block;
  font-size: 12px;
  color: #666;
  line-height: 1.4;
  margin-top: 6px;
}

.preventivi-modal-usp {
  padding: 14px;
  margin-bottom: 14px;
  background: #f5f5f5;
  border-left: 3px solid #111;
  border-radius: 0 4px 4px 0;
}

.preventivi-modal-usp strong {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #111;
  margin-bottom: 6px;
}

.preventivi-modal-usp p {
  margin: 0;
  font-size: 13px;
  color: #666;
  line-height: 1.45;
}

.preventivi-modal-paid-hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: #666;
  line-height: 1.45;
}

.preventivi-modal-paid-hint a {
  color: #111;
  font-weight: 600;
}

.preventivi-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preventivi-modal-actions .preventivi-btn {
  width: 100%;
  text-align: center;
  text-decoration: none;
}

body.preventivi-modal-open {
  overflow: hidden;
}