/* Quote builder app */

body.app-page {
  background: var(--bg);
}

.app-container {
  width: min(1320px, 94vw);
}

.app-hero-bar {
  background: var(--surface);
  color: var(--text);
  padding: 2rem 0 1.75rem;
  border-bottom: 1px solid var(--border);
}

.app-hero-bar .container {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
}

.app-hero-bar h1 {
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 3vw, 2.1rem);
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}

.app-hero-bar p {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 36rem;
  line-height: 1.55;
}

.app-hero-bar .section-eyebrow {
  color: var(--accent) !important;
}

.app-hero-bar__stats {
  display: flex;
  gap: 1.5rem;
}

.hero-stat {
  text-align: center;
  padding: 0.75rem 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 100px;
}

.hero-stat strong {
  display: block;
  font-size: 1.35rem;
  color: var(--accent);
  font-family: var(--font-display);
}

.hero-stat span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.app-shell {
  display: grid;
  grid-template-columns: 1fr min(440px, 38vw);
  gap: 1.75rem;
  align-items: start;
  padding: 2rem 0 4rem;
}

.app-form-col {
  min-width: 0;
}

.form-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  position: sticky;
  top: calc(var(--header-h) + 0.25rem);
  z-index: 20;
  background: var(--bg);
  padding: 0.5rem 0 0.75rem;
}

.form-nav button {
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 100px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.form-nav button:hover,
.form-nav button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.form-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem 1.65rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.form-section--estimate {
  border-color: #d4c4a8;
  box-shadow: 0 4px 24px rgba(180, 83, 9, 0.08);
}

.form-section h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.15rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.section-head-row h2 {
  margin-bottom: 0.35rem;
  border-bottom: none;
  padding-bottom: 0;
}

.section-lead {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.55;
  margin-bottom: 1rem;
}

.label-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.form-section h2 .sec-icon {
  width: 28px;
  height: 28px;
  background: #fef7ed;
  color: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* Templates */
.template-bar {
  margin-bottom: 1.25rem;
}

.template-bar__label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.template-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.template-chip {
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px dashed #c4b5a0;
  background: #faf8f4;
  border-radius: 100px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s;
}

.template-chip:hover {
  border-color: var(--accent);
  background: #fef7ed;
  color: var(--accent);
}

/* Option tabs */
.option-tabs-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.option-tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.option-tab {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  border: 2px solid var(--border);
  background: #faf9f7;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s;
}

.option-tab.active {
  border-color: var(--accent);
  background: #fff;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(180, 83, 9, 0.12);
}

.tab-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 700;
}

.tab-badge--good { background: #fef3c7; color: #92400e; }
.tab-badge--better { background: #d1fae5; color: #065f46; }
.tab-badge--best { background: #ffedd5; color: #9a3412; }

.option-tab-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-text {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  padding: 0.25rem 0;
}

.btn-text:hover { text-decoration: underline; }

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
}

/* Line items */
.option-meta {
  margin-bottom: 0;
}

.line-items-head {
  display: grid;
  grid-template-columns: 1fr 70px 100px 90px 80px 36px;
  gap: 0.5rem;
  margin-top: 1.75rem;
  padding: 1rem 0.25rem 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.line-items {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.line-item-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.line-item-foot {
  padding: 0 0.5rem 0.15rem 0.65rem;
}

.line-breakdown-toggle {
  font-size: 0.78rem;
}

.line-subs-panel {
  margin: 0 0.5rem 0.35rem 0.85rem;
  padding: 0.55rem 0.65rem 0.65rem 0.85rem;
  border-left: 3px solid #e8dfd0;
  background: #fdfbf8;
  border-radius: 0 8px 8px 0;
}

.line-subs-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

.line-sub-row {
  display: grid;
  grid-template-columns: 1fr 110px 28px;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.4rem;
}

.line-sub-row input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font-size: 0.84rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.line-sub-amount-wrap {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.line-sub-remove {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
}

.line-sub-remove:hover {
  background: #fee2e2;
  color: #991b1b;
}

.line-add-sub {
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.line-item-row {
  display: grid;
  grid-template-columns: 1fr 70px 100px 90px 80px 36px;
  gap: 0.5rem;
  align-items: center;
  padding: 0.65rem 0.5rem;
  background: #faf9f7;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.line-item-row:focus-within {
  border-color: #d4a574;
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.1);
  background: #fff;
}

.line-field input,
.line-field select {
  width: 100%;
  padding: 0.45rem 0.5rem;
  font-size: 0.88rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.line-field--desc input {
  padding: 0.5rem 0.65rem;
}

.line-field--rate {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.line-rate-prefix {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.line-field--total {
  font-weight: 700;
  font-size: 0.9rem;
  text-align: right;
  color: var(--text);
}

.line-remove {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #a8a29e;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}

.line-remove:hover:not(:disabled) {
  background: #fee2e2;
  color: #b91c1c;
}

.line-remove:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.estimate-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

.quick-adds {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.quick-add-btn {
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 100px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.12s;
}

.quick-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #fef7ed;
}

.option-subtotal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.25rem;
  padding: 1rem 1.15rem;
  background: linear-gradient(135deg, #1a120c, #2d1f12);
  color: #fff;
  border-radius: 10px;
  font-size: 0.95rem;
}

.option-subtotal strong {
  font-size: 1.35rem;
  font-family: var(--font-display);
  color: #fbbf24;
}

/* Present mode */
.present-mode {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  grid-auto-rows: 1fr;
  align-items: stretch;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.present-card {
  cursor: pointer;
  display: flex;
  height: 100%;
}

.present-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.present-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.1rem 1.15rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #faf9f7;
  width: 100%;
  min-height: 7.25rem;
  transition: all 0.15s;
}

.present-card--featured .present-card__body {
  background: #fffdf8;
}

.present-card input:checked + .present-card__body {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 4px 16px rgba(180, 83, 9, 0.12);
}

.present-card__body strong {
  font-size: 0.95rem;
}

.present-card__body span {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.present-card__foot {
  min-height: 1.25rem;
  margin-top: auto;
  padding-top: 0.55rem;
}

.present-card__foot--highlight {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  line-height: 1.45;
}

.customer-saved-bar {
  margin-bottom: 1.15rem;
  padding: 0.9rem 1rem;
  background: #faf9f7;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.customer-save-option {
  margin: 0.85rem 0 1.15rem;
}

.save-customer-check {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  line-height: 1.45;
}

.save-customer-check input {
  margin-top: 0.2rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.required-key {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  background: #faf9f7;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.req {
  color: #b45309;
  font-weight: 700;
}

input.field-invalid,
select.field-invalid,
textarea.field-invalid {
  border-color: #b91c1c;
  background: #fef2f2;
}

input.field-invalid:focus,
select.field-invalid:focus,
textarea.field-invalid:focus {
  outline-color: #b91c1c;
}

.address-block {
  border: none;
  margin: 1.25rem 0 0;
  padding: 0;
}

.address-block legend {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.65rem;
  padding: 0;
}

.estimate-start-note {
  font-size: 0.9rem;
  color: var(--text-muted);
  background: #faf9f7;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.estimate-start-note strong {
  color: var(--text);
}

.terms-mode-section {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.terms-mode-label {
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.65rem;
}

.terms-mode-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.terms-mode-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  cursor: pointer;
}

.terms-mode-option input {
  accent-color: var(--accent);
}

.terms-default-preview {
  background: #faf9f7;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 1rem 1.1rem 1rem 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.terms-default-preview ul {
  margin: 0;
  padding-left: 1.15rem;
}

.terms-default-preview li {
  margin-bottom: 0.35rem;
  padding-left: 0.2rem;
}

.terms-custom-wrap textarea {
  width: 100%;
  margin-top: 0.35rem;
}

.present-tip {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: #fef7ed;
  border-left: 3px solid var(--accent);
  padding: 0.85rem 1rem;
  border-radius: 0 8px 8px 0;
  line-height: 1.5;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Preview sidebar */
.app-preview-col {
  position: sticky;
  top: 5.5rem;
}

.preview-sidebar {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(28, 28, 26, 0.14);
  overflow: hidden;
}

.preview-sidebar__head {
  background: linear-gradient(135deg, #14100c, #1f2937);
  color: #fff;
  padding: 1rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-pill {
  color: #86efac;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(134, 239, 172, 0.12);
  padding: 0.25rem 0.55rem;
  border-radius: 100px;
}

.preview-sidebar__body {
  padding: 0;
  max-height: calc(100vh - 11rem);
  overflow-y: auto;
  background: #f8f6f2;
}

.preview-sidebar__empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 2.5rem 1.5rem;
  line-height: 1.6;
}

.preview-sidebar__actions {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: #faf9f7;
}

.preview-sidebar__actions .btn {
  width: 100%;
  text-align: center;
}

/* Document preview */
.doc-preview {
  padding: 1.25rem;
  font-size: 0.82rem;
}

.doc-preview__letterhead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid #14100c;
}

.doc-preview__brand {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.doc-preview__doc-type {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.doc-preview__contact {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.doc-preview__block {
  margin-bottom: 0.85rem;
}

.doc-preview__label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.doc-preview__value {
  font-weight: 700;
}

.doc-preview__muted {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.doc-preview__headline {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin: 0.75rem 0 0.25rem;
  line-height: 1.35;
}

.doc-preview__meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.doc-preview__notes {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.85rem;
  line-height: 1.45;
}

.doc-preview__options-grid {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.doc-preview__options-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.doc-preview__options-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.doc-option {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.5rem;
  text-align: center;
  position: relative;
}

.doc-option--featured {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(180, 83, 9, 0.2);
}

.doc-option__badge {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.2rem;
}

.doc-option__name {
  font-weight: 700;
  font-size: 0.8rem;
}

.doc-option__sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin: 0.15rem 0;
  line-height: 1.3;
}

.doc-option__total {
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--accent);
  margin-top: 0.25rem;
}

.doc-option__deposit {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.doc-preview__tier {
  margin-bottom: 1rem;
}

.doc-preview__tier-head {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 0.4rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.72rem;
}

.doc-table th,
.doc-table td {
  padding: 0.4rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid #f0ece4;
}

.doc-table th {
  background: #faf9f7;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}

.doc-table td:last-child,
.doc-table th:last-child {
  text-align: right;
  white-space: nowrap;
}

.doc-table tfoot td {
  font-weight: 700;
  border-bottom: none;
  background: #faf9f7;
}

.doc-table .deposit-row td {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.doc-table__sub td {
  font-size: 0.68rem;
  color: var(--text-muted);
  background: #fdfbf8;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.doc-table__sub td:first-child {
  padding-left: 1.1rem;
}

.doc-preview__terms {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

.doc-preview__terms-head {
  font-weight: 700;
  color: var(--text);
  font-size: 0.78rem;
  margin-bottom: 0.4rem;
}

.doc-preview__terms ul {
  margin: 0 0 0.5rem 1rem;
  padding: 0;
}

.doc-preview__terms li {
  margin-bottom: 0.25rem;
}

.doc-preview__sig-hint {
  font-size: 0.68rem;
  font-style: italic;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-preview-col {
    position: static;
    order: -1;
  }

  .preview-sidebar__body {
    max-height: 420px;
  }

  .line-items-head {
    display: none;
  }

  .line-item-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "desc desc"
      "qty unit"
      "rate total"
      "remove remove";
    gap: 0.4rem;
  }

  .line-field--desc { grid-area: desc; }
  .line-field--qty { grid-area: qty; }
  .line-field--unit { grid-area: unit; }
  .line-field--rate { grid-area: rate; }
  .line-field--total { grid-area: total; text-align: left; }
  .line-remove { grid-area: remove; justify-self: end; }
}

@media (max-width: 640px) {
  .app-hero-bar {
    padding-top: 5rem;
  }

  .form-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    top: 4rem;
  }

  .form-nav button {
    white-space: nowrap;
  }

  .doc-preview__options-grid.cols-2,
  .doc-preview__options-grid.cols-3 {
    grid-template-columns: 1fr;
  }
}