/* Quote builder shell — calm Apple settings chrome */

:root {
  --panel-bg: #f5f5f7;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --faint: #86868b;
  --line: rgba(60, 60, 67, 0.12);
  --line-strong: rgba(60, 60, 67, 0.18);
  --blue: #0071e3;
  --blue-soft: rgba(0, 113, 227, 0.12);
  --fill: rgba(120, 120, 128, 0.08);
}

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

body.builder {
  margin: 0;
  min-height: 100vh;
  background: #e5e5ea;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.builder-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
  align-items: stretch;
}

.builder-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border-right: 1px solid var(--line-strong);
  z-index: 40;
  overflow: hidden;
}

.panel-top {
  flex: 0 0 auto;
  padding: 16px 14px 6px;
}

.panel-logo {
  display: block;
  height: 33px;
  width: auto;
  margin: 0 0 8px;
}

.builder-panel h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
  line-height: 1.15;
}

.builder-panel .lede {
  margin: 4px 0 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
}

#builder-form {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 6px 12px 12px;
  scrollbar-width: thin;
}

.group {
  margin-bottom: 12px;
}

.group-title {
  margin: 0 0 5px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--faint);
}

.group-card {
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.row {
  display: grid;
  grid-template-columns: 100px 1fr;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
}

.row-control {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.row-control select,
.row-control input,
.row-control .suffix-input {
  flex: 1 1 auto;
  min-width: 0;
}

.export-hint {
  margin: 0 0 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

#btn-print:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.row.last,
.row:last-child {
  border-bottom: 0;
}

.row.stack {
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 8px 10px;
  align-items: stretch;
}

.row label {
  font-size: 12px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.1px;
}

.row input,
.row select,
.row textarea {
  width: 100%;
  margin: 0;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 12px;
  line-height: 1.25;
  color: var(--blue);
  text-align: right;
  -webkit-appearance: none;
  appearance: none;
}

.row.stack input,
.row.stack textarea {
  text-align: left;
  color: var(--blue);
  background: var(--fill);
  border-radius: 7px;
  padding: 6px 8px;
}

.row select {
  padding: 6px 0;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2386868b' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 2px center;
  padding-right: 16px;
}

.row input[type="date"] {
  min-width: 0;
  color-scheme: light;
}

.row input:focus,
.row select:focus,
.row textarea:focus {
  color: var(--blue);
}

.row input[readonly] {
  color: var(--muted);
}

.row textarea {
  min-height: 42px;
  resize: vertical;
  text-align: left;
}

.suffix-input {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  color: var(--blue);
  font-size: 12px;
}

.suffix-input span {
  color: var(--faint);
}

.suffix-input input {
  width: 88px;
  text-align: right;
}

.hint {
  margin: 5px 4px 0;
  font-size: 10px;
  line-height: 1.3;
  color: var(--muted);
}

.price-ref {
  margin: 0;
  padding: 6px 10px 7px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.015);
  font-size: 10px;
  line-height: 1.35;
  color: var(--muted);
}

.price-ref-line {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.price-ref-line + .price-ref-line {
  margin-top: 2px;
}

.price-ref strong {
  color: var(--ink);
  font-weight: 600;
}

/* Hide number-spinner arrows so Units looks like a plain field. */
.row input[type="number"] {
  -moz-appearance: textfield;
}

.row input[type="number"]::-webkit-outer-spin-button,
.row input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.panel-foot {
  flex: 0 0 auto;
  padding: 8px 12px 12px;
  border-top: 1px solid var(--line-strong);
  background: rgba(245, 245, 247, 0.92);
  backdrop-filter: blur(16px);
}

.totals-chip {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.2px;
  text-align: center;
}

.builder-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.builder-actions button {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.1px;
  padding: 8px 12px;
  border-radius: 980px;
  border: none;
  cursor: pointer;
  background: var(--blue);
  color: #fff;
}

.builder-actions button:active {
  opacity: 0.88;
}

.builder-preview {
  padding: 24px 20px 56px;
  overflow-x: auto;
}

.app-version {
  position: fixed;
  right: 10px;
  bottom: 8px;
  z-index: 50;
  margin: 0;
  font-size: 9px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: rgba(60, 60, 67, 0.35);
  pointer-events: none;
  user-select: none;
}

.desktop-only-gate {
  display: none;
  box-sizing: border-box;
  min-height: 100vh;
  padding: 48px 28px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  background: var(--panel-bg);
  color: var(--ink);
}

.desktop-only-gate h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.15;
}

.desktop-only-gate p {
  margin: 10px 0 0;
  max-width: 28em;
  font-size: 15px;
  line-height: 1.45;
  color: var(--muted);
}

/* Side-by-side panel + A4 preview need a real desktop viewport. */
@media (max-width: 1099px), (max-height: 639px) {
  .builder-shell {
    display: none !important;
  }

  .desktop-only-gate {
    display: flex;
  }

  .app-version {
    display: none;
  }
}

@media print {
  body.builder {
    background: #fff !important;
  }

  .builder-panel {
    display: none !important;
  }

  .builder-preview {
    padding: 0 !important;
    margin: 0 !important;
  }

  .builder-shell {
    display: block;
  }
}
