:root {
  color-scheme: light;
  --ink: #1b2421;
  --muted: #66736f;
  --line: #d8dfdc;
  --bg: #f5f7f4;
  --panel: #ffffff;
  --left-surface: #edf3f6;
  --left-accent: #2f6172;
  --left-line: #b9cbd2;
  --quote-surface: #fffefa;
  --soft-surface: #f3f7f5;
  --accent: #1f3a35;
  --accent-2: #f4c542;
  --danger: #9d3028;
  --ok: #2f6f4e;
  --shadow: 0 10px 28px rgba(31, 58, 53, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

button,
.button,
input,
select,
textarea {
  font: inherit;
}

button,
.button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  cursor: pointer;
  text-align: center;
}

button.secondary {
  background: #fff;
  color: var(--accent);
}

button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

input,
select,
textarea {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  width: 100%;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  padding: 10px max(14px, env(safe-area-inset-left)) 10px max(14px, env(safe-area-inset-right));
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.account-bar {
  margin-left: auto;
  display: grid;
  grid-template-columns: minmax(150px, 220px) auto auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.account-bar span {
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand strong {
  display: block;
  font-size: 17px;
}

.brand-copy {
  min-width: 0;
}

.brand-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.brand .brand-tagline {
  margin-left: 4px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.brand span {
  display: block;
  max-width: 44vw;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-panel {
  min-height: calc(100vh - 65px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(500px, 100%);
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.region-picker {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.region-picker > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
  overflow: visible;
  white-space: normal;
}

.region-picker select {
  min-height: 38px;
}

.region-context {
  margin: -2px 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.auth-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
  background: var(--soft-surface);
}

.auth-mode button {
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.auth-mode button.active {
  border-bottom-color: var(--accent-2);
  background: #fff;
  color: var(--accent);
  font-weight: 700;
}

.login-box {
  display: grid;
  gap: 12px;
  padding: 22px;
}

.auth-form h1 {
  margin: 3px 0 5px;
  font-size: 24px;
}

.auth-form label:not(.consent-row) {
  display: grid;
  gap: 5px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.auth-kicker {
  color: var(--ok);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-intro,
.auth-note,
.password-help {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.password-field {
  position: relative;
  display: block;
}

.password-field > input {
  width: 100%;
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 44px;
  height: 44px;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: #35534d;
  line-height: 1;
}

.password-toggle::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 14px;
  width: 18px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 50% 50% 48% 48%;
}

.password-toggle::after {
  content: "";
  position: absolute;
  left: 19px;
  top: 19px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.password-toggle[aria-pressed="true"]::before {
  opacity: 0.68;
}

.password-toggle[aria-pressed="true"]::after {
  box-shadow: -8px -6px 0 -2px #eaf2f0;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  background: #eaf2f0;
  color: #173e36;
}

.auth-intro {
  font-size: 14px;
}

.auth-note,
.password-help {
  font-size: 12px;
}

.password-help {
  margin-top: -7px;
}

.auth-text-button {
  justify-self: center;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-text-button:hover,
.auth-text-button:focus-visible {
  background: var(--soft-surface);
}

.reset-code-fields {
  display: grid;
  gap: 12px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.auth-status {
  margin: 0;
  padding: 10px;
  border-left: 3px solid var(--success);
  background: #f1f7f3;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.consent-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  align-items: start;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.consent-row input {
  width: 18px;
  min-height: 18px;
  margin: 1px 0 0;
}

.consent-row a {
  color: var(--accent);
}

.admin-mfa {
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.admin-mfa p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.form-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.company-guidance {
  max-width: 760px;
  margin: 5px 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.app-workspace {
  width: 100%;
  padding: 10px 12px 12px;
  margin: 0;
}

.top-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.top-tabs::-webkit-scrollbar {
  display: none;
}

.mobile-shell-header,
.mobile-bottom-nav,
.mobile-search-tools,
.mobile-search-status,
.mobile-search-submit,
.mobile-add-label,
.mobile-provider-chips,
.mobile-product-info,
.mobile-workflow-control,
.mobile-quote-entry-heading,
.mobile-quote-entry-mount,
.mobile-client-form-heading,
.product-store-link,
.quantity-stepper button,
.quote-quantity-stepper button {
  display: none;
}

.mobile-more-dialog {
  border: 0;
}

.quantity-stepper {
  display: contents;
}

.quote-entry-forms,
.quote-quantity-stepper,
.mobile-quote-filter-actions,
.mobile-client-form-actions {
  display: contents;
}

.product-store-link[hidden] {
  display: none;
}

@keyframes mobile-search-spin {
  to { transform: rotate(360deg); }
}

.tab-button {
  min-height: 38px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
}

.tab-button.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.builder-grid {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) minmax(620px, 1.08fr);
  gap: 12px;
  align-items: stretch;
  height: calc(100dvh - 126px);
  min-height: 610px;
}

.tab-stack {
  display: grid;
  gap: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px;
  min-width: 0;
}

.catalog-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(260px, 1fr) auto auto;
  min-height: 0;
  overflow: hidden;
  background: var(--left-surface);
  border-color: var(--left-line);
  border-top: 6px solid var(--left-accent);
  box-shadow: 0 10px 24px rgba(47, 97, 114, 0.1);
}

.quote-panel {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(80px, 1fr) auto auto auto;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--quote-surface);
  border-color: #aebfb8;
  border-top: 6px solid var(--accent);
  box-shadow: 0 16px 34px rgba(31, 58, 53, 0.14);
  padding: 16px;
}

.panel-head,
.quote-top,
.search-row,
.line-editor,
.service-row,
.manual-grid,
.cost-grid,
.quote-actions,
.company-grid,
.quote-filter-grid,
.client-form,
.client-list-head {
  display: grid;
  gap: 8px;
  align-items: center;
}

.panel-head {
  grid-template-columns: 1fr auto;
  margin-bottom: 10px;
}

.module-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.module-count {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  margin: 0;
}

.panel-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.catalog-panel .panel-head {
  border-bottom: 1px solid var(--left-line);
  padding: 2px 0 12px;
  margin-bottom: 14px;
}

.catalog-panel .panel-head h1 {
  color: #173d4b;
  font-size: 22px;
  font-weight: 800;
}

.panel-title-block {
  display: grid;
  gap: 3px;
}

.panel-kicker {
  display: block;
  color: var(--left-accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.quote-panel-title {
  background: var(--accent);
  border-radius: 5px;
  color: #fff;
  margin: -4px -4px 14px;
  padding: 12px 14px;
}

.quote-panel-title h1 {
  font-size: 23px;
  font-weight: 800;
}

.quote-panel-title .panel-kicker {
  color: #c9dbd4;
  margin-bottom: 3px;
}

h1,
h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.search-row {
  grid-template-columns: 1fr auto;
  margin-bottom: 14px;
}

.catalog-panel input,
.catalog-panel select,
.catalog-panel textarea {
  border-color: #b8c9d0;
}

.catalog-panel input:focus,
.catalog-panel select:focus,
.catalog-panel textarea:focus {
  border-color: var(--left-accent);
  outline: 2px solid rgba(47, 97, 114, 0.14);
}

.quote-top {
  grid-template-columns: 1fr 0.85fr;
  background: #edf4f1;
  border: 1px solid #cbd9d3;
  border-radius: 5px;
  padding: 12px;
  margin-bottom: 14px;
}

.quote-items-area {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  background: #fff;
  border: 1px solid #cbd8d2;
  border-radius: 5px;
  margin-top: 0;
  padding: 12px;
}

.quote-items-head {
  border-bottom: 1px solid #d3ded8;
  margin-bottom: 10px;
  padding-bottom: 8px;
}

.quote-items-head h2 {
  color: var(--accent);
  font-size: 19px;
  font-weight: 800;
}

.line-editor,
.cost-grid {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 10px;
}

.cost-grid {
  background: #edf4f1;
  border: 1px solid #cbd9d3;
  border-radius: 5px;
  padding: 12px;
}

.quote-filter-grid {
  grid-template-columns: 1.2fr 1fr 140px 140px 140px auto;
  margin-bottom: 12px;
}

.quote-meta-grid {
  display: grid;
  grid-template-columns: 1fr 160px 160px;
  gap: 8px;
  margin-bottom: 10px;
}

.quote-meta-grid output {
  min-height: 40px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--accent);
  font-weight: 700;
  padding: 8px 10px;
}

.quote-commercial-details {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  margin-bottom: 10px;
  padding: 9px 10px;
}

.quote-commercial-details summary {
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.quote-commercial-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.quote-commercial-grid .wide {
  grid-column: 1 / -1;
}

.catalog-line-editor {
  margin: 0 0 10px;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.catalog-list,
.quote-items,
.option-list,
.saved-list,
.clients-list {
  display: grid;
  gap: 8px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.admin-stats div {
  border-left: 4px solid var(--accent);
  background: var(--soft-surface);
  padding: 10px;
}

.admin-stats span,
.admin-stats strong {
  display: block;
}

.admin-stats span {
  color: var(--muted);
  font-size: 12px;
}

.admin-stats strong {
  font-size: 22px;
  margin-top: 3px;
}

.admin-user-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 180px auto;
  gap: 8px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.admin-users-list {
  display: grid;
  gap: 8px;
}

.admin-contact-head {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 2px solid var(--accent);
}

.admin-contact-head p {
  margin: 3px 0 0;
}

.admin-contacts-list {
  display: grid;
  gap: 8px;
}

.admin-contact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid #83938f;
  background: #fff;
}

.admin-contact-row.contact-new {
  border-left-color: var(--danger);
  background: #fffaf9;
}

.admin-contact-row.contact-resolved {
  opacity: .78;
}

.admin-contact-message {
  margin: 9px 0 0;
  white-space: pre-wrap;
  line-height: 1.5;
}

.admin-user-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.admin-user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.admin-user-actions select {
  width: 160px;
}

.status-accepted { color: var(--ok); }
.status-rejected,
.status-expired { color: var(--danger); }

.catalog-list {
  min-height: 120px;
  max-height: none;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--left-line);
  border-radius: 5px;
  padding: 8px 6px 8px 8px;
  margin-bottom: 16px;
}

.quote-items {
  min-height: 0;
  max-height: none;
  overflow: auto;
  align-content: start;
  padding-right: 2px;
}

.product-row,
.quote-row,
.option-row,
.saved-row,
.client-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 8px;
  background: #fff;
}

.product-row {
  grid-template-columns: minmax(250px, 1fr) minmax(270px, 0.78fr);
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-left: 4px solid #8faeb9;
}

.catalog-load-more {
  position: sticky;
  bottom: 0;
  z-index: 2;
  width: 100%;
  min-height: 42px;
  margin-top: 8px;
  box-shadow: 0 -6px 12px rgba(47, 97, 114, 0.14);
  background: #e8f1f4;
  border: 1px solid #8faeb9;
  color: #173d4b;
  font-weight: 700;
}

.catalog-load-more:hover {
  background: #dcebee;
}

.provider-empty-state {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  align-items: center;
  padding: 14px;
  border-left: 4px solid #c48b2f;
  background: #fffaf0;
}

.provider-empty-state strong,
.provider-empty-state span {
  grid-column: 1;
}

.provider-empty-state span {
  color: var(--muted);
  font-size: 13px;
}

.provider-empty-state button {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.product-main {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.product-thumbnail,
.product-thumbnail-placeholder {
  width: 68px;
  height: 68px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  overflow: hidden;
  flex: none;
}

.product-thumbnail {
  padding: 0;
  cursor: zoom-in;
}

.product-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.product-thumbnail-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.product-image-dialog {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.product-image-dialog::backdrop {
  background: rgba(20, 35, 32, 0.72);
}

.product-image-dialog-head,
.product-image-dialog-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
}

.product-image-dialog-head {
  border-bottom: 1px solid var(--line);
}

.product-image-dialog-head h2 {
  margin: 0;
  font-size: 18px;
}

.product-image-dialog-foot {
  border-top: 1px solid var(--line);
}

.product-image-stage {
  height: min(66vh, 620px);
  min-height: 260px;
  padding: 16px;
  display: grid;
  place-items: center;
  background: #f4f7f6;
}

.product-image-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.product-action {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) 96px auto;
  gap: 8px;
  align-items: end;
  width: 100%;
}

.product-action input {
  min-height: 36px;
}

.product-price {
  display: grid;
  gap: 2px;
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.product-price strong {
  color: var(--accent);
  font-size: 18px;
  line-height: 1.1;
}

.product-title,
.quote-title {
  font-weight: 700;
  line-height: 1.25;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  background: #f8faf8;
}

.warn {
  color: var(--danger);
}

.ok {
  color: var(--ok);
}

.quote-row {
  grid-template-columns: 1fr auto;
  align-items: start;
  border-left: 4px solid #88a79a;
}

.quote-section {
  display: grid;
  gap: 8px;
}

.quote-section h3 {
  background: #e3eee9;
  border-left: 5px solid var(--accent);
  margin: 8px 0 2px;
  padding: 7px 10px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}

.saved-row,
.client-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.row-actions button {
  min-height: 36px;
}

.quote-row button {
  align-self: end;
}

.quote-row-static {
  align-items: center;
}

.static-line-total {
  color: var(--accent);
  font-size: 16px;
  white-space: nowrap;
}

.quote-edit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(88px, 1fr));
  gap: 8px;
  margin-top: 8px;
  align-items: end;
}

.quote-edit-grid input {
  min-height: 36px;
}

.line-total-field output {
  min-height: 36px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf8;
  color: var(--accent);
  font-weight: 700;
  padding: 8px 10px;
}

.manual-entry {
  background: transparent;
  border: 0;
  border-top: 2px solid var(--left-line);
  border-radius: 0;
  padding: 10px 0 2px;
  margin: 0 0 8px;
}

.manual-entry h2,
.service-entry h2 {
  color: #173d4b;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 7px;
}

.service-entry {
  background: transparent;
  border: 0;
  border-top: 2px solid var(--left-line);
  border-radius: 0;
  padding: 10px 0 2px;
  margin-bottom: 0;
}

.manual-grid {
  grid-template-columns: minmax(170px, 1.7fr) 76px 92px 112px auto;
}

.manual-grid .wide {
  grid-column: auto;
}

.service-row {
  grid-template-columns: minmax(210px, 1fr) 76px 112px auto;
  margin-top: 0;
}

.manual-grid button,
.service-row button {
  align-self: end;
}

.totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
  background: #f0f5f2;
  border-top: 3px solid var(--accent);
  padding: 14px 12px;
}

.totals span {
  display: grid;
  gap: 4px;
  color: var(--muted);
}

.totals strong {
  color: var(--ink);
  font-size: 18px;
}

.totals .grand strong {
  color: var(--accent);
  font-size: 25px;
}

.quote-actions {
  grid-template-columns: repeat(4, 1fr);
  margin-top: 10px;
}

.options-panel,
.saved-panel,
.company-panel {
  min-height: 180px;
}

.company-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.company-grid .wide,
.client-form .wide {
  grid-column: 1 / -1;
}

.client-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.client-form button {
  align-self: end;
}

.client-list-head {
  grid-template-columns: 1fr minmax(240px, 360px);
  margin-bottom: 10px;
}

.client-list-head h2 {
  font-size: 15px;
}

.logo-box {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 8px;
  align-items: end;
}

.logo-box img {
  width: 84px;
  height: 58px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(24px);
  opacity: 0;
  pointer-events: none;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
  max-width: calc(100vw - 28px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

[hidden] {
  display: none !important;
}

.sync-panel {
  max-width: 920px;
  margin-inline: auto;
  padding: 28px;
}

.sync-summary {
  margin: 22px 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.sync-summary > div {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  background: #f6faf9;
}

.sync-summary dt {
  color: var(--muted);
  font-size: 12px;
}

.sync-summary dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 700;
}

.sync-cloud-counts,
.sync-note {
  margin: 16px 0 0;
  color: var(--muted);
}

.device-access {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.device-access h3 {
  margin: 4px 0 6px;
  font-size: 20px;
}

.device-access p {
  margin: 0;
  color: var(--muted);
}

.device-slot-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.device-slot {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #f7faf9;
}

.device-slot.is-active {
  border-color: #8ab5a9;
  background: #edf7f3;
}

.device-slot-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.device-slot strong,
.device-slot span,
.device-slot small {
  display: block;
}

.device-slot small {
  margin-top: 4px;
  color: var(--muted);
}

.device-slot-status {
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.device-replacement-dialog {
  width: min(520px, calc(100vw - 28px));
  padding: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(10, 37, 31, .25);
}

.device-replacement-dialog::backdrop {
  background: rgba(10, 28, 24, .62);
}

.device-replacement-dialog h2 {
  margin: 7px 0 12px;
}

.logout-confirmation-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 18px 50px rgba(10, 37, 31, .24);
}

.logout-confirmation-dialog::backdrop {
  background: rgba(10, 28, 24, .58);
}

.logout-confirmation-dialog h2 {
  margin: 8px 0 12px;
}

.logout-confirmation-dialog p {
  margin: 0 0 12px;
  line-height: 1.5;
}

.logout-confirmation-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.logout-confirmation-actions button {
  min-height: 44px;
}

@media (max-width: 640px) {
  .logout-confirmation-dialog {
    width: calc(100vw - 24px);
    padding: 20px;
  }

  .logout-confirmation-actions {
    flex-direction: column-reverse;
  }

  .logout-confirmation-actions button {
    width: 100%;
  }
}

.device-replacement-warning {
  padding: 12px;
  border-left: 3px solid #c99b24;
  background: #fff8e6;
}

.sync-actions {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cloud-restore-dialog {
  width: min(560px, calc(100vw - 28px));
  padding: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(10, 37, 31, .25);
}

.cloud-restore-dialog::backdrop {
  background: rgba(10, 28, 24, .6);
}

.cloud-restore-dialog h2 {
  margin: 8px 0 14px;
  font-size: 25px;
}

.cloud-restore-dialog > p {
  line-height: 1.55;
}

.cloud-restore-dialog > small {
  display: block;
  margin-top: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.cloud-restore-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e5f0ee;
  color: var(--green);
  font-size: 25px;
}

.restore-counts {
  margin: 18px 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.restore-counts span {
  padding: 14px;
  border: 1px solid var(--line);
  background: #f6faf9;
  text-align: center;
}

.restore-counts strong {
  display: block;
  font-size: 24px;
}

.restore-actions {
  display: grid;
  gap: 9px;
}

@media (min-width: 1241px) {
  body.builder-mode {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  body.builder-mode .app-workspace {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  body.builder-mode .builder-grid {
    height: calc(100% - 49px);
  }
}

@media (max-width: 1240px) {
  .builder-grid {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .catalog-list {
    max-height: 55vh;
  }

  .catalog-panel,
  .quote-panel {
    height: auto;
    overflow: visible;
    border-left-width: 1px;
  }

  .catalog-panel,
  .quote-panel {
    display: block;
  }

  .quote-items {
    min-height: 240px;
    max-height: 46vh;
  }
}

.mobile-stage1-home,
.mobile-quote-summary-bar {
  display: none;
}

@media (max-width: 640px) {
  body.app-active {
    overflow-x: hidden;
  }

  body.app-active .appbar {
    display: none;
  }

  body.app-active .app-workspace {
    min-height: 100dvh;
    padding:
      calc(64px + env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      calc(76px + env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  body.app-active .top-tabs {
    display: none;
  }

  .mobile-shell-header {
    position: fixed;
    z-index: 30;
    top: 0;
    right: 0;
    left: 0;
    min-height: calc(56px + env(safe-area-inset-top));
    display: grid;
    grid-template-columns: 44px 32px minmax(0, 1fr) 44px;
    gap: 8px;
    align-items: center;
    padding:
      calc(6px + env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      6px
      max(8px, env(safe-area-inset-left));
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 4px 16px rgba(31, 58, 53, 0.08);
  }

  .mobile-shell-action,
  .mobile-shell-action-spacer {
    width: 44px;
    height: 44px;
  }

  .mobile-shell-action {
    min-height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    font-size: 24px;
  }

  body.app-active .mobile-shell-header #mobileBackBtn[hidden] {
    display: block !important;
    visibility: hidden;
    pointer-events: none;
  }

  .mobile-shell-heading {
    min-width: 0;
    display: grid;
    gap: 1px;
  }

  .mobile-shell-heading span {
    color: var(--left-accent);
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
  }

  .mobile-shell-heading strong {
    overflow: hidden;
    color: var(--ink);
    font-size: 17px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-bottom-nav {
    position: fixed;
    z-index: 30;
    right: 0;
    bottom: 0;
    left: 0;
    min-height: calc(64px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding:
      3px
      max(4px, env(safe-area-inset-right))
      calc(3px + env(safe-area-inset-bottom))
      max(4px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -6px 18px rgba(31, 58, 53, 0.1);
  }

  .mobile-bottom-nav button {
    position: relative;
    min-width: 0;
    min-height: 58px;
    display: grid;
    grid-template-rows: 24px auto;
    place-items: center;
    gap: 1px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    padding: 5px 2px 3px;
    font-size: 11px;
    line-height: 1.1;
  }

  .mobile-bottom-nav button::before {
    position: absolute;
    top: 0;
    left: 24%;
    width: 52%;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: transparent;
    content: "";
  }

  .mobile-bottom-nav button.active,
  .mobile-bottom-nav button[aria-current="page"] {
    color: var(--accent);
    font-weight: 700;
  }

  .mobile-bottom-nav button.active::before,
  .mobile-bottom-nav button[aria-current="page"]::before {
    background: var(--accent-2);
  }

  .mobile-nav-icon {
    font-family: "Segoe UI Symbol", Arial, sans-serif;
    font-size: 21px;
    font-weight: 400;
    line-height: 24px;
  }

  .mobile-more-dialog {
    position: fixed;
    inset: auto 8px 0;
    width: auto;
    max-width: 430px;
    max-height: min(78svh, 680px);
    margin: 0 auto;
    overflow: auto;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    background: #fff;
    color: var(--ink);
    padding:
      16px
      max(16px, env(safe-area-inset-right))
      calc(16px + env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
    box-shadow: 0 -18px 48px rgba(18, 36, 32, 0.24);
  }

  .mobile-more-dialog::backdrop {
    background: rgba(20, 35, 32, 0.58);
  }

  .mobile-more-head {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
  }

  .mobile-more-head h2 {
    margin: 2px 0 0;
    font-size: 21px;
  }

  .mobile-more-links {
    display: grid;
    gap: 6px;
  }

  .mobile-more-links button {
    min-height: 50px;
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 10px;
    align-items: center;
    border-color: var(--line);
    background: #fff;
    color: var(--ink);
    text-align: left;
  }

  .mobile-more-links button span:first-child {
    color: var(--left-accent);
    font-family: "Segoe UI Symbol", Arial, sans-serif;
    font-size: 20px;
    text-align: center;
  }

  .mobile-more-links button.active {
    border-color: var(--accent);
    background: var(--soft-surface);
    color: var(--accent);
    font-weight: 700;
  }

  .mobile-more-region {
    display: grid;
    gap: 5px;
    margin-top: 14px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  .mobile-more-region select {
    min-height: 48px;
    color: var(--ink);
    font-size: 15px;
    font-weight: 400;
  }

  .mobile-more-logout {
    width: 100%;
    min-height: 48px;
    margin-top: 10px;
  }

  html.mobile-menu-open,
  html.mobile-menu-open body {
    overflow: hidden;
  }

  .mobile-shell-action:focus-visible,
  .mobile-bottom-nav button:focus-visible,
  .mobile-more-dialog button:focus-visible,
  .mobile-more-dialog select:focus-visible {
    outline: 3px solid var(--accent-2);
    outline-offset: 2px;
  }

  .appbar {
    align-items: center;
    flex-wrap: wrap;
  }

  .account-bar {
    width: 100%;
    grid-template-columns: 1fr auto;
  }

  .account-bar span {
    grid-column: 1 / -1;
    order: -1;
  }

  .quote-top,
  .quote-meta-grid,
  .quote-commercial-grid,
  .line-editor,
  .service-row,
  .manual-grid,
  .cost-grid,
  .quote-filter-grid,
  .quote-edit-grid,
  .totals,
  .quote-actions,
  .company-grid,
  .sync-summary,
  .client-form,
  .client-list-head,
  .admin-stats,
  .admin-user-form,
  .admin-user-row,
  .admin-contact-row,
  .quote-row,
  .product-row,
  .saved-row,
  .client-row {
    grid-template-columns: 1fr;
  }

  .saved-panel .panel-head {
    grid-template-columns: 1fr;
  }

  .saved-panel .panel-head-actions {
    justify-content: flex-start;
  }

  .cloud-restore-dialog {
    padding: 24px 20px;
  }

  .region-picker {
    grid-column: 1;
  }

  .region-picker > span {
    grid-column: auto;
    order: initial;
  }

  .catalog-panel {
    padding: 12px;
  }

  .catalog-panel .panel-head,
  .catalog-panel .region-context {
    display: none;
  }

  .catalog-panel .search-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin-bottom: 10px;
  }

  .catalog-panel .search-row input {
    min-width: 0;
    min-height: 50px;
    font-size: 16px;
  }

  .catalog-panel .search-row #clearSearchBtn {
    min-height: 50px;
  }

  .mobile-search-submit {
    grid-column: 1 / -1;
    min-height: 50px;
    display: block;
    width: 100%;
    font-weight: 700;
  }

  .mobile-search-submit:disabled {
    cursor: not-allowed;
    opacity: 0.55;
  }

  .mobile-search-tools {
    display: grid;
    gap: 8px;
    margin-bottom: 8px;
  }

  .mobile-search-region {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  .mobile-search-region select {
    min-height: 48px;
    width: 100%;
    color: var(--ink);
    font-size: 16px;
    font-weight: 400;
  }

  .mobile-search-filters {
    border: 1px solid var(--left-line);
    border-radius: 6px;
    background: #fff;
  }

  .mobile-search-filters summary {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    color: var(--left-accent);
    cursor: pointer;
    font-weight: 800;
    list-style: none;
  }

  .mobile-search-filters summary::-webkit-details-marker {
    display: none;
  }

  .mobile-search-filters summary::after {
    content: "+";
    font-size: 22px;
    font-weight: 400;
  }

  .mobile-search-filters[open] summary::after {
    content: "\2212";
  }

  .mobile-filter-content {
    display: grid;
    gap: 10px;
    border-top: 1px solid var(--line);
    padding: 12px;
  }

  .mobile-filter-content p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  .mobile-provider-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .mobile-provider-list span {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--soft-surface);
    padding: 5px 9px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 700;
  }

  .mobile-filter-content label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  .mobile-filter-content select {
    min-height: 48px;
    width: 100%;
    color: var(--ink);
    font-size: 16px;
    font-weight: 400;
  }

  .mobile-filter-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .mobile-filter-actions button {
    min-height: 48px;
  }

  .mobile-filter-actions button:last-child {
    grid-column: 1 / -1;
  }

  .mobile-search-status {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 9px;
    border-left: 4px solid var(--left-accent);
    background: #e9f2f5;
    margin: 8px 0 10px;
    padding: 9px 11px;
    color: #173d4b;
    font-size: 13px;
    line-height: 1.35;
  }

  .mobile-search-status.is-busy::before {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    border: 2px solid #a9c2cb;
    border-top-color: var(--left-accent);
    border-radius: 50%;
    content: "";
    animation: mobile-search-spin 0.8s linear infinite;
  }

  .mobile-search-status.is-error {
    border-left-color: var(--danger);
    background: #fff5f3;
    color: var(--danger);
  }

  body.app-active .catalog-list {
    min-height: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
    margin-bottom: 14px;
  }

  .catalog-list .product-row {
    width: 100%;
    gap: 10px;
    border-left-width: 4px;
    padding: 12px;
    margin-bottom: 8px;
    overflow: hidden;
  }

  .catalog-list .product-main {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
  }

  .catalog-list .product-thumbnail,
  .catalog-list .product-thumbnail-placeholder {
    width: 64px;
    height: 64px;
  }

  .catalog-list .product-title {
    overflow-wrap: anywhere;
    font-size: 16px;
    line-height: 1.28;
  }

  .catalog-list .meta {
    gap: 4px;
    margin-top: 6px;
    font-size: 11px;
  }

  .catalog-list .pill {
    padding: 3px 6px;
  }

  .catalog-list .product-action {
    grid-template-columns: minmax(0, 1fr) 146px;
    gap: 8px;
    align-items: end;
  }

  .catalog-list .product-price {
    align-self: center;
    text-align: left;
  }

  .catalog-list .product-price strong {
    font-size: 24px;
  }

  .quantity-stepper {
    display: grid;
    grid-template-columns: 44px minmax(50px, 1fr) 44px;
    align-items: end;
  }

  .quantity-stepper button {
    min-width: 44px;
    min-height: 48px;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 0;
    font-size: 22px;
  }

  .quantity-stepper button:first-child {
    border-radius: 6px 0 0 6px;
  }

  .quantity-stepper button:last-child {
    border-radius: 0 6px 6px 0;
  }

  .quantity-stepper label {
    gap: 2px;
    font-size: 11px;
  }

  .quantity-stepper input {
    min-height: 48px;
    border-radius: 0;
    padding-inline: 4px;
    font-size: 16px;
    text-align: center;
  }

  .catalog-list [data-add-product] {
    min-height: 48px;
    width: 100%;
    font-weight: 700;
  }

  .desktop-add-label {
    display: none;
  }

  .mobile-add-label {
    display: inline;
  }

  .product-store-link {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 1px solid var(--left-accent);
    border-radius: 6px;
    color: var(--left-accent);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
  }

  .catalog-load-more {
    position: static;
    min-height: 50px;
    margin: 12px 0 4px;
    box-shadow: none;
  }

  body.app-active[data-mobile-route="search"] #quotePanel,
  body.app-active[data-mobile-route="quote"] #catalogPanel,
  body.app-active[data-mobile-route="quote-detail"] #catalogPanel {
    display: none;
  }

  .mobile-workflow-control,
  .mobile-quote-entry-mount,
  .mobile-quote-entry-heading,
  .mobile-client-form-heading {
    display: block;
  }

  .quote-entry-forms {
    display: grid;
    gap: 12px;
  }

  .mobile-quote-entry-mount {
    margin: 14px 0;
  }

  .mobile-quote-entry-heading {
    border-bottom: 1px solid var(--left-line);
    padding-bottom: 8px;
  }

  .mobile-quote-entry-heading h2,
  .mobile-client-form-heading h2 {
    margin-top: 3px;
    color: var(--accent);
    font-size: 20px;
  }

  body.app-active .quote-panel {
    height: auto;
    min-height: 0;
    display: block;
    overflow: visible;
    padding: 12px;
  }

  .quote-panel-title {
    margin: -2px -2px 12px;
    padding: 11px 12px;
  }

  .quote-panel-title h1 {
    font-size: 22px;
  }

  .quote-panel select,
  .quote-panel select option,
  .quote-panel input[type="date"] {
    background-color: #fff;
    color: #14201d;
    color-scheme: light;
  }

  .quote-items-head {
    align-items: center;
    gap: 10px;
  }

  #mobileAddQuoteItemsBtn {
    width: auto;
    min-height: 44px;
    padding: 8px 12px;
    white-space: nowrap;
  }

  .quote-top {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    margin-bottom: 10px;
  }

  .quote-top input,
  .quote-meta-grid input,
  .quote-meta-grid select,
  .quote-commercial-grid textarea,
  .cost-grid input,
  .manual-grid input,
  .service-row input,
  .client-form input,
  .client-form textarea,
  .client-list-head input,
  .quote-filter-grid input,
  .quote-filter-grid select,
  .company-grid input,
  .company-grid textarea {
    min-height: 48px;
    font-size: 16px;
  }

  .mobile-workflow-control {
    min-height: 48px;
    width: 100%;
  }

  .quote-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .quote-meta-grid label:first-child {
    grid-column: 1 / -1;
  }

  .quote-meta-grid output {
    min-height: 48px;
  }

  .quote-commercial-details {
    padding: 0;
    overflow: hidden;
  }

  .quote-commercial-details summary {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 0 12px;
  }

  .quote-commercial-grid {
    padding: 0 10px 10px;
  }

  .quote-items-area {
    display: block;
    border: 0;
    background: transparent;
    padding: 0;
  }

  .quote-items-head {
    margin-top: 14px;
  }

  body.app-active .quote-items {
    display: grid;
    gap: 10px;
  }

  .quote-section {
    gap: 8px;
  }

  .quote-section h3 {
    min-height: 40px;
    display: flex;
    align-items: center;
    margin-top: 4px;
    font-size: 16px;
  }

  .quote-row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .quote-row .quote-title {
    overflow-wrap: anywhere;
    font-size: 16px;
  }

  .quote-row .meta {
    margin-top: 6px;
  }

  .quote-edit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .quote-edit-grid input,
  .line-total-field output {
    min-height: 48px;
    font-size: 16px;
  }

  .quote-quantity-stepper {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    align-items: end;
  }

  .quote-quantity-stepper button {
    min-width: 48px;
    min-height: 48px;
    display: grid;
    place-items: center;
    padding: 0;
    border-radius: 0;
    font-size: 22px;
  }

  .quote-quantity-stepper button:first-child {
    border-radius: 6px 0 0 6px;
  }

  .quote-quantity-stepper button:last-child {
    border-radius: 0 6px 6px 0;
  }

  .quote-quantity-stepper input {
    border-radius: 0;
    text-align: center;
  }

  .line-total-field {
    grid-column: 1 / -1;
  }

  .quote-row > .danger {
    min-height: 48px;
    width: 100%;
  }

  .quote-row-static {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .manual-entry,
  .service-entry {
    border: 1px solid var(--left-line);
    border-left: 5px solid var(--left-accent);
    border-radius: 6px;
    background: #f4f9fa;
    margin: 0;
    padding: 12px;
  }

  .service-entry {
    border-left-color: var(--accent-2);
    background: #f5f9f7;
  }

  .manual-grid,
  .service-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .manual-grid .wide,
  .service-row label:first-child,
  .manual-grid button,
  .service-row button {
    grid-column: 1 / -1;
  }

  .manual-grid button,
  .service-row button {
    min-height: 48px;
    width: 100%;
  }

  .cost-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 10px 8px;
  }

  .cost-grid label {
    font-size: 11px;
  }

  .cost-grid input {
    min-width: 0;
    padding-inline: 6px;
  }

  .totals {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding: 12px 8px;
  }

  .totals span {
    min-width: 0;
    font-size: 11px;
  }

  .totals strong {
    overflow-wrap: anywhere;
    font-size: 16px;
  }

  .totals .grand strong {
    font-size: 21px;
  }

  .quote-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 8px;
  }

  .quote-actions button {
    min-height: 50px;
  }

  .saved-panel,
  .clients-panel,
  .company-panel,
  .sync-panel {
    padding: 14px;
  }

  .saved-panel .panel-head,
  .clients-panel .panel-head,
  .company-panel .panel-head {
    gap: 10px;
  }

  .saved-panel .panel-head-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .saved-panel .panel-head-actions button,
  .clients-panel .panel-head > button,
  .company-panel .panel-head > button {
    min-height: 48px;
  }

  .quote-filter-grid.mobile-filter-closed {
    display: none;
  }

  .quote-filter-grid {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f6faf9;
    padding: 12px;
  }

  .mobile-quote-filter-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .mobile-quote-filter-actions button {
    min-height: 48px;
  }

  .mobile-quote-filter-actions button:last-child {
    grid-column: 1 / -1;
  }

  .saved-row,
  .client-row {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 10px;
    border-left: 4px solid var(--accent);
    padding: 12px;
  }

  .saved-row .quote-title,
  .client-row .quote-title {
    overflow-wrap: anywhere;
    font-size: 16px;
  }

  .saved-row .row-actions,
  .client-row .row-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .saved-row .row-actions button,
  .client-row .row-actions button {
    min-height: 48px;
  }

  .saved-row .row-actions .danger:last-child {
    grid-column: 1 / -1;
  }

  body.app-active[data-mobile-route="clients"] #clientForm,
  body.app-active[data-mobile-route="client-edit"] .client-list-head,
  body.app-active[data-mobile-route="client-edit"] #clientsList {
    display: none;
  }

  body.app-active[data-mobile-route="client-edit"] .clients-panel > .panel-head button {
    display: none;
  }

  .mobile-client-form-heading {
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
  }

  .client-form {
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .mobile-client-form-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .mobile-client-form-actions button {
    min-height: 50px;
  }

  .client-list-head {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .company-panel .panel-head {
    grid-template-columns: 1fr;
  }

  .company-guidance {
    font-size: 14px;
    line-height: 1.5;
  }

  .company-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .logo-box {
    grid-template-columns: 88px minmax(0, 1fr);
    align-items: end;
  }

  .logo-box button {
    grid-column: 1 / -1;
    min-height: 48px;
  }

  .sync-panel {
    margin: 0;
  }

  .sync-summary {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 14px;
  }

  .sync-summary > div {
    border-left: 4px solid var(--left-accent);
    padding: 12px;
  }

  #syncPanel[data-sync-state="sincronizado"] #syncStatusText {
    color: var(--ok);
  }

  #syncPanel[data-sync-state="sin-conexion"] #syncStatusText,
  #syncPanel[data-sync-state="error-de-sincronizacion"] #syncStatusText {
    color: var(--danger);
  }

  .sync-pending {
    border-left: 4px solid #c48b2f;
    background: #fff8e8;
    padding: 10px 12px;
    color: #76510f;
    font-weight: 700;
  }

  .sync-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .sync-actions button {
    min-height: 50px;
    width: 100%;
  }

  .cloud-restore-dialog {
    width: calc(100vw - 16px);
    max-width: 560px;
    max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow: auto;
    padding:
      calc(20px + env(safe-area-inset-top))
      18px
      calc(20px + env(safe-area-inset-bottom));
  }

  .cloud-restore-dialog h2 {
    font-size: 22px;
  }

  .restore-counts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .restore-actions button {
    min-height: 50px;
  }

  .restore-progress {
    margin-top: 12px;
    border-left: 4px solid var(--left-accent);
    background: #e9f2f5;
    padding: 11px;
    color: #173d4b;
    font-weight: 700;
  }

  .toast {
    bottom: calc(76px + env(safe-area-inset-bottom));
    width: min(420px, calc(100vw - 24px));
    border-radius: 6px;
    white-space: normal;
    text-align: center;
  }

  .manual-grid .wide {
    grid-column: 1 / -1;
  }

  .product-main {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .product-action {
    grid-template-columns: minmax(76px, 1fr) 86px auto;
    gap: 6px;
  }

  .provider-empty-state {
    grid-template-columns: 1fr;
  }

  .provider-empty-state button {
    grid-column: 1;
    grid-row: auto;
  }

  .product-thumbnail,
  .product-thumbnail-placeholder {
    width: 58px;
    height: 58px;
  }

  .product-image-dialog-foot {
    align-items: flex-start;
    flex-direction: column;
  }

  .logo-box {
    grid-template-columns: 1fr;
  }

  .app-workspace {
    padding: 8px;
  }

  .device-slot-list {
    grid-template-columns: 1fr;
  }

  .device-slot {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    min-height: 84px;
  }

  .device-replacement-dialog {
    padding: 22px;
  }

  body.app-active .catalog-list,
  body.app-active .quote-items {
    max-height: none;
    overflow: visible;
  }

  body.app-active .catalog-panel,
  body.app-active .quote-panel,
  body.app-active [data-tab-panel] {
    scroll-margin-top: calc(68px + env(safe-area-inset-top));
  }
}

@media (max-width: 640px) {
  body.app-active .mobile-stage1-home {
    display: none;
  }

  body.app-active[data-mobile-route="home"] .mobile-stage1-home {
    display: block;
  }

  body.app-active[data-mobile-route="home"] #builderView {
    display: none;
  }

  .mobile-stage1-home {
    padding: 16px 8px 28px;
  }

  .mobile-home-intro {
    margin-bottom: 18px;
  }

  .mobile-home-eyebrow {
    display: block;
    margin-bottom: 5px;
    color: #24675a;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
  }

  .mobile-home-intro h1 {
    font-size: 25px;
    font-weight: 700;
  }

  .mobile-home-intro p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.45;
  }

  .mobile-home-actions {
    display: grid;
    gap: 10px;
  }

  .mobile-home-action {
    min-height: 68px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 20px;
    gap: 11px;
    align-items: center;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    padding: 10px 12px;
    text-align: left;
    box-shadow: 0 3px 12px rgba(23, 63, 56, 0.04);
  }

  .mobile-home-action.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
  }

  .mobile-home-action strong,
  .mobile-home-action small {
    display: block;
  }

  .mobile-home-action strong {
    font-size: 16px;
    font-weight: 600;
  }

  .mobile-home-action small {
    margin-top: 3px;
    color: inherit;
    font-size: 13px;
    font-weight: 400;
    opacity: 0.74;
  }

  .mobile-home-action-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: #e9f2ef;
    color: #24675a;
    font-size: 25px;
    font-weight: 400;
  }

  .mobile-home-action.primary .mobile-home-action-icon {
    background: rgba(255, 255, 255, 0.14);
    color: var(--accent-2);
  }

  .mobile-home-action-icon.search::before {
    width: 15px;
    height: 15px;
    border: 2px solid currentColor;
    border-radius: 50%;
    content: "";
  }

  .mobile-home-action-icon.search::after {
    width: 8px;
    height: 2px;
    margin: -11px 0 0 18px;
    background: currentColor;
    content: "";
    transform: rotate(45deg);
  }

  .mobile-active-quote {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-top: 24px;
    border: 1px solid var(--line);
    border-top: 4px solid var(--accent);
    background: #fff;
    padding: 14px;
  }

  .mobile-active-quote[hidden] {
    display: none;
  }

  .mobile-active-quote div > span,
  .mobile-active-quote div > strong,
  .mobile-active-quote div > small {
    display: block;
  }

  .mobile-active-quote div > span,
  .mobile-active-quote div > small {
    color: var(--muted);
    font-size: 13px;
  }

  .mobile-active-quote div > strong {
    margin: 4px 0;
    font-size: 17px;
    font-weight: 600;
  }

  .mobile-active-quote output {
    color: var(--accent);
    font-size: 20px;
    font-weight: 700;
  }

  .mobile-active-quote button {
    grid-column: 1 / -1;
    min-height: 48px;
    width: 100%;
    font-weight: 600;
  }

  .mobile-home-sync {
    min-height: 46px;
    display: flex;
    gap: 9px;
    align-items: center;
    margin-top: 22px;
    border-left: 4px solid var(--ok);
    background: #e7f4ed;
    padding: 10px 12px;
    color: #19583c;
    font-size: 14px;
  }

  .mobile-quote-summary-bar {
    position: fixed;
    z-index: 29;
    right: 10px;
    bottom: calc(70px + env(safe-area-inset-bottom));
    left: 10px;
    min-height: 52px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: var(--accent);
    padding: 4px 6px 4px 12px;
    color: #fff;
    box-shadow: 0 8px 22px rgba(23, 63, 56, 0.26);
  }

  .mobile-quote-summary-bar[hidden] {
    display: none;
  }

  .mobile-quote-summary-bar strong {
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-quote-summary-bar button {
    min-height: 44px;
    border-color: #fff;
    background: #fff;
    color: var(--accent);
    padding: 7px 10px;
    font-weight: 600;
    white-space: nowrap;
  }

  body.app-active.mobile-stage1-has-quote .app-workspace {
    padding-bottom: calc(140px + env(safe-area-inset-bottom));
  }

  body.mobile-keyboard-open .mobile-bottom-nav,
  body.mobile-keyboard-open .mobile-quote-summary-bar {
    display: none !important;
  }

  body.app-active.mobile-keyboard-open .app-workspace {
    padding-bottom: 12px;
  }

  body.app-active[data-mobile-route="search"] .catalog-panel {
    border: 0;
    border-top: 5px solid var(--left-accent);
    border-radius: 8px 8px 0 0;
    background: #edf3f6;
    padding: 14px 12px;
  }

  body.app-active[data-mobile-route="search"] .catalog-panel .search-row {
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 8px;
  }

  body.app-active[data-mobile-route="search"] #searchInput {
    min-height: 50px;
    border: 1px solid #b9c9c3;
    background: #fff;
    font-size: 16px;
  }

  body.app-active[data-mobile-route="search"] #searchInput::-webkit-search-cancel-button {
    display: none;
    -webkit-appearance: none;
    appearance: none;
  }

  body.app-active[data-mobile-route="search"] #searchInput:focus,
  body.app-active[data-mobile-route="search"] #searchInput:focus-visible {
    border: 2px solid #24675a;
    outline: 0;
    box-shadow: 0 0 0 1px rgba(36, 103, 90, 0.08);
  }

  body.app-active[data-mobile-route="search"] #clearSearchBtn {
    width: 44px;
    min-height: 44px;
    overflow: hidden;
    border: 0;
    background: transparent;
    color: transparent;
    padding: 0;
    position: relative;
  }

  body.app-active[data-mobile-route="search"] #clearSearchBtn::before,
  body.app-active[data-mobile-route="search"] #clearSearchBtn::after {
    position: absolute;
    top: 23px;
    left: 12px;
    width: 21px;
    height: 2px;
    background: var(--accent);
    content: "";
  }

  body.app-active[data-mobile-route="search"] #clearSearchBtn::before { transform: rotate(45deg); }
  body.app-active[data-mobile-route="search"] #clearSearchBtn::after { transform: rotate(-45deg); }

  body.app-active[data-mobile-route="search"] .mobile-search-submit {
    display: none;
  }

  body.app-active[data-mobile-route="search"] .mobile-search-tools {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  body.app-active[data-mobile-route="search"] .mobile-search-filters {
    min-width: 112px;
  }

  body.app-active[data-mobile-route="search"] .mobile-search-status {
    min-height: 36px;
    border: 0;
    background: transparent;
    margin: 4px 0 8px;
    padding: 4px 0;
    color: var(--muted);
    font-size: 13px;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .product-row {
    min-height: 139px;
    display: grid;
    gap: 8px;
    border: 0;
    border-bottom: 1px solid var(--left-line);
    border-radius: 0;
    background: transparent;
    padding: 10px 0;
    margin: 0;
    box-shadow: none;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .product-main {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 10px;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .product-thumbnail,
  body.app-active[data-mobile-route="search"] .catalog-list .product-thumbnail-placeholder {
    position: relative;
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    padding: 0;
  }

  .product-image-loading {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #e5ebe8 25%, #f4f7f5 50%, #e5ebe8 75%);
    background-size: 200% 100%;
    animation: mobile-search-spin 1.4s linear infinite;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .product-thumbnail img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    background: #fff;
    object-fit: contain;
  }

  body.app-active[data-mobile-route="search"] .product-thumbnail-placeholder {
    background: #f4f7f5;
  }

  body.app-active[data-mobile-route="search"] .product-thumbnail-placeholder span {
    width: 23px;
    height: 20px;
    border: 2px solid #77857f;
    border-radius: 3px;
  }

  body.app-active[data-mobile-route="search"] .product-thumbnail-placeholder span::before,
  body.app-active[data-mobile-route="search"] .product-thumbnail-placeholder span::after {
    display: block;
    width: 9px;
    height: 9px;
    border: 2px solid #77857f;
    content: "";
    transform: rotate(45deg);
  }

  body.app-active[data-mobile-route="search"] .product-thumbnail-placeholder span::before { margin: -6px 0 0 5px; }
  body.app-active[data-mobile-route="search"] .product-thumbnail-placeholder span::after { margin: 4px 0 0 5px; }

  body.app-active[data-mobile-route="search"] .catalog-list .product-title {
    display: -webkit-box;
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .meta {
    max-height: 42px;
    overflow: hidden;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .pill {
    min-height: 19px;
    padding: 2px 6px;
    font-weight: 500;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .product-action {
    grid-template-columns: minmax(76px, 1fr) auto auto;
    gap: 6px;
    align-items: center;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .product-price strong {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.05;
    white-space: nowrap;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .product-price span {
    font-size: 11px;
  }

  body.app-active[data-mobile-route="search"] .quantity-stepper {
    grid-template-columns: 44px 28px 44px;
  }

  body.app-active[data-mobile-route="search"] .quantity-stepper label {
    overflow: hidden;
    color: transparent;
    font-size: 0;
  }

  body.app-active[data-mobile-route="search"] .quantity-stepper input {
    min-height: 44px;
    color: var(--ink);
    font-size: 16px;
  }

  body.app-active[data-mobile-route="search"] .quantity-stepper button,
  body.app-active[data-mobile-route="search"] .catalog-list [data-add-product] {
    min-height: 44px;
    font-weight: 600;
  }

  body.app-active[data-mobile-route="search"] .catalog-list [data-add-product] {
    width: auto;
    padding: 7px 10px;
  }

  body.app-active[data-mobile-route="search"] .product-store-link {
    display: none;
  }

  body.app-active[data-mobile-route="search"] .catalog-load-more {
    min-height: 48px;
    width: 100%;
    margin: 12px 0 4px;
    background: #fff;
    color: var(--accent);
    font-weight: 600;
  }
}

@media (max-width: 370px) {
  body.app-active[data-mobile-route="search"] .catalog-list .product-action {
    grid-template-columns: minmax(70px, 1fr) auto auto;
  }

  body.app-active[data-mobile-route="search"] .quantity-stepper {
    grid-template-columns: 44px 24px 44px;
  }

  body.app-active[data-mobile-route="search"] .catalog-list [data-add-product] {
    padding-inline: 8px;
  }
}

/* Etapa 1: proporciones aprobadas en el prototipo movil 06A.2. */
@media (max-width: 640px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body.app-active {
    background: #f6f8f7;
  }

  body.app-active .app-workspace {
    width: min(100%, 520px);
    margin: 0 auto;
    padding:
      calc(60px + env(safe-area-inset-top))
      max(16px, env(safe-area-inset-right))
      calc(82px + env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
  }

  .mobile-shell-header {
    width: min(100%, 520px);
    min-height: calc(60px + env(safe-area-inset-top));
    grid-template-columns: 44px 34px minmax(0, 1fr) 44px;
    gap: 10px;
    margin: 0 auto;
    padding: env(safe-area-inset-top) 10px 0;
    box-shadow: none;
    backdrop-filter: blur(12px);
  }

  .mobile-shell-header > img {
    width: 34px;
    height: 34px;
    border-radius: 7px;
  }

  .mobile-shell-heading {
    gap: 2px;
  }

  .mobile-shell-heading span {
    color: var(--ink);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.1;
  }

  .mobile-shell-heading strong {
    color: var(--muted);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.15;
  }

  body.app-active:not([data-mobile-route="home"]) .mobile-shell-header {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 0;
  }

  body.app-active:not([data-mobile-route="home"]) .mobile-shell-header > img,
  body.app-active:not([data-mobile-route="home"]) .mobile-shell-heading span {
    display: none;
  }

  body.app-active:not([data-mobile-route="home"]) .mobile-shell-heading {
    text-align: center;
  }

  body.app-active:not([data-mobile-route="home"]) .mobile-shell-heading strong {
    color: var(--ink);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
  }

  .mobile-shell-action {
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--accent);
    font-size: 23px;
  }

  .mobile-bottom-nav {
    right: 0;
    left: 0;
    width: min(100%, 520px);
    min-height: calc(70px + env(safe-area-inset-bottom));
    margin: 0 auto;
    padding: 5px 4px env(safe-area-inset-bottom);
    box-shadow: 0 -5px 18px rgba(23, 63, 56, 0.08);
  }

  .mobile-bottom-nav button {
    min-height: 58px;
    grid-template-rows: 24px auto;
    gap: 4px;
    padding: 3px 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
  }

  .mobile-bottom-nav button::before {
    display: none;
  }

  .mobile-bottom-nav button.active,
  .mobile-bottom-nav button[aria-current="page"] {
    color: #24675a;
    font-weight: 600;
  }

  .mobile-nav-icon {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
  }

  .mobile-stage1-home {
    padding: 16px 0 24px;
  }

  .mobile-home-intro {
    margin-bottom: 18px;
  }

  .mobile-home-eyebrow {
    margin-bottom: 4px;
    font-size: 13px;
  }

  .mobile-home-intro h1 {
    margin-bottom: 8px;
    font-size: 24px;
    line-height: 1.2;
  }

  .mobile-home-intro p {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
  }

  .mobile-home-actions {
    gap: 10px;
  }

  .mobile-home-action {
    min-height: 64px;
    grid-template-columns: 44px minmax(0, 1fr) 20px;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 7px;
    box-shadow: none;
  }

  .mobile-home-action strong {
    font-size: 16px;
  }

  .mobile-home-action small {
    margin-top: 2px;
    font-size: 13px;
  }

  .mobile-active-quote {
    margin-top: 24px;
    border-top-width: 1px;
    border-radius: 7px;
    padding: 14px;
    box-shadow: 0 8px 24px rgba(23, 63, 56, 0.09);
  }

  .mobile-home-sync {
    display: none;
  }

  body.app-active[data-mobile-route="search"] .catalog-panel {
    width: 100%;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 16px 0 0;
  }

  body.app-active[data-mobile-route="search"] .catalog-panel .search-row {
    position: relative;
    display: block;
    margin: 0 0 10px;
  }

  body.app-active[data-mobile-route="search"] .catalog-panel .search-row::before {
    position: absolute;
    z-index: 2;
    top: 15px;
    left: 14px;
    width: 17px;
    height: 17px;
    border: 2px solid var(--muted);
    border-radius: 50%;
    content: "";
    pointer-events: none;
  }

  body.app-active[data-mobile-route="search"] .catalog-panel .search-row::after {
    position: absolute;
    z-index: 2;
    top: 31px;
    left: 30px;
    width: 8px;
    height: 2px;
    background: var(--muted);
    content: "";
    transform: rotate(45deg);
    pointer-events: none;
  }

  body.app-active[data-mobile-route="search"] #searchInput {
    width: 100%;
    min-height: 52px;
    border-radius: 8px;
    padding: 10px 48px 10px 44px;
    font-size: 16px;
  }

  body.app-active[data-mobile-route="search"] #clearSearchBtn {
    position: absolute;
    z-index: 3;
    top: 4px;
    right: 4px;
    width: 44px;
    min-height: 44px;
  }

  body.app-active[data-mobile-route="search"] #clearSearchBtn::before,
  body.app-active[data-mobile-route="search"] #clearSearchBtn::after {
    top: 21px;
    left: 12px;
    width: 20px;
  }

  body.app-active[data-mobile-route="search"] .mobile-search-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 0 8px;
  }

  body.app-active[data-mobile-route="search"] .mobile-search-region {
    min-width: 0;
    flex: 1 1 auto;
  }

  body.app-active[data-mobile-route="search"] .mobile-search-region > span {
    display: none;
  }

  body.app-active[data-mobile-route="search"] .mobile-search-region select {
    width: 100%;
    min-height: 44px;
    overflow: hidden;
    border: 0;
    background: transparent;
    color: #24675a;
    padding: 0 26px 0 0;
    font-size: 15px;
    font-weight: 600;
    text-overflow: ellipsis;
  }

  body.app-active[data-mobile-route="search"] .mobile-search-filters {
    min-width: 44px;
    width: 44px;
    height: 44px;
    overflow: visible;
    border-radius: 50%;
  }

  body.app-active[data-mobile-route="search"] .mobile-search-filters summary {
    position: relative;
    width: 44px;
    min-height: 44px;
    overflow: hidden;
    color: transparent;
    padding: 0;
    font-size: 0;
  }

  body.app-active[data-mobile-route="search"] .mobile-search-filters summary::after {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    margin: auto;
    background:
      radial-gradient(circle at 7px 6px, currentColor 0 2px, transparent 2.5px),
      radial-gradient(circle at 17px 12px, currentColor 0 2px, transparent 2.5px),
      radial-gradient(circle at 10px 18px, currentColor 0 2px, transparent 2.5px),
      linear-gradient(currentColor, currentColor) 2px 5px / 20px 2px no-repeat,
      linear-gradient(currentColor, currentColor) 2px 11px / 20px 2px no-repeat,
      linear-gradient(currentColor, currentColor) 2px 17px / 20px 2px no-repeat;
    color: var(--accent);
    content: "";
  }

  body.app-active[data-mobile-route="search"] .mobile-search-filters[open] {
    width: min(330px, calc(100vw - 32px));
    height: auto;
    border-radius: 8px;
  }

  body.app-active[data-mobile-route="search"] .mobile-search-filters[open] summary {
    width: 100%;
    color: var(--accent);
    padding: 0 12px;
    font-size: 14px;
  }

  body.app-active[data-mobile-route="search"] .mobile-search-filters[open] summary::after {
    display: none;
  }

  .mobile-provider-chips {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    margin-bottom: 10px;
    padding-bottom: 3px;
    scrollbar-width: none;
  }

  .mobile-provider-chips::-webkit-scrollbar {
    display: none;
  }

  .mobile-provider-chips button {
    min-height: 44px;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: #fff;
    color: var(--muted);
    padding: 8px 13px;
    font-size: 14px;
    font-weight: 400;
  }

  .mobile-provider-chips button.active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
  }

  body.app-active[data-mobile-route="search"] .mobile-search-status {
    min-height: 32px;
    margin: 0 0 4px;
    padding: 3px 0;
    font-size: 13px;
  }

  body.app-active[data-mobile-route="search"] .catalog-list {
    border-top: 1px solid var(--line);
    margin: 0;
    padding-bottom: 8px;
  }

  body.app-active[data-mobile-route="search"] .catalog-empty-state {
    min-height: 360px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 10px;
    padding: 24px 18px 80px;
    text-align: center;
  }

  body.app-active[data-mobile-route="search"] .catalog-empty-state strong {
    font-size: 17px;
  }

  body.app-active[data-mobile-route="search"] .catalog-empty-state small {
    max-width: 290px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
  }

  .catalog-empty-icon {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: #e9f2ef;
  }

  .catalog-empty-icon::before {
    position: absolute;
    top: 19px;
    left: 19px;
    width: 22px;
    height: 22px;
    border: 2px solid #24675a;
    border-radius: 50%;
    content: "";
  }

  .catalog-empty-icon::after {
    position: absolute;
    top: 42px;
    left: 41px;
    width: 11px;
    height: 2px;
    background: #24675a;
    content: "";
    transform: rotate(45deg);
  }

  body.app-active[data-mobile-route="search"] .catalog-list .product-row {
    min-height: 139px;
    max-height: 155px;
    gap: 8px;
    padding: 10px 0;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .product-main {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 10px;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .product-thumbnail,
  body.app-active[data-mobile-route="search"] .catalog-list .product-thumbnail-placeholder {
    width: 56px;
    height: 56px;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .product-title {
    margin-bottom: 2px;
    font-size: 16px;
    line-height: 1.2;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .meta {
    display: none;
  }

  body.app-active[data-mobile-route="search"] .mobile-product-info {
    display: grid;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.3;
  }

  body.app-active[data-mobile-route="search"] .mobile-product-info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .product-action {
    grid-template-columns: minmax(78px, 1fr) auto auto;
    gap: 6px;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .product-price strong {
    font-size: 19px;
  }

  body.app-active[data-mobile-route="search"] .catalog-list .product-price span {
    font-size: 12px;
  }

  body.app-active[data-mobile-route="search"] .quantity-stepper {
    height: 44px;
    grid-template-columns: 44px 28px 44px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
  }

  body.app-active[data-mobile-route="search"] .quantity-stepper button,
  body.app-active[data-mobile-route="search"] .quantity-stepper input,
  body.app-active[data-mobile-route="search"] .catalog-list [data-add-product] {
    min-height: 44px;
    height: 44px;
  }

  body.app-active[data-mobile-route="search"] .catalog-list [data-add-product] {
    border-radius: 7px;
    padding: 8px 11px;
    font-size: 15px;
  }

  body.app-active[data-mobile-route="search"] .catalog-list [data-add-product].is-added {
    border: 0;
    background: transparent;
    color: var(--ok);
    padding-inline: 6px;
    font-size: 13px;
  }

  body.app-active[data-mobile-route="search"] .catalog-load-more {
    min-height: 48px;
    margin: 12px 0 8px;
  }

  .mobile-quote-summary-bar {
    right: 10px;
    bottom: calc(70px + env(safe-area-inset-bottom) + 8px);
    left: 10px;
    width: min(calc(100% - 20px), 500px);
    min-height: 52px;
    margin: 0 auto;
    padding: 4px 6px 4px 12px;
  }

  .mobile-quote-summary-bar strong {
    font-size: 15px;
  }

  body.app-active.mobile-stage1-has-quote .app-workspace {
    padding-bottom: calc(142px + env(safe-area-inset-bottom));
  }

  body.app-active.mobile-stage1-has-quote[data-mobile-route="search"] .catalog-list {
    padding-bottom: 62px;
  }
}

@media (max-width: 640px) {
  .mobile-quote-workflow {
    width: 100%;
    max-width: 500px;
    min-height: calc(100dvh - 132px - env(safe-area-inset-bottom));
    margin: 0 auto;
    padding: 14px 16px calc(88px + env(safe-area-inset-bottom));
    background: #f7faf8;
  }

  .mobile-quote-workflow[hidden] { display: none !important; }

  body.app-active[data-mobile-route="quote"] #builderView,
  body.app-active[data-mobile-route="quote-materials"] #builderView,
  body.app-active[data-mobile-route="quote-work"] #builderView,
  body.app-active[data-mobile-route="quote-conditions"] #builderView,
  body.app-active[data-mobile-route="quote-review"] #builderView { display: none !important; }

  .mobile-quote-workflow h1 {
    margin: 16px 0 4px;
    color: #14201d;
    font-size: 24px;
    line-height: 1.18;
    letter-spacing: 0;
  }

  .mobile-quote-lead {
    margin: 0 0 18px;
    color: #64736e;
    font-size: 15px;
    line-height: 1.4;
  }

  .mobile-quote-step > strong {
    display: block;
    margin-bottom: 8px;
    color: #536660;
    font-size: 13px;
  }

  .mobile-quote-step > div {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }

  .mobile-quote-step span {
    height: 5px;
    border-radius: 4px;
    background: #dbe4e0;
  }

  .mobile-quote-step span.done { background: #267565; }
  .mobile-quote-step span.current { background: #f5c63d; }

  .mobile-quote-search {
    min-height: 52px;
    display: grid;
    grid-template-columns: 28px 1fr;
    align-items: center;
    gap: 8px;
    border: 1px solid #b8cac4;
    border-radius: 8px;
    background: #fff;
    padding: 0 12px;
  }

  .mobile-quote-search span {
    width: 18px;
    height: 18px;
    border: 2px solid #697b75;
    border-radius: 50%;
    position: relative;
  }

  .mobile-quote-search span::after {
    position: absolute;
    width: 8px;
    height: 2px;
    right: -6px;
    bottom: -3px;
    background: #697b75;
    content: "";
    transform: rotate(45deg);
  }

  .mobile-quote-search input {
    min-height: 50px;
    border: 0;
    background: transparent;
    padding: 0;
    font-size: 16px;
  }

  .mobile-quote-section { margin-top: 24px; }
  .mobile-quote-section h2 { margin: 0 0 10px; font-size: 18px; }

  .mobile-client-choices,
  .mobile-review-list,
  .mobile-quote-lines { display: grid; gap: 8px; }

  .mobile-client-choices > button,
  .mobile-review-list > button {
    min-height: 62px;
    display: grid;
    grid-template-columns: 42px 1fr auto;
    align-items: center;
    gap: 10px;
    border: 1px solid #cfdbd7;
    border-radius: 8px;
    background: #fff;
    color: #14201d;
    padding: 8px 11px;
    text-align: left;
  }

  .mobile-client-choices i,
  .mobile-review-list i {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #e7f2ee;
    color: #126656;
    font-size: 14px;
    font-style: normal;
    font-weight: 700;
  }

  .mobile-client-choices strong,
  .mobile-client-choices small,
  .mobile-review-list strong,
  .mobile-review-list small { display: block; }
  .mobile-client-choices small,
  .mobile-review-list small { margin-top: 2px; color: #687771; font-size: 13px; }

  .mobile-quote-actions-stack { display: grid; gap: 10px; margin-top: 24px; }
  .mobile-quote-actions-stack button,
  .mobile-quote-continue,
  .mobile-inline-form button,
  .mobile-review-actions button {
    min-height: 48px;
    border: 1px solid #174c42;
    border-radius: 7px;
    background: #174c42;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
  }
  .mobile-quote-actions-stack .secondary { background: #fff; color: #126656; }
  .mobile-quote-actions-stack .quiet { border-color: #d1dcd8; background: #fff; color: #14201d; }

  .mobile-quote-line {
    min-height: 96px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #cfdbd7;
    background: #fff;
    padding: 10px 2px;
  }

  .mobile-quote-line strong,
  .mobile-quote-line span { display: block; }
  .mobile-quote-line strong { font-size: 15px; line-height: 1.25; }
  .mobile-quote-line span { margin-top: 4px; color: #66766f; font-size: 13px; }
  .mobile-quote-line > div:first-child button,
  .mobile-section-heading > button {
    min-height: 44px;
    border: 0;
    background: transparent;
    color: #126656;
    padding: 6px 0;
    font-weight: 600;
  }
  .mobile-quote-line > div:last-child { display: flex; align-items: center; gap: 6px; }
  .mobile-quote-line > div:last-child > button { width: 44px; min-height: 44px; border: 0; background: transparent; font-size: 22px; }

  .mobile-inline-form {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    border: 1px solid #b8cac4;
    border-radius: 8px;
    background: #fff;
    padding: 12px;
  }
  .mobile-inline-form[hidden] { display: none !important; }
  .mobile-inline-form > div { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

  .mobile-inline-form label,
  .mobile-cost-fields label,
  .mobile-condition-fields label {
    display: grid;
    gap: 5px;
    color: #21302c;
    font-size: 13px;
    font-weight: 600;
  }
  .mobile-inline-form input,
  .mobile-cost-fields input,
  .mobile-condition-fields input,
  .mobile-condition-fields select,
  .mobile-condition-fields textarea {
    width: 100%;
    min-height: 48px;
    border: 1px solid #bdcdc8;
    border-radius: 7px;
    background: #fff;
    padding: 10px 12px;
    color: #14201d;
    font-size: 16px;
  }
  .mobile-condition-fields textarea { min-height: 72px; resize: vertical; }
  .mobile-quote-continue { width: 100%; margin-top: 18px; }

  .mobile-section-heading { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
  .mobile-section-heading h2 { margin-bottom: 2px; }
  .mobile-section-heading small { color: #66766f; }
  .mobile-cost-fields,
  .mobile-condition-fields { display: grid; gap: 12px; }

  .mobile-quote-empty {
    border: 1px dashed #bdcdc8;
    border-radius: 8px;
    background: #fff;
    color: #64736e;
    padding: 18px;
    text-align: center;
  }

  .mobile-review-list { gap: 0; }
  .mobile-review-list > button { min-height: 58px; border-width: 0 0 1px; border-radius: 0; }
  .mobile-review-list i { border-radius: 6px; }
  .mobile-review-totals { display: grid; margin-top: 14px; }
  .mobile-review-totals span { min-height: 40px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #d4dfdb; color: #5f706a; }
  .mobile-review-totals span:last-child { min-height: 50px; color: #14201d; font-weight: 700; }
  .mobile-review-totals span:last-child strong { color: #075c4d; font-size: 24px; }
  .mobile-review-actions { display: grid; gap: 8px; margin-top: 16px; }
  .mobile-review-actions p { margin: 0; color: #66766f; font-size: 13px; text-align: center; }

  body.app-active[data-mobile-route="quote-materials"].mobile-stage1-has-quote .app-workspace,
  body.app-active[data-mobile-route="quote-work"].mobile-stage1-has-quote .app-workspace,
  body.app-active[data-mobile-route="quote-conditions"].mobile-stage1-has-quote .app-workspace {
    padding-bottom: calc(142px + env(safe-area-inset-bottom));
  }
}

.mobile-records-switch,
.mobile-account-shortcuts {
  display: none;
}

/* Desktop commercial controls. Kept outside the approved mobile workflow. */
@media (min-width: 761px) {
  .manual-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .manual-grid > label:nth-child(1) { grid-column: span 7; }
  .manual-grid > label:nth-child(2) { grid-column: span 2; }
  .manual-grid > label:nth-child(3) { grid-column: span 3; }
  .manual-grid > label:nth-child(4) { grid-column: span 4; }
  .manual-grid > label:nth-child(5) { grid-column: span 5; }
  .manual-grid > button { grid-column: span 3; }

  .manual-grid .wide {
    grid-column: span 7;
  }

  .service-row {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .service-row > label:nth-child(1) { grid-column: span 7; }
  .service-row > label:nth-child(2) { grid-column: span 2; }
  .service-row > label:nth-child(3) { grid-column: span 3; }
  .service-row > label:nth-child(4) { grid-column: span 8; }
  .service-row > button { grid-column: span 4; }

  .quote-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quote-actions {
    grid-template-columns: repeat(5, minmax(108px, 1fr));
  }

  .mobile-client-form-actions {
    display: flex;
    align-items: end;
    gap: 8px;
    grid-column: 1 / -1;
  }

  .mobile-client-form-actions button {
    min-width: 150px;
  }
}

button.danger {
  border-color: #b7392f;
  background: #fff;
  color: #a12b22;
}

button.danger:hover:not(:disabled) {
  background: #fff1ef;
}

.confirm-dialog,
.quote-preview-dialog {
  border: 1px solid #bdcbc6;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(12, 35, 30, .28);
  color: var(--ink);
}

.confirm-dialog::backdrop,
.quote-preview-dialog::backdrop {
  background: rgba(11, 28, 25, .62);
}

.confirm-dialog {
  width: min(480px, calc(100vw - 32px));
  padding: 24px;
}

.confirm-dialog h2,
.confirm-dialog p {
  margin: 0 0 12px;
}

.dialog-actions,
.quote-preview-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.quote-preview-dialog {
  width: min(1120px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: hidden;
}

.quote-preview-head,
.quote-preview-actions {
  position: sticky;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f3f7f5;
  padding: 12px 18px;
}

.quote-preview-head {
  top: 0;
  border-bottom: 1px solid #ccd9d4;
}

.quote-preview-head h2 {
  font-size: 18px;
}

.quote-preview-actions {
  bottom: 0;
  border-top: 1px solid #ccd9d4;
}

.quote-preview-content {
  max-height: calc(100vh - 152px);
  overflow: auto;
  background: #e8eeeb;
  padding: 24px;
}

.quote-preview-document {
  width: min(900px, 100%);
  min-height: 900px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #ccd8d3;
  padding: 34px 40px;
}

.quote-preview-document > header,
.quote-preview-summary,
.quote-preview-totals,
.quote-preview-notes {
  display: grid;
  gap: 16px;
}

.quote-preview-document > header {
  grid-template-columns: 1fr auto;
  border-bottom: 3px solid var(--accent);
  padding-bottom: 18px;
}

.quote-preview-document p,
.quote-preview-document h1,
.quote-preview-document h2 {
  margin: 0;
}

.quote-preview-number {
  display: grid;
  justify-items: end;
  gap: 5px;
}

.quote-preview-number strong {
  color: var(--accent);
  font-size: 20px;
}

.quote-preview-summary {
  grid-template-columns: 2fr repeat(3, 1fr);
  border-bottom: 1px solid #d4dfda;
  padding: 18px 0;
}

.quote-preview-summary > div {
  display: grid;
  align-content: start;
  gap: 4px;
}

.quote-preview-summary span,
.quote-preview-summary small {
  color: var(--muted);
  font-size: 12px;
}

.quote-preview-document > h1 {
  padding: 20px 0 10px;
  color: var(--accent);
  font-size: 24px;
}

.quote-preview-section {
  margin-top: 18px;
}

.quote-preview-section h3 {
  margin: 0 0 8px;
  color: var(--accent);
}

.quote-preview-table-wrap {
  overflow-x: auto;
}

.quote-preview-section table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.quote-preview-section th,
.quote-preview-section td {
  border-bottom: 1px solid #dce5e1;
  padding: 8px 7px;
  text-align: left;
  vertical-align: top;
}

.quote-preview-section th:last-child,
.quote-preview-section td:last-child,
.quote-preview-section th:nth-last-child(2),
.quote-preview-section td:nth-last-child(2) {
  text-align: right;
}

.quote-preview-totals {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 24px;
  border-top: 3px solid var(--accent);
  background: #f1f6f3;
  padding: 14px;
}

.quote-preview-totals span {
  display: grid;
  gap: 4px;
}

.quote-preview-totals .grand strong {
  color: var(--accent);
  font-size: 22px;
}

.quote-preview-notes {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 22px;
}

.quote-preview-notes > div {
  border-top: 1px solid #cfdad5;
  padding-top: 10px;
}

@media (max-width: 760px) {
  .desktop-commercial-only {
    display: none !important;
  }
}

@media (max-width: 760px) {
  .mobile-records-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    margin-bottom: 12px;
    border: 1px solid #cad8d5;
    background: #eef3f2;
  }

  .mobile-records-switch button {
    min-height: 44px;
    border: 0;
    background: transparent;
    color: #34544f;
  }

  .mobile-records-switch button.is-active {
    background: #173f38;
    color: #fff;
  }

  .mobile-account-shortcuts {
    display: grid;
    gap: 10px;
    margin: 14px 0;
  }

  .mobile-account-shortcuts > button,
  .mobile-account-shortcuts select {
    width: 100%;
    min-height: 44px;
  }

  .mobile-account-shortcuts label {
    display: grid;
    gap: 6px;
    color: #34544f;
    font-size: 14px;
  }
}

@media print {
  .appbar,
  .top-tabs,
  .catalog-panel,
  .options-panel,
  .company-panel,
  .saved-panel,
  .clients-panel,
  .quote-actions,
  .service-row,
  .line-editor {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .app-workspace {
    display: block;
    padding: 0;
  }

  .panel {
    box-shadow: none;
    border: 0;
  }
}
