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

.hidden,
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #f0f4f8;
  color: #1a202c;
  line-height: 1.5;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

header {
  margin-bottom: 2rem;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  color: #1a365d;
}

h2 {
  font-size: 1.1rem;
  color: #2d3748;
  margin: 2rem 0 1rem;
}

.subtitle {
  margin: 0;
  color: #718096;
  font-size: 0.95rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.alert-error {
  background: #fed7d7;
  color: #9b2c2c;
  border: 1px solid #fc8181;
}

.alert-success {
  background: #c6f6d5;
  color: #276749;
  border: 1px solid #9ae6b4;
}

.quote-form {
  background: #fff;
  border-radius: 10px;
  padding: 1.5rem 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.form-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.form-section:last-of-type {
  border-bottom: none;
}

.notes-section {
  background: #f8fafc;
  margin-left: -2rem;
  margin-right: -2rem;
  padding: 1.5rem 2rem;
  border-top: 2px solid #e2e8f0;
  border-bottom: none;
}

.section-heading {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  color: #1a365d;
}

.section-hint {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: #718096;
}

.form-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.trade-block {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  background: #fafbfc;
}

.trade-block.hidden {
  display: none;
}

.trade-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  color: #2d3748;
  cursor: pointer;
}

.trade-label input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: #1a365d;
}

.trade-details {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px dashed #cbd5e0;
}

.trade-details.hidden,
.nested-fields.hidden {
  display: none;
}

.trade-note {
  margin: 0;
  font-size: 0.85rem;
  color: #718096;
}

.tiling-material-fields,
.tiling-material-price-row {
  min-width: 0;
  max-width: 100%;
}

.tiling-material-price-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Override .form-row input { width: 100% } so the GST label stays in-flow */
.tiling-material-price-wrap .tiling-material-price,
.form-row .tiling-material-price-wrap .tiling-material-price {
  flex: 1 1 10rem;
  min-width: 0;
  width: auto;
  max-width: 100%;
}

.tiling-gst-check,
.form-row label.tiling-gst-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 1 auto;
  margin-bottom: 0;
  white-space: nowrap;
  font-weight: 500;
  font-size: 0.85rem;
  color: #4a5568;
  cursor: pointer;
}

.tiling-gst-check input[type="checkbox"],
.form-row .tiling-gst-check input[type="checkbox"] {
  width: auto;
  min-width: 1rem;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  accent-color: #1a365d;
}

.sub-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #4a5568;
  cursor: pointer;
}

.prime-fixture-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.prime-item-row {
  display: grid;
  grid-template-columns: 40% 60%;
  align-items: center;
  gap: 0.75rem 1rem;
}

.prime-custom-row {
  grid-template-columns: minmax(8rem, 1.4fr) minmax(4rem, 0.5fr) minmax(7rem, 1fr) auto;
  align-items: end;
  padding: 0.5rem 0;
  border-top: 1px dashed #e2e8f0;
}

.prime-custom-name-wrap,
.prime-custom-row .prime-override-inline {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.25rem;
  min-width: 0;
}

.prime-custom-name-wrap .prime-override-label,
.prime-custom-row .prime-override-label {
  font-size: 0.75rem;
  color: #718096;
}

.btn-delete-prime-custom {
  border: none;
  background: transparent;
  color: #c53030;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
}

.btn-add-prime-custom {
  align-self: flex-start;
  margin-top: 0.25rem;
}

.prime-item-name .sub-check {
  margin-bottom: 0;
}

.prime-override-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.prime-override-label {
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 0;
  white-space: nowrap;
}

.prime-override {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: none;
  padding: 0.45rem 0.6rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 0.85rem;
}

.form-row.compact {
  margin-bottom: 0.75rem;
}

.form-row.compact label {
  font-size: 0.8rem;
}

.form-row.compact input,
.form-row.compact select {
  padding: 0.5rem 0.65rem;
  font-size: 0.9rem;
}

.form-row {
  margin-bottom: 1.25rem;
}

.form-row label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.35rem;
  color: #4a5568;
}

.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: #3182ce;
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.15);
}

.btn-primary,
.btn-secondary {
  display: inline-block;
  padding: 0.65rem 1.5rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: #1a365d;
  color: #fff;
}

.btn-primary:hover {
  background: #2c5282;
}

.btn-owner {
  display: inline-block;
  padding: 0.65rem 1.5rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: #8b0000;
  color: #fff;
  margin-left: 0.75rem;
}

.btn-owner:hover {
  background: #a52a2a;
}

.btn-secondary {
  background: #e2e8f0;
  color: #2d3748;
  margin-left: 0.75rem;
}

.btn-secondary:hover {
  background: #cbd5e0;
}

.actions {
  margin-bottom: 1.5rem;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: #fff;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.card .label {
  display: block;
  font-size: 0.8rem;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.card .value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: #1a365d;
  margin-top: 0.25rem;
}

.card.highlight {
  border-left: 4px solid #3182ce;
}

.card.owner-stat {
  border-left: 4px solid #8b0000;
}

.notes-box {
  border-left: 4px solid #d69e2e;
}

.scope-box {
  background: #fff;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.scope-box p {
  margin: 0;
  color: #4a5568;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  font-size: 0.875rem;
}

.items-table th,
.items-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.items-table th {
  background: #1a365d;
  color: #fff;
  font-weight: 600;
  font-size: 0.8rem;
}

.items-table td:nth-child(n+2) {
  text-align: right;
}

.items-table td:first-child {
  text-align: left;
  white-space: pre-line;
}

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.tag-labour { background: #bee3f8; color: #2c5282; }
.tag-materials { background: #c6f6d5; color: #276749; }
.tag-preliminaries { background: #fefcbf; color: #975a16; }
.tag-subcontract { background: #e9d8fd; color: #553c9a; }
.tag-margin { background: #fed7d7; color: #9b2c2c; }
.tag-other { background: #e2e8f0; color: #4a5568; }

.category-split {
  background: #fff;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.split-row {
  display: grid;
  grid-template-columns: 100px 1fr 50px 80px;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.cat-name {
  text-transform: capitalize;
  font-weight: 600;
}

.bar-track {
  height: 10px;
  background: #edf2f7;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
}

.bar-labour { background: #3182ce; }
.bar-materials { background: #38a169; }
.bar-preliminaries { background: #d69e2e; }
.bar-subcontract { background: #805ad5; }
.bar-margin { background: #e53e3e; }
.bar-other { background: #a0aec0; }

.cat-pct {
  font-weight: 700;
  text-align: right;
}

.cat-target {
  color: #a0aec0;
  font-size: 0.75rem;
  text-align: right;
}

.container-wide {
  max-width: 1100px;
}

.room-block {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.room-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid #1a365d;
}

.room-title {
  margin: 0;
  font-size: 1.15rem;
  color: #1a365d;
}

.btn-remove-room {
  background: transparent;
  border: 1px solid #fc8181;
  color: #9b2c2c;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-remove-room:hover {
  background: #fed7d7;
}

.room-actions {
  margin-bottom: 1.5rem;
}

.btn-submit {
  margin-top: 0.5rem;
}

.form-submit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.clear-form-form {
  display: inline;
  margin: 0;
}

.trade-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.override-field {
  display: flex;
  flex-direction: column;
  min-width: 140px;
}

.override-field label {
  font-size: 0.75rem;
  color: #718096;
  margin-bottom: 0.2rem;
}

.override-field input {
  padding: 0.4rem 0.55rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 0.85rem;
}

.calc-subline {
  font-size: 0.75rem;
  color: #666;
  font-style: italic;
  margin-top: 0.2rem;
  line-height: 1.3;
}

.prime-labour-section {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed #cbd5e0;
}

.prime-labour-note {
  margin-top: 0.35rem;
  margin-bottom: 0;
}

.preview-prime-summary td {
  font-style: italic;
  color: #4a5568;
}

.preview-prime-labour-subrow td {
  color: #666;
}

.preview-prime-total td {
  font-weight: 700;
  border-top: 1px solid #cbd5e0;
}

.preview-tiling-subrow td {
  color: #666;
  font-size: 0.9rem;
}

.preview-tiling-subrow .desc-cell {
  padding-left: 1.25rem;
}

.room-notes {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed #cbd5e0;
}

.room-notes label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.35rem;
  color: #4a5568;
}

.room-notes textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
}

.rooms-results details.room-result {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.rooms-results summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.rooms-results summary::-webkit-details-marker {
  display: none;
}

.room-result-name {
  flex: 1;
  color: #1a365d;
}

.room-result-meta {
  color: #718096;
  font-size: 0.85rem;
  font-weight: 400;
}

.room-result-subtotal {
  color: #1a365d;
  font-size: 1rem;
}

.room-result-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid #e2e8f0;
}

.room-subtotal-row td {
  background: #f0f4f8;
  border-top: 2px solid #1a365d;
}

.pre-line {
  white-space: pre-line;
}

.room-scope,
.room-notes-text {
  font-size: 0.875rem;
  color: #4a5568;
  margin: 0.75rem 0;
}

/* Quote preview tabs */
.quote-preview {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.preview-tabs {
  display: flex;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.preview-tab {
  flex: 1;
  padding: 0.85rem 1.25rem;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 600;
  color: #4a5568;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.preview-tab:hover {
  background: #edf2f7;
}

.preview-tab.active.preview-tab--client {
  color: #1a365d;
  border-bottom-color: #1a365d;
  background: #fff;
}

.preview-tab.active.preview-tab--internal {
  color: #8b0000;
  border-bottom-color: #8b0000;
  background: #fff;
}

.preview-panel {
  display: none;
  padding: 1.25rem 1.5rem 1.5rem;
}

.preview-panel.active {
  display: block;
}

.preview-document {
  max-width: 100%;
}

.preview-doc-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

.preview-doc-title {
  margin: 0;
  font-size: 1.35rem;
}

.preview-doc-header--client .preview-doc-title {
  color: #1a365d;
}

.preview-doc-header--internal .preview-doc-title {
  color: #8b0000;
  font-size: 1.1rem;
}

.preview-meta {
  text-align: right;
  font-size: 0.875rem;
  color: #4a5568;
}

.preview-meta p {
  margin: 0.15rem 0;
}

.preview-room-heading {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
}

.preview-room-header-row td {
  background: #d0dce8;
  color: #1e3a5f;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  border-color: #d0dce8;
  text-align: left;
}

.preview-column-header-row th {
  font-weight: 600;
  border-color: transparent;
  text-align: right;
}

.preview-column-header-row th:first-child {
  text-align: left;
}

.preview-column-header-row--client th {
  background: #1a365d;
  color: #fff;
}

.preview-column-header-row--internal th {
  background: #8b0000;
  color: #fff;
}

.preview-room-heading--client {
  color: #1a365d;
}

.preview-room-heading--internal {
  color: #8b0000;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.preview-table th,
.preview-table td {
  padding: 0.55rem 0.65rem;
  border: 1px solid #e2e8f0;
  text-align: right;
  vertical-align: top;
}

.preview-table tbody tr.preview-column-header-row th {
  padding: 0.55rem 0.65rem;
}

.preview-table th:first-child,
.preview-table td:first-child {
  text-align: left;
}

.preview-table--client thead {
  background: #1a365d;
  color: #fff;
}

.preview-table--client tbody tr.preview-room-header-row + tr.preview-column-header-row th {
  border-top: none;
}

.preview-table--internal thead {
  background: #8b0000;
  color: #fff;
}

.preview-table thead th {
  font-weight: 600;
  border-color: transparent;
}

.preview-table tbody tr:nth-child(even):not(.preview-room-header-row):not(.preview-column-header-row):not(.preview-room-subtotal) {
  background: #f5f7fa;
}

.preview-table .desc-cell {
  white-space: pre-line;
  max-width: 280px;
}

.preview-room-subtotal td {
  background: #eef2f7;
  border-top: 2px solid #1a365d;
}

.preview-table--internal .preview-room-subtotal td {
  border-top-color: #8b0000;
}

.preview-totals {
  margin-left: auto;
  margin-top: 1.25rem;
  margin-bottom: 1rem;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 260px;
  width: auto;
  display: table;
}

.preview-totals td {
  padding: 0.35rem 0.75rem;
  text-align: right;
}

.preview-totals td:first-child {
  text-align: right;
  color: #4a5568;
}

.preview-grand-total td {
  font-weight: 700;
  font-size: 1.05rem;
  padding-top: 0.6rem;
  border-top: 1px solid #1a365d;
}

.preview-totals--internal .preview-grand-total td {
  border-top-color: #8b0000;
  color: #8b0000;
}

.preview-totals--internal .preview-margin-pct td {
  font-weight: 700;
  color: #8b0000;
}

.preview-footer-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
  font-size: 0.875rem;
  color: #444;
}

.preview-footer-section h4 {
  margin: 1rem 0 0.5rem;
  font-size: 0.95rem;
  color: #1a365d;
}

.preview-footer-section--internal h4 {
  color: #8b0000;
}

.preview-schedule {
  width: 100%;
  max-width: 420px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.preview-schedule td {
  padding: 0.4rem 0;
  border-bottom: 1px solid #e2e8f0;
}

.preview-bullets {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
}

.preview-notes {
  margin: 0.25rem 0 0;
  color: #4a5568;
}

@media (max-width: 640px) {
  .preview-tabs {
    flex-direction: column;
  }

  .preview-meta {
    text-align: left;
    width: 100%;
  }

  .preview-table {
    font-size: 0.75rem;
  }

  .preview-table .desc-cell {
    max-width: 140px;
  }

  .split-row {
    grid-template-columns: 80px 1fr 45px;
  }
  .cat-target {
    display: none;
  }
}

/* —— Schedule of Finishes (form) —— */
.schedule-section {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 2px solid #e2e8f0;
}

.schedule-section-header {
  margin-bottom: 1rem;
}

.schedule-section-title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  color: #1a365d;
}

.schedule-suggestions {
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  background: #fff;
  border: 1px dashed #cbd5e0;
  border-radius: 8px;
}

.schedule-suggestions-label {
  margin: 0 0 0.55rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #4a5568;
}

.schedule-suggestions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
}

.schedule-suggestion-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  background: #edf2f7;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  font-size: 0.82rem;
  color: #2d3748;
  cursor: pointer;
  user-select: none;
}

.schedule-suggestion-chip:hover {
  background: #e2e8f0;
}

.schedule-suggestion-chip input {
  margin: 0;
  cursor: pointer;
}

.schedule-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.schedule-item-card {
  position: relative;
  background: #f7f8fa;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem 2.25rem 1rem 1rem;
}

.btn-delete-finish-item {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  border-radius: 4px;
  background: #fed7d7;
  color: #c53030;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  font-weight: 700;
}

.btn-delete-finish-item:hover {
  background: #feb2b2;
}

.schedule-item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem 1rem;
}

.schedule-size-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.schedule-size-controls select,
.schedule-size-controls .finish-size-custom {
  flex: 1 1 140px;
  min-width: 0;
  width: 100%;
}

.schedule-size-row.hidden {
  display: none;
}

.schedule-colour-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.schedule-colour-controls select,
.schedule-colour-controls .finish-colour-custom {
  flex: 1 1 140px;
  min-width: 0;
  width: 100%;
}

.schedule-colour-row.hidden {
  display: none;
}

.schedule-brand-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.schedule-brand-controls select,
.schedule-brand-controls .finish-brand-other {
  width: 100%;
  min-width: 0;
}

.schedule-qty-unit {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.schedule-internal-field {
  background: #fff8f0;
  border: 1px dashed #e8b98a;
  border-radius: 6px;
  padding: 0.65rem;
}

.internal-only-tag {
  font-weight: 500;
  font-size: 0.75rem;
  color: #c05621;
}

.schedule-image-row-inner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.schedule-image-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #cbd5e0;
  flex-shrink: 0;
  background: #edf2f7;
}

.schedule-image-input-col {
  flex: 1;
  min-width: 0;
}

.schedule-image-actions {
  margin-top: 0.35rem;
}

.schedule-image-status {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: #4a5568;
}

.schedule-image-error {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: #c53030;
}

.btn-add-finish-item {
  margin-top: 0.25rem;
}

/* —— Schedule of Finishes (results preview) —— */
.preview-tab--finishes.active {
  border-bottom-color: #1a365d;
  color: #1a365d;
}

.schedule-preview-subtitle {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: #666;
  line-height: 1.45;
  max-width: 720px;
}

.schedule-preview-room {
  margin: 1.25rem 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: #1a365d;
}

.schedule-preview-empty {
  color: #718096;
  font-size: 0.9rem;
}

.finish-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.finish-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.finish-card-image {
  height: 180px;
  min-height: 180px;
  flex-shrink: 0;
  background: #f5f7fa;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.finish-card-image img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.finish-card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0.75rem;
  text-align: center;
  font-style: italic;
  font-size: 0.85rem;
  color: #999;
}

.finish-card-body {
  padding: 0.65rem 0.75rem 0.85rem;
}

.finish-card-name {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a365d;
}

.finish-card-spec {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: #555;
  line-height: 1.35;
}

.finish-card-meta {
  margin: 0;
  font-size: 0.8rem;
  color: #666;
  line-height: 1.35;
}

@media (max-width: 900px) {
  .finish-card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .finish-card-grid {
    grid-template-columns: 1fr;
  }
}

/* —— Custom Quote mode —— */
.page-header-with-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.quote-mode-nav {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

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

.form-row--wide {
  grid-column: 1 / -1;
}

.custom-group-card {
  position: relative;
  border: 1px solid #cbd5e0;
  border-radius: 8px;
  padding: 1rem 1rem 1.25rem;
  margin-bottom: 1rem;
  background: #fff;
}

.custom-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.custom-group-heading {
  margin: 0;
  font-size: 1rem;
  color: #1a365d;
}

.btn-delete-group {
  border: none;
  background: #fed7d7;
  color: #9b2c2c;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.btn-delete-group:hover {
  background: #feb2b2;
}

.form-grid--group-meta {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.custom-lines-wrap {
  overflow-x: auto;
}

.custom-lines-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.custom-lines-table th {
  text-align: left;
  font-size: 0.8rem;
  color: #4a5568;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.custom-lines-table td {
  padding: 0.35rem 0.5rem;
  vertical-align: middle;
}

.custom-lines-table input {
  width: 100%;
  min-width: 0;
}

.custom-lines-table td:nth-child(2),
.custom-lines-table td:nth-child(3),
.custom-lines-table td:nth-child(4) {
  width: 110px;
}

.custom-line-actions {
  width: 2rem;
  text-align: center;
}

.btn-delete-line {
  border: none;
  background: #fed7d7;
  color: #9b2c2c;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
}

.btn-delete-line:hover {
  background: #feb2b2;
}

.field-hint {
  font-weight: 400;
  font-size: 0.75rem;
  color: #718096;
}

.preview-table--custom th,
.preview-table--custom td:last-child {
  text-align: right;
}

.preview-table--custom th:first-child,
.preview-table--custom td:first-child {
  text-align: left;
}

.preview-table--custom-internal th,
.preview-table--custom-internal td:not(:first-child) {
  text-align: right;
}

.preview-internal-group-title {
  margin-top: 1rem;
}

@media (max-width: 720px) {
  .form-grid--group-meta {
    grid-template-columns: 1fr;
  }
}

/* —— Invoice —— */
.invoice-lines-wrap {
  overflow-x: auto;
}

.invoice-lines-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.invoice-lines-table th {
  text-align: left;
  font-size: 0.8rem;
  color: #4a5568;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.invoice-lines-table td {
  padding: 0.35rem 0.5rem;
  vertical-align: middle;
}

.invoice-lines-table input {
  width: 100%;
  min-width: 0;
}

.invoice-lines-table td:nth-child(2),
.invoice-lines-table td:nth-child(3),
.invoice-lines-table td:nth-child(4) {
  width: 90px;
}

.invoice-gst-incl-header,
.invoice-gst-incl-cell {
  width: 72px;
  text-align: center;
}

.invoice-gst-incl-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.invoice-gst-hint {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: #718096;
  font-style: italic;
}

.invoice-unit-price-cell {
  min-width: 110px;
}

.invoice-unit-price-cell--gst-incl .invoice-unit-price {
  font-size: 0.78rem;
}

.invoice-unit-price-display {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #1a365d;
  white-space: nowrap;
}

.invoice-unit-price-cell--gst-incl .invoice-unit-price-display::before {
  content: "Ex-GST: ";
  font-weight: 400;
  color: #718096;
}

.invoice-line-total {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.invoice-summary-row td {
  border-top: 1px solid #e2e8f0;
  padding-top: 0.5rem;
}

.invoice-summary-label {
  text-align: right;
  font-weight: 600;
  color: #4a5568;
}

.invoice-summary-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.invoice-summary-row--total td {
  border-top: 2px solid #1a365d;
  color: #1a365d;
  font-size: 1rem;
}

.invoice-preview-bill-to,
.invoice-preview-details {
  margin: 0.75rem 0 1rem;
  font-size: 0.9rem;
  color: #2d3748;
}

.invoice-preview-bill-to p,
.invoice-preview-details p {
  margin: 0.15rem 0;
}

/* —— Login —— */
.login-container {
  max-width: 420px;
  padding-top: 3rem;
}

.login-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-logo {
  display: block;
  max-width: 220px;
  height: auto;
  margin: 0 auto 1rem;
}

.login-form {
  margin-top: 0.5rem;
}

/* —— History —— */
.history-summary {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: #edf2f7;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #2d3748;
}

.history-filters {
  margin-bottom: 0.75rem;
}

.history-filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}

.history-filters-row label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #4a5568;
}

.history-filters-row select,
.history-filters-row input[type="search"] {
  min-width: 10rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 0.9rem;
}

.history-show-all {
  flex-direction: row !important;
  align-items: center;
  gap: 0.4rem !important;
  font-weight: 500 !important;
}

.history-bulk-actions {
  margin-bottom: 1rem;
}

.history-table-wrap {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.history-table th,
.history-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
}

.history-table th {
  background: #1a365d;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
}

.history-client {
  font-weight: 600;
  color: #2d3748;
}

.history-address {
  font-size: 0.8rem;
  color: #718096;
}

.history-total {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.history-rev {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: #e2e8f0;
  color: #4a5568;
  font-size: 0.7rem;
  font-weight: 700;
}

.history-rev-children {
  background: #bee3f8;
  color: #2b6cb0;
}

.history-status-form {
  margin: 0;
}

.history-status-select {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
}

.status-badge.status-draft,
.history-status-select.status-draft {
  background: #e2e8f0;
  color: #4a5568;
}

.status-badge.status-sent,
.history-status-select.status-sent {
  background: #bee3f8;
  color: #2b6cb0;
}

.status-badge.status-won,
.history-status-select.status-won,
.status-badge.status-paid,
.history-status-select.status-paid {
  background: #c6f6d5;
  color: #276749;
}

.status-badge.status-lost,
.history-status-select.status-lost {
  background: #fed7d7;
  color: #9b2c2c;
}

.status-badge.status-issued,
.history-status-select.status-issued {
  background: #feebc8;
  color: #c05621;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.history-actions .btn-primary,
.history-actions .btn-owner,
.history-actions .btn-secondary {
  margin-left: 0;
}

.history-pdf-label-short {
  display: none;
}

@media (max-width: 720px) {
  .history-pdf-label-full {
    display: none;
  }

  .history-pdf-label-short {
    display: inline;
  }
}

.history-inline-form {
  display: inline;
  margin: 0;
}

.history-delete-btn {
  color: #c53030;
}

.history-empty {
  color: #718096;
  font-style: italic;
}
