/* Consistent product-photo frames that preserve the source image proportions. */
.mini-photo,
.photo {
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}

.mini-photo {
  width: 40px;
  height: 52px;
  flex: 0 0 40px;
}

.photo {
  width: 52px;
  height: 68px;
}

.mini-photo img,
.photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

@media (max-width: 720px) {
  .product-card {
    grid-template-columns: 46px 1fr;
  }

  .product-card .photo {
    width: 46px;
    height: 60px;
  }
}

.store-slots {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: 16px;
  margin-top: 18px;
}

.connected-stores,
.store-connect-form {
  padding: 20px;
  border: 1px solid #e4e5ec;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(36, 25, 66, .05);
}
.connected-stores-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.connected-stores-head h2 { margin: 0; font-size: 18px; }
.connected-stores-head span { color: var(--muted); font-size: 12px; }
.connected-store { display: grid; grid-template-columns: minmax(140px, 1fr) auto; gap: 8px 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.connected-store:first-child { border-top: 0; }
.connected-store > div:first-child { display: flex; align-items: center; gap: 10px; min-width: 0; }
.connected-store strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connected-store > div:nth-child(2) { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.connected-store .store-message { grid-column: 1 / -1; min-height: 0; margin: 0; padding: 0; background: transparent; }
.store-connect-form > label { display: grid; gap: 7px; margin-top: 13px; color: #3d3d49; font-size: 12px; font-weight: 700; }
.store-form-grid { display: grid; grid-template-columns: 150px 1fr; gap: 12px; }
.store-form-grid label { display: grid; gap: 7px; color: #3d3d49; font-size: 12px; font-weight: 700; }
.store-connect-form input,
.store-connect-form select,
.fbs-store-picker select { width: 100%; box-sizing: border-box; padding: 10px 11px; border: 1px solid #d9dbe3; border-radius: 9px; background: #fff; color: var(--text); font: inherit; }
.fbs-store-picker { display: grid; gap: 5px; min-width: 220px; color: var(--muted); font-size: 11px; font-weight: 750; }

.store-slot {
  padding: 20px;
  border: 1px solid #e4e5ec;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(36, 25, 66, .05);
}

.store-slot.connected { border-color: #cce7d6; }
.store-slot-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.store-slot-head h2 { margin: 3px 0 0; font-size: 18px; }
.store-number { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.connection-badge { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; padding: 6px 9px; border-radius: 99px; background: #f2f3f6; color: var(--muted); font-size: 11px; font-weight: 750; }
.connection-badge i { width: 7px; height: 7px; border-radius: 50%; background: #a4a7b0; }
.connection-badge.connected { background: #eaf7ef; color: #17763c; }
.connection-badge.connected i { background: #29a357; }
.store-slot label { display: grid; gap: 7px; margin-top: 13px; color: #3d3d49; font-size: 12px; font-weight: 700; }
.store-slot input { width: 100%; min-width: 0; box-sizing: border-box; padding: 11px 12px; border: 1px solid #d9dbe3; border-radius: 9px; background: #fff; color: var(--text); font: inherit; }
.store-slot input:focus-visible { outline: 3px solid rgba(111, 45, 189, .18); border-color: var(--purple); }
.store-privacy { margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.store-message { min-height: 32px; margin-top: 15px; padding: 9px 10px; border-radius: 8px; background: #f6f6f8; color: var(--muted); font-size: 11px; line-height: 1.35; }
.store-message.ok { background: #eaf7ef; color: #17763c; }
.store-message.error { background: #fff0ef; color: #a9332c; }
.store-message.pending { background: #fff8e5; color: #866100; }
.store-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.store-actions button { font-size: 11px; padding: 8px 10px; }
.disconnect-button { border: 0; background: transparent; color: #a9332c; font-weight: 750; cursor: pointer; }
.disconnect-button:hover { background: #fff0ef; border-radius: 8px; }

@media (max-width: 980px) {
  .store-slots { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .store-slot { padding: 15px; }
  .store-slot-head { align-items: center; }
  .store-actions { flex-direction: column; }
  .store-actions button { width: 100%; }
  .store-form-grid { grid-template-columns: 1fr; }
  .connected-store { grid-template-columns: 1fr; }
  .connected-store > div:nth-child(2) { justify-content: flex-start; }
  .fbs-store-picker { width: 100%; min-width: 0; }
}

.tools-grid { display: block; }
.tools-grid[hidden],
.tool-chooser[hidden],
.tool-switcher[hidden],
.volume-tool[hidden],
.pallet-tool[hidden],
.sync-tool-panel[hidden],
.questions-tool-panel[hidden] { display: none !important; }
.tool-chooser { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.tool-choice { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 18px; border: 1px solid #e4e5ec; border-radius: 14px; background: #fff; color: var(--text); text-align: left; cursor: pointer; box-shadow: 0 5px 16px rgba(36,25,66,.04); }
.tool-choice:hover { border-color: #d5b9e7; background: #fcf9ff; transform: translateY(-1px); }
.tool-choice:focus-visible { outline: 3px solid rgba(111,45,189,.2); border-color: var(--purple); }
.tool-choice-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; background: var(--purple-pale); color: var(--purple); font-size: 23px; }
.tool-choice span:nth-child(2) { display: grid; gap: 4px; }
.tool-choice small { color: var(--muted); font-size: 11px; font-weight: 500; }
.tool-choice b { color: var(--purple); font-size: 11px; white-space: nowrap; }
.tool-switcher { display: flex; justify-content: space-between; align-items: end; gap: 14px; margin-bottom: 14px; }
.tool-switcher label { display: grid; gap: 5px; min-width: 230px; color: var(--muted); font-size: 11px; font-weight: 700; }
.tool-switcher select { padding: 9px 10px; border: 1px solid #d9dbe3; border-radius: 9px; background: #fff; color: var(--text); font: inherit; }
.topbar #sync-button { display: none; }
.topbar #sync-state { display: none; }
.page-update-status { margin-top: 22px; padding-top: 9px; border-top: 1px solid #f0f1f5; color: var(--muted); font-size: 10px; line-height: 1.4; text-align: right; }
.page-update-status.ok { color: var(--green); }
.page-update-status.error { color: #a14d45; }
.sync-tool-panel { max-width: 680px; }
.sync-tool-panel > p { max-width: 560px; color: var(--muted); line-height: 1.5; }
.sync-tool-action { margin-top: 18px; }
.sync-tool-action #sync-button { display: inline-flex; align-items: center; justify-content: center; min-height: 41px; padding: 11px 15px; border: 0; border-radius: 10px; background: var(--purple); color: #fff; font-size: 13px; font-weight: 750; line-height: 1.45; white-space: normal; }
.sync-tool-action #sync-button:hover:not(:disabled) { background: #75119e; }
.sync-tool-action #sync-button:focus-visible { outline: 3px solid rgba(111,45,189,.22); outline-offset: 2px; }
.sync-tool-action #sync-button:disabled { opacity: .55; cursor: wait; box-shadow: none; transform: none; }
.tool-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tool-fields label,
.pallet-sheet label { display: grid; gap: 6px; color: #3d3d49; font-size: 12px; font-weight: 700; }
.tool-fields input,
.pallet-sheet input,
.pallet-sheet textarea { width: 100%; box-sizing: border-box; padding: 10px 11px; border: 1px solid #d9dbe3; border-radius: 9px; background: #fff; color: var(--text); font: inherit; }
.volume-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.volume-results article { display: grid; gap: 4px; padding: 14px; border-radius: 12px; background: #f7f4fb; }
.volume-results small { color: var(--muted); }
.volume-results strong { color: var(--purple); font-size: 22px; }
.volume-results span { color: var(--muted); font-size: 12px; }
.pallet-sheet { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.pallet-sheet .wide { grid-column: 1 / -1; }
.pallet-sheet textarea { resize: vertical; }

.questions-tool-panel { overflow: hidden; }
.questions-tool-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 18px; border-bottom: 1px solid var(--line); }
.questions-tool-head h2 { margin: 3px 0 5px; }
.questions-tool-head p:last-child { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.questions-load-control { display: flex; align-items: end; gap: 9px; }
.questions-load-control label { display: grid; gap: 5px; min-width: 180px; color: var(--muted); font-size: 10px; font-weight: 750; }
.questions-load-control select { min-height: 42px; padding: 8px 10px; border: 1px solid #d9dbe3; border-radius: 9px; background: #fff; color: var(--text); }
.questions-load-control button { min-height: 42px; max-width: 260px; }
.questions-filters { display: grid; grid-template-columns: minmax(220px, 1.5fr) 150px minmax(190px, 1fr) 150px auto; gap: 9px; align-items: end; padding: 14px 18px; background: #fafbfe; }
.questions-filters label, .question-link-fields label, .question-draft-field { display: grid; gap: 6px; color: #3d3d49; font-size: 11px; font-weight: 750; }
.questions-filters input, .questions-filters select, .question-link-fields select, .question-draft-field textarea { width: 100%; box-sizing: border-box; padding: 9px 10px; border: 1px solid #d9dbe3; border-radius: 9px; background: #fff; color: var(--text); font: inherit; }
.questions-filters input:focus, .questions-filters select:focus, .question-link-fields select:focus, .question-draft-field textarea:focus { border-color: var(--purple); outline: 3px solid rgba(111,45,189,.13); }
.questions-result-line { display: flex; justify-content: space-between; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.questions-result-line strong { color: var(--purple); }
.questions-workspace { display: grid; grid-template-columns: minmax(280px, .85fr) minmax(390px, 1.4fr); min-height: 470px; }
.questions-list { max-height: 650px; overflow-y: auto; border-right: 1px solid var(--line); background: #fafbfe; }
.question-list-item { width: 100%; display: grid; gap: 7px; padding: 13px 14px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.question-list-item:hover, .question-list-item.active { background: #f3ebf8; }
.question-list-item > span:first-child { display: flex; justify-content: space-between; gap: 8px; }
.question-list-item b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.question-list-item small { color: var(--muted); font-size: 9px; white-space: nowrap; }
.question-list-item p { margin: 0; overflow: hidden; color: #555865; font-size: 11px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.question-status { width: fit-content; padding: 4px 7px; border-radius: 99px; background: #eef0f5; color: #656b78; font-size: 9px; font-weight: 800; }
.question-status.new { background: #fff3df; color: #925c00; }
.question-status.draft { background: #f1e7f7; color: var(--purple); }
.question-status.answered { background: #eaf7ef; color: #17763c; }
.question-detail { min-width: 0; padding: 18px; }
.question-detail-head { display: flex; justify-content: space-between; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.question-detail-head h3 { margin: 7px 0 4px; font-size: 17px; }
.question-detail-head small, .question-detail-head time { color: var(--muted); font-size: 10px; }
.question-text, .question-wb-answer { margin: 14px 0; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfe; }
.question-text small, .question-wb-answer small { color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.question-text p, .question-wb-answer p { margin: 6px 0 0; font-size: 12px; line-height: 1.55; }
.question-draft-field textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
.assistant-proposal-placeholder { display: grid; gap: 5px; margin-top: 12px; padding: 11px 12px; border: 1px dashed #d5c7df; border-radius: 10px; background: #fcf9ff; }
.assistant-proposal-placeholder strong { color: var(--purple); font-size: 10px; }
.assistant-proposal-placeholder span { color: var(--muted); font-size: 10px; line-height: 1.45; }
.question-link-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.question-draft-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 14px; }
.question-send-gate { display: grid; gap: 6px; margin-top: 14px; padding: 12px; border: 1px solid #efd7a9; border-radius: 10px; background: #fff9eb; }
.question-send-gate strong { color: #8a5b05; font-size: 11px; }
.question-send-gate span, .question-send-gate label { color: #7b6740; font-size: 10px; line-height: 1.45; }
.question-send-gate label { display: flex; align-items: center; gap: 7px; }
.question-send-gate button { width: fit-content; padding: 8px 11px; border: 0; border-radius: 8px; }
.question-detail-message { min-height: 18px; margin: 10px 0 0; color: var(--purple); font-size: 10px; line-height: 1.45; }
.questions-empty { display: grid; gap: 6px; padding: 28px 18px; color: var(--muted); text-align: center; }
.questions-empty strong { color: var(--text); }
.questions-empty span { font-size: 10px; line-height: 1.5; }

@media (max-width: 900px) { .tool-chooser { grid-template-columns: 1fr; } }
@media (max-width: 980px) {
  .questions-filters { grid-template-columns: 1fr 1fr; }
  .questions-workspace { grid-template-columns: 1fr; }
  .questions-list { max-height: 340px; border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 520px) {
  .tool-fields,
  .volume-results,
  .pallet-sheet { grid-template-columns: 1fr; }
  .pallet-sheet .wide { grid-column: auto; }
  .tool-choice { grid-template-columns: 38px minmax(0, 1fr); padding: 14px; }
  .tool-choice b { grid-column: 2; }
  .tool-switcher { align-items: stretch; flex-direction: column; }
  .tool-switcher label { width: 100%; min-width: 0; }
  .questions-tool-head, .questions-result-line, .question-detail-head, .questions-load-control { align-items: stretch; flex-direction: column; }
  .questions-tool-head button { width: 100%; }
  .questions-load-control label, .questions-load-control button { width: 100%; max-width: none; }
  .questions-filters, .question-link-fields { grid-template-columns: 1fr; }
  .questions-filters { padding: 12px; }
  .questions-result-line, .question-detail { padding-left: 12px; padding-right: 12px; }
  .question-draft-actions { flex-direction: column; }
  .question-draft-actions button { width: 100%; }
}

@media print {
  body * { visibility: hidden !important; }
  #pallet-sheet,
  #pallet-sheet * { visibility: visible !important; }
  #pallet-sheet { position: absolute; inset: 0; width: 100%; box-sizing: border-box; display: grid; border: 2px solid #111; border-radius: 0; }
  #pallet-sheet input,
  #pallet-sheet textarea { border: 1px solid #777; color: #000; }
}

/* Read-only today snapshot from currently available new FBS orders. */
.sales-today {
  margin: 0 0 18px;
}

.sales-today .panel-head {
  gap: 16px;
}

.source-note {
  max-width: 390px;
  color: var(--orange);
  font-size: 11px;
  text-align: right;
}

.sales-metrics {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.sales-metrics article {
  padding: 15px 19px;
}

.sales-metrics article + article {
  border-left: 1px solid var(--line);
}

.sales-metrics small,
.sales-metrics span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.sales-metrics strong {
  display: block;
  margin: 4px 0 2px;
  font-size: 23px;
}

.comparison.up { color: var(--green); }
.comparison.down { color: #b23a48; }
.comparison.neutral { color: var(--muted); }

.hourly-chart-wrap {
  padding: 15px 19px 12px;
}

.chart-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.chart-title h3 {
  margin: 0;
  font-size: 13px;
}

.chart-title span {
  color: var(--muted);
  font-size: 10px;
}

.hourly-chart {
  height: 150px;
  display: grid;
  grid-template-columns: repeat(24,minmax(16px,1fr));
  align-items: end;
  gap: 4px;
  overflow-x: auto;
}

.chart-unavailable {
  grid-column: 1 / -1;
  align-self: center;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.hour-column {
  height: 128px;
  min-width: 16px;
  display: grid;
  grid-template-rows: 16px 1fr 16px;
  align-items: end;
  justify-items: center;
}

.hour-column i {
  width: min(16px,80%);
  min-height: 2px;
  border-radius: 4px 4px 1px 1px;
  background: linear-gradient(180deg,#b34bce,var(--purple));
}

.hour-column small,
.hour-value {
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
}

@media (max-width: 720px) {
  .sales-today .panel-head,
  .chart-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .source-note {
    text-align: left;
  }

  .sales-metrics {
    grid-template-columns: 1fr;
  }

  .sales-metrics article + article {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .hourly-chart {
    grid-template-columns: repeat(24,22px);
  }
}

/* Clear column grid for unit economics without changing calculations. */
.economics-table th + th,
.economics-table td + td {
  border-left: 1px solid var(--line);
}

.economics-table th {
  background: #fafbfe;
}

.economics-table th:first-child,
.economics-table td:first-child {
  border-right: 1px solid var(--line);
}

/* Dedicated product-search toolbar and interactive table rows. */
.product-search-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 22px 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f9fc;
}

.product-search {
  position: relative;
  width: min(480px,100%);
}

.product-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  z-index: 1;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  transform: translateY(-52%);
  pointer-events: none;
}

.product-search input {
  width: 100%;
  padding: 11px 13px 11px 40px;
  border: 1px solid #d9deea;
  border-radius: 10px;
  background: #fff;
  transition: border-color .18s ease,box-shadow .18s ease;
}

.product-search input:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-pale);
}

.products-table tbody tr {
  outline: none;
  transition: background-color .16s ease,box-shadow .16s ease;
}

.products-table tbody tr:hover,
.products-table tbody tr:focus,
.products-table tbody tr:focus-within {
  background: #fbf6fd;
  box-shadow: inset 3px 0 0 var(--purple);
}

.products-table tbody tr:hover td,
.products-table tbody tr:focus td,
.products-table tbody tr:focus-within td {
  background: #fbf6fd;
}

.product-list-item .mini-photo img {
  transition: transform .18s ease;
}

.products-table tbody tr:hover .mini-photo img,
.products-table tbody tr:focus .mini-photo img,
.products-table tbody tr:focus-within .mini-photo img {
  transform: scale(1.06);
}

@media (max-width: 720px) {
  .product-search-toolbar {
    margin: 17px 0 10px;
    padding: 9px;
  }

  .product-search {
    width: 100%;
  }
}

/* Dense unit-economics grid with compact, proportional thumbnails. */
.economics-table table {
  min-width: 2160px;
  table-layout: fixed;
}

.economics-table .table-wrap { max-height: min(68vh, 720px); overflow: auto; overscroll-behavior: contain; }
.economics-table thead th { position: sticky; top: 0; z-index: 4; background: #fafbfe; box-shadow: inset 0 -1px 0 var(--line); }
.economics-table thead th:first-child { top: 0; left: 0; z-index: 6; background: #fafbfe; }

.economics-table th {
  min-width: 126px;
  padding: 8px 6px;
  font-size: 10px;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}

.economics-table th:nth-child(2),
.economics-table td:nth-child(2) { width: 136px; }
.economics-table th:nth-child(3),
.economics-table td:nth-child(3) { width: 130px; }
.economics-table th:nth-child(4),
.economics-table td:nth-child(4) { width: 136px; }
.economics-table th:nth-child(14),
.economics-table td:nth-child(14),
.economics-table th:nth-child(15),
.economics-table td:nth-child(15) { width: 132px; }
.economics-table th:nth-child(16),
.economics-table td:nth-child(16) { width: 145px; }
.economics-table td:nth-child(16) { text-align: center; }

.economics-table td {
  padding: 5px 6px;
}

.economics-table th:first-child {
  min-width: 230px;
  width: 230px;
}

.economics-table td:first-child {
  min-width: 230px;
  width: 230px;
}

.economics-product {
  display: flex;
  align-items: center;
  min-width: 210px;
  gap: 8px;
  line-height: 1.25;
}

.economics-product .mini-photo {
  display: grid;
  width: 32px;
  height: 42px;
  flex: 0 0 32px;
}

.economics-product span {
  display: block;
  min-width: 0;
  max-width: 165px;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.economics-product small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.economics-input {
  width: 88px;
  padding: 6px 7px;
  border-radius: 7px;
  font-size: 12px;
}

@media (max-width: 720px) {
  .economics-table table {
    min-width: 2160px;
  }

  .economics-table .table-wrap { max-height: calc(100svh - 250px); min-height: 320px; }

  .economics-table th:first-child,
  .economics-table td:first-child {
    min-width: 205px;
  }

  .economics-product {
    min-width: 185px;
  }

  .economics-product .mini-photo {
    display: grid;
    width: 28px;
    height: 37px;
    flex-basis: 28px;
  }
}

/* Compact FBS rows: image, primary text, date/amount and status. */
.order-tabs {
  display: flex;
  gap: 7px;
  margin: 0 0 15px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.fbs-source-status { margin: 12px 0 8px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fafbfe; color: var(--muted); font-size: 10px; line-height: 1.45; }
.wb-order-state, .local-order-state { display: inline-flex; width: fit-content; padding: 3px 6px; border-radius: 99px; font-size: 8px; font-weight: 750; line-height: 1.25; }
.wb-order-state { background: #eaf2ff; color: #285f9d; }
.wb-order-state.unknown { background: #f0f1f5; color: #697083; }
.local-order-state { background: #f1e7f7; color: var(--purple); }

.order-tab {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.order-tab.active {
  border-color: #dcbbe9;
  background: var(--purple-pale);
  color: var(--purple);
}

.order-tab b {
  margin-left: 4px;
  font-size: 11px;
}

.order-tab.unmapped {
  border-style: dashed;
}

.order-toolbar {
  min-height: 39px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.order-toolbar:empty {
  min-height: 0;
  margin: 0;
}

.order-toolbar button,
.row-actions button {
  padding: 7px 9px;
  border: 0;
  border-radius: 8px;
  background: var(--purple-pale);
  color: var(--purple);
  font-size: 11px;
  font-weight: 750;
}

.order-toolbar .primary {
  background: var(--purple);
  color: #fff;
}

.order-toolbar button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.order-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.order-check {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.order-check input {
  margin: 0;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
}

.ready-note,.group-id {
  color: var(--green);
  font-size: 10px;
  font-weight: 750;
}

.group-id {
  display: block;
  margin-top: 5px;
}

.order {
  grid-template-columns: 40px minmax(0, 1fr) 150px auto;
  gap: 10px;
  padding: 12px 14px;
}

.order > .mini-photo {
  align-self: center;
}

.order h2,
.order p {
  overflow-wrap: anywhere;
}

.order-meta {
  min-width: 130px;
}

@media (max-width: 720px) {
  .order-toolbar {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .order-title-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .row-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .order {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 6px 10px;
    padding: 12px;
  }

  .order > .mini-photo {
    grid-row: 1 / span 3;
    align-self: start;
  }

  .order-meta,
  .order > div:last-child {
    grid-column: 2;
    min-width: 0;
    text-align: left;
  }

  .order-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
  }
}

.product-card .availability {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
}

.product-card .availability small {
  font-weight: 700;
}

.pill.danger {
  background: #fde8eb;
  color: #b23a48;
}

.products-table {
  margin-top: 16px;
}

.products-table table {
  min-width: 1220px;
}

.actual-stock,
.pending-stock {
  display: block;
  white-space: nowrap;
}

.pending-stock {
  margin-top: 3px;
  color: var(--orange);
  font-size: 10px;
}

.stock-edit-button {
  padding: 7px 9px;
  border: 1px solid #dcbbe9;
  border-radius: 8px;
  background: var(--purple-pale);
  color: var(--purple);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.current-fbs,
.pending-warning {
  padding: 10px 11px;
  border-radius: 9px;
  font-size: 12px;
}

.current-fbs {
  background: #f4f5f9;
}

.pending-warning {
  background: #fff4e5;
  color: var(--orange);
}

.products-table th:first-child,
.products-table td:first-child {
  min-width: 280px;
}

.product-list-item .mini-photo {
  width: 40px;
  height: 52px;
}

@media (max-width: 720px) {
  .products-table {
    border-radius: 11px;
  }

  .products-table th:first-child,
  .products-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 220px;
    background: #fff;
  }

.products-table th:first-child {
    z-index: 2;
  }
}

/* FBS table matching the compact operational reference. */
.order-table-head,
.order {
  display: grid;
  grid-template-columns: 104px 110px 105px 90px minmax(250px,1fr) 90px 105px minmax(150px,auto);
  gap: 10px;
  align-items: center;
}

.order-table-head {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: #f7f8fc;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.order-table-head + .orders-list .order:first-child {
  border-radius: 0 0 14px 14px;
}

.order {
  padding: 10px 14px;
}

.order-select {
  display: grid;
  align-items: center;
  justify-items: start;
  padding-left: 2px;
  color: var(--muted);
}

.order-check input {
  width: 17px;
  height: 17px;
}

.order-number,
.order-product,
.order-row-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.order-number {
  align-items: flex-start;
  flex-direction: column;
}

.order-number strong,
.order-cost b {
  white-space: nowrap;
}

.order-date,
.order-elapsed,
.order-warehouse,
.order-cost {
  color: var(--muted);
  font-size: 11px;
}

.order-elapsed {
  color: var(--orange);
  font-weight: 750;
}

.order-warehouse {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.order-warehouse strong {
  color: var(--ink);
  font-size: 12px;
}

.order-warehouse small {
  color: var(--muted);
  font-size: 11px;
}

.assembly-warehouse-group {
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.assembly-warehouse-group > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #f7f4ff;
}

.assembly-warehouse-group > header div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.assembly-warehouse-group > header small,
.assembly-warehouse-group > header span {
  color: var(--muted);
  font-size: 12px;
}

.assembly-warehouse-group .order {
  border-radius: 0;
  border-width: 0 0 1px;
}

.assembly-warehouse-group .order:last-child {
  border-bottom: 0;
}

.order-product {
  min-width: 0;
}

.order-product > div:last-child {
  min-width: 0;
}

.order-product h2,
.order-product p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-row-actions {
  align-items: flex-start;
  flex-direction: column;
}

.order-row-actions button {
  padding: 6px 8px;
  border: 0;
  border-radius: 7px;
  background: var(--purple-pale);
  color: var(--purple);
  font-size: 10px;
  font-weight: 750;
  text-align: left;
}

.supply-card { margin-bottom: 10px; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: 0 4px 14px rgba(35,27,55,.04); }
.supply-card.unlinked { border-style: dashed; background: #fcfcfd; }
.supply-summary { display: grid; grid-template-columns: 34px 34px minmax(190px,1fr) minmax(150px,.75fr) 80px minmax(180px,.9fr) minmax(120px,auto); gap: 10px; align-items: center; padding: 13px 14px; }
.supply-check input { width: 18px; height: 18px; }
.supply-expand { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid #d9dbe3; border-radius: 8px; background: #fff; color: var(--purple); font-size: 20px; font-weight: 700; }
.supply-main, .supply-id, .supply-count, .supply-state { display: grid; gap: 4px; min-width: 0; }
.supply-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.supply-summary small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.supply-id b { overflow: hidden; color: #363441; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.supply-count b { color: var(--purple); font-size: 19px; }
.supply-actions button { min-height: 36px; padding: 7px 9px; border: 0; border-radius: 8px; background: var(--purple-pale); color: var(--purple); font-size: 10px; font-weight: 750; }
.supply-orders { border-top: 1px solid var(--line); background: #fafbfe; }
.supply-orders[hidden] { display: none; }
.supply-order { display: grid; grid-template-columns: 130px 46px minmax(180px,1fr) 110px; gap: 10px; align-items: center; padding: 9px 50px 9px 82px; border-bottom: 1px solid var(--line); font-size: 11px; }
.supply-order:last-child { border-bottom: 0; }
.supply-order > div { display: grid; gap: 3px; min-width: 0; }
.supply-order > div strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.supply-order small { color: var(--muted); }

@media (max-width: 720px) {
  .supply-summary { grid-template-columns: 28px 32px minmax(0,1fr); padding: 11px; }
  .supply-main { grid-column: 3; }
  .supply-id, .supply-count, .supply-state, .supply-actions { grid-column: 3; }
  .supply-id { margin-top: 4px; }
  .supply-count { display: flex; align-items: baseline; gap: 5px; }
  .supply-actions button { width: 100%; min-height: 44px; }
  .supply-order { grid-template-columns: 45px minmax(0,1fr); padding: 10px 12px 10px 71px; }
  .supply-order > span, .supply-order > b { grid-column: 2; }
  .supply-order > .mini-photo { grid-column: 1; grid-row: 1 / span 3; }
  .supply-order > div { grid-column: 2; }
  .supply-order > div strong { white-space: normal; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  .order-table-head {
    display: none;
  }

  .order {
    grid-template-columns: 28px minmax(0,1fr);
    gap: 5px 9px;
    padding: 11px;
    border-radius: 12px !important;
  }

  .order-select {
    grid-column: 1;
    grid-row: 1;
    place-items: center;
    padding-left: 0;
  }

  .order-number,
  .order-date,
  .order-elapsed,
  .order-product,
  .order-cost,
  .order-warehouse,
  .order-row-actions {
    grid-column: 2;
  }

  .order-product {
    margin: 5px 0;
  }

  .order-product h2,
  .order-product p {
    white-space: normal;
  }

  .order-cost::before {
    content: "Цена: ";
  }

  .order-warehouse::before {
    content: "Склад";
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
  }
}

.economics-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.economics-filter-panel {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto auto;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbfe;
}

.economics-search-filter { display: grid; gap: 6px; color: var(--text); font-size: 10px; font-weight: 750; }
.economics-search-control { position: relative; display: flex; align-items: center; }
.economics-search-control > span { position: absolute; left: 12px; color: var(--muted); font-size: 20px; pointer-events: none; }
.economics-search-control input { width: 100%; min-height: 42px; padding: 9px 86px 9px 38px; border: 1px solid #d9dde7; border-radius: 9px; background: #fff; color: var(--text); font: inherit; font-size: 12px; }
.economics-search-control input:focus { border-color: var(--purple); outline: 3px solid rgba(112, 56, 150, .13); }
.economics-search-control button { position: absolute; right: 5px; min-height: 32px; padding: 5px 9px; border: 0; border-radius: 7px; background: var(--purple-pale); color: var(--purple); font-size: 10px; font-weight: 750; cursor: pointer; }
.economics-search-control button[hidden] { display: none; }
.economics-hidden-toggle { display: inline-flex; align-items: center; min-height: 42px; gap: 7px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--text); font-size: 11px; font-weight: 650; white-space: nowrap; cursor: pointer; }
.economics-hidden-toggle input { width: 17px; height: 17px; margin: 0; accent-color: var(--purple); }
.economics-results-count { min-height: 42px; display: inline-flex; align-items: center; padding: 0 11px; border-radius: 9px; background: var(--purple-pale); color: var(--purple); font-size: 11px; font-weight: 750; white-space: nowrap; }
.economics-hidden-row { opacity: .72; }

.economics-visibility {
  padding: 6px 8px;
  border: 0;
  border-radius: 7px;
  background: var(--purple-pale);
  color: var(--purple);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}

.economics-visibility:hover { background: #eadcf5; }

.select-all-orders,
.mobile-select-all { display: inline-flex; align-items: center; gap: 6px; color: inherit; font-size: 10px; font-weight: 750; text-transform: none; letter-spacing: 0; white-space: nowrap; }
.select-all-orders input,
.mobile-select-all input { width: 16px; height: 16px; margin: 0; accent-color: var(--purple); }
.mobile-select-all { display: none; color: var(--text); font-size: 11px; }

#load-more-orders { display: block; margin: 14px auto 0; padding: 9px 16px; border: 1px solid #d8c5e6; border-radius: 9px; background: var(--purple-pale); color: var(--purple); font-size: 11px; font-weight: 750; cursor: pointer; }
#load-more-orders[hidden] { display: none; }
#load-more-orders:disabled { opacity: .45; cursor: default; }
.buyer-type { padding: 3px 6px; border-radius: 99px; background: #f2f3f6; color: var(--muted); font-size: 8px; font-weight: 750; white-space: nowrap; }
.buyer-type.b2b { background: #eaf2ff; color: #285f9d; }
.buyer-type.individual { background: #eaf7ef; color: #17763c; }
.buyer-type.unknown { background: #fff3df; color: #925c00; }
.fbs-group-warning { margin: 0 0 10px; padding: 10px 12px; border: 1px solid #efc6a4; border-radius: 9px; background: #fff8ed; color: #874d18; font-size: 11px; font-weight: 650; }
.fbs-group-warning[hidden] { display: none; }
.fbs-group-warning div { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.fbs-group-warning button { padding: 6px 8px; border: 0; border-radius: 7px; background: #fff; color: #874d18; font-size: 10px; font-weight: 750; }
.stock-safety-preview { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin: 14px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: #fafbfe; }
.stock-safety-preview > div { display: grid; gap: 3px; }
.stock-safety-preview strong { font-size: 12px; }
.stock-safety-preview small { color: var(--muted); font-size: 10px; }
.stock-safety-preview label { min-width: 245px; color: var(--muted); font-size: 10px; }
.stock-safety-preview select { width: 100%; background: #fff; }
.order-stock-state { display: inline-flex; align-items: center; min-height: 22px; padding: 3px 7px; border-radius: 99px; background: #eaf7ef; color: #17763c; font-size: 9px; font-weight: 800; white-space: nowrap; }
.order-stock-state.unknown { background: #f0f1f5; color: #697083; }
.order-stock-state.none { background: #ffe7e4; color: #a9332c; }
.order-stock-state.insufficient { background: #fff3df; color: #925c00; }
.stock-block-note { display: block; margin-top: 5px; color: #a14d45; font-size: 9px; line-height: 1.35; }

@media (max-width: 520px) {
  .economics-toolbar { align-items: stretch; flex-direction: column; }
  .economics-filter-panel { display: grid; grid-template-columns: 1fr; padding: 10px; }
  .economics-search-control input { min-height: 46px; font-size: 16px; }
  .economics-search-control button, .economics-hidden-toggle, .economics-results-count { min-height: 44px; }
  .page-update-status { margin-top: 16px; text-align: left; }
  .sync-tool-action #sync-button { width: 100%; }
}

@media (max-width: 720px) {
  .mobile-select-all { display: inline-flex; }
  .stock-safety-preview { align-items: stretch; flex-direction: column; }
  .stock-safety-preview label { min-width: 0; }
  .order-number { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
  .order-number > strong { width: 100%; font-size: 14px; }
  .order-stock-state { min-height: 26px; }
  .order-date, .order-elapsed, .order-cost, .order-warehouse { color: var(--muted); font-size: 11px; }
  .order-product h2 { font-size: 13px; line-height: 1.35; }
  .order-row-actions { margin-top: 7px; padding-top: 9px; border-top: 1px solid var(--line); }
}

.task-layout { display: grid; grid-template-columns: minmax(430px, 1.15fr) minmax(320px, .85fr); gap: 16px; }
.calendar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.calendar-head h2 { margin: 0; font-size: 18px; text-transform: capitalize; }
.calendar-weekdays,
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays span { padding: 6px; color: var(--muted); font-size: 10px; font-weight: 750; text-align: center; }
.calendar-grid { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.calendar-day { min-width: 0; min-height: 88px; padding: 7px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; color: var(--text); text-align: left; cursor: pointer; }
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day > span { display: inline-grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; font-size: 11px; font-weight: 750; }
.calendar-day.outside { background: #fafafd; color: #a9abb3; }
.calendar-day.today > span { background: var(--purple); color: #fff; }
.calendar-day.selected { box-shadow: inset 0 0 0 2px var(--purple); background: #fcf9ff; }
.calendar-task { display: block; overflow: hidden; margin-top: 4px; padding: 3px 4px; border-radius: 4px; background: var(--purple-pale); color: var(--purple); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.calendar-task.done { background: #eaf7ef; color: #17763c; text-decoration: line-through; }
.calendar-more { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.tasks-side { min-width: 0; }
.task-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.task-filters label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 700; }
.task-filters select { width: 100%; padding: 8px; border: 1px solid #d9dbe3; border-radius: 8px; background: #fff; color: var(--text); }
.selected-date-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.selected-date-line small { color: var(--muted); }
.selected-date-line h2 { margin: 2px 0 0; font-size: 17px; text-transform: capitalize; }
.task-list { display: grid; gap: 9px; }
.task-card { padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.task-card.overdue { border-color: #efb8b3; background: #fffafa; }
.task-card.done { opacity: .72; }
.task-card-head,
.task-meta,
.task-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 7px; }
.task-card h3 { margin: 10px 0 5px; font-size: 15px; }
.task-card p { margin: 0 0 9px; color: var(--muted); font-size: 11px; line-height: 1.45; white-space: pre-wrap; }
.task-meta { justify-content: flex-start; color: var(--muted); font-size: 10px; }
.task-actions { justify-content: flex-end; margin-top: 11px; }
.task-category,
.task-priority,
.overdue-label,
.task-status { display: inline-flex; padding: 4px 6px; border-radius: 99px; background: #f2f3f6; color: var(--muted); font-size: 9px; font-weight: 750; }
.task-category.purchase { background: #fff3df; color: #925c00; }
.task-category.supply { background: #eaf2ff; color: #285f9d; }
.task-category.warehouse { background: #eaf7ef; color: #17763c; }
.task-priority.high,
.overdue-label { background: #ffe7e4; color: #a9332c; }
.task-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }

#task-dialog { width: min(680px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid #e2e4eb; border-radius: 19px; background: #fff; box-shadow: 0 24px 75px rgba(24,32,51,.26); overflow: auto; }
#task-dialog::backdrop { background: rgba(24,32,51,.52); backdrop-filter: blur(2px); }
#task-dialog form { display: grid; gap: 13px; padding: 26px 28px 24px; background: #fbfbfd; }
#task-dialog .eyebrow { margin-bottom: -9px; }
#task-dialog h2 { margin: 0 42px 2px 0; font-size: 22px; letter-spacing: -.35px; }
#task-dialog label { display: grid; gap: 6px; color: #3d3d49; font-size: 12px; font-weight: 700; line-height: 1.3; text-transform: none; letter-spacing: 0; }
#task-dialog form > label { padding: 0 14px; }
#task-dialog input,
#task-dialog select,
#task-dialog textarea { width: 100%; min-height: 38px; box-sizing: border-box; padding: 10px 11px; border: 1px solid #d9dbe3; border-radius: 9px; background: #fff; color: var(--text); font: 600 12px/1.35 Inter, ui-sans-serif, system-ui, sans-serif; text-align: left; }
#task-dialog select { padding-right: 28px; }
#task-dialog textarea { min-height: 76px; resize: vertical; }
#task-dialog input:hover,
#task-dialog select:hover,
#task-dialog textarea:hover { border-color: #c7bbd2; }
#task-dialog input:focus-visible,
#task-dialog select:focus-visible,
#task-dialog textarea:focus-visible { outline: 3px solid rgba(111,45,189,.16); outline-offset: 1px; border-color: var(--purple); }
#task-dialog .close { display: grid; place-items: center; right: 18px; top: 16px; width: 34px; height: 34px; padding: 0; border-radius: 9px; background: #f3f4f7; color: #646b7a; font-size: 21px; line-height: 1; }
#task-dialog .close:hover { background: var(--purple-pale); color: var(--purple); }
#task-dialog .task-form-grid { gap: 12px; margin-top: 2px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.task-assignee-help { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 500; line-height: 1.35; }
#task-dialog .store-privacy { margin: 0 14px; padding: 10px 12px; border-radius: 8px; background: #f2f3f7; line-height: 1.45; }
#task-dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin: 3px 14px 0; padding-top: 13px; border-top: 1px solid var(--line); }
#task-dialog .dialog-actions button { min-width: 118px; }

@media (max-width: 980px) { .task-layout { grid-template-columns: 1fr; } }
@media (max-width: 620px) {
  .calendar-day { min-height: 62px; padding: 4px; }
  .calendar-task { width: 6px; height: 6px; padding: 0; border-radius: 50%; color: transparent; }
  .calendar-more { display: none; }
  .task-filters,
  .task-form-grid { grid-template-columns: 1fr; }
  #task-dialog { width: calc(100% - 20px); max-height: calc(100vh - 20px); border-radius: 15px; }
  #task-dialog form { gap: 11px; padding: 19px 12px 15px; }
  #task-dialog form > label { padding: 0 8px; }
  #task-dialog .task-form-grid { margin: 0; padding: 11px; }
  #task-dialog .store-privacy,
  #task-dialog .dialog-actions { margin-left: 8px; margin-right: 8px; }
  #task-dialog h2 { font-size: 20px; }
  #task-dialog .close { right: 12px; top: 11px; }
  #task-dialog .dialog-actions { flex-direction: column-reverse; }
  #task-dialog .dialog-actions button { width: 100%; }
}

button,
.nav-item,
.tool-choice,
.task-card,
.calendar-day,
.product-list-item,
.order { transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease, border-color .16s ease; }

button:focus-visible,
.nav-item:focus-visible,
.tool-choice:focus-visible,
.task-card:focus-visible,
.calendar-day:focus-visible,
.product-list-item:focus-visible,
.order:focus-visible { outline: 3px solid rgba(111,45,189,.22); outline-offset: 2px; }

@media (hover: hover) and (pointer: fine) {
  button:not(:disabled):hover,
  .tool-choice:hover { transform: translateY(-1px) scale(1.01); box-shadow: 0 7px 18px rgba(36,25,66,.09); }
  .calendar-day:hover,
  .task-card:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(36,25,66,.07); }
}

@media (prefers-reduced-motion: reduce) {
  button,
  .nav-item,
  .tool-choice,
  .task-card,
  .calendar-day,
  .product-list-item,
  .order { transition: none !important; }
}

.role-preview-select { display: grid; gap: 2px; color: var(--muted); font-size: 9px; font-weight: 700; }
.role-preview-select select { padding: 7px 8px; border: 1px solid #d9dbe3; border-radius: 8px; background: #fff; color: var(--text); font-size: 11px; }
.role-preview-notice { padding: 6px 24px; border-bottom: 1px solid var(--line); background: #fff8e5; color: #7d6208; font-size: 10px; text-align: center; }

body:not(.auth-ready) .app-shell { display: none; }
.auth-screen { min-height: 100vh; display: grid; place-items: center; box-sizing: border-box; padding: 24px; background: radial-gradient(circle at top left, #f4eafb, transparent 42%), #f7f7fa; }
.auth-screen[hidden] { display: none !important; }
.auth-card { width: min(430px, 100%); box-sizing: border-box; padding: 30px; border: 1px solid #e4e5ec; border-radius: 20px; background: #fff; box-shadow: 0 18px 55px rgba(36,25,66,.12); }
.auth-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; font-size: 17px; font-weight: 850; }
.auth-brand span { width: 15px; height: 15px; border-radius: 5px; background: var(--purple); }
.auth-card h1 { margin: 5px 0 9px; font-size: 27px; }
.auth-intro { margin: 0 0 20px; color: var(--muted); line-height: 1.5; }
.auth-card form { display: grid; gap: 13px; }
.auth-card [hidden] { display: none !important; }
.auth-card label,
.user-form-grid label { display: grid; gap: 6px; color: #3d3d49; font-size: 12px; font-weight: 700; }
.auth-card input,
.user-form-grid input,
.user-form-grid select { width: 100%; box-sizing: border-box; padding: 11px; border: 1px solid #d9dbe3; border-radius: 9px; background: #fff; color: var(--text); font: inherit; }
.auth-message { min-height: 18px; color: #a9332c; font-size: 11px; }
.auth-local-note { margin: 16px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.current-user { display: grid; grid-template-columns: auto auto auto; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 10px; }
.current-user b { color: var(--purple); }
.current-user button { padding: 5px 7px; border: 0; border-radius: 6px; background: #f2f3f6; color: var(--muted); font-size: 9px; font-weight: 750; }
.local-users-panel { margin-top: 18px; }
.user-form-grid { display: grid; grid-template-columns: 1fr 1fr 150px auto; gap: 10px; align-items: end; }
.local-user-list { display: grid; gap: 7px; margin-top: 15px; }
.local-user-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 10px; border-radius: 8px; background: #f7f8fc; font-size: 11px; }
.local-user-list span { color: var(--muted); }

@media (max-width: 720px) {
  .role-preview-select { width: 100%; }
  .role-preview-select select { width: 100%; }
  .role-preview-notice { padding: 6px 12px; }
  .current-user { width: 100%; grid-template-columns: 1fr auto auto; }
  .user-form-grid { grid-template-columns: 1fr; }
}

/* Mobile application shell and installable local PWA. */
.pwa-install-button { min-height: 40px; padding: 8px 11px; border: 1px solid #d8c5e6; border-radius: 9px; background: var(--purple-pale); color: var(--purple); font-size: 11px; font-weight: 800; }
.pwa-install-button[hidden], .pwa-guidance[hidden] { display: none !important; }
.pwa-guidance { position: fixed; right: 18px; bottom: 18px; z-index: 30; max-width: 330px; padding: 11px 13px; border: 1px solid #d8c5e6; border-radius: 12px; background: #fff; color: #56455f; box-shadow: 0 12px 32px rgba(36,25,66,.16); font-size: 11px; line-height: 1.45; }

@media (max-width: 720px) {
  :root { scroll-padding-bottom: 86px; }
  body { min-width: 320px; padding-bottom: env(safe-area-inset-bottom); }
  .app-shell { overflow: visible; padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .topbar { position: sticky; top: 0; z-index: 20; min-height: 56px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
  .brand { font-size: 17px; }
  .topbar-actions { width: auto; margin-left: auto; gap: 6px; }
  .shop-select { max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .current-user { width: auto; grid-template-columns: auto auto; min-height: 44px; padding: 5px 6px; }
  .current-user > span { display: none; }
  .current-user button { min-width: 44px; min-height: 34px; }
  .pwa-install-button { min-height: 44px; }

  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(62px + env(safe-area-inset-bottom)); padding: 5px 6px env(safe-area-inset-bottom); gap: 3px; border-top: 1px solid var(--line); border-bottom: 0; background: rgba(255,255,255,.97); box-shadow: 0 -8px 24px rgba(24,32,51,.08); overscroll-behavior-x: contain; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { min-width: 76px; min-height: 52px; padding: 5px 7px; border-radius: 10px; font-size: 10px; line-height: 1.15; text-align: center; white-space: normal; }
  .nav-item::before { display: block; margin-bottom: 3px; font-size: 16px; line-height: 1; }
  .nav-item[data-page="overview"]::before { content: "⌂"; }
  .nav-item[data-page="products"]::before { content: "▦"; }
  .nav-item[data-page="orders"]::before { content: "▤"; }
  .nav-item[data-page="economics"]::before { content: "₽"; }
  .nav-item[data-page="connections"]::before { content: "⚙"; }
  .nav-item[data-page="tasks"]::before { content: "✓"; }
  .nav-item[data-page="tools"]::before { content: "⌘"; }
  .nav-item b { padding: 1px 4px; font-size: 8px; }

  main { padding: 17px 12px 12px; }
  .heading { align-items: stretch; flex-direction: column; gap: 10px; }
  .heading h1 { font-size: 22px; line-height: 1.12; }
  .heading .muted { font-size: 12px; line-height: 1.4; }
  .heading > button, .heading .primary { min-height: 44px; width: 100%; }
  .panel { border-radius: 13px; }
  .panel-head { align-items: flex-start; padding: 14px; }
  button, .primary, .secondary, .text-button, .load-more, .order-tab, .order-toolbar button, .row-actions button, .tool-choice { min-height: 44px; }
  input, select, textarea { min-height: 44px; font-size: 16px; }
  input[type="checkbox"], input[type="radio"] { min-width: 22px; min-height: 22px; }

  .metrics, .sales-metrics, .volume-results { grid-template-columns: 1fr; }
  .metrics article:last-child { grid-column: auto; }
  .source-note { max-width: none; text-align: left; }
  .hourly-chart-wrap { padding: 13px; }
  .chart-title { align-items: flex-start; flex-direction: column; }

  .table-wrap { position: relative; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
  .products-table th:first-child, .products-table td:first-child,
  .economics-table th:first-child, .economics-table td:first-child { position: sticky; left: 0; z-index: 3; background: #fff; box-shadow: 1px 0 0 var(--line), 7px 0 12px rgba(24,32,51,.04); }
  .products-table th:first-child, .products-table td:first-child { min-width: 190px; }
  .products-table table { min-width: 1120px; }
  .product-search-toolbar { margin-top: 14px; }
  .product-search { width: 100%; }

  .order-tabs { margin-top: 14px; padding-bottom: 3px; scroll-snap-type: x proximity; }
  .order-tab { min-height: 44px; scroll-snap-align: start; }
  .order-toolbar { display: grid; grid-template-columns: 1fr; align-items: stretch; }
  .order-toolbar > * { width: 100%; }
  .order { grid-template-columns: 34px minmax(0,1fr); padding: 12px 10px; }
  .order-select { min-width: 34px; min-height: 44px; }
  .order-product { display: grid; grid-template-columns: 42px minmax(0,1fr); align-items: start; }
  .order-row-actions, .row-actions { width: 100%; }
  .row-actions button, .order-row-actions button { width: 100%; text-align: center; }

  .tool-chooser { gap: 10px; }
  .tool-choice { padding: 14px; }
  .tool-fields, .pallet-sheet { grid-template-columns: 1fr; }
  .pallet-sheet .wide { grid-column: auto; }
  .tools-switcher { align-items: stretch; flex-direction: column; }

  .task-layout { grid-template-columns: 1fr; }
  .calendar-panel { padding: 10px; }
  .calendar-head button { min-width: 44px; }
  .calendar-day { min-height: 54px; padding: 3px; }
  .calendar-day > span { width: 28px; height: 28px; }
  .task-filters { grid-template-columns: 1fr; }
  .task-card { padding: 13px; }
  .task-actions { align-items: stretch; flex-direction: column; }
  .task-actions button { width: 100%; }

  dialog, #task-dialog { width: 100%; max-width: none; max-height: min(92svh, 760px); margin: auto 0 0; border: 0; border-radius: 20px 20px 0 0; }
  dialog form, #task-dialog form { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  dialog .close, #task-dialog .close { min-width: 44px; min-height: 44px; }
  .dialog-actions { align-items: stretch; flex-direction: column-reverse; }
  .dialog-actions button { width: 100%; min-height: 46px; }

  .auth-screen { align-items: end; padding: 12px 10px calc(12px + env(safe-area-inset-bottom)); }
  .auth-card { max-height: calc(100svh - 24px); overflow: auto; padding: 22px 18px; border-radius: 20px; }
  .auth-card button { min-height: 46px; }
  .pwa-guidance { left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); max-width: none; }
}

@media (display-mode: standalone) {
  .pwa-install-button, .pwa-guidance { display: none !important; }
}

/* Market Pilot assistant: advisory only, no marketplace writes. */
.assistant-privacy { margin: 18px 0 14px; padding: 12px 14px; border: 1px solid #d9c6e8; border-radius: 12px; background: #fbf7fe; color: #62466f; font-size: 11px; }
.assistant-tabs { display: flex; gap: 7px; padding: 5px; overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; background: #f5f5f8; }
.assistant-tabs button { flex: 0 0 auto; padding: 9px 13px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 750; }
.assistant-tabs button.active { background: #fff; color: var(--purple); box-shadow: 0 2px 8px rgba(24,32,51,.08); }
.assistant-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin: 16px 0; }
.assistant-summary > div { padding: 14px 16px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.assistant-summary small { display: block; color: var(--muted); font-size: 10px; }
.assistant-summary strong { display: block; margin-top: 5px; font-size: 19px; }
.assistant-insights { display: grid; gap: 10px; }
.assistant-card { display: grid; grid-template-columns: 8px minmax(0,1fr) auto; align-items: center; gap: 13px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.assistant-card-mark { width: 8px; height: 38px; border-radius: 8px; background: #aeb4c1; }
.assistant-card.ok .assistant-card-mark { background: #2ba66f; }.assistant-card.info .assistant-card-mark { background: #558be8; }.assistant-card.attention .assistant-card-mark { background: #e5a323; }.assistant-card.warning .assistant-card-mark { background: #d47725; }.assistant-card.danger .assistant-card-mark { background: #d54b59; }
.assistant-card h2 { margin: 0; font-size: 14px; }.assistant-card p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.assistant-events-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 22px 0 9px; }.assistant-events-head h2,.assistant-recommendations-title { margin: 0; font-size: 16px; }.assistant-events-head small { color: var(--muted); font-size: 10px; }
.assistant-event-list { display: grid; gap: 7px; }.assistant-event { display: grid; grid-template-columns: 7px minmax(0,1fr) auto; align-items: center; gap: 11px; width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--ink); text-align: left; }.assistant-event > span { width: 7px; height: 30px; border-radius: 7px; background: #e5a323; }.assistant-event.danger > span { background:#d54b59; }.assistant-event.warning > span { background:#d47725; }.assistant-event.read { opacity:.68; }.assistant-event div { display:grid; gap:2px; }.assistant-event small,.assistant-event time { color:var(--muted); font-size:10px; }.assistant-events-empty { padding:18px; border:1px dashed var(--line); border-radius:11px; color:var(--muted); text-align:center; font-size:11px; }.assistant-recommendations-title { margin:22px 0 9px; }
@media (max-width:720px) { .nav-item[data-page="assistant"]::before { content: "✦"; }.assistant-summary { grid-template-columns: 1fr; }.assistant-card { grid-template-columns: 7px minmax(0,1fr); }.assistant-card button { grid-column: 2; width: 100%; }.assistant-tabs button { min-height: 44px; }.assistant-events-head { align-items:stretch; flex-direction:column; }.assistant-event { grid-template-columns:7px minmax(0,1fr); }.assistant-event time { grid-column:2; }.assistant-events-head button { width:100%; } }

/* Keep every account action fully inside the desktop header. */
.topbar {
  min-height: 70px;
  height: auto;
  padding-block: 10px;
}
.topbar-actions {
  min-width: 0;
  flex: 0 1 auto;
  flex-flow: row wrap;
  align-content: center;
}
.topbar-actions > * { flex: 0 0 auto; }

@media (min-width: 721px) {
  .topbar-actions { max-width: calc(100% - 250px); }
}

/* Unified pallet-sheet-inspired stock and receipt dialogs. */
#fbs-stock-dialog, #receipt-dialog { width: min(640px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid #e2e4eb; border-radius: 19px; background: #fff; box-shadow: 0 24px 75px rgba(24,32,51,.26); overflow: auto; }
#fbs-stock-dialog::backdrop, #receipt-dialog::backdrop { background: rgba(24,32,51,.52); backdrop-filter: blur(2px); }
.stock-dialog-form, .receipt-dialog-form { display: grid; gap: 13px; padding: 26px 28px 24px; background: #fbfbfd; }
.stock-dialog-form h2, .receipt-dialog-form h2 { margin: 0 42px 0 0; font-size: 22px; }
.stock-dialog-product, .receipt-dialog-intro { margin: -4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.stock-dialog-group, .stock-write-group, .receipt-dialog-group { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.stock-dialog-group > label, .receipt-dialog-group > label:last-child, .stock-write-consequence, .stock-write-confirm { grid-column: 1 / -1; }
.stock-dialog-form label, .receipt-dialog-form label { color: #3d3d49; font-size: 12px; font-weight: 700; }
.stock-dialog-form input, .stock-dialog-form select, .receipt-dialog-form input, .receipt-dialog-form select, .receipt-dialog-form textarea { width: 100%; min-height: 40px; box-sizing: border-box; padding: 10px 11px; border: 1px solid #d9dbe3; border-radius: 9px; background: #fff; color: var(--text); font: 600 12px/1.35 Inter,ui-sans-serif,system-ui,sans-serif; }
.receipt-dialog-form textarea { min-height: 78px; resize: vertical; }
.stock-dialog-form label small, .receipt-dialog-form label small { color: var(--muted); font-size: 9px; font-weight: 500; }
.stock-state-row, .receipt-stock-context { display: grid; gap: 4px; padding: 11px 12px; border-radius: 9px; background: #f3f4f8; }
.stock-state-row.pending { background: #fff8e8; }
.stock-state-row span, .receipt-stock-context span { color: var(--muted); font-size: 10px; font-weight: 700; }
.stock-state-row strong, .receipt-stock-context strong { font-size: 16px; }
.stock-state-row small, .receipt-stock-context small { color: var(--muted); font-size: 9px; }
.stock-write-consequence { padding: 10px 11px; border-radius: 9px; background: #f4eef8; color: #60406b; font-size: 10px; line-height: 1.45; }
.stock-write-confirm { display: flex !important; align-items: flex-start; gap: 9px !important; padding: 10px 11px; border: 1px solid #d8c5e6; border-radius: 9px; background: #fcf9ff; line-height: 1.4; }
.stock-write-confirm input { width: 20px; min-width: 20px; min-height: 20px; margin: 0; accent-color: var(--purple); }
.stock-write-result { min-height: 18px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.stock-dialog-form .dialog-actions, .receipt-dialog-form .dialog-actions { flex-wrap: wrap; padding-top: 13px; border-top: 1px solid var(--line); }

@media (max-width: 620px) {
  #fbs-stock-dialog, #receipt-dialog { width: 100%; max-height: 92svh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
  .stock-dialog-form, .receipt-dialog-form { gap: 11px; padding: 19px 12px calc(15px + env(safe-area-inset-bottom)); }
  .stock-dialog-group, .stock-write-group, .receipt-dialog-group { grid-template-columns: 1fr; padding: 11px; }
  .stock-dialog-group > label, .receipt-dialog-group > label:last-child, .stock-write-consequence, .stock-write-confirm { grid-column: auto; }
  .stock-dialog-form .dialog-actions, .receipt-dialog-form .dialog-actions { flex-direction: column-reverse; }
  .stock-dialog-form .dialog-actions button, .receipt-dialog-form .dialog-actions button { width: 100%; min-height: 46px; }
}
