:root {
  --ink: #17201c;
  --muted: #68756f;
  --line: #e7ebe8;
  --paper: #fbfcfb;
  --white: #ffffff;
  --green: #11a861;
  --green-dark: #087a45;
  --green-soft: #eaf8f1;
  --amber: #b7791f;
  --amber-soft: #fff8e7;
  --slate-soft: #f2f5f3;
  --danger: #c0392b;
  --shadow: 0 18px 55px rgba(26, 46, 36, .08);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: #eef2ef;
  font-family: "Segoe UI", "Noto Sans Thai", Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.d-none { display: none !important; }

.support-app {
  display: grid;
  grid-template-columns: 78px minmax(310px, 390px) minmax(460px, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100dvh;
  max-width: 1680px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--white);
  box-shadow: var(--shadow);
}

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 22px 12px;
  background: #11251c;
  color: white;
}

.brand-mark, .admin-avatar, .customer-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 16px;
  font-weight: 800;
}

.brand-mark { width: 46px; height: 46px; background: var(--green); letter-spacing: -.04em; }
.admin-avatar { width: 40px; height: 40px; border-radius: 50%; background: #2e463b; color: #bff2d5; }
.rail-spacer { flex: 1; }

.rail-button {
  display: grid;
  gap: 4px;
  place-items: center;
  width: 54px;
  min-height: 56px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #95aaa0;
}
.rail a.rail-button { text-decoration: none; }

.knowledge-app { display: grid; grid-template-columns: 78px 330px minmax(500px, 1fr); width: min(1680px, 100%); height: 100dvh; margin: 0 auto; overflow: hidden; background: white; box-shadow: var(--shadow); }
.knowledge-sidebar { display: flex; min-height: 0; flex-direction: column; gap: 18px; padding: 28px 20px; border-right: 1px solid var(--line); background: var(--paper); }
.knowledge-sidebar header h1 { margin: 0; font-size: 26px; letter-spacing: -.04em; }
.knowledge-sidebar header > p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.knowledge-primary, .knowledge-secondary { border: 0; border-radius: 11px; padding: 10px 15px; font-weight: 750; }
.knowledge-primary { background: var(--green); color: white; }
.knowledge-primary:hover { background: var(--green-dark); }
.knowledge-primary:disabled { opacity: .55; cursor: wait; }
.knowledge-secondary { border: 1px solid #cfd9d3; background: white; color: #31443a; }
.knowledge-base-list { min-height: 0; overflow-y: auto; }
.knowledge-base-card { display: grid; grid-template-columns: 36px 1fr; gap: 10px; width: 100%; margin-bottom: 7px; padding: 12px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: inherit; text-align: left; }
.knowledge-base-card:hover { background: #f0f5f2; }
.knowledge-base-card.active { border-color: #c8e9d7; background: white; box-shadow: 0 5px 18px rgba(35,67,50,.07); }
.kb-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--green-soft); color: var(--green-dark); }
.knowledge-base-card strong, .knowledge-base-card small { display: block; }
.knowledge-base-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.knowledge-base-card small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.kb-loading, .kb-empty, .kb-error { padding: 20px 8px; color: var(--muted); font-size: 12px; text-align: center; }
.kb-error { color: var(--danger); }
.knowledge-main { min-width: 0; min-height: 0; overflow-y: auto; background: #f8faf9; }
.knowledge-empty { display: grid; place-items: center; align-content: center; height: 100%; color: var(--muted); text-align: center; }
.knowledge-empty div { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 24px; background: var(--green-soft); color: var(--green); font-size: 32px; }
.knowledge-empty h2 { margin: 18px 0 6px; color: var(--ink); }
.knowledge-empty p { margin: 0; max-width: 430px; }
.knowledge-content { padding: 34px; }
.knowledge-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.knowledge-header h2 { margin: 0; font-size: 28px; letter-spacing: -.035em; }
.knowledge-header p:last-child { margin: 7px 0 0; color: var(--muted); }
.knowledge-header > div:last-child { display: flex; gap: 8px; }
.knowledge-header-actions { flex-wrap: wrap; justify-content: flex-end; }
.knowledge-danger { border: 1px solid #efc7c2; border-radius: 9px; padding: 9px 13px; background: #fff5f3; color: var(--danger); font-weight: 700; }
.knowledge-danger:hover { background: #fee9e6; }
.knowledge-danger.blocked { opacity: .62; cursor: not-allowed; }
.knowledge-stats { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 12px; margin: 26px 0; }
.knowledge-stats div { padding: 17px 19px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.knowledge-stats strong, .knowledge-stats span { display: block; }
.knowledge-stats strong { font-size: 24px; }
.knowledge-stats span { margin-top: 3px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.knowledge-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 15px; background: white; }
.knowledge-table { width: 100%; border-collapse: collapse; }
.knowledge-table th { padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--muted); background: #fafcfb; font-size: 10px; text-align: left; text-transform: uppercase; }
.knowledge-table td { padding: 15px 16px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
.knowledge-table tr:last-child td { border-bottom: 0; }
.knowledge-table td strong, .knowledge-table td small, .knowledge-table td em { display: block; }
.knowledge-table td small { max-width: 390px; margin-top: 5px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.knowledge-table td em { margin-top: 5px; color: var(--danger); font-size: 10px; }
.knowledge-table code { font-size: 10px; }
.kb-status { display: inline-block; padding: 5px 8px; border-radius: 99px; background: var(--slate-soft); color: var(--muted); font-size: 10px; font-weight: 800; }
.kb-status.ready { background: var(--green-soft); color: var(--green-dark); }
.kb-status.awaiting_review { background: #e8f0ff; color: #315da8; }
.kb-status.processing { background: var(--amber-soft); color: var(--amber); }
.kb-status.failed { background: #fee9e6; color: var(--danger); }
.kb-actions { white-space: nowrap; }
.kb-actions button { width: auto; min-width: 30px; height: 30px; margin-left: 4px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.kb-actions button.danger { color: var(--danger); }
.table-empty { padding: 45px !important; color: var(--muted); text-align: center; }
.knowledge-modal { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(10,28,19,.48); backdrop-filter: blur(3px); }
.knowledge-modal form { width: min(580px, 100%); max-height: 92dvh; overflow-y: auto; padding: 24px; border-radius: 18px; background: white; box-shadow: 0 24px 80px rgba(0,0,0,.2); }
.knowledge-modal form.search-modal-form { width: min(760px, 100%); }
.knowledge-modal form > header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.knowledge-modal h2 { margin: 0; font-size: 21px; }
.knowledge-modal [data-close] { border: 0; background: transparent; color: var(--muted); font-size: 26px; }
.knowledge-modal label { display: grid; gap: 7px; margin-bottom: 15px; color: #35463d; font-size: 12px; font-weight: 700; }
.knowledge-modal input, .knowledge-modal textarea { width: 100%; border: 1px solid #ccd7d1; border-radius: 10px; padding: 10px 12px; outline: 0; resize: vertical; }
.knowledge-modal input:focus, .knowledge-modal textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(17,168,97,.09); }
.form-note { margin: -3px 0 16px; color: var(--muted); font-size: 11px; }
.knowledge-dropzone { position: relative; display: grid; place-items: center; min-height: 145px; padding: 20px; border: 2px dashed #b9d8c7; border-radius: 14px; outline: 0; background: #f5fbf8; color: var(--green-dark); text-align: center; transition: .15s ease; }
.knowledge-dropzone:hover, .knowledge-dropzone:focus, .knowledge-dropzone.dragging { border-color: var(--green); background: var(--green-soft); transform: translateY(-1px); }
.knowledge-dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.knowledge-dropzone > span { margin-top: 6px; color: var(--muted); font-size: 11px; }
.knowledge-mode-picker { display: grid; gap: 8px; margin: 0 0 16px; padding: 0; border: 0; }
.knowledge-mode-picker legend { margin-bottom: 7px; color: #35463d; font-size: 12px; font-weight: 700; }
.knowledge-mode-picker label { display: flex; grid-template-columns: none; align-items: flex-start; gap: 10px; margin: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: #fbfdfc; cursor: pointer; }
.knowledge-mode-picker input { width: auto; margin-top: 3px; }
.knowledge-mode-picker span, .knowledge-mode-picker strong, .knowledge-mode-picker small { display: block; }
.knowledge-mode-picker small { margin-top: 3px; color: var(--muted); font-weight: 400; }
.knowledge-modal form.section-preview-form { width: min(850px, 100%); }
.document-edit-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.section-preview-form > header p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.section-preview-list { display: grid; gap: 12px; max-height: 60vh; overflow-y: auto; padding-right: 4px; }
.section-preview-card { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fbfdfc; }
.section-preview-card > label:first-child { display: flex; grid-template-columns: auto 1fr; align-items: center; }
.section-preview-card > label:first-child input { width: auto; }
.section-preview-card textarea { min-height: 120px; font-family: inherit; line-height: 1.55; }
.section-source { margin: -5px 0 10px; color: var(--muted); font-size: 10px; }
#selectedFiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
#selectedFiles > span { padding: 5px 8px; border: 1px solid #cde4d7; border-radius: 8px; background: white; color: #30483b; font-size: 10px; }
#selectedFiles small { color: var(--muted); }
.knowledge-or { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: 10px; }
.knowledge-or::before, .knowledge-or::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.knowledge-search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.knowledge-results { display: grid; gap: 10px; max-height: 60vh; margin-top: 18px; overflow-y: auto; }
.knowledge-results > p { color: var(--muted); text-align: center; }
.knowledge-results article { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfdfc; }
.knowledge-results article header { display: flex; justify-content: space-between; gap: 12px; }
.knowledge-results article header span { color: var(--green-dark); font-weight: 800; }
.knowledge-results article p { margin: 10px 0; color: #35463d; line-height: 1.55; white-space: pre-wrap; }
.knowledge-results article small { color: var(--muted); }
@media (max-width: 850px) { .knowledge-app { grid-template-columns: 65px 230px minmax(400px, 1fr); } .knowledge-content { padding: 22px; } }

.rail-button span { font-size: 22px; }
.channel-button span { font-size: 12px; font-weight: 800; }
.rail-button small { font-size: 10px; }
.rail-button.active { background: rgba(17, 168, 97, .18); color: #9ff0c5; }
.channel-button[data-platform="lazada"].active { background: rgba(14, 46, 126, .38); color: #9fb8ff; }

.channel-settings {
  margin: 12px 0;
  padding: 14px;
  border: 1px solid #dce8e2;
  border-radius: 14px;
  background: #f5fbf8;
}
.channel-settings.lazada-settings { background: #f5f7ff; border-color: #dce2f6; }
.channel-settings h3 { margin: 0 0 10px; font-size: 15px; }
.channel-settings label { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 7px 0; }

.lazada-product-composer { display: flex; gap: 8px; margin-bottom: 8px; }
.lazada-product-composer select { flex: 1; min-width: 0; border: 1px solid #ccd6e6; border-radius: 10px; padding: 9px 11px; }
.lazada-product-composer button { border: 0; border-radius: 10px; padding: 9px 14px; color: white; background: #183b88; font-weight: 700; }
.lazada-connection { margin-top: 10px; padding-top: 10px; border-top: 1px solid #dce2f6; font-size: 13px; color: #44516b; }
.lazada-callbacks { display: grid; gap: 8px; margin-top: 10px; }
.lazada-callbacks div { display: grid; gap: 4px; }
.lazada-callbacks small { color: #66728a; font-weight: 700; }
.lazada-callbacks code { display: block; overflow-wrap: anywhere; border: 1px solid #dce2f6; border-radius: 8px; padding: 7px 9px; background: white; color: #24324d; font-size: 11px; }
.lazada-connection-actions { display: flex; gap: 8px; margin-top: 9px; }
.lazada-connection-actions a, .lazada-connection-actions button { border: 0; border-radius: 9px; padding: 8px 11px; background: #183b88; color: white; text-decoration: none; font-weight: 700; font-size: 12px; }

.ai-feedback { display: flex; flex-wrap: wrap; gap: 6px; padding: 7px 18px; border-bottom: 1px solid #e7ece9; background: #fbfdfc; }
.ai-feedback button { border: 1px solid #d6dfda; border-radius: 999px; padding: 5px 10px; background: white; color: #405148; font-size: 12px; }
.ai-feedback button:hover { border-color: #16a365; color: #0d7c4b; }
.field-label textarea { width: 100%; margin-top: 7px; border: 1px solid #ccd8d2; border-radius: 10px; padding: 10px; resize: vertical; }
.generative-limits input { width: 92px; margin-left: 6px; }

.inbox-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  height: 100%;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.inbox-header { display: flex; align-items: flex-end; justify-content: space-between; padding: 28px 24px 18px; }
.eyebrow { margin: 0 0 6px; color: var(--green-dark); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.title-row { display: flex; align-items: center; gap: 10px; }
.title-row h1 { margin: 0; font-size: 27px; letter-spacing: -.035em; }
.conversation-count { min-width: 26px; padding: 3px 7px; border-radius: 99px; background: var(--green-soft); color: var(--green-dark); font-size: 12px; font-weight: 800; text-align: center; }

.live-indicator { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
.live-indicator i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(17, 168, 97, .12); }

.search-box { display: flex; align-items: center; gap: 9px; margin: 0 20px 14px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; background: white; color: var(--muted); }
.search-box input { width: 100%; height: 42px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; }

.status-tabs { display: flex; gap: 6px; padding: 0 20px 16px; overflow-x: auto; }
.status-tab { white-space: nowrap; padding: 7px 11px; border: 1px solid var(--line); border-radius: 99px; background: white; color: var(--muted); font-size: 11px; font-weight: 700; }
.status-tab.active { border-color: #b7e8cf; background: var(--green-soft); color: var(--green-dark); }

.conversation-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 18px; }
.conversation-card { position: relative; display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 11px; width: 100%; padding: 14px 12px; border: 0; border-radius: 14px; background: transparent; color: inherit; text-align: left; }
.conversation-card:hover { background: #f0f5f2; }
.conversation-card.active { background: white; box-shadow: 0 7px 24px rgba(32, 62, 47, .08); }
.conversation-card.active::before { content: ""; position: absolute; inset: 14px auto 14px 0; width: 3px; border-radius: 0 4px 4px 0; background: var(--green); }
.conversation-avatar { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 15px; background: linear-gradient(145deg, #dff5e9, #c1ead4); color: var(--green-dark); font-weight: 800; }
.conversation-avatar img, .customer-avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.conversation-main { min-width: 0; }
.conversation-name-row { display: flex; align-items: center; gap: 7px; }
.attention-badge { flex: 0 0 auto; padding: 3px 6px; border-radius: 99px; background: #fff1cc; color: #946200; font-size: 8px; font-weight: 900; }
.attention-badge.critical { background: #fee5e2; color: #ad3024; }
.conversation-name { overflow: hidden; font-size: 13px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.conversation-preview { overflow: hidden; margin-top: 5px; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.conversation-time { color: #929d98; font-size: 10px; white-space: nowrap; }
.unread-badge { display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--green); color: white; font-size: 10px; font-weight: 800; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.status-dot.pending { background: #e2a93b; }
.status-dot.resolved { background: #9da7a2; }

.list-loading { display: grid; gap: 10px; padding: 10px; }
.list-loading span { height: 70px; border-radius: 13px; background: linear-gradient(90deg, #edf1ee 25%, #f8faf9 50%, #edf1ee 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty-list { padding: 48px 25px; color: var(--muted); text-align: center; }

.chat-panel { min-width: 0; min-height: 0; height: 100%; overflow: hidden; background: white; }
.empty-chat { display: grid; height: 100%; place-content: center; padding: 24px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 74px; height: 74px; margin: 0 auto 20px; border-radius: 24px; background: var(--green-soft); color: var(--green); font-size: 34px; }
.empty-chat h2 { margin: 0 0 8px; font-size: 21px; }
.empty-chat p { max-width: 360px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.active-chat { display: flex; min-height: 0; height: 100%; flex-direction: column; overflow: hidden; }

.chat-header { display: flex; align-items: center; min-height: 82px; gap: 13px; padding: 16px 24px; border-bottom: 1px solid var(--line); }
.customer-avatar { width: 48px; height: 48px; background: #dff5e9; color: var(--green-dark); }
.customer-details { min-width: 0; }
.customer-details h2 { overflow: hidden; margin: 0 0 4px; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.customer-details p { margin: 0; color: var(--muted); font-size: 11px; }
.chat-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.chat-actions label { color: var(--muted); font-size: 11px; }
.chat-actions select { padding: 8px 30px 8px 11px; border: 1px solid var(--line); border-radius: 10px; outline: 0; background: var(--paper); color: var(--ink); font-size: 12px; font-weight: 700; }
.mobile-back { display: none; border: 0; background: transparent; color: var(--ink); font-size: 22px; }

.message-list {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-color: #a9cdb9 #edf3ef;
  scrollbar-width: thin;
  padding: 28px clamp(20px, 5vw, 70px);
  background: linear-gradient(180deg, #fbfcfb, #f7faf8);
}
.message-list::-webkit-scrollbar { width: 10px; }
.message-list::-webkit-scrollbar-track { background: #edf3ef; }
.message-list::-webkit-scrollbar-thumb { border: 2px solid #edf3ef; border-radius: 99px; background: #a9cdb9; }
.message-list::-webkit-scrollbar-thumb:hover { background: #7eb898; }
.message-day { margin: 6px 0 22px; color: #8c9892; font-size: 10px; font-weight: 700; text-align: center; }
.message-row { display: flex; margin: 8px 0; }
.message-row.outgoing { justify-content: flex-end; }
.message-bubble { max-width: min(72%, 620px); padding: 11px 14px 8px; border: 1px solid #e2e8e4; border-radius: 5px 17px 17px 17px; background: white; box-shadow: 0 3px 12px rgba(36, 61, 48, .04); }
.message-row.outgoing .message-bubble { border-color: #c9ead8; border-radius: 17px 5px 17px 17px; background: #e7f8ef; }
.message-text { color: #27332d; font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-meta { display: flex; justify-content: flex-end; gap: 7px; margin-top: 5px; color: #829089; font-size: 9px; }
.delivery-failed { color: var(--danger); font-weight: 700; }
.message-row:has(.sticker-content) .message-bubble { border: 0; background: transparent; box-shadow: none; }
.sticker-content { display: grid; place-items: center; min-width: 120px; min-height: 120px; }
.sticker-image { display: block; width: min(180px, 42vw); max-height: 180px; object-fit: contain; }
.sticker-fallback { display: grid; place-items: center; gap: 7px; width: 130px; min-height: 110px; padding: 14px; border: 1px dashed #b7c9bf; border-radius: 20px; background: #f5f9f7; color: var(--green); font-size: 36px; text-align: center; }
.sticker-fallback small { color: var(--muted); font-size: 10px; line-height: 1.4; }

.ai-insight { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 8px 24px; border-bottom: 1px solid #dcefe5; background: #f3fbf7; }
.ai-insight div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ai-insight small { color: var(--green-dark); font-size: 9px; font-weight: 900; letter-spacing: .12em; }
.ai-insight strong { overflow: hidden; color: #395047; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.attention-banner { display: flex; align-items: center; gap: 11px; padding: 11px 24px; border-bottom: 1px solid #f0d28f; background: #fff8e7; color: #79520a; }
.attention-banner.critical { border-color: #efb8b1; background: #fff0ee; color: #8f2f25; }
.attention-icon { display: grid; place-items: center; flex: 0 0 auto; width: 25px; height: 25px; border-radius: 50%; background: #e5a92d; color: white; font-size: 13px; font-weight: 900; }
.attention-banner.critical .attention-icon { background: var(--danger); }
.attention-banner div { min-width: 0; flex: 1; }
.attention-banner strong { font-size: 11px; }
.attention-banner p { overflow: hidden; margin: 2px 0 0; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.attention-banner button { flex: 0 0 auto; padding: 6px 10px; border: 1px solid currentColor; border-radius: 9px; background: transparent; color: inherit; font-size: 10px; font-weight: 800; }
.attention-tab { color: #946200; }
.draft-button { flex: 0 0 auto; padding: 6px 10px; border: 1px solid #b8dec9; border-radius: 9px; background: white; color: var(--green-dark); font-size: 10px; font-weight: 800; }

.auto-message-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px !important; font-weight: 700; }
.auto-message-toggle input, .switch input { position: absolute; opacity: 0; pointer-events: none; }
.auto-message-toggle span, .switch span { position: relative; width: 34px; height: 19px; border-radius: 99px; background: #cbd5d0; transition: .2s; }
.auto-message-toggle span::after, .switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 13px; height: 13px; border-radius: 50%; background: white; box-shadow: 0 1px 4px rgba(0,0,0,.18); transition: .2s; }
.auto-message-toggle input:checked + span, .switch input:checked + span { background: var(--green); }
.auto-message-toggle input:checked + span::after, .switch input:checked + span::after { transform: translateX(15px); }

.settings-overlay { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(10, 24, 17, .48); backdrop-filter: blur(4px); }
.settings-panel { width: min(620px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto; border-radius: 22px; background: white; box-shadow: 0 25px 80px rgba(0,0,0,.25); }
.settings-panel > header { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 15px; border-bottom: 1px solid var(--line); }
.settings-panel h2 { margin: 0; font-size: 21px; }
.settings-panel header button { width: 36px; height: 36px; border: 0; border-radius: 10px; background: var(--slate-soft); color: var(--ink); font-size: 24px; }
.settings-panel form { display: grid; gap: 12px; padding: 20px 24px 24px; }
.setting-card { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; }
.setting-card.primary-setting { border-color: #bce7d1; background: var(--green-soft); }
.setting-card div { display: grid; gap: 4px; }
.setting-card strong { font-size: 13px; }
.setting-card small { color: var(--muted); font-size: 10px; }
.switch { display: flex; flex: 0 0 auto; }
.setting-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px; border-radius: 14px; background: var(--slate-soft); }
.setting-grid label { display: flex; align-items: center; gap: 7px; color: #405049; font-size: 11px; font-weight: 700; }
.setting-grid input { accent-color: var(--green); }
.auto-mode-note { display: flex; align-items: center; color: var(--green-dark); font-size: 10px; font-weight: 700; }
.field-label { display: grid; gap: 7px; color: #425149; font-size: 11px; font-weight: 800; }
.field-label select { height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.field-label input[type="range"] { width: 100%; accent-color: var(--green); }
.agent-style-settings { display: grid; gap: 11px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: #fbfcfb; }
.agent-style-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.agent-style-heading h3 { margin: 0 0 4px; color: var(--ink); font-size: 13px; }
.agent-style-heading p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.agent-style-heading > span { flex: 0 0 auto; padding: 4px 7px; border-radius: 999px; background: var(--slate-soft); color: var(--muted); font-size: 9px; font-weight: 700; }
.agent-style-grid { display: grid; gap: 9px; }
.agent-style-card { display: grid; gap: 7px; padding: 11px; border: 1px solid #e4e9e6; border-left-width: 4px; border-radius: 12px; background: white; }
.agent-style-card > span { display: grid; gap: 2px; }
.agent-style-card b { color: var(--ink); font-size: 11px; }
.agent-style-card small { color: var(--muted); font-size: 9px; }
.agent-style-card textarea { width: 100%; min-height: 76px; resize: vertical; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); font: inherit; font-size: 11px; line-height: 1.5; }
.agent-style-card textarea:focus { outline: 2px solid rgba(38, 151, 91, .15); border-color: var(--green); }
.marketing-style { border-left-color: #e3a12f; }
.order-style { border-left-color: #4b83d1; }
.support-style { border-left-color: var(--green); }
.settings-meta { padding: 9px 11px; border-radius: 9px; background: #f5f7f6; color: var(--muted); font-size: 10px; }
.settings-save { min-height: 44px; border: 0; border-radius: 12px; background: var(--green); color: white; font-size: 12px; font-weight: 800; }

.composer-area { position: relative; padding: 15px 22px 13px; border-top: 1px solid var(--line); background: white; }
.composer-area form { display: flex; align-items: flex-end; gap: 10px; padding: 8px 8px 8px 15px; border: 1px solid #dce3df; border-radius: 16px; background: var(--paper); }
.composer-tools { display: flex; align-items: center; gap: 4px; align-self: center; }
.composer-tool-button { display: grid; place-items: center; min-width: 38px; height: 42px; padding: 2px 5px; border: 0; border-radius: 10px; background: transparent; color: #41534a; font-size: 19px; cursor: pointer; }
.composer-tool-button:hover, .composer-tool-button[aria-expanded="true"] { background: #e4f3eb; color: var(--green-dark); }
.composer-tool-button small { display: block; color: #728078; font-size: 7px; font-weight: 800; line-height: 1; }
.sticker-tool-icon { font-size: 21px; line-height: 1; transform: rotate(2deg); }
.composer-popover { position: absolute; z-index: 15; bottom: calc(100% - 10px); left: 22px; width: min(340px, calc(100% - 44px)); overflow: hidden; border: 1px solid #d9e4de; border-radius: 16px; background: white; box-shadow: 0 16px 45px rgba(25, 54, 39, .18); }
.composer-popover > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 13px; border-bottom: 1px solid #e8eeeb; }
.composer-popover > header div { display: grid; gap: 2px; }
.composer-popover > header strong { font-size: 12px; }
.composer-popover > header small { color: var(--muted); font-size: 9px; }
.composer-popover > header button { width: 28px; height: 28px; border: 0; border-radius: 8px; background: #f0f4f2; color: #526159; font-size: 18px; cursor: pointer; }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 10px; }
.emoji-grid button { display: grid; place-items: center; aspect-ratio: 1; border: 0; border-radius: 10px; background: transparent; font-size: 23px; cursor: pointer; }
.emoji-grid button:hover { background: #edf7f2; transform: scale(1.08); }
.sticker-picker { width: min(430px, calc(100% - 44px)); }
.sticker-picker-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; max-height: 330px; overflow-y: auto; padding: 11px; }
.sticker-picker-item { display: grid; place-items: center; gap: 3px; min-width: 0; padding: 5px; border: 1px solid transparent; border-radius: 12px; background: transparent; cursor: pointer; }
.sticker-picker-item:hover { border-color: #bfe5d1; background: #eff9f4; }
.sticker-picker-item:disabled { cursor: wait; opacity: .45; }
.sticker-picker-item img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.sticker-picker-item small { width: 100%; overflow: hidden; color: #68776f; font-size: 8px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.picker-loading, .picker-error { grid-column: 1 / -1; padding: 28px 10px; color: var(--muted); font-size: 11px; text-align: center; }
.picker-error { color: var(--danger); }
.composer-area textarea { flex: 1; max-height: 140px; padding: 9px 0; resize: none; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; line-height: 1.45; }
.send-button { display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--green); color: white; font-size: 12px; font-weight: 800; }
.send-button:hover { background: #0e9657; }
.send-button:disabled { cursor: wait; opacity: .55; }
.send-button b { font-size: 16px; }
.composer-hint { margin: 7px 4px 0; color: #98a29d; font-size: 9px; text-align: right; }

.toast-message { position: fixed; z-index: 20; right: 24px; bottom: 24px; max-width: min(380px, calc(100vw - 48px)); padding: 12px 16px; transform: translateY(20px); border-radius: 12px; background: #18251f; color: white; box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast-message.show { transform: translateY(0); opacity: 1; }
.toast-message.error { background: #8f2f25; }

@media (max-width: 900px) {
  .support-app { grid-template-columns: 64px 330px minmax(0, 1fr); }
  .rail { padding-inline: 8px; }
  .message-list { padding-inline: 24px; }
}

@media (max-width: 720px) {
  body { overflow: hidden; }
  .support-app { display: block; position: relative; }
  .rail { display: none; }
  .inbox-panel, .chat-panel { position: absolute; inset: 0; }
  .inbox-panel { z-index: 1; border: 0; }
  .chat-panel { z-index: 2; transform: translateX(100%); transition: transform .22s ease; }
  .support-app.chat-open .chat-panel { transform: translateX(0); }
  .mobile-back { display: block; }
  .chat-header { padding-inline: 14px; }
  .chat-actions label { display: none; }
  .send-button span { display: none; }
  .send-button { width: 44px; justify-content: center; padding: 0; }
  .message-bubble { max-width: 86%; }
}

.rail-logout { margin: 0; }
.rail-logout .rail-button { width: 100%; }

.auth-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #e9f8f0, #f5f7f6 55%); }
.auth-card { width: min(420px, 100%); padding: 36px; border: 1px solid #dce7e1; border-radius: 24px; background: #fff; box-shadow: 0 24px 70px rgba(24, 61, 42, .12); }
.auth-logo { display: grid; place-items: center; width: 54px; height: 54px; margin-bottom: 22px; border-radius: 16px; background: var(--green); color: #fff; font-size: 18px; font-weight: 900; }
.auth-card h1 { margin: 0 0 8px; font-size: 30px; }
.auth-subtitle { margin: 0 0 24px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.auth-card form { display: grid; gap: 9px; }
.auth-card label { margin-top: 6px; font-size: 12px; font-weight: 800; }
.auth-card input { min-height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 11px; outline: none; font: inherit; }
.auth-card input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(17, 168, 97, .12); }
.auth-card form > button, .auth-link { min-height: 46px; margin-top: 12px; border: 0; border-radius: 11px; background: var(--green); color: #fff; font-weight: 800; text-decoration: none; }
.auth-link { display: grid; place-items: center; }
.auth-error, .field-validation-error { color: var(--danger); font-size: 11px; }

.admin-page { min-height: 100dvh; padding: 28px clamp(18px, 4vw, 60px) 60px; background: #f4f7f5; }
.admin-header { display: flex; align-items: center; justify-content: space-between; max-width: 1500px; margin: 0 auto 22px; }
.admin-header h1 { margin: 0; font-size: 28px; }
.admin-header a { color: var(--green-dark); font-size: 13px; font-weight: 800; text-decoration: none; }
.admin-card { max-width: 1500px; margin: 0 auto 18px; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.admin-card h2 { margin: 0 0 15px; font-size: 17px; }
.user-form { display: grid; grid-template-columns: 1fr 1.2fr 1.4fr 140px auto auto; gap: 9px; align-items: center; }
.user-form input, .user-form select, .user-row-form input, .user-row-form select { min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; }
.user-form button, .user-row-form button { min-height: 40px; padding: 0 14px; border: 0; border-radius: 9px; background: var(--green); color: #fff; font-weight: 800; }
.check { display: flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 12px; }
.table-wrap { overflow-x: auto; }
.admin-card table { width: 100%; border-collapse: collapse; font-size: 12px; }
.admin-card th, .admin-card td { padding: 11px 9px; border-bottom: 1px solid #edf1ef; text-align: left; vertical-align: middle; }
.user-row-form { display: grid; grid-template-columns: 1.2fr 110px auto 135px 1.2fr auto; gap: 8px; align-items: center; }
.delete-form { display: inline; }
.delete-form button { margin-top: 7px; border: 0; background: transparent; color: var(--danger); font-size: 11px; font-weight: 800; }
.notice { max-width: 1500px; margin: 0 auto 14px; padding: 11px 14px; border-radius: 10px; font-size: 12px; }
.notice.success { background: #dff5e9; color: #087143; }.notice.error { background: #fee8e5; color: #982f25; }
@media (max-width: 1000px) { .user-form { grid-template-columns: 1fr 1fr; }.user-row-form { grid-template-columns: 1fr 1fr; } }

/* User administration stays inside the same dashboard shell as Chat/Knowledge. */
.users-app { display: grid; grid-template-columns: 78px minmax(0, 1fr); width: min(1680px, 100%); height: 100dvh; margin: 0 auto; overflow: hidden; background: white; box-shadow: var(--shadow); }
.users-main { min-width: 0; min-height: 0; overflow-y: auto; background: #f4f7f5; }
.users-content { width: min(1500px, 100%); margin: 0 auto; padding: 30px clamp(20px, 3vw, 46px) 60px; }
.users-content .admin-header { max-width: none; margin: 0 0 22px; }
.users-content .admin-header h1 { margin: 0; font-size: 28px; letter-spacing: -.035em; }
.users-content .admin-header > div > p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.admin-role-badge, .admin-card-heading > span { padding: 6px 9px; border-radius: 99px; background: var(--green-soft); color: var(--green-dark); font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.users-content .admin-card { max-width: none; margin: 0 0 18px; padding: 20px; box-shadow: 0 8px 30px rgba(27, 55, 41, .035); }
.admin-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.admin-card-heading h2 { margin: 0 0 4px; font-size: 17px; }
.admin-card-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.users-content .notice { max-width: none; }
.admin-tabs { display: flex; gap: 8px; margin: 0 0 18px; padding: 5px; width: fit-content; border: 1px solid #dde7e1; border-radius: 14px; background: #eaf0ec; }
.admin-tab { display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 9px 16px; border: 0; border-radius: 10px; background: transparent; color: #65746c; font: inherit; cursor: pointer; transition: background .18s ease, color .18s ease, box-shadow .18s ease; }
.admin-tab span { font-size: 12px; font-weight: 850; }
.admin-tab small { padding: 3px 7px; border-radius: 99px; background: rgba(25, 61, 42, .07); font-size: 9px; font-weight: 800; }
.admin-tab:hover { color: var(--green-dark); }
.admin-tab.active { background: #fff; color: var(--green-dark); box-shadow: 0 3px 12px rgba(20, 54, 36, .09); }
.admin-tab.active small { background: var(--green-soft); color: var(--green-dark); }
.admin-tab:focus-visible { outline: 3px solid rgba(17,168,97,.18); outline-offset: 2px; }
.admin-tab-panel[hidden] { display: none; }
.user-form input:focus, .user-form select:focus, .user-row-form input:focus, .user-row-form select:focus { outline: 0; border-color: var(--green); box-shadow: 0 0 0 3px rgba(17,168,97,.09); }
.user-form button:hover, .user-row-form button:hover { background: var(--green-dark); }
.user-identity { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.user-identity > div { display: grid; gap: 3px; }
.user-identity small { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.user-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--green-soft); color: var(--green-dark); font-weight: 900; }
.last-login { color: var(--muted); font-size: 9px; line-height: 1.45; }
.last-login b { color: #34473d; font-size: 10px; }
.status-code { display: inline-block; min-width: 38px; padding: 4px 7px; border-radius: 99px; background: var(--green-soft); color: var(--green-dark); font-weight: 800; text-align: center; }
.status-code.failed { background: #fee9e6; color: var(--danger); }
.audit-card code { color: #34473d; font-size: 10px; }
.auth-notice { max-width: none; margin: 0 0 14px; }

@media (max-width: 1100px) {
  .user-form { grid-template-columns: 1fr 1fr; }
  .user-row-form { grid-template-columns: 1fr 110px auto; }
}
@media (max-width: 720px) {
  .users-app { grid-template-columns: 64px minmax(0, 1fr); }
  .users-app .rail { display: flex; padding-inline: 8px; }
  .users-content { padding: 22px 14px 45px; }
  .users-content .admin-header { align-items: flex-start; }
  .admin-role-badge { display: none; }
  .admin-tabs { width: 100%; }
  .admin-tab { flex: 1; justify-content: center; padding-inline: 10px; }
  .user-form, .user-row-form { grid-template-columns: 1fr; }
}
