:root {
  --admin-scroll-track: #f8f6fa;
  --admin-scroll-thumb: #c5b8cf;
  --admin-scroll-hover: #a991ba;
  --material-green: #07883f;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #332c39;
  background: #f8f6fa;
  font-synthesis: none;
}

* { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: var(--admin-scroll-thumb) var(--admin-scroll-track); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--admin-scroll-track); }
::-webkit-scrollbar-thumb { background: var(--admin-scroll-thumb); border: 2px solid var(--admin-scroll-track); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--admin-scroll-hover); }
@media (forced-colors: active) { * { scrollbar-color: auto; } }
html, body { min-height: 100%; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { outline-color: #8d70c9; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(142, 110, 203, .24);
  outline-offset: 2px;
}
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
.plain { border: 0; background: transparent; color: #6d6272; cursor: pointer; }
.outline { color: #73578f !important; background: #fff !important; border: 1px solid #d9cde3 !important; }
.danger { color: #bd444c !important; background: #fff !important; border: 1px solid #e7b5b8 !important; }
.danger-solid { color: #fff; background: #bd5159; border: 1px solid #bd5159; }

/* Login */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px 16px;
  background:
    radial-gradient(circle at 12% 10%, rgba(217, 202, 250, .75), transparent 34%),
    radial-gradient(circle at 90% 90%, rgba(255, 211, 204, .72), transparent 32%),
    #fbf9fc;
}
.login-card {
  width: min(430px, 94vw);
  padding: 44px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid #eee8f1;
  border-radius: 26px;
  box-shadow: 0 24px 70px rgba(76, 49, 86, .11);
  text-align: center;
}
.logo, .brand b, .sidebar-brand b {
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #9474d2, #ee8d91);
  border-radius: 13px;
  font-weight: 800;
}
.logo { width: 54px; height: 54px; font-size: 25px; }
.login-kicker { margin-top: 18px !important; color: #8a699d !important; font-weight: 700; }
.login h1 { margin: 6px 0 8px; color: #3f3445; font-size: 27px; }
.login p, .login small { display: block; color: #817786; font-size: 13px; line-height: 1.6; }
.login label, .profile label {
  display: block;
  margin: 20px 0 0;
  color: #5e5362;
  font-size: 13px;
  text-align: left;
}
.login input, .profile textarea, .profile input {
  width: 100%;
  margin-top: 7px;
  padding: 12px 13px;
  color: #3d3541;
  background: #fff;
  border: 1px solid #ddd4e1;
  border-radius: 10px;
}
.login button, .composer button, #accept {
  border: 0;
  border-radius: 10px;
  background: linear-gradient(110deg, #9475d5, #ed8b91);
  color: #fff;
  padding: 12px;
  font-weight: 700;
}
.login button { width: 100%; margin: 24px 0 13px; }
.error { min-height: 18px; margin-top: 10px; color: #c9444d; font-size: 13px; }

/* Customer service desk */
#desk { height: 100vh; height: var(--desk-viewport-height, 100dvh); display: flex; flex-direction: column; overflow: hidden; }
.desk-header {
  height: 66px;
  flex: 0 0 66px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: #fff;
  border-bottom: 1px solid #eae4ec;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.brand b { width: 34px; height: 34px; }
.brand em { margin-left: 2px; padding-left: 12px; border-left: 1px solid #e2dce5; color: #9a909e; font-size: 12px; font-style: normal; }
.desk-account { display: flex; align-items: center; gap: 14px; color: #605565; font-size: 13px; }
.desk-live { display: inline-flex; align-items: center; gap: 6px; color: #3d8f68; }
.desk-live i { width: 8px; height: 8px; background: #42b77c; border-radius: 50%; box-shadow: 0 0 0 4px #e1f5e9; }
.management-link { padding: 8px 12px; color: #745a90; background: #f3eef8; border-radius: 9px; font-weight: 600; }
.desk-grid { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr); grid-template-columns: 310px minmax(470px, 1fr) 290px; overflow: hidden; }
.conversations, .profile { min-height: 0; min-width: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; background: #fff; }
.conversations { border-right: 1px solid #e9e3eb; }
.profile { padding: 24px; border-left: 1px solid #e9e3eb; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 16px 12px; }
.panel-head > div { display: flex; flex-direction: column; gap: 4px; }
.panel-head small { color: #968c9a; font-size: 11px; }
.filters { display: flex; gap: 8px; padding: 8px 12px 13px; border-bottom: 1px solid #f0ebf2; }
.filter { padding: 7px 10px; color: #716777; background: #f5f2f7; border: 0; border-radius: 8px; font-size: 12px; }
.filter.active { color: #765893; background: #eee6f8; font-weight: 700; }
.conv { width: 100%; padding: 15px 16px; background: #fff; border: 0; border-bottom: 1px solid #f0ecf2; text-align: left; }
.conv:hover, .conv.selected { background: #faf6fc; }
.conv.selected { box-shadow: inset 3px 0 #9c78ce; }
.conv-line { display: flex; align-items: center; gap: 9px; }
.mini-avatar, .profile-avatar { display: grid; place-items: center; color: #765893; background: #eee7f8; border-radius: 50%; font-weight: 700; }
.mini-avatar { width: 36px; height: 36px; }
.conv-name { flex: 1; font-size: 14px; font-weight: 700; }
.badge { padding: 1px 6px; color: #fff; background: #df5d65; border-radius: 10px; font-size: 11px; }
.conv-preview { margin: 6px 0 0 45px; overflow: hidden; color: #928895; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.chat { min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; background: linear-gradient(180deg, #f5f0fa, #fbf9fc 35%); }
.chat #chatContent { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
.chat-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-title > div { min-width: 0; overflow-wrap: anywhere; }
.mobile-back { display: none; }
.empty-select { margin-top: 18px; padding: 10px 18px; border-radius: 9px; }
.empty-select:hover, .mobile-back:hover { filter: brightness(.96); }
.empty-select:active, .mobile-back:active { transform: translateY(1px); }
.chat-head, .quick-replies, .composer, .media-status { flex-shrink: 0; }
.empty { margin: auto; padding: 30px; color: #958a99; text-align: center; }
.empty h2 { margin: 12px 0 7px; color: #55495b; font-size: 18px; }
.empty h3 { color: #55495b; }
.empty p { max-width: 390px; margin: 0; font-size: 13px; line-height: 1.7; }
.empty-kicker { display: inline-flex; padding: 7px 12px; color: #795d94; background: #eee7f8; border-radius: 999px; font-size: 12px; font-weight: 700; }
.small { padding-top: 86px; }
.chat-head { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 11px 22px; background: rgba(255, 255, 255, .94); border-bottom: 1px solid #e9e3eb; }
.chat-head span { margin-left: 9px; color: #3e946b; font-size: 12px; }
.chat-actions { display: flex; align-items: center; gap: 8px; }
.chat-head button { width: auto; margin: 0; padding: 8px 13px; font-size: 13px; }
.chat-head select { max-width: 150px; padding: 8px; border: 1px solid #dcd3e0; border-radius: 9px; background: #fff; }
.messages { flex: 1; display: flex; flex-direction: column; gap: 16px; min-height: 0; min-width: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 24px; }
.media-status { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; min-height: 30px; padding: 6px 16px 12px; color: #756b79; background: #fff; border-top: 1px solid #eee8f0; font-size: 12px; }
.media-status > span { overflow-wrap: anywhere; }
.media-status progress { width: 100px; max-width: 100%; height: 8px; accent-color: #3b8a63; }
.media-status.error { color: #b44e4e; }
.media-status button { width: auto; margin: 0; padding: 5px 10px; color: #3b8a63; border: 1px solid #b7d9c5; border-radius: 7px; background: #f3fbf6; font-size: 12px; }
.message { max-width: 72%; min-width: 0; flex-shrink: 0; display: flex; align-items: flex-start; gap: 10px; }
.message > .mini-avatar { flex: 0 0 36px; }
.message-content { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.message-content.material-content { width: 365px; max-width: 100%; }
.material-content .material-bubble { width: 100%; }
.message-status { align-self: flex-end; color: #817786; font-size: 11px; line-height: 1.4; }
.message.me { align-self: flex-end; flex-direction: row-reverse; }
.bubble { min-width: 0; overflow-wrap: anywhere; padding: 10px 13px; color: #493f4d; background: #fff; border: 1px solid #ece6ee; border-radius: 5px 13px 13px; box-shadow: 0 4px 12px rgba(71, 50, 79, .04); font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.me .bubble { background: linear-gradient(120deg, #eee5ff, #ffe4e1); border-color: #e8dceb; border-radius: 13px 5px 13px 13px; }
.msg-image { display: block; width: 230px; max-width: 100%; border-radius: 10px; }
.msg-video { display: block; width: 280px; max-width: 100%; max-height: 260px; border-radius: 10px; background: #17151b; }
.msg-audio { display: block; width: 250px; max-width: 100%; }
.quick-replies { display: flex; gap: 7px; overflow: auto; padding: 8px 16px; background: #fff; }
.quick-replies button { padding: 5px 10px; color: #71558c; background: #faf7fc; border: 1px solid #ded2e6; border-radius: 13px; font-size: 12px; white-space: nowrap; }
.composer { display: flex; gap: 10px; padding: 12px 16px; background: #fff; border-top: 1px solid #e7e0e9; }
.composer textarea { flex: 1; padding: 10px 12px; resize: none; border: 1px solid #ddd4e2; border-radius: 11px; }
.composer button { width: 74px; margin: 0; padding: 0; }
.upload { display: grid; place-items: center; width: 52px; color: #72588a; background: #f2ebf7; border-radius: 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.composer .upload { flex: 0 0 52px; width: 52px; color: #72588a; background: #f2ebf7; box-shadow: none; }
.composer .upload:hover:not(:disabled) { background: #e8dcf1; }
.composer .upload:focus-visible, .media-status button:focus-visible { outline: 2px solid #72588a; outline-offset: 2px; }
.composer .upload:disabled, .media-status button:disabled { opacity: .5; cursor: not-allowed; }
.profile-avatar { width: 68px; height: 68px; margin: auto; font-size: 24px; }
.profile h3 { margin: 12px 0 3px; text-align: center; }
.profile > div > p { color: #958b99; font-size: 12px; text-align: center; word-break: break-all; }
.profile dl { margin: 28px 0; font-size: 13px; }
.profile dt { float: left; margin-bottom: 15px; color: #8c8290; }
.profile dd { margin: 0 0 15px; text-align: right; }
.wide { width: 100%; margin-top: 10px; padding: 10px; border-radius: 9px; }
.notice { padding: 30px; color: #908694; text-align: center; }

/* Management shell */
.management-page { overflow: hidden; background: #f8f6fa; }
.manage-shell { min-height: 100vh; display: flex; }
.manage-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 268px;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  overflow-y: auto;
  color: #4b3f50;
  background: #fff;
  border-right: 1px solid #ebe5ed;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.sidebar-brand b { width: 38px; height: 38px; }
.sidebar-brand span { display: flex; flex-direction: column; gap: 2px; }
.sidebar-brand strong { font-size: 16px; }
.sidebar-brand small { color: #958a99; font-size: 11px; }
.side-nav { display: flex; flex-direction: column; gap: 18px; }
.side-nav-group h2 { margin: 0 10px 7px; color: #a198a5; font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.side-nav-item { width: 100%; min-height: 42px; display: flex; align-items: center; margin: 2px 0; padding: 10px 12px; color: #5e5363; background: transparent; border: 0; border-radius: 10px; text-align: left; }
.side-nav-item:hover { background: #f8f4fa; }
.side-nav-item.active { color: #6f518c; background: linear-gradient(100deg, #f0e9fa, #fff0f2); font-weight: 700; }
.workbench-item { color: #fff; background: linear-gradient(110deg, #8e70ca, #e9878d); font-weight: 700; box-shadow: 0 9px 24px rgba(143, 94, 147, .18); }
.workbench-item:hover { background: linear-gradient(110deg, #8264c0, #df7c82); }
.sidebar-help { margin-top: auto; padding: 16px; background: #faf7fb; border: 1px solid #eee7f0; border-radius: 15px; }
.sidebar-help strong { font-size: 13px; }
.sidebar-help p { margin: 7px 0 12px; color: #8e8492; font-size: 11px; line-height: 1.55; }
.sidebar-help a { color: #765993; font-size: 12px; font-weight: 700; }
.manage-stage { min-width: 0; flex: 1; margin-left: 268px; }
.manage-topbar { position: sticky; top: 0; z-index: 10; height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 28px; background: rgba(255, 255, 255, .94); border-bottom: 1px solid #ebe5ed; backdrop-filter: blur(10px); }
.topbar-context { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.topbar-context strong { color: #403546; font-size: 17px; }
.topbar-context span { overflow: hidden; color: #8c8290; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.manager-account { display: flex; align-items: center; gap: 10px; color: #5e5362; font-size: 12px; }
.presence-dot { width: 9px; height: 9px; background: #42b57a; border-radius: 50%; box-shadow: 0 0 0 4px #e2f5e9; }
.manager-copy { display: flex; flex-direction: column; }
.manager-copy small { color: #978d9b; }
.mobile-menu { display: none; padding: 7px 10px; color: #72558e; background: #f1eaf7; border: 0; border-radius: 8px; }
.manage-main { max-width: 1440px; margin: 0 auto; padding: 28px; }
.manage-content { min-height: calc(100vh - 128px); padding: 24px; background: #fff; border: 1px solid #ece6ee; border-radius: 20px; }
.manage-content.view-dashboard { padding: 0; background: transparent; border: 0; }
.form-notice { min-height: 0; margin-bottom: 10px; padding: 0; font-size: 13px; }
.form-notice:empty { display: none; }
.form-notice.success:not(:empty), .form-notice.error:not(:empty) { padding: 11px 14px; border-radius: 10px; }
.form-notice.success:not(:empty) { color: #267a55; background: #eaf7ef; }
.form-notice.error:not(:empty) { color: #ad3f47; background: #fff0f1; }

/* Dashboard */
.dashboard { display: flex; flex-direction: column; gap: 20px; }
.dashboard-hero { display: flex; align-items: center; justify-content: space-between; gap: 30px; min-height: 230px; padding: 34px 38px; overflow: hidden; background: linear-gradient(125deg, #eee8fb, #fff8fb 54%, #ffe2dd); border: 1px solid #e9dfee; border-radius: 22px; }
.dashboard-kicker { display: inline-flex; padding: 6px 10px; color: #775b90; background: rgba(255, 255, 255, .68); border-radius: 999px; font-size: 11px; font-weight: 700; }
.dashboard-hero h1 { margin: 14px 0 7px; color: #3e3344; font-size: clamp(25px, 3vw, 36px); }
.dashboard-hero p { margin: 0 0 22px; color: #776c7b; font-size: 14px; }
.primary-link { display: inline-flex; align-items: center; min-height: 42px; padding: 0 18px; color: #fff; background: linear-gradient(110deg, #8f70ca, #eb898e); border-radius: 11px; font-size: 13px; font-weight: 700; box-shadow: 0 10px 24px rgba(145, 92, 143, .2); }
.queue-summary { display: flex; gap: 1px; overflow: hidden; background: rgba(255, 255, 255, .65); border: 1px solid rgba(255, 255, 255, .8); border-radius: 18px; }
.queue-summary div { min-width: 135px; display: flex; flex-direction: column; padding: 24px; background: rgba(255, 255, 255, .42); }
.queue-summary strong { color: #49384f; font-size: 32px; }
.queue-summary span { margin-top: 4px; color: #837587; font-size: 12px; }
.dashboard-section { padding: 24px; background: #fff; border: 1px solid #ece6ee; border-radius: 18px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.section-heading h2, .system-panel h2 { margin: 0; color: #453a4a; font-size: 17px; }
.section-heading p { margin: 5px 0 0; color: #968c99; font-size: 12px; }
.metric-list { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); border-top: 1px solid #f0ebf2; border-left: 1px solid #f0ebf2; }
.metric-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 66px; padding: 14px 16px; border-right: 1px solid #f0ebf2; border-bottom: 1px solid #f0ebf2; }
.metric-row span { color: #776d7b; font-size: 12px; }
.metric-row b { color: #5f4776; font-size: 23px; }
.dashboard-lower { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, .7fr); gap: 20px; }
.onboarding-steps { margin: 0; padding: 0; list-style: none; }
.onboarding-steps li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid #f0ebf2; }
.onboarding-steps li:last-child { border-bottom: 0; }
.onboarding-steps li > span { width: 28px; height: 28px; display: grid; place-items: center; color: #74558e; background: #f0e9f7; border-radius: 50%; font-size: 12px; font-weight: 700; }
.onboarding-steps li div { display: flex; flex-direction: column; gap: 3px; }
.onboarding-steps strong { font-size: 13px; }
.onboarding-steps small { color: #958b98; font-size: 11px; }
.step-action { padding: 7px 10px; color: #73568e; background: #fff; border: 1px solid #dcd0e4; border-radius: 8px; font-size: 11px; }
.system-panel { align-self: start; }
.system-panel p { color: #827783; font-size: 13px; line-height: 1.65; }
.system-ok { display: inline-flex; margin-top: 18px; padding: 7px 10px; color: #2e8059; background: #e7f6ed; border-radius: 999px; font-size: 12px; }
.system-panel button { padding: 8px 11px; border-radius: 8px; font-size: 12px; }

/* Management forms and tables */
.editor { margin-bottom: 24px; padding: 20px; background: #fcfafc; border: 1px solid #ece6ee; border-radius: 15px; }
.editor h2 { margin: 0 0 16px; color: #4a3e4f; font-size: 16px; }
.editor-form, .filter-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; gap: 13px; }
.filter-form { margin-bottom: 20px; padding: 17px; background: #faf7fb; border: 1px solid #eee8f0; border-radius: 14px; }
.field { display: flex !important; flex-direction: column; gap: 7px; margin: 0 !important; color: #5c5161; font-size: 12px; }
.field input, .field textarea, .field select { width: 100%; min-height: 40px; padding: 9px 10px; color: #413745; background: #fff; border: 1px solid #dcd3e0; border-radius: 9px; }
.field textarea { resize: vertical; }
.field-checkbox { flex-direction: row !important; align-items: center; justify-content: flex-start; padding-top: 25px; }
.field-checkbox input { width: auto; min-height: auto; }
.field small { color: #958b99; font-size: 11px; line-height: 1.45; }
.form-actions, .table-actions, .pager { display: flex; align-items: center; gap: 8px; }
.form-actions button, .filter-form button, .table-actions button, .pager button { width: auto; min-height: 38px; margin: 0; padding: 8px 12px; border-radius: 8px; }
.form-actions button:first-child, .filter-form > button { color: #fff; background: linear-gradient(110deg, #8e70ca, #e9898e); border: 0; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { max-width: 320px; padding: 12px 11px; border-bottom: 1px solid #f0ebf2; text-align: left; vertical-align: top; word-break: break-word; }
th { color: #7e7381; background: #faf8fb; font-size: 11px; font-weight: 700; }
td { color: #4f4553; }
.table-empty { padding: 42px 20px; color: #918694; text-align: center; }
.material-thumb { width: 58px; height: 58px; object-fit: cover; border-radius: 10px; }
.pager { margin-top: 17px; color: #817683; font-size: 12px; }
.load-error { display: grid; place-items: center; min-height: 360px; color: #827784; text-align: center; }
.load-error strong { color: #514557; font-size: 17px; }
.load-error p { margin: 8px 0 14px; }
.load-error button { padding: 8px 12px; border-radius: 8px; }
.sidebar-mask { position: fixed; inset: 0; z-index: 15; background: rgba(40, 30, 44, .34); }

@media (max-width: 1120px) {
  .desk-grid { grid-template-columns: 270px 1fr; }
  .profile { display: none; }
  .metric-list { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
}

@media (max-width: 860px) {
  .management-page { overflow: auto; }
  .manage-sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 16px 0 40px rgba(49, 34, 55, .15); }
  .manage-sidebar.open { transform: translateX(0); }
  .manage-stage { margin-left: 0; }
  .mobile-menu { display: inline-flex; }
  .manage-topbar { padding: 0 16px; }
  .topbar-context { flex: 1; }
  .manager-copy, .presence-dot { display: none; }
  .manage-main { padding: 18px; }
  .dashboard-hero { align-items: stretch; flex-direction: column; }
  .queue-summary { align-self: stretch; }
  .queue-summary div { flex: 1; }
  .dashboard-lower { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .desk-header { padding: 0 12px; gap: 12px; }
  .brand { min-width: 0; flex: 1; font-size: 15px; }
  .brand b { flex: 0 0 34px; }
  .brand > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .brand em, .desk-account .desk-live, .desk-account #agentName { display: none; }
  .desk-account { flex: 0 0 auto; gap: 10px; font-size: 12px; }
  .management-link { padding: 8px; }
  .desk-grid { grid-template-columns: minmax(0, 1fr); }
  .conversations { display: block; border-right: 0; }
  .chat { display: none; }
  #desk[data-mobile-view="chat"] .conversations { display: none; }
  #desk[data-mobile-view="chat"] .chat { display: flex; }
  .chat .mobile-back { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; min-height: 40px; }
  .chat-title { width: 100%; }
  .chat-title > div { flex: 1; }
  .chat-head { padding: 9px 12px; gap: 8px; }
  .messages { padding: 16px 12px; }
  .message { max-width: 92%; }
  .composer { padding: 10px 12px max(10px, env(safe-area-inset-bottom)); }
  .composer textarea { min-height: 44px; font-size: 16px; }
  .composer > button { flex: 0 0 58px; width: 58px; }
  .chat-head { align-items: flex-start; flex-direction: column; }
  .chat-actions { width: 100%; overflow-x: auto; }
  .manage-main { padding: 12px; }
  .manage-content { padding: 15px; border-radius: 15px; }
  .dashboard-hero { padding: 25px; }
  .queue-summary div { min-width: 0; padding: 17px; }
  .metric-list { grid-template-columns: 1fr; }
  .editor-form, .filter-form { grid-template-columns: 1fr; }
  .onboarding-steps li { grid-template-columns: 30px minmax(0, 1fr); }
  .onboarding-steps .step-action { grid-column: 2; justify-self: start; }
}
.field .field-error {
  color: #b4233e;
  min-height: 1.2em;
}



/* Authorization and notification settings share the established management fields. */
.settings-editor { max-width: 1020px; }
.settings-form { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.settings-help, .settings-platform-link, .settings-readiness, .settings-mapping, .settings-status, .settings-actions { grid-column: 1 / -1; }
.settings-help { margin: 0; color: #776d7b; font-size: 13px; line-height: 1.7; }
.settings-platform-link { justify-self: start; color: #73578f; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.settings-form .field-checkbox { padding: 10px 0; min-height: 42px; }
.settings-readiness { padding: 12px 14px; background: #f0e9f7; border: 1px solid #dcd3e0; border-radius: 9px; color: #5c5161; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.settings-mapping h3 { margin: 12px 0 8px; color: #4a3e4f; font-size: 14px; }
.settings-mapping-list { display: grid; gap: 14px; margin: 12px 0; }
.settings-mapping-row { min-width: 0; margin: 0; padding: 14px; display: grid; grid-template-columns: minmax(120px, .8fr) minmax(150px, 1fr) minmax(180px, 1.3fr); gap: 12px; border: 1px solid #dcd3e0; border-radius: 10px; background: #fff; }
.settings-mapping-row legend { padding: 0 5px; color: #5c5161; font-size: 12px; font-weight: 600; }
.settings-mapping-empty, .settings-field-guide { margin: 0; color: #776d7b; font-size: 12px; line-height: 1.6; }
.settings-field-guide { grid-column: 1 / -1; }
.settings-mapping button { min-height: 38px; padding: 8px 12px; border-radius: 8px; }
.settings-mapping .settings-remove { grid-column: 1 / -1; justify-self: end; }
.settings-form .field input:disabled { color: #776d7b; background: #f8f6fa; cursor: not-allowed; }
.settings-form .field [aria-invalid="true"] { border-color: #b4233e; }
.settings-status { min-height: 1.6em; font-size: 13px; line-height: 1.6; }
.settings-status.error { color: #b4233e; }
.settings-status.success { color: #2e8059; }
.settings-actions { flex-wrap: wrap; }
.settings-actions .settings-save { min-width: 104px; }
.settings-dirty { color: #776d7b; font-size: 12px; }
.settings-dialog { max-width: min(420px, calc(100vw - 32px)); padding: 24px; color: #4a3e4f; border: 1px solid #dcd3e0; border-radius: 15px; background: #fff; }
.settings-dialog::backdrop { background: rgba(40, 30, 44, .34); }
.settings-dialog h2 { margin: 0 0 10px; font-size: 18px; }
.settings-dialog p { margin: 0 0 20px; color: #776d7b; line-height: 1.6; }
.settings-dialog .form-actions { justify-content: flex-end; flex-wrap: wrap; }
.settings-editor button:not(:disabled):hover, .settings-dialog button:not(:disabled):hover { filter: brightness(.96); }
.settings-editor button:not(:disabled):active, .settings-dialog button:not(:disabled):active { transform: translateY(1px); }
@media (max-width: 860px) {
  .settings-form, .settings-mapping-row { grid-template-columns: 1fr; }
  .settings-actions > button { flex: 1; }
  .settings-dirty { flex-basis: 100%; }
}

.settings-form .field { min-width: 0; }
.settings-form .field input, .settings-form .field select { min-width: 0; }
.material-workspace { min-width: 0; }
.material-heading { display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 20px; }
.material-heading h2 { margin: 0 0 8px; font-size: 21px; }
.material-heading p { max-width: 720px; }
.material-workspace button, .material-image-dialog button { min-height: 38px; padding: 8px 14px; border-radius: 9px; border: 1px solid #a884bd; color: #fff; background: #9a72b2; font-weight: 600; }
.material-workspace button:not(:disabled):hover, .material-image-dialog button:not(:disabled):hover { filter: brightness(.96); }
.material-workspace button:not(:disabled):active, .material-image-dialog button:not(:disabled):active { transform: translateY(1px); }
.material-toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.material-library { min-height: 260px; }
.material-library-item, .material-job-row { display: flex; gap: 16px; align-items: center; padding: 17px 0; border-bottom: 1px solid #ece6ee; min-width: 0; }
.material-library-thumb { width: 76px; height: 76px; flex: 0 0 76px; object-fit: cover; border-radius: 10px; background: #f2f3f5; }
.material-library-info, .material-job-row > div { flex: 1; min-width: 0; }
.material-library-info h3, .material-job-row h3 { font-size: 15px; margin: 0 0 6px; overflow-wrap: anywhere; }
.material-library-excerpt { margin: 6px 0 0; max-width: 650px; color: #776d7b; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.material-empty { padding: 38px 18px; text-align: center; color: #776d7b; border: 1px dashed #dcd3e0; border-radius: 12px; }
.material-empty strong { color: #4a3e4f; }
.material-empty p { line-height: 1.7; }
.material-editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 365px); align-items: start; gap: 26px; }
.material-package-form { display: flex; flex-direction: column; align-items: stretch; gap: 16px; min-width: 0; }
.material-package-form textarea { resize: none; min-height: 130px; overflow-y: auto; }
.material-upload-section { min-width: 0; border-top: 1px solid #ece6ee; padding-top: 15px; }
.material-upload-section h3, .material-live-preview h3 { margin: 0 0 10px; font-size: 15px; }
.material-upload-section input[type=file] { max-width: 100%; }
.material-file-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.material-file { display: grid; grid-template-columns: 20px 58px minmax(0, 1fr); gap: 9px; align-items: center; border: 1px solid #e7dfe9; padding: 12px; border-radius: 10px; background: #fff; }
.material-file-number { color: #776d7b; text-align: center; font-size: 12px; }
.material-file-thumb { width: 58px; height: 58px; object-fit: cover; border-radius: 7px; background: #f2f3f5; }
.material-file-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.material-file-info strong { overflow-wrap: anywhere; font-size: 12px; }
.material-file-info small, .material-file-state { color: #776d7b; font-size: 12px; line-height: 1.5; }
.material-file-state.error { color: #b4233e; }
.material-file-info progress { width: 100%; height: 8px; accent-color: #9a72b2; }
.material-file-controls { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 5px; }
.material-file-controls button { min-height: 32px; padding: 5px 9px; font-size: 12px; }
.material-package-form .settings-actions { position: sticky; bottom: 0; z-index: 1; padding: 12px 0; background: #fff; border-top: 1px solid #ece6ee; }
.material-live-preview { background: #f2f3f5; padding: 17px; border-radius: 14px; min-width: 0; }
.material-live-preview > .settings-help { margin-bottom: 14px; }
.material-message-card { width: 100%; padding: 10px 12px 20px; background: #fff; border-radius: 13px; color: #202124; overflow: hidden; white-space: normal; }
.material-card-images { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-bottom: 18px; }
.material-message-card .material-card-thumb { position: relative; aspect-ratio: 1; padding: 0; border: 0; overflow: hidden; border-radius: 6px; background: #f2f3f5; min-height: 0; display: block; }
.material-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.material-card-more { position: absolute; inset: 0; background: rgba(0,0,0,.48); display: flex; align-items: center; justify-content: center; color: #fff; }
.material-card-more b { font-size: 26px; }
.material-card-more small { position: absolute; right: 4px; bottom: 5px; background: rgba(0,0,0,.6); border-radius: 3px; font-size: 11px; padding: 2px 4px; }
.material-message-card .material-card-save { display: block; min-height: 0; color: #fff; background: #07c160; border: 1px solid #07c160; padding: 6px 18px; font-size: 16px; line-height: 1.3; border-radius: 24px; font-weight: 400; margin: 0 3px 13px; opacity: 1; cursor: default; }
.material-card-copy { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 3px 12px; color: #202124; font-size: 16px; line-height: 1.65; }
.material-message-card .material-card-copy-button { padding: 3px 14px; line-height: 1.35; min-height: 0; color: #07995b; background: #fff; border: 1px solid #9bd7bd; border-radius: 24px; font-size: 15px; font-weight: 400; margin: 0 3px; opacity: 1; }
.material-card-copy-button:disabled { cursor: default; }
.material-card-note { white-space: pre-wrap; overflow-wrap: anywhere; border-top: 1px solid #f2f3f5; padding-top: 12px; margin: 14px 3px 0; color: #767676; font-size: 14px; line-height: 1.7; font-weight: 500; }
.material-card-feedback { font-size: 12px; color: #6b7280; margin-left: 6px; }
.material-card-empty { grid-column: 1 / -1; padding: 35px 12px; color: #6b7280; text-align: center; font-size: 13px; background: #f2f3f5; border-radius: 7px; }
.material-image-unavailable { display: block; padding: 10px; color: #6b7280; font-size: 12px; }
.material-bubble { padding: 0 !important; width: min(365px, 100%); }
.material-image-dialog { width: min(850px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); overflow-y: auto; }
.material-image-full { display: block; max-width: 100%; max-height: 66dvh; object-fit: contain; margin: auto; }
.material-image-count { text-align: center; margin: 12px !important; }
.material-audience-form { display: flex; flex-direction: column; gap: 15px; min-width: 0; }
.material-audience-modes { display: flex; gap: 20px; flex-wrap: wrap; border: 1px solid #dcd3e0; padding: 14px; border-radius: 10px; }
.material-audience-modes legend { padding: 0 5px; font-size: 13px; }
.material-radio, .material-recipient { display: flex; gap: 10px; align-items: center; cursor: pointer; font-size: 14px; }
.material-radio input, .material-recipient input { accent-color: #9a72b2; width: 18px; height: 18px; flex: 0 0 18px; cursor: pointer; }
.material-search { display: flex; gap: 8px; align-items: flex-start; }
.material-search .field { flex: 1; min-width: 0; }
.material-search > button { margin-top: 24px; }
.material-selection { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 0; font-size: 14px; }
.material-recipient-list { min-height: 230px; max-height: 500px; overflow-y: auto; scrollbar-gutter: stable; border: 1px solid #e7dfe9; border-radius: 10px; padding: 10px; }
.material-recipient-list > button { margin-bottom: 8px; }
.material-recipient { padding: 12px 6px; border-bottom: 1px solid #f1ecf4; }
.material-recipient:hover { background: #faf7fc; }
.material-recipient > span { display: flex; flex-direction: column; gap: 5px; min-width: 0; overflow-wrap: anywhere; }
.material-recipient small { color: #776d7b; font-size: 12px; }
.material-confirm { max-width: 680px; }
.material-confirm > h3 { font-size: 24px; margin: 0 0 8px; }
.material-confirm > .material-message-card { max-width: 365px; margin: 20px 0; border: 1px solid #ece6ee; }
.material-confirm > .form-actions { flex-wrap: wrap; padding: 15px 0; }
.material-job-detail { padding: 20px; background: #faf8fc; border: 1px solid #e7dfe9; border-radius: 12px; }
.material-job-detail h3 { margin-top: 0; }
.material-job-detail > progress { width: 100%; accent-color: #9a72b2; }
.material-job-detail .form-actions { flex-wrap: wrap; }
.material-failures li { font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
.material-job-content { margin-top: 24px; max-width: 365px; }
.material-job-content > .material-message-card { border: 1px solid #ece6ee; }
@media (max-width: 1150px) { .material-editor-layout { grid-template-columns: minmax(0, 1fr); } .material-live-preview { max-width: 400px; width: 100%; } }
@media (max-width: 650px) {
  .material-heading, .material-library-item, .material-job-row { flex-wrap: wrap; }
  .material-library-item .table-actions { flex-basis: 100%; }
  .material-heading h2 { font-size: 19px; }
  .material-package-form .settings-actions { position: static; }
  .material-workspace .pager { flex-wrap: wrap; }
  .material-file { grid-template-columns: 16px 45px minmax(0, 1fr); padding: 8px; gap: 7px; }
  .material-file-thumb { width: 45px; height: 45px; }
  .material-search { flex-wrap: wrap; }
  .material-search > button { margin-top: 0; }
}
@media (max-width: 1050px) {
  .settings-mapping-row { grid-template-columns: 1fr; }
}

/* Workbench package selection shares the settings dialog and material card. */
.composer-tools { display: flex; align-items: stretch; gap: 7px; flex: 0 0 auto; }
.composer .package-tool { width: 68px; flex-basis: 68px; }
.composer textarea { min-width: 0; }
.material-picker-dialog { width: min(930px, calc(100vw - 32px)); max-width: none; height: min(760px, calc(100dvh - 32px)); max-height: calc(100dvh - 32px); padding: 0; overflow: hidden; }
.material-picker-dialog[open] { display: flex; flex-direction: column; }
.material-picker-dialog button { min-height: 38px; padding: 8px 12px; border-radius: 9px; font-size: 13px; border: 1px solid #a884bd; background: #9a72b2; color: #fff; font-weight: 600; }
.material-picker-dialog button:not(:disabled):hover { filter: brightness(.96); }
.material-picker-dialog button:not(:disabled):active { transform: translateY(1px); }
.material-picker-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 22px 8px; flex: 0 0 auto; }
.material-picker-heading h2 { margin: 0; }
.material-picker-dialog .material-picker-recipient { margin: 0; padding: 0 22px 16px; overflow-wrap: anywhere; font-size: 13px; flex: 0 0 auto; }
.material-picker-layout { display: grid; grid-template-columns: minmax(250px, 1fr) minmax(0, 365px); gap: 20px; padding: 18px 22px; border-block: 1px solid #ece6ee; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; flex: 1; }
.material-picker-library, .material-picker-preview { min-width: 0; }
.material-picker-search { display: block; }
.material-picker-search label { display: block; font-size: 13px; margin-bottom: 7px; }
.material-picker-search-controls { display: flex; align-items: center; gap: 7px; }
.material-picker-search input { min-width: 0; width: 100%; flex: 1; border: 1px solid #ddd4e2; border-radius: 9px; padding: 10px; color: #493f4d; background: #fff; }
.material-picker-search-controls button { white-space: nowrap; }
.material-picker-dialog .material-picker-count { min-height: 20px; margin: 10px 0 3px; font-size: 12px; }
.material-picker-dialog .material-picker-error { min-height: 21px; margin: 0 0 9px; color: #b4233e; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.material-picker-list { display: grid; gap: 9px; margin: 12px 0; min-height: 120px; }
.material-picker-dialog .material-picker-item { width: 100%; display: flex; gap: 12px; text-align: left; align-items: center; color: #493f4d; background: #fff; border: 1px solid #e5dce9; min-width: 0; padding: 12px; }
.material-picker-dialog .material-picker-item[aria-pressed=true] { background: #f5effa; border-color: #9474bd; box-shadow: inset 3px 0 #9474bd; }
.material-picker-thumb { width: 56px; height: 56px; flex: 0 0 56px; object-fit: cover; border-radius: 7px; background: #f2f3f5; }
.material-picker-no-image { display: grid; place-items: center; font-size: 12px; color: #776d7b; }
.material-picker-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.material-picker-info strong { overflow-wrap: anywhere; }
.material-picker-meta, .material-picker-excerpt { font-size: 12px; color: #776d7b; font-weight: 400; }
.material-picker-excerpt { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.material-picker-preview { align-self: start; padding: 14px; border-radius: 12px; background: #f2f3f5; }
.material-picker-package-title { font-size: 15px; line-height: 1.6; margin: 0 0 5px; overflow-wrap: anywhere; }
.material-picker-dialog .material-picker-preview > .material-picker-meta { font-size: 12px; margin: 0 0 14px; }
.material-picker-preview > button { margin-top: 14px; }
.material-picker-dialog .material-picker-hint { font-size: 12px; line-height: 1.7; margin: 12px 0 0; }
.material-picker-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 22px; flex: 0 0 auto; }
.material-picker-footer > span { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 12px; color: #776d7b; }
.material-picker-footer .material-picker-send { min-width: 132px; }
@media (max-width: 640px) {
  .material-picker-dialog { width: calc(100vw - 16px); height: calc(100dvh - 16px); max-height: calc(100dvh - 16px); }
  .material-picker-heading { padding: 14px 14px 8px; }
  .material-picker-dialog .material-picker-recipient { padding: 0 14px 12px; }
  .material-picker-layout { grid-template-columns: minmax(0, 1fr); padding: 14px; gap: 14px; }
  .material-picker-preview { width: 100%; max-width: 390px; justify-self: center; }
  .material-picker-footer { flex-wrap: wrap; padding: 10px 14px max(10px, env(safe-area-inset-bottom)); }
  .material-picker-footer > span { flex-basis: 100%; }
  .composer { flex-wrap: wrap; }
  .composer-tools { flex-basis: 100%; min-height: 38px; }
  .composer textarea { flex-basis: 0; }
}
.material-picker-preview .material-card-copy { margin: 0 3px 12px; color: #202124; font-size: 16px; line-height: 1.65; }
.material-picker-preview .material-card-note { margin: 14px 3px 0; color: #767676; font-size: 14px; line-height: 1.7; }
