: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; table-layout: fixed; }
.proposal-table th, .proposal-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--b4y-border); overflow-wrap: break-word; word-wrap: break-word; }
.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); }

/* v34: Old "loud green pill always-visible" .app-version-badge rules removed.
   The new rules live near the v34 CSS block at the bottom of this file:
   hidden by default; show as a yellow "update available" pill when the
   service worker signals NEW_VERSION. Keeps the topbar clean in normal use. */

/* ════════════════════════════════════════════════════════════════════════
   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,
body.customer-safe .overflow-menu-btn,
body.customer-safe .overflow-menu-item {
  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.
   v35a: Semi-transparent (75%) by default so cabinets at the corner are
   still readable underneath; fully opaque on hover/focus/popover-open. */
.legend-toggle-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: white;
  color: var(--b4y-blue);
  border: 1px solid var(--b4y-border);
  font-size: 14px;
  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;
  opacity: 0.75;
  transition: opacity 0.15s, background 0.15s;
}
.legend-toggle-btn:hover,
.legend-toggle-btn:focus,
.legend-toggle-btn.legend-open {
  opacity: 1;
  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;
}

/* ════════════════════════════════════════════════════════════════════════
   v30 — Chrome reduction (topbar 64→40, Settings tabs, auto-hide, etc.)
   ──────────────────────────────────────────────────────────────────────── */

/* Shrink the topbar */
.topbar {
  height: calc(44px + env(safe-area-inset-top));
  padding-top: max(2px, env(safe-area-inset-top));
  padding-bottom: 2px;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.brand-title-compact { font-size: 15px; font-weight: 600; }
.brand-icon { height: 32px; }

/* Topbar auto-hide when idle on canvas (Procreate pattern). The .topbar-faded
   class is added by JS after ~3s of canvas interaction without topbar use.
   Hovering / tapping the topbar restores full opacity. */
.topbar.topbar-faded { opacity: 0.25; }
.topbar.topbar-faded:hover,
.topbar.topbar-faded:focus-within { opacity: 1; }

/* Layout height accounts for the new shorter topbar */
.layout {
  height: calc(100vh - 44px - env(safe-area-inset-top));
}

/* Projects switcher — merged dropdown */
.projects-dropdown {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  min-height: 32px;
  min-width: auto;
}
.projects-dropdown .dropdown-caret { font-size: 10px; opacity: 0.7; }

/* Topbar buttons — slightly smaller than the 44pt baseline since v30 is denser */
.topbar .btn { min-height: 32px; padding: 6px 12px; font-size: 13px; }
.topbar .btn-icon { min-height: 32px; min-width: 32px; font-size: 16px; padding: 0; }
.topbar .btn-primary { font-size: 13px; padding: 6px 16px; }

/* Smaller Add wall / Add island / Add peninsula buttons (per user request) —
   words stay the same size; padding shrinks. */
.btn-add-wall {
  padding: 5px 10px;
  min-height: 28px;
  min-width: 0;
  font-size: 12px;
}
.btn-add-island { padding: 5px 10px; min-height: 28px; min-width: 0; font-size: 12px; }

/* Compact Clear button */
.btn-clear-compact { padding: 4px 10px; font-size: 12px; min-height: 28px; min-width: 0; }

/* Fit button — accent outline so it stands out.
   v32: lived inside .preset-row (next to Galley).
   v33: now lives inside .room-controls-essentials (always-visible). */
.preset-row .zoom-btn-fit,
.room-controls-essentials .zoom-btn-fit {
  margin-left: 0;
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12px;
  background: white;
  color: var(--b4y-accent);
  border: 2px solid var(--b4y-accent);
  font-weight: 600;
}

/* Zoom readout becomes a clickable chip → opens preset popover */
.zoom-readout-btn {
  background: white;
  border: 1px solid var(--b4y-border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  min-height: 28px;
  min-width: 0;
  cursor: pointer;
  color: var(--b4y-text);
}
.zoom-readout-btn:hover { background: var(--b4y-bg); border-color: var(--b4y-accent); }

/* Zoom popover (anchored relative to zoom-controls in panel header) */
.zoom-popover {
  position: absolute;
  z-index: 30;
  background: white;
  border: 1px solid var(--b4y-border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 100px;
}
.zoom-popover.hidden { display: none; }
.zoom-popover button {
  background: transparent;
  border: none;
  text-align: left;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.zoom-popover button:hover { background: var(--b4y-bg); }

/* Settings modal — left-rail tabs */
.settings-modal-content {
  width: min(900px, 95vw);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.settings-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  flex: 1;
  overflow: hidden;
  min-height: 400px;
}
.settings-tabs {
  background: var(--b4y-bg);
  border-right: 1px solid var(--b4y-border);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.settings-tab {
  background: transparent;
  border: none;
  text-align: left;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--b4y-text);
  border-left: 3px solid transparent;
  transition: background 0.15s;
}
.settings-tab:hover { background: white; }
.settings-tab.active {
  background: white;
  border-left-color: var(--b4y-accent);
  color: var(--b4y-blue);
  font-weight: 600;
}
.settings-panes { padding: 24px; overflow-y: auto; }
.settings-pane { display: none; }
.settings-pane.active { display: block; }
.settings-pane h4 {
  margin: 0 0 8px;
  color: var(--b4y-blue);
  font-size: 16px;
}
.settings-help { color: var(--b4y-text-muted); font-size: 13px; margin: 0 0 16px; }
.settings-help-small { color: var(--b4y-text-muted); font-size: 12px; display: block; margin-top: 4px; }
.settings-row {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.settings-row label { font-size: 13px; cursor: pointer; }
.settings-row label input[type="checkbox"] { margin-right: 6px; }
.settings-row .btn { width: 100%; max-width: 320px; text-align: left; padding: 10px 14px; }
.settings-row .settings-file-btn { display: inline-block; cursor: pointer; }
.settings-about-row { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }

@media (max-width: 700px) {
  .settings-body { grid-template-columns: 1fr; }
  .settings-tabs {
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--b4y-border);
    padding: 4px;
    gap: 4px;
    overflow-x: auto;
  }
  .settings-tab { padding: 8px 12px; border-left: none; border-bottom: 3px solid transparent; flex: 0 0 auto; }
  .settings-tab.active { border-left: none; border-bottom-color: var(--b4y-accent); }
}

/* ════════════════════════════════════════════════════════════════════════
   v31 — Walls popover (A2) + cabinet floating toolbar (B2)
   ──────────────────────────────────────────────────────────────────────── */

/* Compact + Add wall/island/peninsula buttons inline in layout header */
.btn-add-compact {
  padding: 5px 10px;
  min-height: 28px;
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
}

/* Selection toolbar — floats above the selected cabinet (Figma pattern) */
.selection-toolbar {
  position: absolute;
  z-index: 12;
  display: flex;
  gap: 2px;
  background: var(--b4y-blue);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  /* Initially positioned off-screen; JS repositions on selection */
  top: -200px;
  left: 0;
  pointer-events: auto;
}
.selection-toolbar.hidden { display: none; }
.selection-toolbar button {
  background: transparent;
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.selection-toolbar button:hover { background: rgba(255,255,255,0.15); }
.selection-toolbar button.danger:hover { background: #b91c1c; }
.selection-toolbar button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
/* v34: Removed dead [data-action="edit"]/[data-action="swap"] dim styling
   — those buttons no longer exist in the DOM (they fired "coming in v32"
   alerts). Will be re-added when Edit/Swap are actually built. */
/* Pointer arrow connecting toolbar to cabinet */
.selection-toolbar::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px; height: 10px;
  background: var(--b4y-blue);
}

/* Wall properties popover */
.wall-props-popover {
  position: absolute;
  z-index: 11;
  background: white;
  border: 2px solid var(--b4y-accent);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  min-width: 240px;
  max-width: 280px;
}
.wall-props-popover.hidden { display: none; }
.wpp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.wpp-title { font-weight: 600; color: var(--b4y-blue); font-size: 14px; }
.wpp-close {
  background: transparent;
  border: none;
  font-size: 16px;
  color: var(--b4y-text-muted);
  cursor: pointer;
  padding: 4px 8px;
}
.wpp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}
.wpp-row label { font-size: 12px; color: var(--b4y-text-muted); flex: 0 0 auto; }
.wpp-row input, .wpp-row select {
  padding: 6px 8px;
  border: 1px solid var(--b4y-border);
  border-radius: 5px;
  font-size: 13px;
  flex: 1 1 auto;
  min-width: 0;
  font-family: inherit;
}
.wpp-row-actions {
  margin-top: 8px;
  border-top: 1px solid var(--b4y-border);
  padding-top: 10px;
  display: flex;
  gap: 8px;
}
.wpp-row-actions .btn {
  flex: 1;
  padding: 6px 10px;
  font-size: 12px;
  min-height: 30px;
}
.wpp-delete-btn { color: #b91c1c !important; border-color: #b91c1c !important; }

/* First-use hint toast — appears once, dismisses on tap */
.first-use-toast {
  position: absolute;
  z-index: 13;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--b4y-blue);
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  max-width: 320px;
  text-align: center;
  cursor: pointer;
  animation: toast-pulse 2s ease-in-out;
}
.first-use-toast.hidden { display: none; }
@keyframes toast-pulse {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  10% { opacity: 1; transform: translate(-50%, 0); }
  90% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0.7; transform: translate(-50%, 0); }
}

/* ════════════════════════════════════════════════════════════════════════
   v32 — Undo/redo topbar buttons + zoom-beside-fit + smaller view buttons
   ──────────────────────────────────────────────────────────────────────── */

/* Undo / Redo topbar buttons (Apple Pages / SketchUp pattern) */
.topbar-history {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  margin-left: 4px;
  border-left: 1px solid rgba(255,255,255,0.18);
  height: 32px;
}
.btn-undo-redo {
  width: 36px;
  height: 32px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: white;
  border-radius: 6px;
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s;
  line-height: 1;
}
.btn-undo-redo:hover:not(:disabled) {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.35);
}
.btn-undo-redo:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Zoom readout when placed inline in preset row (next to Fit) */
.zoom-readout-inline {
  margin-left: 4px;
  min-height: 28px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
}
/* Hide the (now-empty) original zoom-controls container — but keep the popover
   accessible (it's positioned via JS as fixed when shown). */
.zoom-controls-hidden { display: contents; }
.zoom-controls-hidden > button[aria-hidden] { display: none; }
.zoom-controls-hidden > #zoomPopover { position: fixed; }

/* Smaller ALL/BASE/WALL view-toggle buttons (font size UNCHANGED — only padding/min-height shrink) */
.room-panel-header .view-controls .view-btn {
  padding: 3px 8px;
  min-height: 26px;
  min-width: 36px;
  font-size: 12px;
  font-weight: 500;
}

/* ════════════════════════════════════════════════════════════════════════
   v33 — Toolbar overflow fix
   ────────────────────────────────────────────────────────────────────────
   Three layers of defense against header-toolbar wrap on narrow iPad widths:
     1. Contextual hide:   preset row vanishes once any wall exists
                           (SketchUp iPad / ProKitchen pattern)
     2. Priority overflow: low-frequency actions hide behind ⋯ menu
                           (Material 3 / Figma pattern)
     3. Container queries: the trigger is *panel width*, not viewport width,
                           because either side panel can collapse. Container
                           queries have been baseline-stable since 2023.
   ──────────────────────────────────────────────────────────────────────── */

/* Establish a containment context so @container queries can react to the
   room-panel's own width (independent of viewport / other panels). */
.room-panel {
  container-type: inline-size;
  container-name: roompanel;
}

/* Layout: essentials → preset → overflow.  Essentials stay first; preset
   row can wrap to a second line on its own; overflow button sticks to the
   far right via margin-left:auto on its wrap. */
.room-controls {
  flex-wrap: wrap;
}
.room-controls-essentials {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.overflow-menu-wrap {
  position: relative;
  margin-left: auto;        /* pushes ⋯ to the far right */
  display: inline-flex;
  align-items: center;
}
.overflow-menu-btn {
  min-height: 28px;
  min-width: 32px;
  padding: 0 8px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  background: white;
  border: 1px solid var(--b4y-border);
  border-radius: 6px;
  color: var(--b4y-text);
  cursor: pointer;
}
.overflow-menu-btn:hover {
  background: var(--b4y-bg);
  border-color: var(--b4y-accent);
  color: var(--b4y-accent);
}
.overflow-menu-btn[aria-expanded="true"] {
  background: var(--b4y-bg);
  border-color: var(--b4y-accent);
  color: var(--b4y-accent);
}

/* The dropdown itself — anchored under the ⋯ button. */
.overflow-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  min-width: 200px;
  background: white;
  border: 1px solid var(--b4y-border);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.14);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.overflow-menu.hidden { display: none; }
.overflow-menu-item {
  background: transparent;
  border: none;
  text-align: left;
  padding: 10px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: var(--b4y-text);
  min-height: 40px;        /* generous tap target for iPad */
}
.overflow-menu-item:hover { background: var(--b4y-bg); color: var(--b4y-accent); }
.overflow-menu-item-danger { color: #b91c1c; }
.overflow-menu-item-danger:hover { background: #fef2f2; color: #b91c1c; }
.overflow-menu-divider {
  height: 1px;
  background: var(--b4y-border);
  margin: 4px 0;
}

/* Contextual hide for the preset row — applied by JS when walls.length > 0 */
.preset-row-hidden { display: none !important; }

/* Container-query refinements: when the room panel itself gets narrow
   (typical iPad portrait with both side panels open), tighten gaps so the
   essentials + ⋯ fit on one row alongside the title + view toggle. */
@container roompanel (max-width: 520px) {
  .room-panel-header { gap: 6px; padding: 8px 10px; }
  .room-panel-header h2 { font-size: 14px; }
  .room-controls { gap: 4px; }
  .room-controls-essentials { gap: 3px; }
  /* Drop the "Preset:" label at narrow widths — buttons speak for themselves */
  .preset-row .preset-label { display: none; }
  /* Tighter preset buttons too */
  .preset-row .btn-preset {
    padding: 4px 8px;
    font-size: 11px;
    min-height: 26px;
  }
}
@container roompanel (max-width: 380px) {
  /* Extremely narrow — collapse view-toggle labels to single letters via CSS? No,
     keep semantics intact; instead let the preset row wrap onto its own line. */
  .preset-row { flex-basis: 100%; }
}

/* ════════════════════════════════════════════════════════════════════════
   v34 — Save indicator + dead-UI cleanup + discoverability + persistence
   ──────────────────────────────────────────────────────────────────────── */

/* Save status indicator — sits next to the project chip in the topbar.
   Three states: saving (in-progress), saved (fresh), idle (drift to relative). */
.save-indicator {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--b4y-text-muted);
  padding: 4px 10px;
  border-radius: 12px;
  margin-left: 4px;
  transition: opacity 0.2s, color 0.2s, background 0.2s;
  min-height: 24px;
}
.save-indicator:empty { display: none; }
.save-indicator-saving {
  color: var(--b4y-accent);
  background: #eff6ff;
}
.save-indicator-saving::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--b4y-accent);
  margin-right: 6px;
  animation: b4y-saveblink 1s infinite;
}
.save-indicator-saved {
  color: #047857;
  background: #ecfdf5;
}
.save-indicator-saved::before {
  content: "✓";
  margin-right: 4px;
  font-weight: 700;
}
.save-indicator-idle {
  color: var(--b4y-text-muted);
  background: transparent;
}
@keyframes b4y-saveblink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Version badge — hidden by default, becomes visible when SW flags an update */
.app-version-badge {
  display: none;
  font-size: 11px;
  padding: 2px 8px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  border-radius: 10px;
  font-weight: 600;
  margin-left: 4px;
}
.app-version-badge.update-available {
  display: inline-block;
  animation: b4y-versionnudge 2s ease-in-out 2;
}
@keyframes b4y-versionnudge {
  0%, 100% { transform: scale(1); }
  20% { transform: scale(1.08); }
}

/* Touch device variant of canvas-help (mutually exclusive with desktop variant) */
.canvas-help-touch { display: none; }
body.touch-device .canvas-help-desktop { display: none; }
body.touch-device .canvas-help-touch { display: block; }

/* Catalog drag-handle glyph — signals "this is grabbable" on iPad */
.catalog-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.catalog-item-drag-handle {
  flex: 0 0 auto;
  color: var(--b4y-text-muted);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -2px;
  cursor: grab;
  padding-top: 2px;
  opacity: 0.55;
  user-select: none;
}
.catalog-item:hover .catalog-item-drag-handle { opacity: 1; color: var(--b4y-accent); }
.catalog-item-body { flex: 1 1 auto; min-width: 0; }

/* Countertop "override active" visual cue:
   - The override input gets an accent border so the user sees "this is overriding"
   - The LF input dims so the user sees "this is being ignored" */
.ct-override-active {
  border: 2px solid var(--b4y-accent) !important;
  background: #eff6ff !important;
  font-weight: 600;
}
.ct-pricing-overridden {
  opacity: 0.55;
  text-decoration: line-through;
  text-decoration-color: var(--b4y-text-muted);
}

/* Keyboard shortcut cheat-sheet modal */
.kbd-help-content {
  width: min(640px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}
.kbd-help-body {
  overflow-y: auto;
  padding: 12px 20px 20px;
}
.kbd-help-body h4 {
  margin: 16px 0 6px;
  color: var(--b4y-blue);
  font-size: 14px;
}
.kbd-help-body h4:first-child { margin-top: 0; }
.kbd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.kbd-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--b4y-border);
}
.kbd-table td:first-child { width: 45%; }
.kbd-table kbd {
  display: inline-block;
  background: var(--b4y-bg);
  border: 1px solid var(--b4y-border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  margin: 0 1px;
  box-shadow: 0 1px 0 var(--b4y-border);
}

/* Selection toolbar — adjust to 3 buttons now that Edit + Swap are hidden (v34) */
.selection-toolbar > [data-action="edit"],
.selection-toolbar > [data-action="swap"] { display: none; }

/* ════════════════════════════════════════════════════════════════════════
   v35a — Recently-used cabinets, tap-to-place, twin-logo, effective margin
   ──────────────────────────────────────────────────────────────────────── */

/* Recently-used cabinets row at top of catalog */
.catalog-recent-row {
  padding: 8px 10px 10px;
  background: linear-gradient(180deg, #f6faff 0%, #ffffff 100%);
  border-bottom: 1px solid var(--b4y-border);
  margin: 0 0 8px;
}
.catalog-recent-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--b4y-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.catalog-recent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.catalog-recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: white;
  border: 1px solid var(--b4y-border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  min-height: 30px;
  color: var(--b4y-text);
  transition: background 0.15s, border-color 0.15s;
}
.catalog-recent-chip:hover {
  background: var(--b4y-bg);
  border-color: var(--b4y-accent);
  color: var(--b4y-accent);
}
.catalog-recent-chip.armed {
  background: var(--b4y-accent);
  color: white;
  border-color: var(--b4y-accent);
}
.catalog-recent-chip-sku { font-weight: 600; }
.catalog-recent-chip-size {
  font-size: 11px;
  color: var(--b4y-text-muted);
}
.catalog-recent-chip:hover .catalog-recent-chip-size,
.catalog-recent-chip.armed .catalog-recent-chip-size {
  color: inherit;
  opacity: 0.85;
}

/* Tap-to-place: armed catalog row + hint banner */
.catalog-item.armed {
  background: #eff6ff;
  border-left: 3px solid var(--b4y-accent);
  box-shadow: inset 0 0 0 1px var(--b4y-accent);
}
body.tap-to-place-armed #roomCanvas { cursor: crosshair; }
.tap-to-place-hint {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 14;
  background: var(--b4y-accent);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  display: flex; align-items: center; gap: 10px;
}
.tap-to-place-hint.hidden { display: none; }
.tap-to-place-hint strong { font-weight: 700; }
.tap-to-place-cancel {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  color: white;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.tap-to-place-cancel:hover { background: rgba(255,255,255,0.32); }

/* Twin-logo brand modal layout */
.brand-logo-twin {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 8px;
}
.brand-logo-twin-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.brand-logo-twin-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--b4y-text);
}
.brand-logo-twin-hint {
  font-weight: 400;
  color: var(--b4y-text-muted);
  font-size: 11px;
}
.brand-logo-preview-wide {
  /* Wider aspect ratio for the proposal-PDF logo preview */
  aspect-ratio: 3 / 1;
  min-height: 70px;
}
@media (max-width: 600px) {
  .brand-logo-twin { grid-template-columns: 1fr; }
}

/* Effective cabinet margin row — subtle styling so it reads as derived info */
.price-row-effective {
  font-size: 11px;
  color: var(--b4y-text-muted);
  font-style: italic;
  padding-left: 16px;
}
.price-row-effective span:last-child {
  color: var(--b4y-accent);
  font-weight: 600;
  font-style: normal;
}

/* ════════════════════════════════════════════════════════════════════════
   v35b.0 — Google Drive Cloud Sync UI (Settings → Data tab)
   ──────────────────────────────────────────────────────────────────────── */

.drive-sync-row {
  flex-direction: column !important;
  align-items: flex-start !important;
  width: 100%;
  max-width: 500px;
}
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--b4y-bg);
  font-size: 13px;
}
.sync-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #9ca3af;
  flex-shrink: 0;
}
.sync-status-dot-connected {
  background: #10b981;            /* green */
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}
.sync-status-dot-stale {
  background: #f59e0b;            /* amber — was connected, refreshing */
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
  animation: b4y-pulse 1.4s ease-in-out infinite;
}
.sync-status-dot-disconnected {
  background: #9ca3af;            /* gray — never connected or disconnected */
}
.sync-status-text {
  color: var(--b4y-text);
  font-weight: 500;
}
@keyframes b4y-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Topbar sync icon — color-coded cloud */
.topbar-sync-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  margin-left: 4px;
  transition: background 0.15s;
}
.topbar-sync-icon:hover { background: rgba(255,255,255,0.1); }
.topbar-sync-icon[data-status="synced"]   { color: #10b981; }
.topbar-sync-icon[data-status="syncing"]  { color: #f59e0b; animation: b4y-pulse 1.4s ease-in-out infinite; }
.topbar-sync-icon[data-status="error"]    { color: #ef4444; }
.topbar-sync-icon[data-status="offline"]  { color: #9ca3af; }

/* Conflict resolution modal */
.conflict-modal-content { width: min(560px, 95vw); }
.conflict-body { padding: 16px 20px 20px; }
.conflict-body p { margin: 0 0 16px; font-size: 14px; color: var(--b4y-text); }
.conflict-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.conflict-option {
  border: 2px solid var(--b4y-border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.conflict-option:hover { border-color: var(--b4y-accent); }
.conflict-option h4 { margin: 0 0 4px; color: var(--b4y-blue); font-size: 14px; }
.conflict-meta { font-size: 12px; color: var(--b4y-text-muted); }
.conflict-option button { margin-top: 8px; }
@media (max-width: 480px) {
  .conflict-options { grid-template-columns: 1fr; }
}

/* v35c.0 — Subtle "pulled changes" sync toast */
.sync-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #047857;
  color: white;
  padding: 10px 18px;
  border-radius: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
  font-size: 13px;
  font-weight: 500;
  font-family: -apple-system, sans-serif;
  z-index: 9999;
  transition: opacity 0.25s ease, transform 0.25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sync-toast::before {
  content: "☁";
  font-size: 16px;
}
.sync-toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  pointer-events: none;
}
