/* ---------- VERSION 1.2 INTERFACE ----------
   Everything is scoped to body.ui-v12 so Version 1.1 offices see no change. */

body:not(.ui-v12) .v12-only { display: none !important; }
body.ui-v12 header.topbar,
body.ui-v12 .tabs,
body.ui-v12 #normalToolbarActions,
body.ui-v12 #bridgeToolbarActions,
body.ui-v12 .builder-left > p.hint { display: none !important; }

body.ui-v12 { background: #f2f2f5; }
body.ui-v12.v12-modal-open { overflow: hidden; }
.v12-topbar, .v12-menu, .v12-finish-side,
body.ui-v12 .builder-left, body.ui-v12 .builder-toolbar {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', var(--app-font), sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* top bar */
.v12-topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 20px; box-sizing: border-box;
  background: rgba(250,250,252,0.9); -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid #e0e0e4; color: #1d1d1f;
}
.v12-icon-btn {
  width: 38px; height: 38px; border: 0; border-radius: 9px; background: transparent; color: #3a3a3c;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; margin: 0; padding: 0;
}
.v12-icon-btn:hover, .v12-icon-btn.on { background: #e3e3e8; }
.v12-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.v12-title #v12PageTitle { font-size: 15px; font-weight: 600; white-space: nowrap; }
.v12-status { font-size: 13px; color: #8e8e93; white-space: nowrap; }
.v12-spacer { flex: 1; }
.v12-office { font-size: 13px; color: #6e6e73; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v12-startover {
  height: 34px; padding: 0 12px; margin: 0; border: 0; border-radius: 9px; background: transparent;
  font-size: 13px; font-weight: 600; color: #b3261e; cursor: pointer; white-space: nowrap;
}
.v12-startover:hover { background: #f6e3e1; }

/* side menu */
.v12-menu-backdrop { position: fixed; inset: 56px 0 0 0; background: rgba(28,28,30,0.18); z-index: 59; }
.v12-menu {
  position: fixed; top: 56px; left: 0; bottom: 0; width: 290px; box-sizing: border-box; z-index: 60;
  display: flex; flex-direction: column; gap: 4px; padding: 18px 14px;
  background: rgba(238,238,242,0.98); box-shadow: 8px 0 30px rgba(0,0,0,0.12);
  animation: v12-slide 0.18s ease-out;
}
.v12-menu[hidden], .v12-menu-backdrop[hidden], .v12-finish-backdrop[hidden] { display: none !important; }
@keyframes v12-slide { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
.v12-nav-item {
  display: flex; align-items: center; gap: 12px; height: 46px; padding: 0 14px; margin: 0;
  border: 0; border-radius: 11px; background: transparent; font-size: 15px; font-weight: 500; color: #3a3a3c;
  text-align: left; cursor: pointer;
}
.v12-nav-item i { font-size: 20px; }
.v12-nav-item:hover { background: rgba(255,255,255,0.6); }
.v12-nav-item.on { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.06); font-weight: 600; color: #1d1d1f; }
.v12-nav-item.on i { color: var(--sage); }
.v12-menu-spacer { flex: 1; }
.v12-menu-footer { display: flex; align-items: center; gap: 10px; padding: 12px 6px 0; border-top: 1px solid #d8d8dd; }
.v12-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #d4d4d9; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #3a3a3c;
}
.v12-menu-office { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: #1d1d1f; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v12-logout { height: 32px; padding: 0 10px; margin: 0; border: 0; border-radius: 8px; background: #e2e2e7; font-size: 12px; font-weight: 600; color: #3a3a3c; cursor: pointer; }

/* layout */
body.ui-v12 .wrap { max-width: 1680px; padding: 20px 24px 40px; }
body.ui-v12 .builder-layout { grid-template-columns: 400px minmax(0, 1fr); gap: 24px; }
body.ui-v12 .builder-right { top: 76px; max-height: calc(100vh - 96px); }

/* product list */
body.ui-v12 .category-search input { height: 42px; border: 0; border-radius: 11px; background: #e8e8ec; font-size: 15px; }
.v12-filter { display: grid; grid-template-columns: 1fr 1fr; padding: 2px; margin: 0 0 14px; border-radius: 9px; background: #e6e6ea; }
.v12-filter button { height: 32px; margin: 0; border: 0; border-radius: 7px; background: transparent; font-size: 13px; font-weight: 500; color: #3a3a3c; cursor: pointer; }
.v12-filter button.on { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.1); font-weight: 600; color: #1d1d1f; }
body.ui-v12 .category-section { border: 0; border-radius: 12px; background: #fff; box-shadow: 0 0 0 1px #e6e6ea; margin-bottom: 8px; }
body.ui-v12 .category-header { padding: 12px 14px; background: #fff; }
body.ui-v12 .category-header:hover { background: #fafafc; }
body.ui-v12 .category-header .cat-title { text-transform: none; letter-spacing: 0; font-size: 15px; font-weight: 600; color: #1d1d1f; }
body.ui-v12 .category-header .badge-count { background: transparent; color: var(--sage); padding: 0; font-weight: 600; }
body.ui-v12 .category-header .cat-count { color: #8e8e93; }
body.ui-v12 .category-header .chevron {
  width: 28px; height: 28px; border-radius: 50%; background: #efeff2; color: #3a3a3c;
  align-items: center; justify-content: center; font-size: 14px; transform: rotate(90deg);
}
body.ui-v12 .category-section.open .chevron { transform: rotate(-90deg); }
body.ui-v12 .category-section.open .category-header { border-bottom: 1px solid #ececef; }
body.ui-v12 .category-body { padding: 0; background: #fff; }
body.ui-v12 .product-grid { display: flex; flex-direction: column; gap: 0; }
body.ui-v12 .product-tile.v12-row {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 14px; box-sizing: border-box;
  border: 0; border-top: 1px solid #ececef; border-radius: 0; background: #fff; box-shadow: none; cursor: default;
}
body.ui-v12 .product-grid .product-tile.v12-row:first-child { border-top: 0; }
body.ui-v12 .product-tile.v12-row:hover { background: #fff; box-shadow: none; }
body.ui-v12 .product-tile.v12-row.selected { background: #fff; }
body.ui-v12 .product-tile.v12-row { padding-left: 4px; gap: 4px; }
.v12-check-btn {
  width: 48px; height: 48px; flex: none; margin: -4px 4px -4px 0; padding: 0; border: 0; border-radius: 50%;
  background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.v12-check-btn:hover .v12-check { border-color: var(--sage); }
.v12-check-btn:active { background: #efeff2; }
.v12-check-btn:focus-visible { outline: 2px solid var(--sage); outline-offset: -4px; }
.v12-check {
  width: 24px; height: 24px; flex: none; box-sizing: border-box; border-radius: 50%; border: 1.5px solid #c7c7cc;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px;
}
.v12-row.selected .v12-check, .v12-row.selected .v12-check-btn:hover .v12-check { background: var(--sage); border-color: var(--sage); }
.v12-row-text { flex: 1; min-width: 0; line-height: 1.3; }
.v12-row-text .name { display: block; font-weight: 500; font-size: 14px; color: #1d1d1f; }
.v12-brand { display: block; font-size: 12px; color: #6e6e73; }
.v12-seg { display: flex; flex: none; padding: 2px; border-radius: 8px; background: #efeff2; }
.v12-seg button { height: 28px; padding: 0 10px; margin: 0; border: 0; border-radius: 6px; background: transparent; font-size: 12px; font-weight: 600; color: #6e6e73; cursor: pointer; }
.v12-seg button.on { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.14); color: #1d1d1f; }
body.ui-v12 .builder-left .card { border-radius: 14px; box-shadow: 0 0 0 1px #e6e6ea; border: 0; }

/* toolbar above the sheet */
body.ui-v12 .builder-toolbar {
  flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px;
  background: transparent; border: 0; box-shadow: none; padding: 0 0 4px; margin-bottom: 14px;
}
body.ui-v12 .builder-toolbar-notes { flex: 1; min-width: 0; gap: 8px; }
body.ui-v12 .note-toggle-btn { border-radius: 10px; border-color: #dcdce1; background: #fff; font-weight: 600; color: #1d1d1f; }
body.ui-v12 .note-toggle-btn.active { background: #1d1d1f; border-color: #1d1d1f; color: #fff; }
body.ui-v12 #v12ToolbarActions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
body.ui-v12 #v12ToolbarActions .secondary { border-radius: 10px; }
.v12-finish-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 22px; margin: 0;
  border: 0; border-radius: 12px; background: var(--sage); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.16);
}
.v12-finish-btn:hover { background: var(--sage-dark); }
body.ui-v12 #sheetPreview .sheet { box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 14px 44px rgba(0,0,0,0.10); }

/* on-screen QR placeholder (the real code is only on the finished sheet) */
.v12-qr-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; box-sizing: border-box;
  background: repeating-linear-gradient(45deg, #f4f4f6, #f4f4f6 6px, #ececf0 6px, #ececf0 12px);
  color: #6e6e73; text-align: center; font-size: 9.5px; line-height: 1.25; font-weight: 600;
}
.v12-qr-placeholder i { font-size: 30px; color: #8e8e93; }

/* finish */
.v12-finish-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(28,28,30,0.32); display: flex; align-items: center; justify-content: center; padding: 20px; box-sizing: border-box; }
.v12-finish {
  width: min(1060px, 100%); height: min(760px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) 380px;
  background: #f5f5f7; border-radius: 22px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,0.3);
}
.v12-finish-preview { display: flex; flex-direction: column; gap: 12px; padding: 24px; background: #e9e9ec; min-height: 0; }
.v12-finish-label { font-size: 13px; font-weight: 600; color: #6e6e73; font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif; }
.v12-finish-sheets { flex: 1; overflow: auto; min-height: 0; }
.v12-sheet-scale { zoom: 0.78; }
.v12-finish-side { display: flex; flex-direction: column; gap: 12px; padding: 26px; overflow-y: auto; color: #1d1d1f; }
.v12-finish-side h2 { text-transform: none; margin: 0 0 4px; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: #1d1d1f; font-family: inherit; }
.v12-name-label { margin: 0; font-size: 13px; font-weight: 600; color: #3a3a3c; }
.v12-muted { display: block; font-weight: 400; color: #8e8e93; margin-top: 2px; }
#v12PatientName { height: 44px; border: 1px solid #d2d2d7; border-radius: 10px; background: #fff; font-size: 15px; }
.v12-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.v12-big {
  display: flex; align-items: center; gap: 14px; min-height: 62px; padding: 8px 16px; margin: 0; box-sizing: border-box;
  border: 1px solid #dcdce1; border-radius: 14px; background: #fff; color: #1d1d1f; text-align: left; cursor: pointer;
}
.v12-big:hover { border-color: #b9b9c0; }
.v12-big strong { display: block; font-size: 16px; font-weight: 600; }
.v12-big small { display: block; font-size: 13px; color: #6e6e73; }
.v12-big-icon { width: 38px; height: 38px; flex: none; border-radius: 10px; background: #f0f0f3; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.v12-big.v12-primary { background: var(--sage); border-color: var(--sage); color: #fff; box-shadow: 0 6px 18px rgba(0,0,0,0.16); }
.v12-big.v12-primary:hover { background: var(--sage-dark); }
.v12-big.v12-primary small { color: rgba(255,255,255,0.85); }
.v12-big.v12-primary .v12-big-icon { background: rgba(255,255,255,0.2); }
.v12-finish-status { min-height: 20px; display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--sage-dark); }
.v12-finish-status i { font-size: 17px; }
.v12-new-btn, .v12-edit-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; height: 46px; margin: 0;
  border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.v12-new-btn { border: 1.5px solid var(--sage); background: #fff; color: var(--sage); }
.v12-new-btn:hover { background: var(--sage-tint); }
.v12-edit-btn { border: 0; background: #e6e6ea; color: #1d1d1f; }
.v12-edit-btn:hover { background: #dcdce1; }

@media (max-width: 900px) {
  body.ui-v12 .builder-layout { grid-template-columns: 1fr; }
  body.ui-v12 .builder-right { position: static; max-height: none; }
  .v12-office { display: none; }
  .v12-finish { grid-template-columns: 1fr; height: 100%; overflow-y: auto; }
  .v12-finish-preview { max-height: 45vh; }
}
@media print {
  .v12-topbar, .v12-menu, .v12-menu-backdrop, .v12-finish-backdrop { display: none !important; }
}
