:root {
  color-scheme: light;
  --navy-950: #061a32;
  --navy-900: #0b2a52;
  --navy-800: #123d70;
  --blue-700: #1657a5;
  --blue-600: #1f6dcc;
  --blue-100: #e9f2ff;
  --red-600: #d62839;
  --green-700: #147a55;
  --green-100: #e2f6ed;
  --amber-700: #9a5b00;
  --amber-100: #fff1d1;
  --gray-950: #172033;
  --gray-800: #303b50;
  --gray-700: #4b586e;
  --gray-600: #667085;
  --gray-500: #8390a5;
  --gray-400: #aab3c2;
  --gray-300: #d2d8e1;
  --gray-200: #e5e9ef;
  --gray-100: #f3f5f8;
  --gray-50: #f8fafc;
  --white: #fff;
  --shadow: 0 14px 44px rgba(10, 35, 67, .12);
  --focus: 0 0 0 3px rgba(31, 109, 204, .23);
  --radius: 12px;
  --sidebar-width: 248px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; color: var(--gray-950); background: var(--gray-100); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; line-height: 1.45; }
button, input, textarea, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:disabled, input:disabled, textarea:disabled, select:disabled { cursor: not-allowed; opacity: .55; }
a { color: var(--blue-700); }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); }

.eyebrow { margin: 0 0 4px; color: var(--blue-700); font-size: .75rem; font-weight: 800; letter-spacing: .11em; }
.brand-mark { position: relative; display: inline-grid; width: 42px; height: 42px; place-items: center; flex: 0 0 auto; overflow: hidden; border: 2px solid rgba(255,255,255,.86); border-radius: 12px 12px 16px 8px; color: var(--white); background: linear-gradient(145deg, #1f6dcc 0 53%, #d62839 54%); box-shadow: 0 8px 18px rgba(0,0,0,.18); font-size: 1.15rem; font-style: italic; font-weight: 900; }
.brand-mark::after { position: absolute; right: -9px; bottom: 7px; width: 31px; height: 4px; content: ""; background: #fff; transform: rotate(-24deg); opacity: .9; }
.brand-mark > span { position: relative; z-index: 1; }
.brand-mark--large { width: 84px; height: 84px; border-radius: 22px 22px 30px 15px; font-size: 2.4rem; }

.button { min-height: 42px; padding: 9px 16px; border: 1px solid transparent; border-radius: 9px; font-weight: 750; transition: background .16s, border .16s, transform .12s; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button--primary { color: var(--white); background: var(--blue-700); box-shadow: 0 7px 16px rgba(22, 87, 165, .2); }
.button--primary:hover { background: var(--navy-800); }
.button--secondary { border-color: #b9cbe3; color: var(--navy-800); background: var(--white); }
.button--secondary:hover { background: var(--blue-100); }
.button--ghost { border-color: var(--gray-300); background: var(--gray-50); }
.button--wide { width: 100%; min-height: 48px; }
.icon-button { display: inline-grid; width: 40px; height: 40px; padding: 0; place-items: center; border: 0; border-radius: 9px; color: var(--gray-700); background: transparent; }
.icon-button:hover { color: var(--navy-900); background: var(--gray-100); }
.icon-button svg, [data-icon] svg { display: block; width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-button--light { color: #dce8f6; }
.icon-button--light:hover { color: #fff; background: rgba(255,255,255,.1); }
.text-button { padding: 4px 7px; border: 0; color: var(--blue-700); background: transparent; font-size: .875rem; font-weight: 750; }
.text-button:hover { text-decoration: underline; }

.login-view { min-height: 100%; display: grid; grid-template-columns: minmax(320px, .85fr) minmax(480px, 1.15fr); background: var(--white); }
.login-brand { display: grid; place-content: center; justify-items: center; color: #fff; background: radial-gradient(circle at 15% 20%, rgba(36,119,214,.45), transparent 32%), radial-gradient(circle at 88% 80%, rgba(214,40,57,.28), transparent 32%), linear-gradient(155deg, var(--navy-950), var(--navy-800)); }
.login-brand p { margin: 20px 0 0; font-size: 2.25rem; font-style: italic; font-weight: 950; letter-spacing: -.04em; }
.login-brand small { margin-top: -5px; color: #b8cee8; font-size: .72rem; font-weight: 800; letter-spacing: .28em; }
.login-card { width: min(420px, calc(100% - 48px)); align-self: center; justify-self: center; }
.login-card h1 { margin: 0; color: var(--navy-950); font-size: clamp(1.8rem, 3vw, 2.4rem); letter-spacing: -.035em; }
.login-copy { margin: 10px 0 30px; color: var(--gray-600); }
.login-card label, .modal-card label, .details-section > label { display: block; margin: 17px 0 7px; color: var(--gray-800); font-size: .875rem; font-weight: 750; }
.login-card input, .modal-card input, .modal-card select, .details-section select { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--gray-300); border-radius: 9px; background: var(--white); }
.login-card input:focus, .modal-card input:focus, .modal-card select:focus, .details-section select:focus { border-color: var(--blue-600); outline: 0; box-shadow: var(--focus); }
.password-field { position: relative; }
.password-field input { padding-right: 48px; }
.password-field .icon-button { position: absolute; top: 3px; right: 3px; }
.form-error { margin: 12px 0 0; padding: 9px 11px; border-left: 3px solid var(--red-600); color: #991b2a; background: #fff0f2; font-size: .875rem; }
.legal-links { display: flex; justify-content: center; gap: 9px; margin: 20px 0 0; color: var(--gray-500); font-size: .8rem; }
.legal-links a { color: var(--gray-600); text-decoration: none; }
.mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 28px; color: var(--navy-900); }

.app-shell { min-height: 100%; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar { position: relative; z-index: 30; min-height: 100vh; display: flex; flex-direction: column; padding: 22px 14px 15px; color: #fff; background: linear-gradient(180deg, var(--navy-950), #092545 62%, #0d325c); }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 25px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1; }
.brand-copy strong { font-size: 1.16rem; font-style: italic; letter-spacing: -.02em; }
.brand-copy small { margin-top: 5px; color: #a9c1dc; font-size: .55rem; font-weight: 800; letter-spacing: .18em; }
.main-nav { display: grid; gap: 6px; }
.nav-item { position: relative; min-height: 47px; display: grid; grid-template-columns: 25px 1fr auto; align-items: center; gap: 11px; padding: 8px 12px; border: 0; border-radius: 10px; color: #c7d8eb; background: transparent; text-align: left; font-size: .93rem; font-weight: 700; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-item.is-active { color: #fff; background: rgba(67,145,232,.2); box-shadow: inset 3px 0 0 #57a4fb; }
.nav-item b { min-width: 21px; padding: 2px 5px; border-radius: 10px; color: #fff; background: var(--red-600); font-size: .7rem; text-align: center; }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 4px; padding: 12px 3px 0; border-top: 1px solid rgba(255,255,255,.1); }
.account-button { min-width: 0; display: flex; flex: 1; align-items: center; gap: 9px; padding: 6px; border: 0; border-radius: 9px; color: #fff; background: transparent; text-align: left; }
.account-button:hover { background: rgba(255,255,255,.07); }
.account-button > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.account-button strong { overflow: hidden; font-size: .85rem; text-overflow: ellipsis; white-space: nowrap; }
.account-button small { color: #adc3dc; font-size: .7rem; }
.avatar { width: 36px; height: 36px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: #fff; background: linear-gradient(145deg, var(--blue-600), var(--navy-900)); font-size: .74rem; font-weight: 850; }
.avatar--contact { color: var(--navy-800); background: var(--blue-100); }
.avatar--large { width: 68px; height: 68px; font-size: 1.2rem; }

.main-area { min-width: 0; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.topbar { min-height: 74px; display: flex; align-items: center; gap: 15px; padding: 11px 22px; border-bottom: 1px solid var(--gray-200); background: var(--white); }
.topbar h1 { margin: 0; color: var(--navy-950); font-size: 1.35rem; letter-spacing: -.02em; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.status-pill { min-height: 30px; display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 15px; color: var(--green-700); background: var(--green-100); font-size: .78rem; font-weight: 750; white-space: nowrap; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill--muted { color: var(--gray-600); background: var(--gray-100); }
.status-pill--warning { color: var(--amber-700); background: var(--amber-100); }
.status-pill--danger { color: #aa2332; background: #ffe8eb; }
.topbar-menu { display: none; }

.workspace { min-height: 0; display: grid; flex: 1; grid-template-columns: 355px minmax(390px, 1fr); background: var(--gray-100); }
.workspace.has-details { grid-template-columns: 340px minmax(390px, 1fr) 310px; }
.conversation-panel, .thread-panel, .details-panel, .empty-thread { min-height: 0; background: var(--white); }
.conversation-panel { display: flex; flex-direction: column; border-right: 1px solid var(--gray-200); }
.panel-tools { padding: 16px 15px 12px; border-bottom: 1px solid var(--gray-200); }
.panel-title { display: flex; align-items: center; justify-content: space-between; margin: -3px 0 10px; }
.panel-title strong { color: var(--navy-900); font-size: .9rem; }
.search-box { min-height: 42px; display: flex; align-items: center; gap: 9px; padding: 0 11px; border: 1px solid var(--gray-300); border-radius: 10px; color: var(--gray-500); background: var(--gray-50); }
.search-box:focus-within { border-color: var(--blue-600); box-shadow: var(--focus); }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; font-size: .9rem; }
.filter-row { display: flex; gap: 6px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.filter-chip { min-height: 32px; padding: 5px 10px; border: 1px solid var(--gray-300); border-radius: 16px; color: var(--gray-600); background: #fff; font-size: .78rem; font-weight: 720; white-space: nowrap; }
.filter-chip.is-active { border-color: #b4d0f1; color: var(--blue-700); background: var(--blue-100); }
.queue-summary { display: flex; justify-content: space-between; margin-top: 12px; color: var(--gray-600); font-size: .72rem; }
.queue-summary strong { color: var(--gray-950); }
.conversation-list { min-height: 0; flex: 1; overflow-y: auto; }
.conversation-item { width: 100%; display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 10px; padding: 13px 14px; border: 0; border-bottom: 1px solid var(--gray-100); background: #fff; text-align: left; }
.conversation-item:hover { background: #f8fbff; }
.conversation-item.is-active { background: var(--blue-100); box-shadow: inset 3px 0 0 var(--blue-600); }
.conversation-content { min-width: 0; }
.conversation-line { min-width: 0; display: flex; align-items: center; gap: 6px; }
.conversation-line strong { overflow: hidden; flex: 1; color: var(--gray-950); font-size: .9rem; text-overflow: ellipsis; white-space: nowrap; }
.conversation-line time { color: var(--gray-500); font-size: .68rem; }
.conversation-preview { margin: 4px 0 0; overflow: hidden; color: var(--gray-600); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.conversation-meta { display: flex; align-items: center; gap: 5px; margin-top: 6px; }
.mini-tag { max-width: 85px; padding: 2px 6px; overflow: hidden; border-radius: 9px; color: var(--gray-800); background: var(--gray-100); font-size: .63rem; text-overflow: ellipsis; white-space: nowrap; }
.unread-badge { min-width: 20px; height: 20px; display: grid; place-items: center; align-self: center; padding: 0 5px; border-radius: 10px; color: #fff; background: var(--blue-600); font-size: .66rem; font-weight: 850; }
.priority-bar { width: 3px; height: 23px; align-self: center; border-radius: 3px; background: transparent; }
.priority-bar.high { background: #e09b24; }
.priority-bar.urgent { background: var(--red-600); }
.load-more { margin: 7px auto; }
.list-state { padding: 42px 24px; color: var(--gray-600); text-align: center; font-size: .875rem; }
.skeleton-row { height: 72px; margin: 1px 12px; background: linear-gradient(90deg, #f4f6f8 20%, #e9edf2 40%, #f4f6f8 60%); background-size: 300% 100%; animation: shimmer 1.5s infinite; }
@keyframes shimmer { to { background-position: -100% 0; } }

.empty-thread { display: grid; place-content: center; justify-items: center; padding: 35px; text-align: center; }
.empty-symbol { width: 62px; height: 62px; display: grid; place-items: center; border-radius: 18px; color: var(--blue-700); background: var(--blue-100); transform: rotate(-4deg); }
.empty-symbol svg { width: 29px; height: 29px; }
.empty-thread h2 { margin: 18px 0 5px; color: var(--navy-900); font-size: 1.15rem; }
.empty-thread p { max-width: 340px; margin: 0; color: var(--gray-600); font-size: .88rem; }
.thread-panel { display: flex; flex-direction: column; }
.thread-header { min-height: 68px; display: flex; align-items: center; gap: 10px; padding: 10px 15px; border-bottom: 1px solid var(--gray-200); }
.thread-person { min-width: 0; display: flex; flex-direction: column; }
.thread-person strong { overflow: hidden; font-size: .93rem; text-overflow: ellipsis; white-space: nowrap; }
.thread-person span { color: var(--gray-600); font-size: .74rem; }
.thread-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.thread-actions select { min-height: 37px; padding: 6px 28px 6px 10px; border: 1px solid var(--gray-300); border-radius: 8px; background: #fff; font-size: .78rem; font-weight: 700; }
.message-list { min-height: 0; display: flex; flex: 1; flex-direction: column; gap: 8px; padding: 20px max(18px, 5%); overflow-y: auto; background-color: #edf2f7; background-image: radial-gradient(circle at 1px 1px, rgba(14,56,99,.055) 1px, transparent 0); background-size: 22px 22px; scroll-behavior: smooth; }
.message-row { max-width: min(76%, 620px); display: flex; flex-direction: column; align-self: flex-start; }
.message-row.outbound { align-self: flex-end; }
.message-bubble { position: relative; min-width: 95px; padding: 9px 11px 7px; border: 1px solid #dce3eb; border-radius: 5px 13px 13px 13px; background: #fff; box-shadow: 0 2px 5px rgba(17, 36, 61, .06); overflow-wrap: anywhere; }
.message-row.outbound .message-bubble { border-color: #cbdff5; border-radius: 13px 5px 13px 13px; background: #dfeeff; }
.message-bubble p { margin: 0; white-space: pre-wrap; }
.message-media { display: block; max-width: min(380px, 100%); max-height: 360px; margin-bottom: 7px; border-radius: 8px; background: #d2dae5; object-fit: contain; }
.message-bubble audio { width: min(315px, 100%); height: 42px; }
.document-link { display: flex; align-items: center; gap: 9px; padding: 9px; border-radius: 8px; color: var(--navy-800); background: rgba(255,255,255,.67); text-decoration: none; }
.message-meta { display: flex; justify-content: flex-end; gap: 5px; margin-top: 4px; color: var(--gray-500); font-size: .64rem; }
.message-meta .failed { color: var(--red-600); font-weight: 700; }
.source-label { margin: 2px 6px; color: var(--gray-500); font-size: .62rem; }
.older-wrap { position: absolute; z-index: 2; align-self: center; margin-top: 73px; }
.older-wrap .text-button { border-radius: 14px; background: rgba(255,255,255,.92); box-shadow: 0 3px 9px rgba(0,0,0,.1); }
.window-notice { display: flex; align-items: center; gap: 8px; padding: 8px 15px; color: var(--amber-700); background: var(--amber-100); font-size: .75rem; }
.window-notice > span:nth-child(2) { flex: 1; }
.window-notice button { padding: 4px 7px; border: 0; color: inherit; background: transparent; font-weight: 800; text-decoration: underline; }
.composer { min-height: 66px; display: flex; align-items: flex-end; gap: 7px; padding: 10px 13px; border-top: 1px solid var(--gray-200); background: #fff; }
.composer-input { min-height: 44px; display: flex; flex: 1; align-items: center; padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: 13px; background: var(--gray-50); }
.composer-input:focus-within { border-color: var(--blue-600); box-shadow: var(--focus); }
.composer textarea { width: 100%; max-height: 126px; resize: none; border: 0; outline: 0; background: transparent; line-height: 1.4; }
.send-button { width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 auto; border: 0; border-radius: 13px; color: #fff; background: var(--blue-700); }
.send-button:hover { background: var(--navy-800); }
.upload-progress { position: absolute; right: 20px; bottom: 72px; min-width: 190px; display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.upload-progress span { width: 17px; height: 17px; border: 2px solid var(--gray-300); border-top-color: var(--blue-600); border-radius: 50%; animation: spin .8s linear infinite; }
.upload-progress p { margin: 0; font-size: .78rem; }
@keyframes spin { to { transform: rotate(360deg); } }

.details-panel { border-left: 1px solid var(--gray-200); overflow-y: auto; }
.details-heading { min-height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 12px 15px; border-bottom: 1px solid var(--gray-200); }
.details-heading h2 { margin: 0; font-size: 1rem; }
.contact-card { display: grid; justify-items: center; padding: 24px 15px 20px; border-bottom: 1px solid var(--gray-200); }
.contact-card h3 { max-width: 100%; margin: 12px 0 2px; overflow: hidden; font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.contact-card p { margin: 0; color: var(--gray-600); font-size: .78rem; }
.details-section { padding: 15px; border-bottom: 1px solid var(--gray-200); }
.details-section h3 { margin: 0; font-size: .86rem; }
.details-section > label:first-child { margin-top: 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border: 1px solid var(--gray-200); border-radius: 12px; background: var(--gray-50); font-size: .72rem; }
.tag i { width: 7px; height: 7px; border-radius: 50%; background: var(--tag-color, var(--blue-600)); }
.tag button { padding: 0; border: 0; color: var(--gray-500); background: transparent; }
.notes-section textarea { width: 100%; margin-top: 10px; padding: 9px 10px; resize: vertical; border: 1px solid var(--gray-300); border-radius: 8px; }
.notes-section .button { width: 100%; margin-top: 7px; }
.note-list { display: grid; gap: 8px; margin-top: 13px; }
.note { padding: 9px; border-left: 3px solid var(--blue-600); border-radius: 4px 8px 8px 4px; background: var(--gray-50); }
.note p { margin: 0; white-space: pre-wrap; font-size: .76rem; }
.note small { display: block; margin-top: 5px; color: var(--gray-500); font-size: .63rem; }

.settings-view { min-height: 0; flex: 1; padding: 26px; overflow-y: auto; }
.settings-header h2 { margin: 0; color: var(--navy-950); font-size: 1.5rem; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(280px, 1fr)); gap: 17px; margin-top: 20px; }
.settings-card { min-width: 0; padding: 20px; border: 1px solid var(--gray-200); border-radius: var(--radius); background: #fff; box-shadow: 0 4px 14px rgba(11,42,82,.035); }
.settings-card--wide { grid-column: 1 / -1; }
.settings-card-title { display: flex; align-items: center; gap: 12px; }
.settings-card-title > div { min-width: 0; flex: 1; }
.settings-card-title h3 { margin: 0; color: var(--navy-900); font-size: 1rem; }
.settings-card-title p { margin: 3px 0 0; color: var(--gray-600); font-size: .78rem; }
.settings-icon { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 10px; color: var(--blue-700); background: var(--blue-100); }
.setup-checklist { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; }
.setup-checklist > div { min-width: 0; display: grid; grid-template-columns: 30px minmax(0,1fr) 14px; align-items: center; gap: 8px; padding: 12px; border: 1px solid var(--gray-200); border-radius: 9px; }
.setup-checklist b { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: var(--gray-600); background: var(--gray-100); font-size: .75rem; }
.setup-checklist span { min-width: 0; display: flex; flex-direction: column; }
.setup-checklist strong { font-size: .78rem; }
.setup-checklist small { overflow: hidden; color: var(--gray-500); font-size: .67rem; text-overflow: ellipsis; white-space: nowrap; }
.setup-checklist i { width: 10px; height: 10px; border: 2px solid var(--gray-300); border-radius: 50%; }
.setup-checklist .is-done i { border-color: var(--green-700); background: var(--green-700); box-shadow: inset 0 0 0 2px #fff; }
.setup-checklist .is-done b { color: var(--green-700); background: var(--green-100); }
.settings-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.inline-message { min-height: 19px; margin: 11px 0 0; color: var(--gray-600); font-size: .78rem; }
.inline-message.is-error { color: var(--red-600); }
.channel-details { display: grid; grid-template-columns: repeat(3, minmax(150px,1fr)); gap: 10px; margin-top: 17px; }
.channel-details div { padding: 10px; border-radius: 8px; background: var(--gray-50); }
.channel-details small { display: block; color: var(--gray-500); font-size: .68rem; }
.channel-details strong { display: block; margin-top: 2px; overflow: hidden; font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.user-list { display: grid; gap: 2px; margin: 16px 0; }
.user-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--gray-100); }
.user-row > span:nth-child(2) { min-width: 0; display: flex; flex-direction: column; }
.user-row strong { overflow: hidden; font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.user-row small { color: var(--gray-500); font-size: .68rem; }
.role-badge { padding: 3px 6px; border-radius: 9px; color: var(--gray-700); background: var(--gray-100); font-size: .64rem; font-weight: 700; }
.legal-menu { display: grid; margin-top: 14px; }
.legal-menu a { display: flex; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--gray-100); color: var(--gray-800); font-size: .8rem; text-decoration: none; }
.legal-menu a:hover { color: var(--blue-700); }

.modal { width: min(500px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 14px; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(5,19,37,.58); backdrop-filter: blur(2px); }
.modal-card { padding: 21px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-header h2 { margin: 0; color: var(--navy-950); font-size: 1.25rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 21px; }
.template-preview { min-height: 70px; padding: 12px; border-radius: 8px; color: var(--gray-700); background: var(--gray-100); font-size: .82rem; white-space: pre-wrap; }
.field-help { margin: 5px 0 0; color: var(--gray-500); font-size: .72rem; }
.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 250px; max-width: 390px; padding: 11px 14px; border-left: 4px solid var(--blue-600); border-radius: 7px; color: var(--gray-950); background: #fff; box-shadow: var(--shadow); font-size: .82rem; animation: toast-in .2s ease-out; }
.toast.error { border-left-color: var(--red-600); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.mobile-only { display: none; }

@media (max-width: 1180px) {
  :root { --sidebar-width: 76px; }
  .sidebar { padding-inline: 10px; }
  .sidebar-brand { justify-content: center; padding-inline: 0; }
  .brand-copy, .nav-item > span:last-of-type, .account-button > span:last-child { display: none; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; padding-inline: 7px; }
  .nav-item b { position: absolute; top: 3px; right: 3px; }
  .sidebar-footer { flex-direction: column; }
  .account-button { flex: initial; }
  .workspace.has-details { grid-template-columns: 325px minmax(380px, 1fr) 290px; }
}

@media (max-width: 940px) {
  .workspace { grid-template-columns: 320px minmax(360px, 1fr); }
  .workspace.has-details { grid-template-columns: 320px minmax(360px, 1fr); }
  .details-panel { position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: min(340px, 92vw); box-shadow: -12px 0 35px rgba(9,32,58,.18); }
  .setup-checklist { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .login-view { display: grid; grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .mobile-brand { display: flex; }
  .app-shell { display: block; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: 248px; min-height: 100%; transform: translateX(-102%); transition: transform .18s ease; box-shadow: 12px 0 32px rgba(0,0,0,.22); }
  .sidebar.is-open { transform: translateX(0); }
  .brand-copy, .nav-item > span:last-of-type, .account-button > span:last-child { display: flex; }
  .nav-item { grid-template-columns: 25px 1fr auto; justify-items: initial; padding-inline: 12px; }
  .sidebar-footer { flex-direction: row; }
  .account-button { flex: 1; }
  .topbar { min-height: 66px; padding-inline: 11px; }
  .topbar-menu { display: inline-grid; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { font-size: 1.12rem; }
  .status-pill { max-width: 145px; overflow: hidden; text-overflow: ellipsis; }
  .workspace, .workspace.has-details { display: block; }
  .conversation-panel, .thread-panel, .empty-thread { height: calc(100vh - 66px); }
  .thread-panel, .empty-thread { display: none; }
  .workspace.thread-open .conversation-panel { display: none; }
  .workspace.thread-open .thread-panel:not([hidden]) { display: flex; }
  .workspace.thread-open .empty-thread { display: none; }
  .mobile-only { display: inline-grid; }
  .message-row { max-width: 87%; }
  .settings-view { padding: 16px 12px; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-card--wide { grid-column: auto; }
  .channel-details { grid-template-columns: 1fr; }
}

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