:root {
  /* Build 4 You Solutions brand palette */
  --b4y-blue: #37434C;        /* primary dark slate */
  --b4y-blue-light: #3E83C3;  /* accent blue */
  --b4y-accent: #3E83C3;      /* accent blue (replaces previous orange) */
  --b4y-accent-light: #A9B8C5;/* tertiary blue-gray */
  --b4y-bg: #EBEBEB;          /* light gray background */
  --b4y-panel: #ffffff;
  --b4y-border: #d4dce3;      /* soft border (lighter than #A9B8C5 for subtlety) */
  --b4y-text: #37434C;
  --b4y-text-muted: #71787F;
  --b4y-internal: #047857;    /* green for internal/profit (not in brand, kept for clarity) */
  --b4y-warning: #b45309;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--b4y-bg);
  color: var(--b4y-text);
  height: 100vh;
  overflow: hidden;
}

.topbar {
  height: 64px;
  background: var(--b4y-blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  height: 38px;
  width: auto;
  /* No background — the chroma-keyed icon sits transparently on the header */
  display: block;
}
.brand-icon:not([src]), .brand-icon[src=""] { display: none; }
.brand-text { display: flex; flex-direction: column; gap: 1px; line-height: 1.2; }
.brand-title { font-size: 16px; font-weight: 600; letter-spacing: 0.1px; color: white; }
.brand-build4you { font-weight: 700; }
.brand-4 { color: #67aef0; }   /* light brand blue — picks up the "4" in the wordmark */
.brand-sep { opacity: 0.4; margin: 0 4px; font-weight: 300; }
.brand-sub { font-size: 11px; opacity: 0.65; font-style: italic; }

.btn-icon {
  width: 36px; height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 18px;
  background: rgba(255,255,255,0.08);
  color: white;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px;
  cursor: pointer;
}
.btn-icon:hover { background: rgba(255,255,255,0.16); }

.topbar-actions { display: flex; gap: 12px; align-items: center; }

.btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.9; }
.btn-primary { background: var(--b4y-accent); color: white; }
.btn-secondary { background: rgba(255,255,255,0.15); color: white; border: 1px solid rgba(255,255,255,0.25); }

.layout {
  display: grid;
  grid-template-columns: 320px 1fr 340px;
  gap: 12px;
  padding: 12px;
  height: calc(100vh - 64px);
}

.panel {
  background: var(--b4y-panel);
  border-radius: 10px;
  border: 1px solid var(--b4y-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--b4y-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-header h2 { margin: 0; font-size: 15px; font-weight: 600; }

.catalog-source {
  font-size: 11px;
  color: var(--b4y-text-muted);
  background: var(--b4y-bg);
  padding: 3px 8px;
  border-radius: 10px;
}

.catalog-filters {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--b4y-border);
}
.catalog-filters input, .catalog-filters select {
  padding: 7px 10px;
  border: 1px solid var(--b4y-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
#lineFilter {
  background: var(--b4y-blue);
  color: white;
  font-weight: 600;
  border-color: var(--b4y-blue);
}

.catalog-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.catalog-item {
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--b4y-bg);
  border: 1px solid var(--b4y-border);
  border-radius: 6px;
  cursor: grab;
  user-select: none;
}
.catalog-item:active { cursor: grabbing; }
.catalog-item:hover { border-color: var(--b4y-blue-light); }
.catalog-item-sku { font-weight: 600; font-size: 13px; color: var(--b4y-blue); }
.catalog-item-desc { font-size: 12px; color: var(--b4y-text-muted); margin-top: 2px; }
.catalog-item-meta {
  font-size: 11px;
  color: var(--b4y-text-muted);
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
}
.catalog-item-price { color: var(--b4y-internal); font-weight: 500; }
.catalog-item-noprice {
  font-size: 10px;
  color: var(--b4y-text-muted);
  font-style: italic;
  background: #fff7ed;
  padding: 1px 6px;
  border-radius: 8px;
}

.catalog-stats {
  padding: 8px 16px;
  border-top: 1px solid var(--b4y-border);
  font-size: 11px;
  color: var(--b4y-text-muted);
}

.room-panel .panel-header { gap: 16px; }
.room-controls { display: flex; gap: 12px; align-items: center; }
.room-controls label { font-size: 12px; color: var(--b4y-text-muted); }
.room-controls input[type=number] {
  width: 64px;
  padding: 4px 8px;
  border: 1px solid var(--b4y-border);
  border-radius: 4px;
  font-size: 13px;
  margin-left: 4px;
}
.room-controls select {
  padding: 4px 8px;
  border: 1px solid var(--b4y-border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}

.preset-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.preset-label { font-size: 12px; color: var(--b4y-text-muted); }
.btn-preset {
  padding: 5px 10px;
  border: 1px solid var(--b4y-border);
  background: white;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.btn-preset:hover { border-color: var(--b4y-blue-light); background: var(--b4y-bg); }

.wall-editor {
  border-top: 1px solid var(--b4y-border);
  background: #fcfcfd;
  padding: 10px 16px;
  max-height: 180px;
  overflow-y: auto;
}
.wall-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.wall-editor-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--b4y-text-muted);
  font-weight: 600;
}
.btn-add-wall {
  padding: 4px 10px;
  background: var(--b4y-blue);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}
.btn-add-wall:hover { background: var(--b4y-blue-light); }

.wall-list { display: flex; flex-direction: column; gap: 4px; }
.wall-row {
  display: grid;
  grid-template-columns: 96px 84px 110px 96px 28px 80px 80px 28px 28px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: white;
  border: 1px solid var(--b4y-border);
  border-radius: 4px;
  font-size: 12px;
}
.wall-row input[type=number] { width: 100%; }
.wall-elevation {
  width: 24px; height: 24px;
  border: 1px solid var(--b4y-border);
  background: white;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
}
.wall-elevation:hover { background: var(--b4y-bg); }
.wall-chain {
  width: 24px; height: 24px;
  border: 1px solid var(--b4y-border);
  background: white;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
}
.wall-chain.linked { background: var(--b4y-bg); color: var(--b4y-text-muted); }
.wall-chain.unlinked { background: white; border-color: var(--b4y-accent); color: var(--b4y-accent); }
.wall-chain:hover { background: var(--b4y-bg); }
.wall-pos input:disabled { opacity: 0.45; background: var(--b4y-bg); cursor: not-allowed; }
.wall-pos { font-size: 11px; }
.wall-row.wall-row-selected {
  border-color: var(--b4y-accent);
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(62, 131, 195, 0.25);
}
.wall-row .wall-id {
  font-weight: 700;
  color: var(--b4y-blue);
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 11px;
}
.wall-free-badge {
  font-size: 9px;
  font-weight: 600;
  color: var(--b4y-internal);
  white-space: nowrap;
}
.wall-row label { display: flex; align-items: center; gap: 4px; color: var(--b4y-text-muted); }
.wall-row input, .wall-row select {
  width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--b4y-border);
  border-radius: 3px;
  font-size: 12px;
  font-family: inherit;
}
.wall-row input[type=number] { text-align: right; }
.wall-delete {
  width: 24px; height: 24px;
  border: none;
  background: transparent;
  color: var(--b4y-text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}
.wall-delete:hover { background: #fee2e2; color: #b91c1c; }

.canvas-wrapper {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(0deg, #fafbfc, #ffffff);
  overflow: auto;
}
#roomCanvas {
  background: white;
  border: 1px solid var(--b4y-border);
  border-radius: 6px;
  display: block;
}
.canvas-help {
  margin-top: 12px;
  font-size: 12px;
  color: var(--b4y-text-muted);
  font-style: italic;
}

.placement-list {
  border-top: 1px solid var(--b4y-border);
  max-height: 120px;
  overflow-y: auto;
  padding: 8px 16px;
  font-size: 12px;
}
.placement-item {
  padding: 5px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-bottom: 1px dashed var(--b4y-border);
}
.placement-item:last-child { border-bottom: none; }
.placement-main { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1; }
.placement-main strong { color: var(--b4y-blue); }
.placement-loc {
  font-size: 10px;
  color: var(--b4y-text-muted);
  background: var(--b4y-bg);
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 600;
  white-space: nowrap;
}
.placement-line {
  font-size: 9px;
  color: white;
  background: var(--b4y-blue);
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.placement-desc {
  color: var(--b4y-text-muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.placement-right { display: flex; align-items: center; gap: 6px; }
.placement-delete {
  width: 22px; height: 22px;
  border: none;
  background: transparent;
  color: var(--b4y-text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
}
.placement-delete:hover { background: #fee2e2; color: #b91c1c; }

.role-toggle {
  display: flex;
  gap: 12px;
  font-size: 12px;
}
.role-toggle label { display: flex; align-items: center; gap: 4px; cursor: pointer; }

.finish-controls {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px solid var(--b4y-border);
  background: white;
}
.finish-controls-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--b4y-text-muted);
  font-weight: 600;
  margin-bottom: 2px;
}
.finish-controls label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--b4y-text-muted);
}
.finish-controls select {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid var(--b4y-border);
  border-radius: 4px;
  font-size: 12px;
  background: white;
  font-family: inherit;
}
.markup-controls {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--b4y-border);
  background: white;
}
.markup-controls::before {
  content: 'Markup & Tax';
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--b4y-text-muted);
  font-weight: 600;
  margin-bottom: 2px;
}
.markup-controls label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--b4y-text-muted);
}
.markup-controls input {
  width: 80px;
  padding: 4px 8px;
  border: 1px solid var(--b4y-border);
  border-radius: 4px;
  font-size: 13px;
  text-align: right;
}
.role-customer .markup-controls { display: none; }

.pricing-breakdown {
  flex: 1;
  padding: 12px 16px;
  overflow-y: auto;
}
.pricing-notice {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 11px;
  padding: 8px 10px;
  border-radius: 5px;
  margin-bottom: 10px;
  line-height: 1.35;
}
.price-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 13px;
}
.price-row.internal-only { color: var(--b4y-internal); font-style: italic; }
.role-customer .internal-only { display: none; }
.price-row.subtotal {
  border-top: 1px solid var(--b4y-border);
  font-weight: 600;
  margin-top: 6px;
  padding-top: 8px;
}
.price-row.total {
  border-top: 2px solid var(--b4y-blue);
  font-weight: 700;
  font-size: 16px;
  margin-top: 8px;
  padding-top: 10px;
  color: var(--b4y-blue);
}
.price-row.profit {
  color: var(--b4y-internal);
  font-weight: 600;
  margin-top: 6px;
}

.customer-info {
  padding: 12px 16px;
  border-top: 1px solid var(--b4y-border);
  background: #fafbfc;
}
.customer-info h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--b4y-text-muted); }
.customer-info label { display: block; margin-bottom: 6px; font-size: 12px; }
.customer-info input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--b4y-border);
  border-radius: 4px;
  font-size: 13px;
  margin-top: 2px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal.hidden { display: none; }
.modal-content {
  background: white;
  border-radius: 10px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-actions {
  padding: 12px 16px;
  background: var(--b4y-bg);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-bottom: 1px solid var(--b4y-border);
}
.modal-actions .btn-secondary { background: white; color: var(--b4y-text); border: 1px solid var(--b4y-border); }

#proposalContent {
  flex: 1;
  overflow-y: auto;
  padding: 40px 48px;
  font-family: Georgia, serif;
  color: #1a1f2e;
}

.proposal-header {
  border-bottom: 3px solid var(--b4y-blue);
  padding-bottom: 16px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.proposal-header .logo { width: 56px; height: 56px; font-size: 22px; }
.proposal-header-text { text-align: right; }
.proposal-header-text h1 { margin: 0; color: var(--b4y-blue); font-size: 22px; }
.proposal-header-text .sub { color: var(--b4y-text-muted); font-size: 13px; }

.proposal-section { margin-bottom: 24px; }
.proposal-section h2 {
  color: var(--b4y-blue);
  font-size: 15px;
  border-bottom: 1px solid var(--b4y-border);
  padding-bottom: 4px;
  margin-bottom: 10px;
}
.proposal-table { width: 100%; border-collapse: collapse; font-size: 13px; font-family: -apple-system, sans-serif; }
.proposal-table th, .proposal-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--b4y-border); }
.proposal-table th { background: var(--b4y-bg); font-weight: 600; }
.proposal-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.proposal-total {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--b4y-blue);
  color: white;
  border-radius: 6px;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
}
.proposal-disclaimer {
  font-size: 11px;
  color: var(--b4y-text-muted);
  font-style: italic;
  margin-top: 24px;
  font-family: -apple-system, sans-serif;
}



/* Brand Settings modal */
.brand-modal-content { max-width: 640px; }
.brand-settings-body { padding: 24px 28px; overflow-y: auto; }
.brand-section { margin-bottom: 28px; }
.brand-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--b4y-text-muted);
  margin: 0 0 12px;
  font-weight: 600;
}
.brand-logo-preview {
  height: 80px;
  background: var(--b4y-blue);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  margin-bottom: 12px;
}
.brand-logo-preview img { max-height: 64px; max-width: 100%; }
.brand-upload-btn { background: var(--b4y-blue); color: white; border: none; margin-right: 8px; }
.brand-help { font-size: 11px; color: var(--b4y-text-muted); margin: 8px 0 0; font-style: italic; }
.brand-color-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.brand-color-row > label {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--b4y-text);
}
.brand-color-row input[type=color] {
  width: 36px; height: 28px;
  padding: 0;
  border: 1px solid var(--b4y-border);
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
}
.brand-color-hex {
  width: 84px;
  padding: 4px 8px;
  border: 1px solid var(--b4y-border);
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", monospace;
  text-align: center;
  text-transform: uppercase;
}
.brand-input-label {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  color: var(--b4y-text);
  margin-bottom: 8px;
}
.brand-input-label input[type=text] {
  padding: 6px 10px;
  border: 1px solid var(--b4y-border);
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
}
.brand-modal-content .modal-actions { gap: 6px; align-items: center; }
.brand-modal-content .modal-actions .btn-secondary {
  background: white;
  color: var(--b4y-text);
  border: 1px solid var(--b4y-border);
}

/* Active project chip in header */
.active-project-name {
  font-size: 12px;
  color: rgba(255,255,255,0.8);
  padding: 4px 10px;
  background: rgba(255,255,255,0.10);
  border-radius: 12px;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.active-project-name:empty { display: none; }

/* Projects modal */
.projects-modal-content { max-width: 900px; }
.projects-body {
  padding: 20px 28px;
  overflow-y: auto;
}
.projects-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--b4y-text-muted);
}
.projects-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.projects-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--b4y-bg);
  color: var(--b4y-text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
  border-bottom: 1px solid var(--b4y-border);
}
.projects-table td {
  padding: 10px;
  border-bottom: 1px solid var(--b4y-border);
  vertical-align: middle;
}
.projects-table tbody tr { cursor: pointer; }
.projects-table tbody tr:hover { background: #f7faff; }
.projects-table tbody tr.active {
  background: #eff6ff;
  border-left: 3px solid var(--b4y-accent);
}
.project-customer { font-weight: 600; color: var(--b4y-blue); }
.project-stage-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--b4y-bg);
  color: var(--b4y-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.project-stage-badge.stage-approved,
.project-stage-badge.stage-deposit,
.project-stage-badge.stage-ordered,
.project-stage-badge.stage-scheduled,
.project-stage-badge.stage-installed,
.project-stage-badge.stage-completed { background: #ecfdf5; color: var(--b4y-internal); }
.project-stage-badge.stage-proposal_sent,
.project-stage-badge.stage-revision { background: #fff7ed; color: #9a3412; }
.project-actions { display: flex; gap: 4px; justify-content: flex-end; }
.project-actions button {
  background: transparent;
  border: 1px solid var(--b4y-border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  color: var(--b4y-text);
}
.project-actions button:hover { background: var(--b4y-bg); }
.project-actions button.delete:hover { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }

/* Zoom controls (top-right of canvas wrapper) */
.canvas-wrapper { position: relative; }
.zoom-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--b4y-border);
  border-radius: 6px;
  padding: 3px 6px;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.zoom-btn {
  width: 26px; height: 26px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--b4y-text);
  border-radius: 4px;
  padding: 0;
  line-height: 1;
}
.zoom-btn:hover { background: var(--b4y-bg); border-color: var(--b4y-border); }
.zoom-btn-fit { width: auto; padding: 0 8px; font-size: 11px; }
.zoom-readout {
  font-size: 12px;
  font-weight: 600;
  color: var(--b4y-text-muted);
  min-width: 42px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.catalog-item-corner {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--b4y-accent);
  color: white;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-left: 4px;
}

.wall-editor-add-group { display: flex; gap: 6px; }
.btn-add-island {
  background: var(--b4y-accent) !important;
}
.btn-add-island:hover { background: var(--b4y-blue-light) !important; }
.wall-group-badge {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-left: 4px;
}
.wall-group-island { background: #ecfdf5; color: var(--b4y-internal); }
.wall-group-peninsula { background: #eff6ff; color: var(--b4y-accent); }

/* Allowances panel */
.allowance-controls {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px solid var(--b4y-border);
  background: white;
}
.allowance-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--b4y-text-muted);
  font-weight: 600;
  margin-top: 8px;
  margin-bottom: 2px;
}
.allowance-section-title:first-child { margin-top: 0; }
.allowance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--b4y-text-muted);
}
.allowance-row input[type=number] {
  width: 90px;
  padding: 4px 8px;
  border: 1px solid var(--b4y-border);
  border-radius: 4px;
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.allowance-row input[type=text] {
  width: 130px;
  padding: 4px 8px;
  border: 1px solid var(--b4y-border);
  border-radius: 4px;
  font-size: 12px;
}
.customer-info textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--b4y-border);
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  margin-top: 2px;
  resize: vertical;
}

/* Elevation modal */
.elevation-modal-content { max-width: 1100px; }
.elevation-body {
  padding: 20px 24px;
  overflow: auto;
}
#elevationCanvas {
  background: white;
  border: 1px solid var(--b4y-border);
  border-radius: 6px;
  display: block;
}
.elevation-legend {
  margin-top: 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--b4y-text-muted);
}
.elevation-legend-item { display: flex; align-items: center; gap: 6px; }
.elevation-legend-swatch { width: 12px; height: 12px; border: 1px solid var(--b4y-blue); }

/* View mode toggle (All / Base / Wall) */
.view-controls {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--b4y-border);
  border-radius: 6px;
  padding: 2px;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.view-btn {
  padding: 4px 12px;
  border: none;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--b4y-text-muted);
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.view-btn:hover { color: var(--b4y-text); }
.view-btn.active { background: var(--b4y-blue); color: white; }

/* End panel lock toggle in placement list */
.placement-lock {
  width: 22px; height: 22px;
  border: 1px solid var(--b4y-border);
  background: white;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
  margin-right: 2px;
}
.placement-lock:hover { background: var(--b4y-bg); }
.placement-lock.locked { background: #eff6ff; border-color: var(--b4y-accent); }
.placement-lock.unlocked { background: #fff7ed; border-color: #f59e0b; }

/* Corner-cabinet rotation button — cycles cornerAngle by 90° */
.placement-rotate {
  width: 22px; height: 22px;
  border: 1px solid var(--b4y-border);
  background: white;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
  margin-right: 2px;
  color: var(--b4y-blue);
  font-weight: 700;
}
.placement-rotate:hover { background: #eff6ff; border-color: var(--b4y-accent); }

/* Version badge — visible signal that the new code actually loaded.
   Made deliberately large/loud so it's impossible to miss which version is live. */
.app-version-badge {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 700;
  color: white;
  background: #10b981;
  padding: 4px 10px;
  border-radius: 6px;
  margin-left: 6px;
  border: 1px solid #059669;
  letter-spacing: 0.5px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.app-version-badge.update-available {
  background: #fef3c7;
  color: #92400e;
  border-color: #f59e0b;
  animation: badge-pulse 1.4s ease-in-out infinite;
}
@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ════════════════════════════════════════════════════════════════════════
   v27 — iPad / touch UX improvements
   ──────────────────────────────────────────────────────────────────────── */

/* Canvas must not intercept Safari's native pan/zoom gestures —
   we handle them via Pointer Events instead. */
#roomCanvas { touch-action: none; }

/* ── Pricing panel: collapsible + scrollable ── */
.pricing-panel { transition: width 0.25s ease, min-width 0.25s ease; }
.pricing-panel.collapsed {
  width: 36px !important;
  min-width: 36px !important;
  overflow: hidden;
}
.pricing-panel.collapsed > *:not(.panel-header) { display: none; }
.pricing-panel.collapsed .panel-header {
  padding: 12px 4px;
  flex-direction: column;
  gap: 8px;
  border-bottom: none;
}
.pricing-panel.collapsed .panel-header h2 {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 13px;
  margin: 0;
}
.pricing-panel.collapsed .role-toggle { display: none; }
.pricing-panel.collapsed .panel-collapse-btn { transform: rotate(180deg); }

.panel-collapse-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--b4y-border);
  background: white;
  font-size: 18px;
  line-height: 1;
  color: var(--b4y-blue);
  cursor: pointer;
  transition: transform 0.25s ease;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.panel-collapse-btn:hover { background: var(--b4y-bg); }

/* Make the pricing panel's content area scroll independently */
.pricing-panel .finish-controls,
.pricing-panel .markup-controls,
.pricing-panel .allowance-controls,
.pricing-panel .pricing-breakdown,
.pricing-panel .customer-info {
  flex: 0 0 auto;
}
.pricing-panel {
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ── 44pt minimum touch targets (Apple HIG) ── */
.btn, .btn-secondary, .btn-primary, .btn-preset, .btn-add-wall,
.view-btn, .zoom-btn, .placement-delete, .placement-lock, .placement-rotate,
.wall-elevation, .wall-chain {
  min-height: 44px;
  min-width: 44px;
}
/* Override for small icon buttons that need to stay compact when many are in a row */
.placement-delete, .placement-lock, .placement-rotate,
.wall-elevation, .wall-chain {
  min-height: 36px;
  min-width: 36px;
}
.btn-icon { min-width: 44px; min-height: 44px; }

/* ── Selected cabinet outline (matches Figma 2px accent) ── */
.selected-cabinet-marker {
  /* drawn on canvas — no CSS needed; here for documentation */
}

/* ── Present mode (fullscreen canvas) ── */
body.present-mode header.topbar,
body.present-mode .catalog-panel,
body.present-mode .pricing-panel,
body.present-mode .wall-editor,
body.present-mode .placement-list,
body.present-mode .canvas-help,
body.present-mode .view-controls,
body.present-mode .zoom-controls {
  display: none !important;
}
body.present-mode .layout {
  grid-template-columns: 1fr;
  height: 100vh;
  padding: 0;
}
body.present-mode .room-panel {
  border-radius: 0;
  border: none;
}
body.present-mode .panel-header {
  background: var(--b4y-blue);
  color: white;
  padding: 12px 20px;
}
body.present-mode .panel-header h2 { color: white; }
body.present-mode .room-controls { display: none; }
body.present-mode #roomCanvas {
  width: 100%;
  height: calc(100vh - 60px);
}
.exit-present-btn {
  position: fixed;
  top: 12px; right: 12px;
  z-index: 100;
  padding: 10px 16px;
  background: white;
  color: var(--b4y-blue);
  border: 2px solid var(--b4y-blue);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.exit-present-btn:hover { background: var(--b4y-blue); color: white; }

/* ── Customer-safe lock mode — disables catalog drag + delete + edit ── */
body.customer-safe .catalog-item,
body.customer-safe .placement-delete,
body.customer-safe .placement-rotate,
body.customer-safe .placement-lock,
body.customer-safe .wall-row input,
body.customer-safe .btn-add-wall {
  pointer-events: none;
  opacity: 0.5;
}
body.customer-safe .catalog-item { cursor: not-allowed; }

/* ── Long-press contextual menu ── */
.context-menu {
  position: absolute;
  z-index: 200;
  background: white;
  border: 1px solid var(--b4y-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  padding: 4px;
  min-width: 160px;
  font-size: 14px;
}
.context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--b4y-blue);
}
.context-menu button:hover { background: var(--b4y-bg); }
.context-menu button.danger { color: #b91c1c; }
.context-menu button.danger:hover { background: #fef2f2; }
.context-menu hr {
  border: none;
  border-top: 1px solid var(--b4y-border);
  margin: 4px 0;
}

/* ── Responsive container query (Stage Manager / narrow iPad) ── */
@container (max-width: 760px) {
  /* hide catalog and pricing by default at narrow widths — tab nav reveals them */
  .layout { grid-template-columns: 1fr; }
}

/* ── Selected wall outline (lighter than blue glow) ── */
.wall-row.selected {
  border-color: var(--b4y-accent);
  background: #eff6ff;
}

/* ════════════════════════════════════════════════════════════════════════
   v28 — iPad PWA layout fixes
   ──────────────────────────────────────────────────────────────────────── */

/* Honor iPad safe-area insets so the topbar isn't covered by the iOS
   status bar (time/battery) when installed as a PWA. */
html, body { height: 100vh; }
.topbar {
  padding-top: max(0px, env(safe-area-inset-top));
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  height: calc(64px + env(safe-area-inset-top));
}
.layout {
  height: calc(100vh - 64px - env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
}

/* When pricing collapses, give that screen real estate back to the canvas */
body:has(.pricing-panel.collapsed) .layout {
  grid-template-columns: 320px 1fr 40px;
}
/* When catalog collapses too */
body:has(.catalog-panel.collapsed) .layout {
  grid-template-columns: 40px 1fr 340px;
}
body:has(.pricing-panel.collapsed):has(.catalog-panel.collapsed) .layout {
  grid-template-columns: 40px 1fr 40px;
}

/* Catalog panel — symmetric collapse (mirrors pricing) */
.catalog-panel { transition: width 0.25s ease, min-width 0.25s ease; }
.catalog-panel.collapsed {
  width: 36px !important;
  min-width: 36px !important;
  overflow: hidden;
}
.catalog-panel.collapsed > *:not(.panel-header) { display: none; }
.catalog-panel.collapsed .panel-header {
  padding: 12px 4px;
  flex-direction: column;
  gap: 8px;
  border-bottom: none;
}
.catalog-panel.collapsed .panel-header h2 {
  writing-mode: vertical-rl;
  font-size: 13px;
  margin: 0;
}
/* On the catalog side, the collapse arrow points LEFT to expand (vs right for pricing) */
.catalog-panel .panel-collapse-btn { transform: rotate(180deg); }
.catalog-panel.collapsed .panel-collapse-btn { transform: rotate(0deg); }

/* Bigger zoom buttons for iPad */
.zoom-btn {
  min-width: 44px; min-height: 44px;
  font-size: 18px;
  font-weight: 600;
}
.zoom-readout { min-width: 56px; text-align: center; font-size: 14px; }

/* Topbar layout adapts to narrow widths — wrap action buttons */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; height: auto; min-height: 64px; padding-bottom: 8px; }
  .topbar-actions { flex-wrap: wrap; row-gap: 6px; }
  .brand-title { font-size: 14px; }
  .brand-sub { display: none; }
}

/* Hide-both-panels toggle (different from Present mode — keeps topbar) */
body.canvas-fullscreen .catalog-panel,
body.canvas-fullscreen .pricing-panel {
  display: none !important;
}
/* v29 fix: must use !important to beat the :has(.collapsed) rules above */
body.canvas-fullscreen .layout {
  grid-template-columns: 1fr !important;
}

/* ════════════════════════════════════════════════════════════════════════
   v29 — Toolbar relocation + legend popover + bonus polish
   ──────────────────────────────────────────────────────────────────────── */

/* Layout panel header — now a flex toolbar */
.room-panel-header {
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 16px;
}
.room-panel-header h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  flex: 0 0 auto;
}
.cabinet-count-chip {
  display: inline-block;
  padding: 2px 8px;
  background: var(--b4y-bg);
  color: var(--b4y-text-muted);
  border: 1px solid var(--b4y-border);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  min-width: 24px;
  text-align: center;
}
.cabinet-count-chip:not(:empty)[data-count]:not([data-count="0"]) {
  background: #eff6ff;
  color: var(--b4y-accent);
  border-color: var(--b4y-accent);
}

/* View controls — now inline in header (no longer overlay) */
.room-panel-header .view-controls {
  position: static;     /* override any prior absolute */
  display: inline-flex;
  gap: 4px;
  background: transparent;
  padding: 0;
  border: none;
  box-shadow: none;
}
.room-panel-header .view-controls .view-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  min-height: 36px;
  min-width: 48px;
}

/* Zoom controls — now inline at the right end of header */
.room-panel-header .zoom-controls {
  position: static;     /* override any prior absolute */
  display: inline-flex;
  gap: 4px;
  background: transparent;
  padding: 0;
  border: none;
  box-shadow: none;
  margin-left: auto;     /* pushes them to the far right */
}
.room-panel-header .zoom-readout {
  min-width: 50px;
  text-align: center;
  font-size: 13px;
  padding: 0 6px;
  align-self: center;
  color: var(--b4y-text);
}

/* Bonus: distinct Fit button — accent outline so it stands out */
.zoom-btn-fit {
  background: white !important;
  color: var(--b4y-accent) !important;
  border: 2px solid var(--b4y-accent) !important;
  font-weight: 600;
}
.zoom-btn-fit:hover { background: var(--b4y-bg) !important; }

/* Canvas wrapper — clean (no absolute overlays now) */
.canvas-wrapper { position: relative; }

/* Legend toggle button — bottom-right corner of canvas */
.legend-toggle-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: white;
  color: var(--b4y-blue);
  border: 1px solid var(--b4y-border);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
}
.legend-toggle-btn:hover { background: var(--b4y-bg); border-color: var(--b4y-accent); color: var(--b4y-accent); }

/* Legend popover */
.canvas-legend-popover {
  position: absolute;
  right: 12px;
  bottom: 56px;
  background: white;
  border: 1px solid var(--b4y-border);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 6;
  font-size: 12px;
  min-width: 140px;
}
.canvas-legend-popover.hidden { display: none; }
.canvas-legend-popover .legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}
.canvas-legend-popover .legend-swatch {
  width: 16px; height: 12px;
  border: 1px solid #37434C;
  display: inline-block;
}

/* Hide the canvas-help text on narrow screens (already cluttered) */
@media (max-width: 900px) {
  .canvas-help { font-size: 11px; }
  /* Toolbar wraps onto two rows on narrow iPad — make it tighter */
  .room-panel-header { padding: 8px 12px; gap: 8px; }
  .room-panel-header .room-controls { width: 100%; }
}

/* v28.1: Present mode safe-area + canvas sizing */
body.present-mode .panel-header {
  padding-top: max(12px, env(safe-area-inset-top));
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
}
body.present-mode .canvas-wrapper {
  height: calc(100vh - 60px - env(safe-area-inset-top));
}
body.present-mode #roomCanvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
body.present-mode .legend-toggle-btn { display: none; }
body.present-mode .canvas-legend-popover { display: none; }

/* canvas-fullscreen safe-area too */
body.canvas-fullscreen .canvas-wrapper {
  width: 100%;
  height: 100%;
}
body.canvas-fullscreen #roomCanvas {
  width: 100% !important;
  height: 100% !important;
}

