* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  padding: 24px;
  background: #f3f4f6;
  color: #111827;
}

h1 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 28px;
}

h2 {
  margin-top: 24px;
  margin-bottom: 12px;
  font-size: 20px;
}

/* BELKA KONTAKTOWA */
.contact-bar {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #374151;
  margin-bottom: 14px;
  font-size: 13px;
}

.contact-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.contact-label {
  color: #6b7280;
  white-space: nowrap;
}

.contact-link {
  color: #111827;
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

.contact-link:hover {
  text-decoration: underline;
}

.top-note {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.45;
  margin-bottom: 16px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  background: #ffffff;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}

label {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
  color: #374151;
}

/* Używamy text + inputmode, żeby zawsze trzymać kropkę jako separator wyświetlany */
input[type="text"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 14px;
  background: #f9fafb;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 1px #2563eb33;
  background: #ffffff;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: #eff6ff;
  color: #1d4ed8;
  margin-left: 6px;
}

.line-items-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 999px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  background: #2563eb;
  color: #ffffff;
  transition: background 0.15s ease, transform 0.03s ease, box-shadow 0.03s ease;
  box-shadow: 0 5px 12px rgba(37, 99, 235, 0.35);
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.btn.secondary {
  background: #6b7280;
  box-shadow: 0 5px 12px rgba(55, 65, 81, 0.3);
}

.btn.secondary:active {
  box-shadow: 0 2px 8px rgba(55, 65, 81, 0.3);
}

.btn.ghost {
  background: transparent;
  color: #374151;
  box-shadow: none;
  border: 1px solid #d1d5db;
}

.btn.ghost:active {
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

.line-item {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  margin-bottom: 10px;
}

.line-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  color: #4b5563;
}

.line-item-title {
  font-size: 16px;
  font-weight: 600;
}

.remove-line {
  background: transparent;
  border: none;
  color: #ef4444;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

/* Parametry ogólne – układ 2x2 + podglądy */
.general-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 24px;
  align-items: flex-start;
}

.general-settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.general-preview-card {
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
}

.general-preview-caption {
  margin-top: 6px;
  font-size: 11px;
  color: #4b5563;
  line-height: 1.35;
}

/* Podgląd szkicu parapetu + detale */
.sill-preview-wrapper {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
}

.sill-visualization {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.sill-main-drawing {
  flex: 2;
  min-width: 0;
}

.sill-wood-info {
  font-size: 11px;
  color: #4b5563;
  text-align: center;
  margin-bottom: 6px;
}

.sill-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sill-detail-card {
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  padding: 6px 6px 4px;
  background: #f9fafb;
}

.sill-detail-title {
  font-size: 11px;
  color: #4b5563;
  margin-bottom: 4px;
  text-align: center;
}

.sill-detail-value {
  font-size: 11px;
  color: #4b5563;
  text-align: center;
  margin-top: 4px;
}

.sill-preview-svg,
.edge-profile-svg,
.corner-detail-svg {
  width: 100%;
  height: auto;
  display: block;
}

.sill-preview-svg { max-height: 260px; }
.edge-profile-svg { max-height: 70px; }
.corner-detail-svg { max-height: 80px; }

.sill-preview-hint {
  font-size: 11px;
  color: #6b7280;
  text-align: center;
  padding: 6px 4px 0;
}

/* Inputy pozycji – 3 kolumny na desktopie */
.line-item-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 16px;
  margin-bottom: 8px;
}

.line-item-inputs-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Koszty pozycji (desktop: zwarte po prawej) */
.item-cost-summary {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #e5e7eb;
  font-size: 12px;
  color: #374151;
  display: flex;
  justify-content: flex-end;
}

.item-cost-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 14px;
  align-items: center;
  width: max-content;
  max-width: 100%;
}

.item-cost-label {
  font-weight: 600;
  color: #374151;
  text-align: right;
  white-space: nowrap;
}

.item-cost-value {
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.item-cost-total-row .item-cost-label,
.item-cost-total-row .item-cost-value {
  font-weight: 700;
  color: #111827;
  padding-top: 6px;
}

/* PODSUMOWANIE */
.summary {
  margin-top: 24px;
  padding: 20px 18px;
  border-radius: 16px;
  background: #e5e7eb;
  color: #111827;
  border: 1px solid #d1d5db;
  box-shadow: 0 6px 18px rgba(148, 163, 184, 0.35);
}

.summary h2 {
  margin-top: 0;
  margin-bottom: 6px;
  color: #0f172a;
}

.summary-note {
  font-size: 12px;
  color: #6b7280;
  margin-top: 6px;
  line-height: 1.45;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  font-size: 12px;
  background: #ffffff;
  color: #111827;
}

.summary-block {
  margin-top: 14px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}

.summary-block-header {
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  font-size: 12px;
  color: #6b7280;
  font-weight: 600;
}

.summary-table-wrap {
  width: 100%;
  overflow: hidden;
}

table.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: #ffffff;
}

table.summary-table th,
table.summary-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
  color: #111827;
  vertical-align: middle;
}

table.summary-table th {
  font-size: 11px;
  color: #6b7280;
  font-weight: 700;
  background: #fafafa;
}

table.summary-table td.value,
table.summary-table th.value {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

table.summary-table tfoot td {
  border-bottom: none;
  background: #fcfcfc;
  font-weight: 800;
}

table.summary-table tfoot td.label {
  text-align: right;
  color: #111827;
}

.summary-mobile-list {
  display: none;
  padding: 10px 12px;
  background: #ffffff;
}

.summary-mobile-item {
  padding: 10px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f9fafb;
}

.summary-mobile-item + .summary-mobile-item {
  margin-top: 10px;
}

.summary-mobile-title {
  font-weight: 800;
  color: #111827;
  margin-bottom: 6px;
  font-size: 13px;
}

.summary-mobile-lines {
  font-size: 12px;
  color: #374151;
  line-height: 1.55;
}

.summary-mobile-lines .row {
  margin-top: 2px;
}

.summary-footer {
  margin-top: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
}

.summary-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 260px;
  flex: 1;
}

.summary-final {
  min-width: 220px;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  padding: 12px 12px;
  text-align: right;
}

.summary-final-label {
  font-size: 14px;
  font-weight: 800;
  color: #111827;
  margin-bottom: 6px;
}

.summary-final-price {
  font-size: 28px;
  font-weight: 900;
  color: #111827;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.print-hint {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.45;
}

.summary-print {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

/* MOBILE / TABLETY */
@media (max-width: 768px) {
  body { padding: 12px; }

  h1 { font-size: 22px; margin-bottom: 8px; }
  h2 { font-size: 18px; }

  .container {
    padding: 16px 14px;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  }

  .contact-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .general-settings-grid { grid-template-columns: 1fr; }
  .line-item-inputs { grid-template-columns: 1fr; }

  .sill-visualization { flex-direction: column; }
  .sill-details { flex-direction: row; }
  .sill-detail-card { flex: 1; }

  input[type="text"], select, textarea { font-size: 16px; }

  /* Koszty pozycji na mobile: zostawiamy „rozstrzelone” (czytelniej) */
  .item-cost-summary {
    display: block;
    justify-content: initial;
  }

  .item-cost-grid {
    width: 100%;
    grid-template-columns: 1fr auto;
  }

  .item-cost-label {
    text-align: left;
    white-space: normal;
  }

  /* Podsumowanie: tabela znika, pojawia się lista */
  table.summary-table { display: none; }
  .summary-mobile-list { display: block; }

  .summary-footer {
    flex-direction: column;
  }

  .summary-final {
    width: 100%;
    text-align: left;
  }

  .summary-final-price {
    font-size: 26px;
  }

  .summary-print {
    align-items: stretch;
  }
  .summary-print .btn {
    width: 100%;
  }
}

/* Drukowanie – tylko zawartość kontenera, biały background */
@media print {
  body {
    padding: 0;
    background: #ffffff;
  }
  .container {
    max-width: 100%;
    box-shadow: none;
    border-radius: 0;
  }
  .btn,
  .remove-line {
    display: none !important;
  }
  .summary {
    box-shadow: none;
  }
}
