:root {
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-2: #f7f8f6;
  --text: #161a17;
  --muted: #6f766f;
  --line: #e4e8e3;
  --primary: #188a55;
  --primary-dark: #0e6f42;
  --primary-soft: #e8f6ef;
  --danger: #d44343;
  --danger-dark: #b72e2e;
  --danger-soft: #fff0f0;
  --warning: #b96a08;
  --warning-soft: #fff5e5;
  --shadow: 0 12px 34px rgba(27, 39, 31, .09);
  --radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--bg); }
body { overflow: hidden; }
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(24, 138, 85, .28); outline-offset: 2px; }
.hidden { display: none !important; }

.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  background: radial-gradient(circle at 50% 0%, #eef9f3 0, var(--bg) 45%);
}
.login-card {
  width: min(100%, 420px);
  padding: 34px 26px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.brand-mark {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 21px;
  background: var(--primary);
  color: white;
  font-size: 31px;
  font-weight: 850;
  box-shadow: 0 10px 24px rgba(24, 138, 85, .23);
}
.brand-mark.small { width: 42px; height: 42px; margin: 0; border-radius: 14px; font-size: 21px; box-shadow: none; }
.login-card h1 { margin: 0; text-align: center; font-size: 30px; letter-spacing: -.03em; }
.login-card > p { margin: 6px 0 28px; text-align: center; color: var(--muted); }
.login-card label { display: block; margin: 0 0 16px; }
.login-card label span { display: block; margin: 0 0 7px; font-size: 13px; font-weight: 750; color: #4f5650; }
.login-card input {
  width: 100%; height: 56px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); color: var(--text); font-size: 17px;
}
.primary-button {
  width: 100%; min-height: 58px; border: 0; border-radius: 17px; background: var(--primary); color: white;
  font-weight: 800; font-size: 17px; cursor: pointer;
}
.primary-button:active { transform: translateY(1px); background: var(--primary-dark); }
.primary-button:disabled { opacity: .55; cursor: default; }
.form-error { min-height: 22px; margin-top: 12px; color: var(--danger); text-align: center; font-size: 14px; }

.app-view { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  height: calc(64px + var(--safe-top));
  padding: calc(10px + var(--safe-top)) 14px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px); z-index: 20;
}
.topbar-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.topbar-brand > div:last-child { min-width: 0; display: grid; }
.topbar-brand strong { font-size: 18px; line-height: 1.1; }
.topbar-brand small { margin-top: 3px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 8px; }
.icon-button {
  width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text); font-size: 22px; font-weight: 750; cursor: pointer;
}
.icon-button:active { background: var(--surface-2); transform: scale(.98); }
.icon-button.is-spinning { animation: spin .8s linear infinite; }

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(330px, 410px) minmax(0, 1fr); }
.orders-pane { min-height: 0; display: flex; flex-direction: column; padding: 16px 14px 18px; border-right: 1px solid var(--line); background: #f8f9f7; }
.search-wrap { height: 52px; display: flex; align-items: center; gap: 9px; padding: 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 17px; }
.search-wrap > span { color: var(--muted); font-size: 23px; transform: rotate(-15deg); }
.search-wrap input { flex: 1; min-width: 0; height: 48px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 16px; }
.clear-search { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #ecefec; color: #59605a; font-size: 20px; }
.list-meta { display: flex; justify-content: space-between; gap: 12px; padding: 16px 4px 10px; font-size: 14px; }
.list-meta strong { font-size: 17px; }
.list-meta span { color: var(--muted); }
.orders-list { min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 0 calc(18px + var(--safe-bottom)); scrollbar-width: thin; }
.order-card {
  width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 16px; margin-bottom: 9px;
  border: 1px solid var(--line); border-radius: 19px; background: var(--surface); text-align: left; color: var(--text); cursor: pointer;
}
.order-card.active { border-color: rgba(24,138,85,.65); box-shadow: 0 0 0 3px rgba(24,138,85,.09); }
.order-card:active { transform: scale(.995); }
.order-card-main { min-width: 0; }
.order-card-number { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.order-card-number strong { font-size: 16px; }
.order-card-number time { color: var(--muted); font-size: 12px; }
.order-card h3 { margin: 0; font-size: 17px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-card p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.order-card-side { display: grid; justify-items: end; align-content: center; gap: 8px; }
.order-card-side b { font-size: 16px; white-space: nowrap; }
.progress-mini { width: 62px; height: 6px; overflow: hidden; border-radius: 999px; background: #e9ece9; }
.progress-mini i { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.order-card.has-missing .progress-mini i { background: var(--warning); }
.load-more { min-height: 52px; margin-top: 8px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); font-weight: 750; color: var(--text); }
.list-empty, .list-loading { padding: 46px 20px; text-align: center; color: var(--muted); }
.list-loading .spinner { margin: 0 auto 12px; }

.detail-pane { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 24px clamp(18px, 4vw, 52px) calc(40px + var(--safe-bottom)); }
.empty-detail { min-height: 70vh; display: grid; place-content: center; justify-items: center; gap: 9px; color: var(--muted); }
.empty-detail div { font-size: 54px; }
.empty-detail strong { color: var(--text); font-size: 20px; }
.order-detail { width: min(100%, 900px); margin: 0 auto; }
.detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.back-button { display: none; width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 28px; }
.detail-title { min-width: 0; flex: 1; }
.detail-title small { display: block; color: var(--muted); font-size: 13px; margin-bottom: 3px; }
.detail-title h1 { margin: 0; font-size: clamp(24px, 4vw, 34px); letter-spacing: -.035em; }
.detail-total { text-align: right; }
.detail-total small { display: block; color: var(--muted); font-size: 12px; }
.detail-total strong { font-size: 22px; white-space: nowrap; }

.customer-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 17px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.customer-card h2 { margin: 0; font-size: 19px; }
.customer-card p { margin: 5px 0 0; color: var(--muted); font-size: 14px; word-break: break-word; }
.customer-contact-actions { align-self: center; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.call-link { align-self: center; display: grid; place-items: center; min-width: 48px; height: 48px; padding: 0; border: 0; border-radius: 15px; background: var(--primary-soft); color: var(--primary-dark); text-decoration: none; font-size: 21px; cursor: pointer; }
.telegram-contact-link { background: #e8f3ff; color: #1768aa; }
.order-note { padding: 14px 16px; margin-bottom: 12px; border-radius: 17px; background: var(--warning-soft); color: #6a430d; }
.order-note small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .7; margin-bottom: 4px; }

.pick-launch { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 15px; padding: 18px; margin-bottom: 14px; border-radius: var(--radius); background: #153c2c; color: white; box-shadow: var(--shadow); }
.pick-launch-copy strong { display: block; font-size: 20px; }
.pick-launch-copy span { display: block; margin-top: 5px; color: rgba(255,255,255,.72); font-size: 14px; }
.pick-launch button { min-height: 54px; padding: 0 20px; border: 0; border-radius: 16px; background: white; color: #123a29; font-weight: 850; cursor: pointer; }
.detail-progress { margin-top: 11px; height: 7px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.18); }
.detail-progress i { display: block; height: 100%; border-radius: inherit; background: #72d9a4; }

.receipt-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.receipt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px; border-bottom: 1px solid var(--line); }
.receipt-head h2 { margin: 0; font-size: 20px; }
.receipt-head span { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }
.add-item-button { min-height: 44px; padding: 0 14px; border: 0; border-radius: 13px; background: var(--primary-soft); color: var(--primary-dark); font-weight: 800; white-space: nowrap; }
.receipt-list { display: grid; }
.receipt-row { width: 100%; display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 13px 15px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--text); text-align: left; cursor: pointer; }
.receipt-row:last-child { border-bottom: 0; }
.receipt-row:active { background: var(--surface-2); }
.receipt-thumb { width: 72px; height: 72px; display: grid; place-items: center; border-radius: 15px; overflow: hidden; background: #f1f3f0; font-size: 28px; }
.receipt-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.receipt-copy { min-width: 0; }
.receipt-copy strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 15px; line-height: 1.3; }
.receipt-copy small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.receipt-copy em { display: block; margin-top: 4px; color: var(--warning); font-size: 12px; font-style: normal; }
.receipt-value { min-width: 82px; text-align: right; }
.receipt-value b { display: block; font-size: 15px; white-space: nowrap; }
.item-state { display: inline-block; margin-top: 6px; padding: 4px 8px; border-radius: 999px; background: #eff1ef; color: #606760; font-size: 11px; font-weight: 800; }
.item-state.picked { background: var(--primary-soft); color: var(--primary-dark); }
.item-state.missing { background: var(--danger-soft); color: var(--danger-dark); }
.item-state.partial { background: var(--warning-soft); color: var(--warning); }
.receipt-row.missing .receipt-copy strong { text-decoration: line-through; opacity: .68; }
.receipt-row.missing .receipt-value b { color: var(--danger); }
.receipt-total { padding: 18px; border-top: 1px solid var(--line); background: #fafbfa; }
.receipt-total-line { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 8px; color: var(--muted); }
.receipt-total-line b { color: var(--danger); }
.receipt-total-main { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; }
.receipt-total-main span { font-weight: 800; }
.receipt-total-main strong { font-size: clamp(25px, 4vw, 34px); white-space: nowrap; color: var(--primary-dark); }
.receipt-total small { display: block; margin-top: 8px; color: var(--muted); line-height: 1.35; }

.picking-view { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; background: var(--bg); }
.picking-header { flex: 0 0 auto; padding: calc(10px + var(--safe-top)) 14px 12px; background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px); }
.picking-header-row { display: grid; grid-template-columns: 48px minmax(0,1fr) 48px; align-items: center; gap: 10px; }
.picking-close { width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); font-size: 28px; }
.picking-title { min-width: 0; text-align: center; }
.picking-title strong { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picking-title span { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; }
.picking-progress-row { display: flex; justify-content: space-between; gap: 14px; margin-top: 11px; font-size: 13px; color: var(--muted); }
.picking-progress-row b { color: var(--text); }
.progress-track { height: 7px; margin-top: 8px; overflow: hidden; border-radius: 999px; background: #e7ebe7; }
.progress-track i { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width .25s ease; }
.picking-body { min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px 150px; }
.picking-card { width: min(100%, 620px); margin: 0 auto; }
.product-image-button { width: 100%; height: clamp(252px, 40.5dvh, 432px); display: grid; place-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 25px; background: white; overflow: hidden; box-shadow: 0 8px 28px rgba(25,35,28,.06); }
.product-image-button img { width: 75%; height: 75%; object-fit: contain; object-position: center 5%; }
.product-image-placeholder { display: grid; place-items: center; gap: 8px; color: var(--muted); font-size: 64px; }
.product-image-placeholder small { font-size: 14px; }
.picking-product { padding: 18px 4px 8px; text-align: center; }
.picking-product h1 { margin: 0; font-size: clamp(23px, 5vw, 32px); line-height: 1.16; letter-spacing: -.025em; }
.picking-codes { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; margin-top: 9px; color: var(--muted); font-size: 12px; }
.picking-note { display: inline-block; margin-top: 10px; padding: 7px 11px; border-radius: 999px; background: var(--warning-soft); color: var(--warning); font-size: 12px; font-weight: 750; }
.need-box { display: flex; align-items: baseline; justify-content: center; gap: 9px; margin: 15px 0 3px; }
.need-box span { color: var(--muted); font-size: 16px; }
.need-box strong { font-size: 38px; line-height: 1; }
.need-box small { font-size: 16px; font-weight: 800; }
.picking-price { color: var(--muted); font-size: 13px; }

.pick-actions { display: grid; gap: 10px; margin-top: 17px; }
.pick-actions-inline { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 49px; }
.pick-actions-inline .pick-yes, .pick-actions-inline .pick-no { min-height: 62px; border-radius: 14px; font-size: 18px; }
.pick-yes, .pick-no, .pick-primary, .pick-secondary, .pick-restore, .pick-replace {
  width: 100%; min-height: 68px; border: 0; border-radius: 20px; font-weight: 850; font-size: 19px; cursor: pointer;
}
.pick-yes, .pick-primary { background: var(--primary); color: white; }
.pick-yes:active, .pick-primary:active { background: var(--primary-dark); }
.pick-no { background: var(--danger); color: white; }
.pick-no:active { background: var(--danger-dark); }
.pick-secondary, .pick-restore { background: white; border: 1px solid var(--line); color: var(--text); }
.pick-replace { background: var(--warning-soft); color: #794706; }
.quantity-caption { margin-top: 14px; text-align: center; color: var(--muted); font-size: 13px; font-weight: 750; }
.quantity-stepper { display: grid; grid-template-columns: 78px minmax(0,1fr) 78px; gap: 10px; align-items: center; margin-top: 8px; }
.quantity-stepper button { height: 72px; border: 0; border-radius: 20px; color: white; font-size: 40px; font-weight: 500; }
.quantity-stepper button.minus { background: var(--danger); }
.quantity-stepper button.plus { background: var(--primary); }
.quantity-stepper button:disabled { opacity: .35; }
.quantity-stepper input { width: 100%; height: 72px; border: 2px solid var(--line); border-radius: 20px; background: white; text-align: center; font-size: 32px; font-weight: 850; color: var(--text); }
.pick-primary.partial { background: var(--warning); }
.pick-state-panel { display: grid; gap: 10px; margin-top: 18px; padding: 18px; border-radius: 22px; background: white; border: 1px solid var(--line); text-align: center; }
.pick-state-panel .state-icon { font-size: 50px; }
.pick-state-panel h2 { margin: 0; font-size: 23px; }
.pick-state-panel p { margin: 0 0 4px; color: var(--muted); line-height: 1.4; }
.pick-state-panel.is-missing { background: var(--danger-soft); border-color: #f3cdcd; }
.pick-state-panel.is-picked {
  margin-top: 9px;
  padding: 12px 14px;
  gap: 5px;
  background: var(--primary-soft);
  border-color: #cbe9d9;
}
.pick-state-panel.is-picked .state-icon { font-size: 37px; line-height: 1; }
.pick-state-panel.is-picked h2 { font-size: 18px; line-height: 1.15; }
.pick-state-panel.is-picked p { margin-bottom: 0; font-size: 12px; line-height: 1.25; }
.pick-state-panel.is-picked .pick-restore {
  min-height: 46px;
  border-radius: 14px;
  font-size: 14px;
}

.picking-footer { position: fixed; z-index: 82; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 10px 14px calc(10px + var(--safe-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(18px); }
.picking-footer button { min-width: 54px; height: 54px; border: 1px solid var(--line); border-radius: 17px; background: white; font-size: 24px; }
.picking-footer-total { text-align: center; }
.picking-footer-total span { display: block; color: var(--muted); font-size: 11px; }
.picking-footer-total strong { display: block; margin-top: 2px; font-size: 19px; color: var(--primary-dark); }
.picking-save { display: block; min-height: 16px; margin-top: 3px; color: var(--muted); font-size: 10px; }
.picking-save.error { color: var(--danger); }
.completion-card { width: min(100%, 560px); margin: 30px auto 0; padding: 28px 22px; border: 1px solid var(--line); border-radius: 27px; background: white; text-align: center; box-shadow: var(--shadow); }
.completion-icon { width: 84px; height: 84px; display: grid; place-items: center; margin: 0 auto 18px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 44px; }
.completion-card h1 { margin: 0; font-size: 28px; }
.completion-card > p { margin: 8px 0 20px; color: var(--muted); }
.completion-summary { display: grid; gap: 10px; padding: 16px; margin-bottom: 18px; border-radius: 18px; background: var(--surface-2); text-align: left; }
.completion-summary div { display: flex; justify-content: space-between; gap: 15px; }
.completion-summary .grand { padding-top: 10px; border-top: 1px solid var(--line); font-size: 19px; }
.completion-card button { min-height: 60px; }
.completion-actions { display: grid; gap: 10px; }
.completion-back-button {
  width: 100%; min-height: 58px; border: 1px solid var(--line); border-radius: 17px;
  background: white; color: var(--text); font-weight: 800; font-size: 16px; cursor: pointer;
}
.completion-back-button:active { background: var(--surface-2); transform: translateY(1px); }
.payment-details-button {
  width: 100%; min-height: 58px; border: 1px solid rgba(24,138,85,.28); border-radius: 17px;
  background: var(--primary-soft); color: var(--primary-dark); font-weight: 850; font-size: 16px; cursor: pointer;
}
.payment-details-button:active { background: #d9f0e4; transform: translateY(1px); }

.send-action { display: inline-flex; align-items: center; justify-content: center; gap: 9px; transition: background .16s ease, border-color .16s ease, color .16s ease; }
.send-action.is-sending:disabled {
  opacity: 1; cursor: wait; border: 1px solid #cfded6;
  background: #edf4f0; color: #446257; box-shadow: none;
}
.send-action.is-sent:disabled {
  opacity: 1; cursor: default; border: 1px solid #91d4b0;
  background: #d9f5e6; color: #087545; box-shadow: none;
}
.send-action.is-pending:disabled {
  opacity: 1; cursor: wait; border: 1px dashed #7fc59f;
  background: #effaf4; color: #176d48; box-shadow: none;
}
.send-action.is-reserved:disabled {
  opacity: 1; cursor: not-allowed; border: 1px solid #e2c77f;
  background: #fff8e7; color: #795c12; box-shadow: none;
}
.send-action.is-resend {
  border-color: #18a866; background: #0dad63; color: white; box-shadow: 0 8px 20px rgba(13,173,99,.2);
}
.send-action.is-resend:active { background: #079452; transform: translateY(1px); }
.primary-button.send-action.is-sent:disabled,
.next-action-card > button.send-action.is-sent:disabled,
.primary-button.send-action.is-pending:disabled,
.next-action-card > button.send-action.is-pending:disabled {
  opacity: 1; border: 1px solid #7dcca2; background: #d9f5e6; color: #087545;
}
.send-action.is-error {
  border: 1px solid #efb7b7; background: #fff1f1; color: #b42323; box-shadow: none;
}
.send-action-spinner {
  width: 18px; height: 18px; flex: 0 0 18px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .72s linear infinite;
}
.send-reservation-resolution {
  display: grid; gap: 9px; width: 100%; padding: 11px; border: 1px solid #e2c77f;
  border-radius: 14px; background: #fffaf0; color: #624a10; text-align: left;
}
.send-reservation-resolution > small { font-size: .78rem; line-height: 1.35; }
.send-reservation-resolution > div { display: grid; grid-template-columns: 1fr; gap: 8px; }
.send-reservation-resolution button {
  min-height: 43px; padding: 8px 11px; border: 1px solid #d6bb72; border-radius: 11px;
  background: white; color: #624a10; font-weight: 800; font-size: .8rem; cursor: pointer;
}
.send-reservation-resolution button:last-child { border-color: #df9c9c; color: #9f2424; }
.next-action-card .send-confirmation-line { color: #087545; font-weight: 850; }
.message-send-summary {
  display: flex; flex-wrap: wrap; gap: 9px; margin: 12px 0; padding: 12px;
  border: 1px solid #b6dfc9; border-radius: 17px; background: #effaf4;
}
.message-send-summary > div { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; color: #087545; }
.message-send-summary > div + div { padding-left: 12px; border-left: 1px solid #cbe8d7; }
.message-send-summary span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #d1f2df; font-weight: 900; }
.message-send-summary strong { font-size: .9rem; }
.message-send-summary small { color: #628273; font-size: .76rem; }
.message-send-summary > div.reserved { color: #795c12; }
.message-send-summary > div.reserved span { background: #fff0c2; color: #795c12; }
.message-send-summary > .send-reservation-resolution { flex: 1 0 100%; padding-left: 11px; border-left: 1px solid #e2c77f; }


.sheet-backdrop { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; padding-top: 30px; background: rgba(9,15,11,.46); backdrop-filter: blur(5px); }
.sheet { width: min(100%, 720px); max-height: min(88dvh, 820px); display: flex; flex-direction: column; overflow: hidden; border-radius: 28px 28px 0 0; background: var(--surface); box-shadow: 0 -16px 50px rgba(0,0,0,.18); padding-bottom: var(--safe-bottom); }
.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.sheet-header strong { display: block; font-size: 20px; }
.sheet-header small { display: block; margin-top: 3px; color: var(--muted); }
.settings-sheet { max-height: min(94dvh, 900px); }
.settings-body { min-height: 0; overflow-y: auto; display: grid; gap: 20px; padding: 17px 16px calc(18px + var(--safe-bottom)); }
.template-field { display: grid; gap: 8px; }
.template-field > span { font-size: 17px; font-weight: 850; }
.template-field > small { color: var(--muted); font-size: 13px; line-height: 1.4; }
.template-field textarea {
  width: 100%; min-height: 205px; resize: vertical; padding: 14px 15px; border: 1px solid var(--line); border-radius: 17px;
  background: var(--surface-2); color: var(--text); font-size: 15px; line-height: 1.48; white-space: pre-wrap;
}
#paymentDetailsTemplate { min-height: 190px; }
.template-help { display: flex; flex-wrap: wrap; gap: 7px; padding: 14px; border-radius: 16px; background: #f0f6f2; color: var(--muted); }
.template-help strong { flex: 0 0 100%; margin-bottom: 2px; color: var(--text); font-size: 13px; }
.template-help code { padding: 6px 8px; border-radius: 9px; background: white; color: var(--primary-dark); font-size: 12px; }
.settings-save-button { position: sticky; bottom: 0; box-shadow: 0 8px 22px rgba(24,138,85,.18); }

.product-search-row { padding: 14px 14px 8px; }
.product-search-row input { width: 100%; height: 54px; padding: 0 16px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface-2); font-size: 16px; }
.product-search-hint { padding: 12px 16px 18px; color: var(--muted); text-align: center; }
.product-results { min-height: 0; overflow-y: auto; padding: 0 12px 18px; }
.product-result { width: 100%; display: grid; grid-template-columns: 76px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 18px; background: white; text-align: left; color: var(--text); }
.product-result:disabled { opacity: .5; }
.product-result img, .product-result .placeholder { width: 76px; height: 76px; object-fit: contain; border-radius: 14px; background: #f2f4f1; }
.product-result .placeholder { display: grid; place-items: center; font-size: 28px; }
.product-result-copy { min-width: 0; }
.product-result-copy strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 15px; line-height: 1.28; }
.product-result-copy small { display: block; margin-top: 5px; color: var(--muted); }
.product-result-side { text-align: right; }
.product-result-side b { display: block; white-space: nowrap; }
.product-result-side span { display: inline-block; margin-top: 8px; padding: 7px 10px; border-radius: 11px; background: var(--primary); color: white; font-size: 12px; font-weight: 800; }

.confirm-card { width: min(calc(100% - 28px), 450px); padding: 26px 20px 20px; margin: auto; border-radius: 26px; background: white; box-shadow: 0 20px 70px rgba(0,0,0,.24); text-align: center; }
.confirm-icon { width: 62px; height: 62px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 50%; background: var(--warning-soft); color: var(--warning); font-size: 31px; font-weight: 850; }
.confirm-card h2 { margin: 0; font-size: 24px; }
.confirm-card p { margin: 9px 0 20px; color: var(--muted); line-height: 1.45; }
.confirm-actions { display: grid; gap: 9px; }
.confirm-actions button { min-height: 56px; border: 0; border-radius: 17px; font-weight: 850; }
.confirm-actions .danger { background: var(--danger); color: white; }
.confirm-actions .primary { background: var(--primary); color: white; }
.confirm-actions .warning { background: var(--warning); color: white; }
.confirm-actions .secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }

.image-viewer { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 54px 14px 24px; background: rgba(0,0,0,.92); }
.image-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.image-close { position: absolute; top: calc(10px + var(--safe-top)); right: 12px; width: 46px; height: 46px; border: 0; border-radius: 50%; background: rgba(255,255,255,.16); color: white; font-size: 27px; }

.busy-overlay { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; background: rgba(255,255,255,.55); backdrop-filter: blur(2px); }
.busy-card { display: flex; align-items: center; gap: 12px; padding: 16px 19px; border-radius: 18px; background: #16261e; color: white; box-shadow: var(--shadow); }
.spinner { width: 22px; height: 22px; display: inline-block; border: 3px solid rgba(255,255,255,.3); border-top-color: white; border-radius: 50%; animation: spin .8s linear infinite; }
.list-loading .spinner { border-color: rgba(24,138,85,.2); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; z-index: 180; left: 50%; bottom: calc(22px + var(--safe-bottom)); transform: translateX(-50%); width: min(calc(100% - 28px), 520px); padding: 14px 17px; border-radius: 16px; background: #18241e; color: white; text-align: center; box-shadow: 0 15px 45px rgba(0,0,0,.2); font-weight: 700; }
.toast.error { background: #8f2828; }
.undo-bar { position: fixed; z-index: 181; left: 50%; bottom: calc(18px + var(--safe-bottom)); transform: translateX(-50%); width: min(calc(100% - 24px), 560px); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 12px 16px; border-radius: 17px; background: #17221c; color: white; box-shadow: 0 15px 45px rgba(0,0,0,.24); }
.undo-bar span { min-width: 0; font-size: 14px; }
.undo-bar button { min-height: 40px; padding: 0 13px; border: 0; border-radius: 12px; background: white; color: #17221c; font-weight: 850; }
.offline .connection-only { display: block; }
body.picking-open .undo-bar { top: calc(116px + var(--safe-top)); bottom: auto; }
body.picking-open .toast { top: calc(116px + var(--safe-top)); bottom: auto; }


@media (max-width: 760px) {
  .picking-product { padding-top: 14px; }
  .picking-product h1 { font-size: clamp(22px, 6vw, 28px); }
  .workspace { display: block; position: relative; }
  .orders-pane { height: calc(100dvh - 64px - var(--safe-top)); border-right: 0; }
  .detail-pane { position: fixed; z-index: 30; inset: calc(64px + var(--safe-top)) 0 0; padding: 13px 12px calc(30px + var(--safe-bottom)); background: var(--bg); transform: translateX(100%); transition: transform .22s ease; }
  body.detail-open .detail-pane { transform: translateX(0); }
  .back-button { display: grid; place-items: center; }
  .detail-header { position: sticky; top: -13px; z-index: 4; margin: -13px -12px 12px; padding: 10px 12px; background: rgba(243,245,242,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
  .detail-title h1 { font-size: 24px; }
  .detail-total strong { font-size: 18px; }
  .pick-launch { grid-template-columns: 1fr; }
  .pick-launch button { width: 100%; }
  .receipt-head { align-items: flex-start; }
  .receipt-row { grid-template-columns: 64px minmax(0,1fr); }
  .receipt-thumb { width: 64px; height: 64px; }
  .receipt-value { grid-column: 2; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; }
  .receipt-value b { order: 2; }
  .product-image-button { height: clamp(225px, 28.8dvh, 270px); }
}

@media (max-width: 390px) {
  .topbar { padding-left: 10px; padding-right: 10px; }
  .orders-pane { padding-left: 10px; padding-right: 10px; }
  .order-card { padding: 14px; }
  .detail-pane { padding-left: 10px; padding-right: 10px; }
  .customer-card { grid-template-columns: 1fr; }
  .customer-contact-actions { justify-content: stretch; }
  .customer-contact-actions .call-link { width: 100%; }
  .receipt-head { display: grid; }
  .add-item-button { width: 100%; min-height: 48px; }
  .settings-body { padding-left: 12px; padding-right: 12px; }
  .template-field textarea { min-height: 185px; font-size: 14px; }
  #paymentDetailsTemplate { min-height: 175px; }
  .quantity-stepper { grid-template-columns: 70px minmax(0,1fr) 70px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* v8.1 workflow: compact status and responsible employee */
.order-workflow-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 10px; }
.order-status-badge { display: inline-flex; align-items: center; width: fit-content; max-width: 100%; padding: 5px 8px; border-radius: 10px; background: #eef1ee; color: #535b54; font-size: 11px; line-height: 1.25; font-weight: 850; }
.order-status-badge.large { padding: 7px 10px; border-radius: 12px; font-size: 13px; white-space: normal; }
.order-status-badge.warning { background: var(--warning-soft); color: var(--warning); }
.order-status-badge.ready { background: #e8f4ff; color: #16679e; }
.order-status-badge.payment { background: #fff4da; color: #8c5b00; }
.order-status-badge.paid { background: var(--primary-soft); color: var(--primary-dark); }
.order-status-badge.shipping { background: #eeeafd; color: #5c3bb0; }
.order-status-badge.success { background: #dff4e8; color: #0e7042; }
.order-status-badge.danger { background: var(--danger-soft); color: var(--danger-dark); }
.order-responsible { min-width: 0; color: var(--muted); font-size: 11px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.workflow-info-card { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; margin-bottom: 12px; }
.workflow-info-cell, .workflow-responsible { min-width: 0; padding: 14px 15px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); text-align: left; }
.workflow-info-cell small, .workflow-responsible small { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.workflow-responsible { position: relative; color: var(--text); }
.workflow-responsible strong { display: block; overflow: hidden; font-size: 15px; white-space: nowrap; text-overflow: ellipsis; }
.workflow-responsible em { display: block; margin-top: 5px; color: var(--primary-dark); font-size: 11px; font-style: normal; font-weight: 800; }
.workflow-responsible:disabled { opacity: 1; cursor: default; }
.workflow-responsible.can-change:active { background: var(--surface-2); }

.next-action-card { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 14px; margin-bottom: 14px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.next-action-card > div:first-child { min-width: 0; }
.next-action-card small { display: block; color: var(--muted); font-size: 12px; }
.next-action-card strong { display: block; margin-top: 3px; font-size: 18px; }
.next-action-card span { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.next-action-card > button, .workflow-button-stack > button { min-height: 50px; padding: 0 16px; border: 0; border-radius: 15px; background: var(--primary); color: white; font-weight: 850; white-space: nowrap; }
.next-action-card.ready { border-color: #cde6f8; background: #f7fbff; }
.next-action-card.payment { border-color: #f0dca9; background: #fffaf0; }
.next-action-card.paid { border-color: #cce7d7; background: #f7fcf9; }
.next-action-card.shipping { border-color: #ddd5f7; background: #faf9ff; }
.next-action-card.shipped { border-color: #c8e7d5; background: #f3fbf6; }
.workflow-button-stack { display: grid; gap: 7px; }
.workflow-button-stack .workflow-fallback { min-height: 38px; padding: 0 10px; border: 1px solid var(--line); background: white; color: var(--muted); font-size: 11px; }
.workflow-input { width: 100%; height: 56px; margin-top: 14px; padding: 0 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-2); color: var(--text); font-size: 18px; text-align: center; }
.completion-shipped { padding: 13px 15px; border-radius: 15px; background: var(--primary-soft); color: var(--primary-dark); font-weight: 850; text-align: center; }

.staff-settings { display: grid; gap: 13px; padding-top: 20px; border-top: 1px solid var(--line); }
.staff-settings header strong { display: block; font-size: 18px; }
.staff-settings header small { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.staff-create-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.staff-create-grid label { display: grid; gap: 5px; }
.staff-create-grid label span { color: var(--muted); font-size: 12px; font-weight: 750; }
.staff-create-grid input { width: 100%; height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); color: var(--text); }
.staff-create-grid button { grid-column: 1 / -1; min-height: 50px; border: 0; border-radius: 14px; background: #173e2e; color: white; font-weight: 850; }
.staff-list { display: grid; gap: 7px; }
.staff-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.staff-row.inactive { opacity: .58; }
.staff-row > div { min-width: 0; }
.staff-row-copy { flex: 1; }
.staff-row strong { display: block; overflow: hidden; font-size: 14px; white-space: nowrap; text-overflow: ellipsis; }
.staff-row small { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.staff-row button { min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); color: var(--text); font-size: 11px; font-weight: 800; }
.staff-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex: 0 0 auto; }
.staff-actions .staff-edit-button { border-color: #cbe6d6; background: var(--primary-soft); color: var(--primary-dark); }
.staff-actions .staff-toggle-button { background: var(--surface-2); }
.staff-role-badge.admin { background: #f3efff; color: #6042a6; }
.staff-edit-backdrop { z-index: 115; }
.staff-edit-sheet { width: min(100%, 560px); }
.staff-edit-body { gap: 12px; }
.staff-edit-field { display: grid; gap: 6px; }
.staff-edit-field > span { color: var(--muted); font-size: 12px; font-weight: 760; }
.staff-edit-field input, .staff-edit-field select { width: 100%; height: 52px; padding: 0 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); color: var(--text); font-size: 16px; }
.staff-edit-field input:focus, .staff-edit-field select:focus { outline: 3px solid rgba(24,138,85,.13); border-color: var(--primary); }
.staff-edit-field select:disabled { opacity: .7; }
.staff-edit-field > small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.staff-active-field { display: flex; align-items: flex-start; gap: 11px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.staff-active-field > input { flex: 0 0 auto; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--primary); }
.staff-active-field > span { min-width: 0; }
.staff-active-field strong { display: block; font-size: 14px; }
.staff-active-field small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.staff-active-field:has(input:disabled) { opacity: .62; }
.staff-edit-note { display: block; margin-top: -5px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.staff-self { color: var(--primary-dark); font-size: 11px; font-weight: 850; }
.staff-empty { padding: 16px; border-radius: 14px; background: var(--surface-2); color: var(--muted); text-align: center; font-size: 13px; }
.confirm-actions { max-height: 52dvh; overflow-y: auto; }

@media (max-width: 760px) {
  .workflow-info-card { grid-template-columns: 1fr 1fr; }
  .next-action-card { grid-template-columns: 1fr; }
  .next-action-card > button, .workflow-button-stack { width: 100%; }
  .staff-create-grid { grid-template-columns: 1fr; }
  .staff-row { align-items: flex-start; }
  .staff-actions { flex-direction: column; align-items: stretch; }
  .staff-actions button { min-width: 88px; }
}

@media (max-width: 390px) {
  .workflow-info-card { grid-template-columns: 1fr; }
  .order-status-badge { font-size: 10px; }
  .order-responsible { max-width: 170px; }
}

/* v8.2–v8.3 — створення ТТН, пакування та маркування 100×100 */
.integration-settings {
  display: grid;
  gap: 11px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-2);
}
.integration-settings > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.integration-settings > header > div { min-width: 0; }
.integration-settings strong { display: block; font-size: 17px; }
.integration-settings small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.integration-settings p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.integration-badge { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; background: #ecefec; color: #5d655f; font-size: 11px; font-weight: 850; }
.integration-badge.ready { background: var(--primary-soft); color: var(--primary-dark); }
.integration-badge.warning { background: var(--warning-soft); color: var(--warning); }
.secondary-settings-button {
  width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px;
  background: white; color: var(--text); font-weight: 820; cursor: pointer;
}
.secondary-settings-button:disabled { opacity: .5; cursor: default; }

.ttn-sheet { width: min(100%, 780px); max-height: min(96dvh, 980px); }
.ttn-body { min-height: 0; overflow-y: auto; display: grid; gap: 13px; padding: 14px 14px calc(20px + var(--safe-bottom)); }
.ttn-warning { padding: 12px 14px; border: 1px solid #efcd8f; border-radius: 14px; background: var(--warning-soft); color: #754707; font-size: 13px; line-height: 1.4; }
.ttn-section { display: grid; gap: 11px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: white; }
.ttn-section h3 { margin: 0; font-size: 17px; }
.ttn-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ttn-section-head button { min-height: 38px; padding: 0 10px; border: 1px solid rgba(24,138,85,.22); border-radius: 11px; background: var(--primary-soft); color: var(--primary-dark); font-size: 12px; font-weight: 850; }
.ttn-section label, .np-sender-sheet label { display: grid; gap: 6px; min-width: 0; }
.ttn-section label > span, .np-sender-sheet label > span { color: var(--muted); font-size: 12px; font-weight: 760; }
.ttn-section input, .ttn-section select, .np-sender-sheet input, .np-sender-sheet select {
  width: 100%; height: 50px; min-width: 0; padding: 0 12px; border: 1px solid var(--line); border-radius: 13px;
  background: var(--surface-2); color: var(--text); font-size: 15px;
}
.ttn-section input:focus, .ttn-section select:focus, .np-sender-sheet input:focus, .np-sender-sheet select:focus {
  outline: 3px solid rgba(24,138,85,.18); border-color: rgba(24,138,85,.45);
}
.ttn-grid { display: grid; gap: 10px; }
.ttn-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.ttn-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.ttn-grid.four { grid-template-columns: repeat(4, minmax(0,1fr)); }
.field-hint { display: block; min-height: 16px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.autocomplete-field { position: relative; }
.autocomplete-results {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0; max-height: 280px; overflow-y: auto;
  padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 18px 45px rgba(25,35,28,.17);
}
.autocomplete-results button { width: 100%; display: grid; gap: 3px; padding: 11px; border: 0; border-radius: 10px; background: white; color: var(--text); text-align: left; }
.autocomplete-results button:active { background: var(--surface-2); }
.autocomplete-results strong { font-size: 13px; }
.autocomplete-results small { color: var(--muted); font-size: 11px; line-height: 1.3; }
.autocomplete-empty { padding: 14px; color: var(--muted); text-align: center; font-size: 12px; }
.ttn-packages { display: grid; gap: 9px; }
.ttn-package { padding: 11px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-2); }
.ttn-package > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.ttn-package > header strong { font-size: 14px; }
.ttn-package > header button { min-height: 34px; padding: 0 9px; border: 0; border-radius: 10px; background: var(--danger-soft); color: var(--danger-dark); font-size: 11px; font-weight: 800; }
.ttn-confirm { display: flex; align-items: flex-start; gap: 10px; padding: 14px; border: 1px solid #c8dfd1; border-radius: 16px; background: #f5fbf7; }
.ttn-confirm input { flex: 0 0 auto; width: 23px; height: 23px; margin: 0; accent-color: var(--primary); }
.ttn-confirm span { color: #27543d; font-size: 13px; font-weight: 760; line-height: 1.4; }
.ttn-create-button { position: sticky; bottom: 0; box-shadow: 0 10px 26px rgba(24,138,85,.2); }
.ttn-after-note { margin: -4px 4px 0; color: var(--muted); text-align: center; font-size: 11px; line-height: 1.4; }

.np-sender-sheet { width: min(100%, 680px); }
.np-api-status { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); color: var(--muted); font-size: 13px; line-height: 1.4; }
.np-sender-sheet .settings-body { gap: 14px; }

.ttn-workflow-copy { min-width: 0; }
.ttn-workflow-number { font-size: clamp(20px, 3vw, 26px) !important; letter-spacing: .025em; word-break: break-all; }
.ttn-workflow-copy em { display: block; margin-top: 7px; color: var(--primary-dark); font-size: 11px; font-style: normal; font-weight: 800; }
.workflow-button-stack.ttn-actions { min-width: 190px; }
.workflow-button-stack .workflow-secondary { min-height: 42px; border: 1px solid var(--line); background: white; color: var(--text); }
.completion-ttn-actions { display: grid; gap: 9px; }
.completion-secondary-button {
  width: 100%; min-height: 54px; border: 1px solid var(--line); border-radius: 16px;
  background: white; color: var(--text); font-size: 15px; font-weight: 820;
}

@media (max-width: 760px) {
  .ttn-sheet, .np-sender-sheet { max-height: 96dvh; }
  .workflow-button-stack.ttn-actions { min-width: 0; }
  .ttn-grid.four { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 480px) {
  .ttn-body { padding-left: 10px; padding-right: 10px; }
  .ttn-section { padding: 12px; border-radius: 16px; }
  .ttn-grid.two, .ttn-grid.three { grid-template-columns: 1fr; }
  .ttn-grid.four { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .integration-settings > header { display: grid; }
  .integration-badge { width: fit-content; }
}

/* v8.3 — окреме робоче місце пакування ТТН */
.staff-create-grid select {
  width: 100%; height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: 13px;
  background: var(--surface-2); color: var(--text);
}
.staff-role-badge {
  display: inline-flex; align-items: center; width: fit-content; margin-top: 5px; padding: 4px 7px;
  border-radius: 999px; background: #eef1ef; color: #5b655f; font-size: 10px; font-weight: 850;
}
.staff-role-badge.packing { background: #eef3ff; color: #315795; }
.staff-role-badge.worker { background: var(--primary-soft); color: var(--primary-dark); }

.packing-station-view { height: 100dvh; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.packing-topbar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 12px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.97);
  backdrop-filter: blur(18px);
}
.packing-station-main {
  flex: 1 1 auto; min-height: 0; width: min(100%, 720px); margin: 0 auto; display: grid; align-content: start; gap: 0;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  padding: 20px 14px calc(42px + var(--safe-bottom));
}
.packing-search-card, .packing-result, .packing-empty {
  border: 1px solid var(--line); border-radius: 22px; background: white; box-shadow: 0 8px 28px rgba(25,35,28,.05);
}
.packing-search-card { padding: 18px; }
.packing-search-card > strong { display: block; font-size: 21px; }
.packing-search-card > span { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.packing-search-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 9px; margin-top: 15px; }
.packing-search-form input {
  width: 100%; height: 56px; min-width: 0; padding: 0 15px; border: 1px solid var(--line); border-radius: 15px;
  background: var(--surface-2); color: var(--text); font-size: 18px; font-weight: 760;
}
.packing-search-form button {
  min-width: 112px; height: 56px; border: 0; border-radius: 15px; background: var(--primary); color: white;
  font-size: 16px; font-weight: 850;
}
.packing-empty { display: grid; place-items: center; gap: 8px; margin-top: 14px; padding: 44px 24px; color: var(--muted); text-align: center; }
.packing-empty > div { font-size: 48px; }
.packing-empty strong { color: var(--text); font-size: 20px; }
.packing-empty span { max-width: 470px; font-size: 14px; line-height: 1.45; }
.packing-result { display: grid; gap: 14px; margin-top: 14px; padding: 18px; }
.packing-result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.packing-result-head > div { min-width: 0; }
.packing-result-head strong { display: block; font-size: 24px; }
.packing-result-head span { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }
.packing-status { flex: 0 0 auto; max-width: 220px; padding: 7px 10px; border-radius: 999px; background: var(--warning-soft); color: #754707; font-size: 11px; font-weight: 850; text-align: center; }
.packing-status.success { background: var(--primary-soft); color: var(--primary-dark); }
.packing-ttn-box { padding: 15px; border-radius: 17px; background: var(--surface-2); }
.packing-ttn-box small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.packing-ttn-box strong { display: block; margin-top: 5px; font-size: 24px; letter-spacing: .025em; word-break: break-all; }
.packing-destination { display: grid; gap: 5px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.packing-destination b { color: var(--text); }

.packing-editor { display: grid; gap: 13px; padding: 15px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-2); }
.packing-editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.packing-editor-head > div { min-width: 0; }
.packing-editor-head strong { display: block; font-size: 18px; }
.packing-editor-head span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.packing-editor-head > button { flex: 0 0 auto; min-height: 40px; padding: 0 11px; border: 1px solid #b9d8c7; border-radius: 12px; background: white; color: var(--primary-dark); font-size: 12px; font-weight: 850; }
.packing-packages { display: grid; gap: 10px; }
.packing-package { padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.packing-package > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.packing-package > header strong { font-size: 15px; }
.packing-package > header button { border: 0; background: transparent; color: var(--danger); font-size: 12px; font-weight: 800; }
.packing-package-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; }
.packing-package-grid label { min-width: 0; }
.packing-package-grid label span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 750; }
.packing-package-grid input { width: 100%; height: 49px; min-width: 0; padding: 0 9px; border: 1px solid var(--line); border-radius: 12px; background: white; color: var(--text); font-size: 17px; font-weight: 800; text-align: center; }
.packing-save-button { width: 100%; min-height: 58px; border: 0; border-radius: 16px; background: var(--primary); color: white; font-size: 16px; font-weight: 850; }
.packing-actions { display: grid; gap: 9px; }
.packing-actions button, .packing-actions a {
  width: 100%; min-height: 58px; display: flex; align-items: center; justify-content: center; padding: 0 14px;
  border-radius: 16px; text-decoration: none; font-size: 16px; font-weight: 850; cursor: pointer;
}
.packing-actions button:disabled { opacity: .45; cursor: default; }
.packing-actions .packing-print-button { border: 1px solid var(--line); background: white; color: var(--text); }
.packing-actions .packing-new-search { min-height: 46px; border: 0; background: transparent; color: var(--muted); font-size: 13px; }
.packing-locked { padding: 13px 14px; border-radius: 14px; background: var(--warning-soft); color: #754707; font-size: 13px; line-height: 1.4; }
.packing-ready { padding: 13px 14px; border-radius: 14px; background: var(--primary-soft); color: var(--primary-dark); font-size: 13px; line-height: 1.4; }

/* v8.3.4 — перегляд маркування з видимою кнопкою закриття */
.packing-label-viewer {
  position: fixed; inset: 0; z-index: 140; display: flex; flex-direction: column;
  min-height: 0; background: #eef0ee;
}
.packing-label-toolbar {
  flex: 0 0 auto; min-height: calc(64px + var(--safe-top));
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(9px + var(--safe-top)) 12px 9px;
  background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px);
}
.packing-label-heading { min-width: 0; display: grid; gap: 3px; }
.packing-label-heading strong { font-size: 17px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.packing-label-heading small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.packing-label-toolbar-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.packing-label-share-button {
  height: 44px; padding: 0 14px; border: 1px solid #b9d8c7; border-radius: 14px;
  background: var(--primary-soft); color: var(--primary-dark); font-size: 14px; font-weight: 850;
}
.packing-label-document { flex: 1; min-height: 0; padding: 8px; overflow: hidden; }
.packing-label-frame { display: block; width: 100%; height: 100%; border: 0; border-radius: 14px; background: white; box-shadow: var(--shadow); }

@media (max-width: 620px) {
  .packing-station-main { padding-left: 10px; padding-right: 10px; }
  .packing-search-card, .packing-result { padding: 14px; border-radius: 18px; }
  .packing-search-form { grid-template-columns: 1fr; }
  .packing-search-form button { width: 100%; }
  .packing-result-head { display: grid; }
  .packing-status { max-width: 100%; width: fit-content; }
  .packing-editor-head { display: grid; }
  .packing-editor-head > button { width: 100%; }
  .packing-package-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* v8.8.5: constrain desktop workspaces to the viewport.
   Body scrolling is intentionally disabled in Hub; therefore the app shell
   must have a real viewport height so lists can receive native mouse-wheel
   and trackpad scrolling instead of expanding below the screen. */
@media (min-width: 761px) {
  html, body { height: 100%; }
  .app-view {
    height: 100vh;
    max-height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  .topbar { flex: 0 0 auto; }
  .workspace,
  .telegram-workspace {
    min-height: 0;
    overflow: hidden;
  }
  .orders-list,
  .detail-pane,
  .telegram-chats-list,
  .telegram-messages {
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    overscroll-behavior-y: contain;
  }
}

/* v8.8.5 — TTN daily registry */
.packing-registry-open { width:100%; min-height:52px; margin-top:12px; border:1px solid #b9d8c7; border-radius:15px; background:#fff; color:var(--primary-dark); font-size:15px; font-weight:850; }
.ttn-registry-sheet { width:min(940px, calc(100vw - 24px)); max-height:min(92dvh, 900px); }
.ttn-registry-body { padding:16px; overflow:auto; display:grid; gap:14px; }
.ttn-registry-toolbar { display:flex; gap:10px; align-items:end; flex-wrap:wrap; }
.ttn-registry-toolbar label { display:grid; gap:5px; font-size:12px; color:var(--muted); font-weight:750; }
.ttn-registry-toolbar input { min-height:44px; padding:0 12px; border:1px solid var(--line); border-radius:12px; background:#fff; }
.ttn-registry-toolbar button { min-height:44px; padding:0 14px; border:1px solid var(--line); border-radius:12px; background:#fff; font-weight:800; }
.ttn-registry-counts { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; }
.ttn-registry-count { padding:12px; border:1px solid var(--line); border-radius:14px; background:var(--surface-2); }
.ttn-registry-count b { display:block; font-size:22px; }
.ttn-registry-count span { display:block; margin-top:2px; color:var(--muted); font-size:11px; font-weight:750; }
.ttn-registry-scan { padding:14px; border:1px solid #b9d8c7; border-radius:16px; background:var(--primary-soft); }
.ttn-registry-scan > label { display:block; margin-bottom:8px; font-weight:850; }
.ttn-registry-scan > div:first-of-type { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; }
.ttn-registry-scan input { min-height:52px; padding:0 13px; border:1px solid var(--line); border-radius:13px; background:#fff; font-size:18px; letter-spacing:.03em; }
.ttn-registry-scan button { min-height:52px; padding:0 16px; border:0; border-radius:13px; background:var(--primary); color:#fff; font-weight:850; }
.ttn-registry-scan small { display:block; margin-top:7px; color:var(--muted); line-height:1.4; }
.ttn-registry-scan-result { min-height:20px; margin-top:8px; font-weight:800; }
.ttn-registry-scan-result.success { color:var(--primary-dark); }
.ttn-registry-scan-result.error { color:var(--danger); }
.ttn-registry-list { display:grid; gap:8px; }
.ttn-registry-empty { padding:34px 18px; border:1px dashed var(--line); border-radius:15px; text-align:center; color:var(--muted); }
.ttn-registry-row { display:grid; grid-template-columns:minmax(120px,.7fr) minmax(180px,1fr) minmax(130px,.7fr) auto; gap:10px; align-items:center; padding:12px; border:1px solid var(--line); border-radius:15px; background:#fff; }
.ttn-registry-row.deleted { opacity:.62; background:#fafafa; }
.ttn-registry-order b,.ttn-registry-number b { display:block; }
.ttn-registry-order small,.ttn-registry-number small,.ttn-registry-meta small { display:block; margin-top:3px; color:var(--muted); }
.ttn-registry-state { justify-self:start; padding:6px 9px; border-radius:999px; background:var(--warning-soft); color:#754707; font-size:11px; font-weight:850; }
.ttn-registry-state.scanned { background:var(--primary-soft); color:var(--primary-dark); }
.ttn-registry-state.deleted { background:#f3f3f3; color:#666; }
.ttn-registry-delete { min-height:38px; padding:0 10px; border:1px solid #edc8c8; border-radius:10px; background:#fff; color:var(--danger); font-weight:800; }
@media (max-width:760px) {
  .ttn-registry-counts { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .ttn-registry-row { grid-template-columns:1fr auto; }
  .ttn-registry-number,.ttn-registry-meta { grid-column:1/-1; }
}

/* v8.8.7 — Focus UI: bright shell + full-width order rows + phone-like detail flow */
:root {
  --bg: #eef6f1;
  --surface-2: #f5faf7;
  --line: #d6e5dc;
  --primary: #0aa35d;
  --primary-dark: #087541;
  --primary-soft: #daf8e8;
  --danger: #ef4444;
  --danger-dark: #b91c1c;
  --danger-soft: #fff0f0;
  --warning: #e88908;
  --warning-soft: #fff3d8;
  --shadow: 0 14px 36px rgba(17, 73, 46, .10);
}

.order-row-card { position: relative; }
.order-row-number,
.order-row-customer,
.order-row-items,
.order-row-status,
.order-row-responsible,
.order-row-ttn,
.order-row-total { min-width: 0; }
.order-row-number strong,
.order-row-customer strong,
.order-row-items b,
.order-row-responsible b,
.order-row-ttn b,
.order-row-total b { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.order-row-number time,
.order-row-customer small,
.order-row-items small,
.order-row-responsible small,
.order-row-ttn small,
.order-row-total small { display: block; color: var(--muted); font-size: 10px; line-height: 1.25; }
.order-row-number strong { font-size: 15px; }
.order-row-customer strong { font-size: 15px; }
.order-row-customer small { margin-top: 3px; }
.order-row-items b { font-size: 13px; }
.order-row-items small { margin: 2px 0 5px; }
.order-row-responsible b,
.order-row-ttn b { margin-top: 3px; font-size: 12px; }
.order-row-total { text-align: right; }
.order-row-total b { margin-top: 2px; font-size: 16px; color: #075b34; }
.order-row-open { color: #1d7f50; font-size: 30px; line-height: 1; font-weight: 500; text-align: right; }

@media (min-width: 761px) {
  .topbar {
    height: 58px;
    padding: 7px 14px;
    background: rgba(255,255,255,.98);
    border-bottom-color: #cfe1d6;
  }
  .brand-mark.small { width: 40px; height: 40px; border-radius: 13px; background: linear-gradient(145deg,#08a85d,#078a4c); }
  .icon-button { width: 42px; height: 42px; border-color: #d3e4da; background: #fff; }
  .icon-button:hover { border-color: #a9d5bb; background: #ecfbf3; }

  /* The desktop behaves like the phone: first the full list, then one focused order. */
  .workspace {
    display: block;
    position: relative;
    min-height: 0;
    overflow: hidden;
    background: var(--bg);
  }
  .orders-pane {
    width: 100%;
    height: 100%;
    padding: 10px 12px 14px;
    border-right: 0;
    background: linear-gradient(180deg,#f8fcfa 0,#eef6f1 100%);
  }
  .orders-pane .search-wrap { height: 46px; border-radius: 14px; border-color: #cfdfd5; box-shadow: 0 3px 12px rgba(15,84,51,.04); }
  .orders-pane .search-wrap input { height: 44px; font-size: 15px; }
  .list-meta { padding: 9px 4px 7px; }
  .list-meta strong { font-size: 16px; }
  .orders-list { display: grid; align-content: start; gap: 6px; padding-bottom: 16px; }

  .order-card.order-row-card {
    width: 100%;
    min-height: 68px;
    display: grid;
    grid-template-columns: 100px minmax(190px,1.35fr) minmax(120px,.7fr) minmax(145px,.9fr) minmax(135px,.8fr) minmax(145px,.9fr) 115px 24px;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 9px 12px 9px 14px;
    border: 1px solid #d4e3d9;
    border-left: 5px solid #9ac9ad;
    border-radius: 14px;
    background: rgba(255,255,255,.97);
    box-shadow: 0 3px 12px rgba(21,67,43,.035);
    transition: border-color .14s ease, box-shadow .14s ease, transform .08s ease, background .14s ease;
  }
  .order-card.order-row-card:hover { border-color: #9dcdb2; background: #fbfffd; box-shadow: 0 8px 22px rgba(21,67,43,.075); }
  .order-card.order-row-card.active { border-color: #35b776; box-shadow: 0 0 0 3px rgba(10,163,93,.12), 0 8px 22px rgba(21,67,43,.07); }
  .order-card.order-row-card.tone-warning { border-left-color: #f59e0b; }
  .order-card.order-row-card.tone-ready { border-left-color: #3b82f6; }
  .order-card.order-row-card.tone-payment { border-left-color: #f0a000; }
  .order-card.order-row-card.tone-paid { border-left-color: #10b981; }
  .order-card.order-row-card.tone-shipping { border-left-color: #8b5cf6; }
  .order-card.order-row-card.tone-success { border-left-color: #08a85d; }
  .order-card.order-row-card.tone-danger { border-left-color: #ef4444; }
  .order-row-items .progress-mini { width: 100%; max-width: 92px; height: 5px; }
  .order-row-status .order-status-badge { max-width: 100%; white-space: normal; font-size: 10px; }

  .detail-pane {
    position: fixed;
    z-index: 42;
    inset: 58px 0 0;
    padding: 14px clamp(18px,3vw,44px) 32px;
    background: #eef6f1;
    transform: translateX(100%);
    transition: transform .16s ease;
    box-shadow: -18px 0 50px rgba(20,59,39,.10);
  }
  body.detail-open .detail-pane { transform: translateX(0); }
  .back-button { display: grid; place-items: center; }
  .detail-header {
    position: sticky;
    top: -14px;
    z-index: 5;
    margin: -14px -4px 12px;
    padding: 10px 4px;
    background: rgba(238,246,241,.97);
    border-bottom: 1px solid #d2e3d9;
    backdrop-filter: blur(14px);
  }
  .order-detail { width: min(100%,1280px); }
  .empty-detail { display: none; }
}

@media (min-width: 761px) and (max-width: 1180px) {
  .order-card.order-row-card {
    grid-template-columns: 94px minmax(180px,1.25fr) 110px minmax(135px,.9fr) minmax(125px,.7fr) 100px 24px;
  }
  .order-row-ttn { display: none; }
}

@media (max-width: 760px) {
  .order-card.order-row-card {
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    gap: 7px 10px;
    padding: 13px 14px;
    border-left: 4px solid #9ac9ad;
  }
  .order-row-number { grid-column: 1; display: flex; align-items: baseline; gap: 7px; }
  .order-row-number time { display: inline; }
  .order-row-customer { grid-column: 1; }
  .order-row-status { grid-column: 1; }
  .order-row-total { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .order-row-open { grid-column: 2; grid-row: 3; align-self: center; }
  .order-row-items,
  .order-row-responsible,
  .order-row-ttn { display: none; }
  .order-row-status .order-status-badge { font-size: 10px; }
}
