:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --panel: #ffffff;
  --ink: #17211c;
  --muted: #65736c;
  --line: #dce4df;
  --accent: var(--brand-accent);
  --accent-dark: var(--brand-accent-dark);
  --warn: #b93815;
  --soft: #e8f4ef;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

h1,
h2,
p,
dl,
dd,
ul {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 800;
}

.brand { display: flex; align-items: center; min-width: 0; gap: 12px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.assistant-identity {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  max-width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  opacity: 0.8;
  text-align: left;
}

.assistant-store-name {
  color: var(--ink);
  font-weight: 800;
}

.assistant-store-name,
.assistant-identity strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-name-separator {
  flex: 0 0 auto;
}

.n8n-status-pill {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--line);
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.n8n-status-pill[data-state="online"] {
  background: #dcfce7;
  color: #166534;
}

.n8n-status-pill[data-state="offline"] {
  background: #fee2e2;
  color: #b91c1c;
}

.assistant-identity strong {
  color: var(--ink);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}

.icon-button[hidden] { display: none; }
.icon-button:hover { border-color: var(--accent); color: var(--accent-dark); }
.icon-button[aria-current="page"] { background: #edf7f2; color: var(--brand-accent); border-color: #b9dccc; }
.icon-button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.tabs {
  position: sticky;
  top: var(--topbar-height, 80px);
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 246, 0.96);
  backdrop-filter: blur(12px);
}

main {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 40px) 48px;
}

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

.summary[hidden] {
  display: none;
}

.summary > div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.summary strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.tab[hidden] { display: none; }

.tab span {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--line);
  color: var(--ink);
  font-size: 12px;
}

.tab.is-active {
  border-bottom-color: var(--accent);
  color: var(--accent-dark);
}

.tab.is-active span {
  background: var(--soft);
  color: var(--accent-dark);
}

.error {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #f0b9a6;
  border-radius: 8px;
  background: #fff1eb;
  color: var(--warn);
  font-weight: 700;
}

.orders {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.orders.is-order-list {
  display: flex;
  flex-direction: column;
}

.orders-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 20px;
}

.orders-pagination[hidden] {
  display: none;
}

.orders-pagination button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-dark);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.orders-pagination button:hover:not(:disabled) {
  background: var(--soft);
}

.orders-pagination span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.delivered-order-search {
  max-width: 360px;
  margin: 20px 0;
}

.priority-order-filter {
  margin: 20px 0;
}

.priority-order-filter[hidden] {
  display: none;
}

.priority-order-filter label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.priority-order-filter input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.delivered-order-search[hidden] {
  display: none;
}

.delivered-order-search input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

.conversations-panel {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  height: calc(100vh - 260px);
  min-height: 520px;
  max-height: calc(100vh - 260px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.conversations-panel[hidden] {
  display: none;
}

.conversation-list-panel {
  position: relative;
  z-index: 2;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: #f8faf9;
}

.conversation-owner-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  flex: 0 0 auto;
  padding: 10px 12px 0;
  border-bottom: 1px solid var(--line);
  background: #f8faf9;
}
.conversation-mine-tabs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 4px 6px 0;
}

.conversation-mine-tabs .conversation-owner-tab {
  gap: 4px;
}

.conversation-owner-tabs[hidden] { display: none; }
.conversation-owner-tab[hidden] { display: none; }

.conversation-owner-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  padding: 10px 6px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.conversation-owner-tab span {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--line);
  color: var(--ink);
  font-size: 12px;
}

.conversation-owner-tab.is-active span {
  background: var(--soft);
  color: var(--accent-dark);
}

.conversation-owner-tab:hover {
  color: var(--accent-dark);
}

.conversation-owner-tab.is-active {
  border-bottom-color: var(--accent);
  color: var(--accent-dark);
}

.conversation-owner-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.conversation-search {
  flex: 0 0 auto;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #f8faf9;
}

.conversation-search input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

.conversation-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.conversation-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  width: 100%;
  min-height: 72px;
  gap: 12px;
  padding: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.conversation-item:hover {
  background: #edf3f0;
}

.conversation-item.is-active {
  background: #dce8e3;
  border-left: 4px solid var(--accent);
}

.conversation-item.is-active.is-closed {
  border-left-color: #a7b2ac;
}

.conversation-item.has-new-message {
  background: #97ff98;
  box-shadow: inset 0 0 0 1px rgba(3, 125, 121, 0.08);
}

.conversation-item.is-active.has-new-message {
  background: #97ff98;
}

.conversation-item.has-new-message .conversation-summary strong,
.conversation-item.has-new-message .conversation-summary small {
  color: var(--accent-dark);
  font-weight: 900;
}

.conversation-item.has-new-message .conversation-avatar {
  background: var(--accent-dark);
}

.conversation-item.is-closed {
  background: #f4f6f5;
  color: var(--muted);
  opacity: 0.68;
}

.conversation-item.is-closed:hover,
.conversation-item.is-closed.is-active {
  background: #e1e7e4;
  opacity: 0.78;
}

.conversation-avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

.conversation-item.is-closed .conversation-avatar {
  background: #a7b2ac;
  color: #ffffff;
}

.conversation-item.is-closed .conversation-summary strong {
  color: var(--muted);
}

.conversation-summary {
  min-width: 0;
}

.conversation-summary > span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.conversation-summary strong,
.conversation-summary small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-summary time,
.conversation-summary small,
.conversation-empty {
  color: var(--muted);
  font-size: 13px;
}

.conversation-summary time {
  flex: 0 0 auto;
  white-space: nowrap;
}

.conversation-assistant-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  margin: 4px 0;
  padding: 3px 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-assistant-tag::before {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  content: '';
}

.conversation-assistant-tag.is-completed {
  background: #e3e8e5;
  color: #6f7c76;
}

.conversation-empty {
  padding: 16px;
  font-weight: 700;
}

.conversation-chat-panel {
  position: relative;
  z-index: 1;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background:
    radial-gradient(circle at 20px 20px, rgba(3, 125, 121, 0.05) 2px, transparent 3px) 0 0 / 46px 46px,
    #eef2ee;
}

.conversation-chat-panel.is-dragging-image::after {
  content: "Solte a imagem para anexar";
  position: absolute;
  z-index: 20;
  inset: 10px;
  display: grid;
  place-items: center;
  border: 3px dashed var(--accent);
  border-radius: 14px;
  background: rgba(232, 244, 239, 0.94);
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 800;
  pointer-events: none;
}

.conversation-chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.conversation-chat-header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.conversation-handoff-button,
.conversation-transfer-button,
.conversation-close-button,
.conversation-complete-button,
.chat-image-reply,
.conversation-view-order-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgb(16 66 49 / 8%);
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease, transform 150ms ease;
  cursor: pointer;
}

.conversation-view-order-button {
  border-color: #73bfa8;
  color: var(--accent-dark);
  background: #fbfffd;
}

.conversation-complete-button,
.chat-image-reply {
  border-color: var(--brand-accent);
  background: linear-gradient(180deg, var(--brand-accent-light) 0%, var(--brand-accent) 100%);
  color: #fff;
  box-shadow: 0 2px 5px rgb(8 124 89 / 20%);
}

.conversation-close-button {
  border-color: #efaaa2;
  background: #fff5f3;
  color: #c93620;
}

.conversation-handoff-button {
  border-color: #efaaa2;
  background: #fff5f3;
  color: #c93620;
}

.conversation-transfer-button {
  width: 42px;
  justify-content: center;
  padding: 0 4px;
  border-color: #008cc9;
  background: #008cc9;
  color: #fff;
  box-shadow: 0 2px 5px rgb(0 140 201 / 20%);
}

.conversation-transfer-button img {
  width: 32px;
  height: 24px;
  object-fit: contain;
}

.conversation-view-order-button:not(:disabled):hover,
.conversation-complete-button:not(:disabled):hover,
.chat-image-reply:not(:disabled):hover,
.conversation-close-button:not(:disabled):hover,
.conversation-handoff-button:not(:disabled):hover {
  box-shadow: 0 3px 8px rgb(16 66 49 / 14%);
  transform: translateY(-1px);
}

.conversation-view-order-button:not(:disabled):hover {
  border-color: var(--accent);
  background: #f1faf6;
}

.conversation-complete-button:not(:disabled):hover,
.chat-image-reply:not(:disabled):hover {
  border-color: var(--brand-accent-dark);
  background: linear-gradient(180deg, var(--brand-accent-light) 0%, var(--brand-accent-dark) 100%);
}

.conversation-close-button:not(:disabled):hover,
.conversation-handoff-button:not(:disabled):hover {
  border-color: #df7669;
  background: #ffebe8;
}

.conversation-transfer-button:not(:disabled):hover {
  border-color: #0079af;
  background: #0079af;
  box-shadow: 0 3px 8px rgb(0 140 201 / 24%);
  transform: translateY(-1px);
}

.conversation-handoff-button svg,
.conversation-close-button svg,
.conversation-complete-button svg,
.conversation-view-order-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.conversation-handoff-button[hidden],
.conversation-transfer-button[hidden],
.conversation-close-button[hidden],
.conversation-complete-button[hidden],
.conversation-view-order-button[hidden] {
  display: none;
}

.conversation-handoff-button:disabled {
  border-color: #e4e8e6;
  background: #f3f5f4;
  color: #98a29e;
  box-shadow: none;
  opacity: 1;
  cursor: default;
}

.conversation-transfer-button:disabled {
  border-color: #e4e8e6;
  background: #f3f5f4;
  color: #98a29e;
  box-shadow: none;
  cursor: default;
}

.conversation-transfer-button:disabled img {
  filter: brightness(0);
  opacity: 0.35;
}

.conversation-complete-button:disabled {
  opacity: 0.45;
}

.conversation-chat-header h2 {
  font-size: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-chat-customer {
  flex: 1 1 165px;
  min-width: 0;
}

#conversation-chat-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

#conversation-chat-subtitle > span {
  display: block;
}

#conversation-chat-order {
  margin-top: 3px;
  align-items: center;
  gap: 5px;
}

#conversation-chat-order[hidden] {
  display: none;
}

#conversation-chat-order:not([hidden]) {
  display: flex;
}

#conversation-chat-order svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.conversation-chat-content {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.conversation-reply-form {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #f4f6f5;
}

.conversation-quote-preview, .chat-quoted-image {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-left: 3px solid var(--brand-accent);
  border-radius: 8px;
  background: #e6f2ed;
}
.conversation-quote-preview { flex: 0 0 100%; }
.chat-quoted-image-link {
  width: 100%;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.chat-quoted-image-link:hover { background: #d6ebe2; }
.chat-quoted-image-link:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
}
.chat-message.is-reference-target {
  outline: 3px solid var(--brand-accent);
  outline-offset: 2px;
}
.conversation-quote-preview[hidden] { display: none; }
.conversation-quote-preview img, .chat-quoted-image img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 4px;
}
.conversation-quote-preview span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.conversation-reply-form #conversation-quote-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
}
.chat-image-reply { margin-top: 6px; }
.chat-message-reply {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  min-height: 24px;
  margin: 0;
  padding: 0;
  justify-content: center;
  border-radius: 7px;
  border-color: #73bfa8;
  background: #fbfffd;
  color: var(--accent-dark);
  box-shadow: 0 1px 2px rgb(16 66 49 / 8%);
}
.chat-message-reply:not(:disabled):hover {
  border-color: var(--accent);
  background: #f1faf6;
}
.chat-message-reply:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}
.chat-message:has(.chat-message-reply) > span:first-child {
  padding-right: 28px;
  min-height: 20px;
}
.chat-image-reply:focus-visible {
  outline: 2px solid var(--brand-accent-dark);
  outline-offset: 3px;
}

.conversation-pasted-image-preview {
  flex: 0 0 100%;
  display: flex;
  position: relative;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.conversation-pasted-image-preview[hidden] {
  display: none;
}

.conversation-pasted-image-preview img {
  display: block;
  width: 100%;
  max-height: min(55vh, 560px);
  border-radius: 8px;
  object-fit: contain;
  background: var(--bg);
}

.conversation-pasted-image-preview span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-reply-form .conversation-pasted-image-preview button {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}

.conversation-reply-form .conversation-pasted-image-preview button svg {
  width: 18px;
  height: 18px;
}

.conversation-reply-form[hidden] {
  display: none;
}

.conversation-reply-form textarea {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  max-height: 150px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  line-height: 1.35;
  overflow-y: hidden;
  resize: none;
}

.conversation-reply-form textarea.is-scrollable-input {
  overflow-y: auto;
}

.conversation-reply-form button {
  display: grid;
  place-items: center;
  width: 48px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

.conversation-reply-form .conversation-record-button {
  border: 1px solid var(--accent);
  background: var(--panel);
  color: var(--accent-dark);
}

.conversation-reply-form .conversation-attach-button {
  border: 1px solid var(--accent);
  background: var(--panel);
  color: var(--accent-dark);
}

.conversation-attach-spinner {
  display: none;
  width: 21px;
  height: 21px;
  border: 3px solid rgba(3, 125, 121, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
}

.conversation-attach-button.is-loading svg {
  display: none;
}

.conversation-attach-button.is-loading .conversation-attach-spinner {
  display: block;
  animation: conversation-attach-spin 0.7s linear infinite;
}

@keyframes conversation-attach-spin {
  to { transform: rotate(360deg); }
}

.conversation-reply-form .conversation-order-summary-button {
  border: 1px solid var(--accent);
  background: var(--panel);
  color: var(--accent-dark);
}

.conversation-reply-form .conversation-predefined-messages-button {
  border: 1px solid var(--accent);
  background: var(--panel);
  color: var(--accent-dark);
}

.conversation-reply-form button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.conversation-reply-form .conversation-record-button.is-recording {
  border-color: var(--warn);
  background: #fff1eb;
  color: var(--warn);
  animation: recording-ring 1.2s ease-out infinite;
}

.conversation-reply-form .conversation-record-button.is-recording svg {
  animation: recording-pulse 0.8s ease-in-out infinite alternate;
}

.conversation-reply-form button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.conversation-audio-preview,
.conversation-chat-panel > .chat-record-status,
.conversation-chat-panel > .chat-reply-error {
  flex: 0 0 auto;
  margin: 0 12px 12px;
}

.order {
  scroll-margin-top: calc(var(--topbar-height, 80px) + var(--tabs-height, 54px) + 16px);
  display: flex;
  flex-direction: column;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.orders.is-order-list .order {
  width: 100%;
  min-height: 0;
}

.order.is-collapsible:not(.is-expanded) .order-header {
  border-bottom: 0;
}

.order.is-collapsible .order-header {
  cursor: pointer;
}

.order.is-collapsible .order-header:hover,
.order.is-collapsible .order-header:focus-visible {
  background: #f7fbf9;
}

.order.is-collapsible .order-header:focus-visible {
  outline: 3px solid rgba(9, 137, 94, 0.25);
  outline-offset: -3px;
}

.order-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.order-header > div {
  min-width: 0;
}

.order h2 {
  margin-top: 8px;
  font-size: 22px;
}

.order.is-collapsible h2 {
  margin-top: 0;
}

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

.order-customer-name {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.order-waiting-time,
.order-assistant-tag,
.order-attention-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  margin: 0;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.order-waiting-time,
.order-attention-tag {
  animation: waiting-blink 2.8s ease-in-out infinite;
}

.order-waiting-time::before,
.order-assistant-tag::before,
.order-attention-tag::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  content: '';
}

.order-waiting-time::before,
.order-attention-tag::before {
  animation: waiting-pulse 2.2s ease-out infinite;
}

.order-assistant-tag {
  background: #dbeafe;
  color: #1d4ed8;
}

.order-attention-tag {
  background: #f3e8ff;
  color: #7e22ce;
  animation-duration: 2.2s;
}

.order-attention-tag::before {
  animation-duration: 1.7s;
}

.waiting-low .order-waiting-time {
  background: #d8f2e7;
  color: var(--brand-accent);
}

.waiting-medium .order-waiting-time {
  background: #ffe8c7;
  color: #a95800;
  animation-duration: 2.2s;
}

.waiting-high .order-waiting-time {
  background: #ffdcd7;
  color: #b92d1d;
  animation-duration: 1.6s;
}

.waiting-medium .order-waiting-time::before {
  animation-duration: 1.7s;
}

.waiting-high .order-waiting-time::before {
  animation-duration: 1.15s;
}

@keyframes waiting-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent);
  }
  65%,
  100% {
    box-shadow: 0 0 0 7px color-mix(in srgb, currentColor 0%, transparent);
  }
}

@keyframes waiting-blink {
  0%,
  42%,
  58%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.48;
  }
}

@media (prefers-reduced-motion: reduce) {
  .order-waiting-time,
  .order-waiting-time::before,
  .order-attention-tag,
  .order-attention-tag::before {
    animation: none;
  }
}

.order-quick-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
  margin: 18px 0 18px 18px;
}

.order-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: auto;
  height: 42px;
  padding: 0 8px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.order-action-button:hover:not(:disabled) {
  background: var(--soft);
}

.order-action-button-danger {
  border-color: var(--warn);
  color: var(--warn);
}

.order-action-button-danger:hover:not(:disabled) {
  background: #fff1ed;
}

.order-action-button:disabled {
  border-color: var(--line);
  background: var(--bg);
  color: #a7b2ac;
  cursor: not-allowed;
  opacity: 0.72;
}

.order-action-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.order-total {
  white-space: nowrap;
  font-size: 22px;
}

.order-total-group {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
}

.order-header-conversation-button {
  height: 36px;
  margin-right: 12px;
  white-space: nowrap;
}

.order-header-deliver-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  margin-right: 12px;
  padding: 0 12px;
  border: 1px solid var(--brand-accent);
  border-radius: 11px;
  background: linear-gradient(180deg, var(--brand-accent-light) 0%, var(--brand-accent) 100%);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgb(8 124 89 / 20%);
  cursor: pointer;
}

.order-header-deliver-button:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--brand-accent-light) 0%, var(--brand-accent-dark) 100%);
}

.order-header-deliver-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.order-header-deliver-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.order-expand-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: transform 160ms ease;
}

.order.is-expanded .order-expand-icon {
  transform: rotate(180deg);
}

.order-expanded-content {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.order-expanded-content[hidden] {
  display: none;
}

.details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 18px;
}

dt,
.address span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-weight: 700;
}

dd.is-unassigned {
  color: var(--warn);
}

.address {
  padding: 0 18px 16px;
}

.address strong {
  display: block;
  margin-top: 4px;
  line-height: 1.35;
}

.items {
  flex: 1;
  list-style: none;
  padding: 0 18px 18px;
}

.items li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.items span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.item-numbers {
  text-align: right;
  white-space: nowrap;
}

.items .promotion-regular-price {
  display: inline;
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.items .promotion-current-price {
  display: inline;
  color: var(--ink);
  font-weight: 700;
}

.deliver-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 36px);
  min-height: 48px;
  margin: 0 18px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.deliver-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
}

.deliver-button:hover:not(:disabled) {
  background: var(--accent-dark);
}

.prescription-dialog {
  width: min(900px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(23, 33, 28, 0.28);
}

.prescription-dialog::backdrop {
  background: rgba(10, 20, 15, 0.66);
}

.delivered-chat-dialog {
  width: min(900px, calc(100% - 32px));
  height: min(760px, calc(100vh - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(23, 33, 28, 0.28);
}

.delivered-chat-dialog[open] {
  display: flex;
  flex-direction: column;
}

.delivered-chat-dialog::backdrop {
  background: rgba(10, 20, 15, 0.66);
}

.delivered-chat-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.delivered-chat-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
#delivered-chat-history { padding: 9px 12px; border: 1px solid var(--accent); border-radius: 8px;
  background: var(--panel); color: var(--accent); font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; }
#delivered-chat-history:hover:not(:disabled) { background: var(--soft); }
@media (max-width: 600px) {
  #delivered-chat-dialog .dialog-header { flex-wrap: wrap; }
  .delivered-chat-actions { margin-left: auto; }
}

.delivered-chat-content {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 20px 20px, rgba(3, 125, 121, 0.05) 2px, transparent 3px) 0 0 / 46px 46px,
    #eef2ee;
}

.previous-session-label,
.today-session-label {
  align-self: center;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.previous-session-label {
  background: #ffebe8;
  color: #a13e3e;
}

.today-session-label {
  box-sizing: border-box;
  width: 33.333333%;
  background: #97ff98;
  color: var(--brand-accent-dark);
  text-align: center;
}

.order-edit-dialog {
  width: min(1040px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(23, 33, 28, 0.28);
}

.predefined-messages-dialog {
  width: min(720px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(23, 33, 28, 0.28);
}

.predefined-messages-dialog[open] {
  display: flex;
  flex-direction: column;
}

.predefined-messages-dialog::backdrop {
  background: rgba(10, 20, 15, 0.66);
}

.predefined-messages-content {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
}

.predefined-message-create-form {
  display: grid;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.predefined-message-create-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.predefined-message-create-form textarea,
.predefined-message-card textarea {
  width: 100%;
  min-height: 88px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  line-height: 1.4;
  resize: vertical;
}

.predefined-message-create-form .confirm-submit {
  justify-self: end;
  padding: 11px 18px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.predefined-messages-list {
  display: grid;
  gap: 12px;
}

.predefined-message-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

.predefined-message-preview {
  max-height: 150px;
  padding: 4px;
  color: var(--ink);
  font: inherit;
  line-height: 1.45;
  text-align: left;
  white-space: pre-wrap;
  overflow-y: auto;
  overflow-wrap: anywhere;
}

.predefined-message-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.predefined-message-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 7px;
  background: var(--panel);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.predefined-message-actions svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.predefined-message-secondary,
.predefined-message-primary {
  border: 1px solid var(--accent);
  color: var(--accent-dark);
}

.predefined-message-delete {
  border: 1px solid #edb5a6;
  color: var(--warn);
}

.predefined-message-send {
  border: 1px solid var(--accent);
  background: var(--accent) !important;
  color: #fff;
}

.predefined-message-counter {
  justify-self: end;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.predefined-messages-empty {
  padding: 28px 12px;
  color: var(--muted);
  text-align: center;
}

.product-search-dialog {
  width: min(760px, calc(100% - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(23, 33, 28, 0.28);
}

.product-search-dialog.promotion-dialog {
  width: min(900px, calc(100% - 32px));
  overflow-x: hidden;
}

.product-search-dialog::backdrop {
  background: rgba(10, 20, 15, 0.66);
}

.product-search-content {
  padding: 20px;
}

.product-search-content > label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.product-search-controls {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.product-search-controls input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
}

.product-search-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.product-search-spinner {
  display: none;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
}

#product-search-submit.is-loading .product-search-spinner,
#promotion-search-submit.is-loading .product-search-spinner {
  display: block;
  animation: promotion-search-spin 0.7s linear infinite;
}

#product-search-submit:disabled,
#promotion-search-submit:disabled {
  cursor: wait;
  opacity: 0.8;
}

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

.product-search-results {
  display: flex;
  max-height: 430px;
  margin-top: 16px;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.product-search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.product-search-result-price {
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  align-items: flex-end;
  color: var(--accent-dark);
}

.product-search-result:hover,
.product-search-result:focus-visible {
  border-color: var(--accent);
  background: #f1faf6;
}

.product-search-result-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.product-search-result-main small {
  color: var(--muted);
}

.promotions-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.promotions-panel[hidden] { display: none; }

.promotions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.promotions-header h2 { font-size: 22px; }

.promotions-header p,
.promotions-empty p {
  margin-top: 4px;
  color: var(--muted);
}

.promotion-add-button,
.promotion-remove-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-dark);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.promotion-add-button[hidden],
.promotion-remove-button[hidden] { display: none; }

.promotion-add-button svg,
.promotion-remove-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.promotions-list { display: grid; }

.promotion-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 24px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.promotion-card:last-child { border-bottom: 0; }

.promotion-product,
.promotion-prices {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.promotion-product strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.promotion-selected-product strong {
  overflow-wrap: anywhere;
  line-height: 1.35;
  white-space: normal;
}

.promotion-product small,
.promotion-prices span,
.promotion-prices small,
.promotion-selected-product span,
.promotion-selected-product small {
  color: var(--muted);
}

.promotion-prices {
  min-width: 150px;
  text-align: right;
}

.promotion-prices > strong {
  color: var(--accent-dark);
  font-size: 22px;
}

.promotion-prices .promotion-quantity-available {
  color: var(--accent-dark);
  font-weight: 800;
}

.promotion-prices .promotion-quantity-unavailable {
  color: var(--warn);
  font-weight: 800;
}

.promotion-remove-button {
  border-color: #efc8bd;
  color: var(--warn);
}

.promotions-empty {
  padding: 48px 20px;
  text-align: center;
}

.promotion-selected-product {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(100px, 130px) repeat(2, minmax(145px, 180px));
  align-items: end;
  gap: 12px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--soft);
}

.promotion-selected-product[hidden] { display: none; }

.promotion-selected-product > div,
.promotion-selected-product > label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}

.promotion-selected-product > div {
  grid-column: 1 / -1;
}

.promotion-selected-product span,
.promotion-selected-product small {
  font-size: 12px;
  font-weight: 700;
}

.promotion-selected-product .currency-input { background: var(--panel); }

.promotion-selected-product .currency-input input {
  width: 100%;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  outline: 0;
}

.promotion-selected-product > label > input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

#promotion-start-input,
#promotion-expiration-input {
  cursor: pointer;
}

.promotion-expiration-dialog {
  width: min(400px, calc(100% - 32px));
}

.promotion-expiration-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.promotion-expiration-picker {
  position: relative;
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

#promotion-expiration-picker-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.promotion-expiration-picker .flatpickr-calendar.inline {
  top: auto;
  box-shadow: none;
}

.promotion-selected-product .confirm-submit {
  grid-column: 1 / -1;
  justify-self: end;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.order-edit-dialog::backdrop {
  background: rgba(10, 20, 15, 0.66);
}

.order-edit-dialog form {
  display: flex;
  max-height: calc(100vh - 34px);
  flex-direction: column;
}

.order-edit-content {
  padding: 20px;
  overflow-y: auto;
}

.order-edit-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.order-edit-fields label,
.order-edit-item label {
  min-width: 0;
}

.order-edit-fields label > span,
.order-edit-item label > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.order-edit-fields input,
.order-edit-fields select,
.order-edit-item input {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

.order-edit-item input[readonly] {
  background: var(--bg);
  color: var(--muted);
}

.currency-input {
  display: flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.currency-input > span {
  flex: 0 0 auto;
  margin: 0;
  padding-left: 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-transform: none;
}

.order-edit-item .currency-input input,
.order-edit-fields .currency-input input {
  min-height: 40px;
  border: 0;
  outline: 0;
}

.currency-input:focus-within {
  border-color: #1769e0;
  box-shadow: 0 0 0 1px #1769e0;
}

.order-edit-address-field {
  grid-column: 1 / -1;
}

.order-edit-items-section {
  margin-top: 24px;
}

.order-edit-section-header,
.order-edit-item-heading,
.order-edit-total,
.order-edit-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.order-edit-section-header h3 {
  font-size: 18px;
}

.order-edit-section-header p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.order-edit-add-item,
.order-edit-item-heading button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-dark);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.order-edit-add-item svg,
.order-edit-item-heading button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.order-edit-item-heading {
  justify-content: flex-end;
}

.order-edit-item-heading button {
  border-color: #efc8bd;
  color: var(--warn);
}

.order-edit-items {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.order-edit-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

.order-edit-item-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.order-edit-product-name {
  grid-column: span 2;
}

.order-edit-total {
  margin-top: 20px;
  padding: 14px;
  border-radius: 8px;
  background: var(--soft);
}

.order-edit-total span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.order-edit-total strong {
  font-size: 20px;
}

.order-edit-error {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #efc8bd;
  border-radius: 8px;
  background: #fff1eb;
  color: var(--warn);
  font-weight: 700;
}

.order-edit-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
}

.order-edit-actions button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.confirm-dialog {
  width: min(460px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(23, 33, 28, 0.28);
}

.confirm-dialog::backdrop {
  background: rgba(10, 20, 15, 0.66);
}

.confirm-dialog form {
  padding: 24px;
}

.assistant-field {
  display: block;
  margin-top: 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

#assistant-name-input {
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
}

.confirm-dialog h2 {
  margin-top: 6px;
  font-size: 23px;
}

.confirm-dialog p {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.transfer-assistant-list {
  display: grid;
  gap: 8px;
  max-height: min(42vh, 330px);
  overflow-y: auto;
  margin-top: 18px;
}

.transfer-assistant-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}

.transfer-assistant-option:has(input:checked) {
  border-color: var(--accent);
  background: #eaf7f1;
}

.transfer-assistant-option input {
  accent-color: var(--accent);
}

.transfer-error {
  color: #c93620 !important;
}

.sale-completion-total-field {
  display: grid;
  gap: 7px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.sale-completion-total-field input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
}

.sale-completion-total-field input:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(3, 125, 121, 0.14);
}

.sale-completion-total-field {
  display: grid;
  gap: 7px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.sale-completion-total-field input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
}

.assignment-assistant-name {
  color: var(--ink);
  font-size: 1.2em;
  font-weight: 800;
}

.validation-list {
  margin: 14px 0 0;
  padding-left: 22px;
  color: var(--ink);
  line-height: 1.7;
}

.validation-list li::marker {
  color: #c43825;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.confirm-actions button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.confirm-cancel {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.confirm-submit {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
}

.item-remove-confirm-submit,
.session-close-confirm-submit,
.handoff-confirm-submit {
  border: 1px solid var(--warn);
  background: var(--warn);
  color: white;
}

.item-remove-confirm-submit:hover,
.confirm-dialog .session-close-confirm-submit:hover,
.handoff-confirm-submit:hover {
  background: #922e12;
}

.confirm-submit:hover {
  background: var(--accent-dark);
}

.dialog-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.dialog-eyebrow,
.extracted-medications > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.dialog-header h2 {
  margin-top: 4px;
}

.chat-customer {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.dialog-close {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.prescription-content {
  display: grid;
  gap: 20px;
  padding: 20px;
}

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

.chat-record-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.chat-audio-preview {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.chat-audio-preview[hidden] {
  display: none;
}

.chat-audio-preview audio {
  width: 100%;
}

.chat-audio-preview > div {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.chat-audio-preview button {
  display: grid;
  place-items: center;
  width: 44px;
  min-height: 40px;
  padding: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.chat-audio-preview button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.chat-audio-preview .audio-discard-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--warn);
}

.chat-audio-preview .audio-send-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
}

@keyframes recording-ring {
  0% { box-shadow: 0 0 0 0 rgba(185, 56, 21, 0.35); }
  70%, 100% { box-shadow: 0 0 0 8px rgba(185, 56, 21, 0); }
}

@keyframes recording-pulse {
  from { transform: scale(0.88); opacity: 0.7; }
  to { transform: scale(1.12); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .conversation-reply-form .conversation-record-button.is-recording,
  .conversation-reply-form .conversation-record-button.is-recording svg {
    animation: none;
  }
}

.chat-reply-error {
  margin-top: 8px;
  color: var(--warn);
  font-size: 13px;
  font-weight: 700;
}

.chat-message {
  position: relative;
  width: fit-content;
  max-width: min(78%, 680px);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

.chat-message.is-user {
  align-self: flex-start;
  border-color: #b9ddcd;
  background: var(--soft);
}

.chat-message.is-user.is-previous-session {
  border-color: #efaaa2;
  background: #fff5f3;
}

.chat-message.is-assistant {
  align-self: flex-end;
}

.chat-message.is-system {
  align-self: center;
  width: min(100%, 560px);
  max-width: calc(100% - 24px);
  border-color: #e5c985;
  background: #fff8e8;
  color: #6b4a13;
  text-align: center;
}

.chat-message.is-system > span {
  color: #8a5b0b;
}

.chat-message span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.chat-message p {
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.chat-message p a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-message p a:hover {
  color: var(--accent);
}

.chat-message audio {
  display: block;
  width: min(320px, 65vw);
  margin-top: 3px;
}

.chat-image {
  margin: 0;
}

.chat-image-button {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: zoom-in;
}

.chat-image img {
  display: block;
  width: min(320px, 62vw);
  max-height: 360px;
  object-fit: contain;
  border-radius: 8px;
  background: #f5f8f6;
}

.chat-sticker img {
  width: min(160px, 42vw);
  max-height: 160px;
  background: transparent;
}

.chat-image figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.image-preview-dialog {
  width: min(96vw, 1200px);
  max-width: none;
  max-height: 94vh;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  overflow: visible;
}

.image-preview-dialog::backdrop {
  background: rgb(20 31 27 / 78%);
}

.image-preview-viewport {
  width: fit-content;
  max-width: 96vw;
  max-height: 94vh;
  margin: auto;
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 80px rgb(0 0 0 / 35%);
  --zoom-x: 50%;
  --zoom-y: 50%;
}

.image-preview-dialog img {
  display: block;
  max-width: 96vw;
  max-height: 94vh;
  margin: auto;
  object-fit: contain;
  transform-origin: var(--zoom-x) var(--zoom-y);
}

@media (hover: hover) and (pointer: fine) {
  .image-preview-viewport:hover img {
    transform: scale(2.2);
    cursor: zoom-in;
  }
}

.image-preview-close {
  position: absolute;
  top: -14px;
  right: -14px;
  z-index: 1;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.chat-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(320px, 62vw);
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.chat-file:hover {
  text-decoration: underline;
}

.prescription-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.prescription-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.prescription-meta span {
  color: var(--muted);
}

.prescription-card img {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: #eef2f0;
}

.extracted-medications {
  padding: 14px;
}

.extracted-medications ul {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 0;
  list-style: none;
}

.extracted-medications li span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.dialog-message {
  padding: 36px 16px;
  color: var(--muted);
  text-align: center;
}

.dialog-message.is-error {
  color: var(--warn);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.is-delivered,
.is-abandoned {
  opacity: 0.68;
}

.empty {
  padding: 48px 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
}

.empty h2 {
  font-size: 22px;
}

.empty p {
  margin-top: 8px;
  color: var(--muted);
}

@media (min-width: 721px) {
  html {
    zoom: 90%;
  }

  .conversations-panel {
    height: calc(111.111vh - 195px);
    max-height: calc(111.111vh - 195px);
  }
}

@media (max-width: 720px) {
  .promotions-header {
    align-items: stretch;
    flex-direction: column;
  }

  .promotion-card,
  .promotion-selected-product {
    grid-template-columns: 1fr;
  }

  .promotion-prices {
    text-align: left;
  }

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

  .summary,
  .orders {
    grid-template-columns: 1fr;
  }

  .details {
    grid-template-columns: 1fr;
  }

  .order-edit-fields,
  .order-edit-item-grid {
    grid-template-columns: 1fr;
  }

  .order-edit-address-field,
  .order-edit-product-name {
    grid-column: auto;
  }

  .order-edit-section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .order {
    min-height: 0;
  }

  .order-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .order-quick-actions {
    grid-row: 2;
    grid-column: 1 / -1;
    justify-self: start;
  }

  .order-total-group {
    grid-row: 1;
    grid-column: 2;
  }

  .order-header-deliver-button {
    margin-right: 0;
    padding: 0 9px;
  }

  .order-header-conversation-button {
    margin-right: 0;
    padding: 0 9px;
  }

  .order-header-conversation-button span,
  .order-header-deliver-button span {
    display: none;
  }

  .conversations-panel {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .conversation-list-panel {
    max-height: 280px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .conversation-chat-panel {
    min-height: 520px;
  }
}

.chat-quoted-text { display: block; text-align: left; white-space: normal; overflow-wrap: anywhere; }
.chat-quoted-text > div { white-space: pre-wrap; max-height: 6em; overflow: hidden; }
.chat-quoted-text.is-expanded > div { max-height: none; }

.chat-quoted-audio { flex-direction: column; align-items: flex-start; min-width: 0; }
.chat-quoted-audio .chat-audio { width: min(300px, 60vw); }
.chat-quoted-audio audio { width: 100%; max-width: 300px; }

.chat-location { display: grid; gap: 8px; }
.chat-location p { margin: 0; }

.chat-quoted-location { flex-direction: column; align-items: flex-start; }

.chat-image-placeholder {display: block; padding: 20px; color: var(--brand-accent); overflow-wrap: anywhere;}


.chat-audio { display: inline-block; width: min(320px, 65vw); max-width: 100%; min-width: 0; }
.chat-message .chat-audio audio { width: 100%; }
.chat-audio-play { padding: 10px 16px; border: 1px solid #cbd5cf; border-radius: 20px; background: #f5f8f6; color: inherit; font: inherit; cursor: pointer; }
.chat-audio-play:disabled { cursor: wait; }
.chat-audio audio[hidden], .chat-audio button[hidden] { display: none; }

.chat-delivery-icon { display: inline-flex; vertical-align: middle; margin-left: 5px; color: #687b83; }
.chat-delivery-icon svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-delivery-icon.is-read { color: #087fb6; }
.chat-delivery-icon.is-cancelled, .chat-delivery-icon.is-warning { color: #a23d3d; }

.chat-activity-notice {
  align-self: center;
  max-width: 100%;
  padding: 4px 10px;
  color: var(--muted, #64748b);
  font-size: 0.78rem;
  text-align: center;
  overflow-wrap: anywhere;
}
.chat-activity-notice time { font-size: inherit; }

.chat-message .chat-reaction-badge {
  display: inline-flex;
  align-self: flex-start;
  margin: 6px 0 0;
  text-transform: none;
  font-weight: 400;
  padding: 2px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  font-size: 1rem;
  line-height: 1.5;
}
.chat-attachment-label { color: #64748b; font-size: 0.8rem; }
.chat-attachment-label small { display: block; margin-top: 4px; }
.chat-attachment-status { padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; }
.chat-attachment-status p { margin: 4px 0 0; font-size: 0.85rem; }
.chat-attachment-status.is-unavailable { border-color: #d97706; }

.chat-image { position: relative; }
.chat-image-delete {
  position: absolute;
  top: 6px;
  right: 36px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 2px;
  margin: 0;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: #b91c1c;
}
.chat-image-delete:hover { background: #fef2f2; border-color: #b91c1c; }
.chat-image-delete:focus-visible { outline: 2px solid #b91c1c; outline-offset: 2px; }

button.chat-media-delivery-warning {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
button.chat-media-delivery-warning:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

#image-delete-error:empty { display: none; }
#image-delete-error { padding: 0; text-align: left; }
