:root {
  --navy: #061b2c;
  --ink: #0b2638;
  --muted: #647482;
  --line: #dbe4ea;
  --paper: #f4f7f9;
  --white: #ffffff;
  --sky: #1a9cd8;
  --deep-sky: #087bb7;
  --orange: #f58a25;
  --soft-sky: #e7f5fc;
  --soft-orange: #fff2e5;
  --danger: #b62c2c;
  --shadow: 0 20px 50px rgba(7, 29, 44, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
[hidden] { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background: radial-gradient(circle at 17% 16%, rgba(26,156,216,.35), transparent 26rem), radial-gradient(circle at 84% 84%, rgba(245,138,37,.25), transparent 28rem), var(--navy);
}
.login-card {
  width: min(100%, 465px);
  padding: 50px;
  color: var(--white);
  background: rgba(8, 36, 54, .94);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 35px 90px rgba(0,0,0,.35);
  border-radius: 24px;
}
.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  font-weight: 850;
  letter-spacing: -.06em;
  color: var(--navy);
  background: linear-gradient(135deg, #2db6ee 0%, #0c79b6 62%, #f58a25 63%, #ffaf42 100%);
  clip-path: polygon(50% 0, 100% 20%, 78% 100%, 22% 100%, 0 20%);
}
.brand-mark.small { width: 38px; height: 38px; font-size: .78rem; flex: none; }
.eyebrow { margin: 0 0 7px; color: var(--sky); font-size: .67rem; font-weight: 800; letter-spacing: .14em; }
.login-card h1 { margin: 0 0 15px; font-size: clamp(2.35rem, 5vw, 3.15rem); line-height: .94; letter-spacing: -.065em; }
.login-copy { margin: 0 0 28px; color: #c4d3dc; line-height: 1.55; }
.stack-form { display: grid; gap: 10px; }
.stack-form label, .field-label { font-size: .84rem; font-weight: 750; }
.stack-form input, .campaign-text, .confirm-content input {
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid #c4d2da;
  border-radius: 9px;
  color: var(--ink);
  background: var(--white);
  outline: none;
}
.stack-form input:focus, textarea:focus, .confirm-content input:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(26,156,216,.18); }
.legal-note { margin: 24px 0 0; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.14); color: #a6bac6; font-size: .76rem; line-height: 1.45; }

.primary-button, .danger-button, .secondary-button, .send-button {
  min-height: 42px;
  border: 0;
  border-radius: 9px;
  padding: 0 16px;
  font-weight: 780;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.primary-button { color: white; background: linear-gradient(135deg, var(--sky), var(--deep-sky)); box-shadow: 0 8px 18px rgba(8,123,183,.24); }
.primary-button:hover:not(:disabled), .send-button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(8,123,183,.28); }
.secondary-button { color: var(--ink); background: #e8eef2; }
.danger-button { color: white; background: var(--danger); }
.full-width { width: 100%; }
.form-error { min-height: 1.2em; margin: 0; color: #efb2b2; font-size: .82rem; line-height: 1.35; }

.workspace { min-height: 100vh; display: grid; grid-template-columns: 330px minmax(460px, 1fr); background: var(--paper); }
.sidebar { display: flex; flex-direction: column; min-height: 100vh; padding: 25px 17px 16px; border-right: 1px solid var(--line); background: var(--white); }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; }
.sidebar-brand h1 { margin: 0; color: var(--navy); font-size: 1.22rem; letter-spacing: -.045em; }
.sidebar-brand .eyebrow { color: var(--orange); font-size: .58rem; margin-bottom: 2px; }
.campaign-button { width: 100%; margin: 0 0 18px; }
.account-strip { display: grid; gap: 5px; padding: 13px 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.account-row { display: grid; grid-template-columns: 23px 1fr auto; align-items: center; gap: 7px; color: #365164; font-size: .82rem; }
.account-row strong { color: var(--navy); font-size: .78rem; }
.platform-icon { width: 20px; height: 20px; display: grid; place-items: center; color: white; font-size: .85rem; font-weight: 800; border-radius: 6px; }
.platform-icon.instagram { background: linear-gradient(145deg, #9056c7, #dd4476, #fa9a3c); }
.platform-icon.facebook { background: #2376e5; font-family: Arial, sans-serif; }
.conversation-toolbar { padding: 17px 0 12px; display: grid; gap: 9px; }
.search-box { display: flex; align-items: center; gap: 8px; padding: 0 10px; background: #f0f4f7; border-radius: 8px; color: #748592; }
.search-box input { width: 100%; height: 36px; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: .83rem; }
.filter-button { width: max-content; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--white); font-size: .73rem; font-weight: 730; }
.filter-button.active { border-color: #a9dcef; color: #0c6f9f; background: var(--soft-sky); }
.filter-button span { display: inline-grid; place-items: center; min-width: 17px; height: 17px; margin-left: 4px; border-radius: 99px; color: white; background: #0b7dae; font-size: .63rem; }
.conversation-list { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -8px; padding: 0 8px; }
.empty-list { padding: 30px 10px; color: var(--muted); text-align: center; font-size: .85rem; line-height: 1.55; }
.empty-list span { font-size: .74rem; }
.conversation-item { width: 100%; display: grid; grid-template-columns: 28px 1fr 8px; gap: 8px; padding: 12px 8px; border: 0; border-bottom: 1px solid #edf1f4; color: inherit; text-align: left; background: transparent; }
.conversation-item:hover, .conversation-item.selected { background: #edf8fd; border-radius: 9px; }
.conversation-platform { width: 23px; height: 23px; display: grid; place-items: center; margin-top: 2px; border-radius: 7px; color: white; font-size: .78rem; font-weight: 800; }
.conversation-platform.facebook { background: #2376e5; font-family: Arial, sans-serif; }
.conversation-platform.instagram { background: linear-gradient(145deg, #9056c7, #dd4476, #fa9a3c); }
.conversation-content { min-width: 0; }
.conversation-topline { display: flex; justify-content: space-between; gap: 7px; align-items: baseline; }
.conversation-name { overflow: hidden; color: var(--ink); font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.conversation-time { flex: none; color: #80909b; font-size: .64rem; }
.conversation-preview { display: block; overflow: hidden; margin-top: 2px; color: #7b8b96; font-size: .74rem; text-overflow: ellipsis; white-space: nowrap; }
.conversation-window { width: 7px; height: 7px; margin-top: 6px; border-radius: 99px; background: #9aabb6; }
.conversation-item.eligible .conversation-window { background: #32a16e; }
.sidebar-footer { padding: 13px 8px 2px; border-top: 1px solid var(--line); }
.connection-status { display: flex; align-items: center; gap: 7px; margin-bottom: 9px; color: var(--muted); font-size: .72rem; }
.status-dot { width: 7px; height: 7px; border-radius: 99px; background: #db9b2d; }
.connection-status.live .status-dot { background: #27a16c; box-shadow: 0 0 0 3px rgba(39,161,108,.12); }
.connection-status.offline .status-dot { background: #c85a5a; }
.text-button { padding: 0; border: 0; color: #607c8d; background: transparent; font-size: .76rem; font-weight: 700; }

.inbox-main { position: relative; display: grid; grid-template-rows: auto 1fr auto; min-height: 100vh; background: #f6f8fa; }
.thread-header { display: flex; justify-content: space-between; align-items: center; min-height: 92px; padding: 19px 29px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.84); }
.thread-header h2 { margin: 0; color: var(--navy); font-size: 1.2rem; letter-spacing: -.04em; }
.thread-header .eyebrow { margin-bottom: 3px; color: #708391; }
.eligibility-badge { padding: 7px 10px; border-radius: 99px; font-size: .72rem; font-weight: 800; }
.eligibility-badge.eligible { color: #17613f; background: #e5f6ed; }
.eligibility-badge.closed { color: #8c3f32; background: #fceae6; }
.eligibility-badge.neutral { color: #69808e; background: #edf2f5; }
.thread { overflow-y: auto; padding: 30px max(30px, 7vw); }
.empty-thread { display: grid; place-items: center; }
.thread-placeholder { max-width: 390px; color: var(--muted); text-align: center; }
.placeholder-icon { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 16px; border-radius: 17px; color: var(--deep-sky); background: var(--soft-sky); font-size: 1.45rem; }
.thread-placeholder h3 { margin: 0 0 8px; color: var(--navy); font-size: 1.3rem; letter-spacing: -.04em; }
.thread-placeholder p { margin: 0; font-size: .9rem; line-height: 1.6; }
.message-row { display: flex; margin: 10px 0; }
.message-row.business { justify-content: flex-end; }
.message-row.contact { justify-content: flex-start; }
.message-bubble { max-width: min(79%, 620px); padding: 11px 13px 8px; border-radius: 13px; color: #183345; background: var(--white); box-shadow: 0 2px 8px rgba(14,41,59,.05); }
.message-row.business .message-bubble { color: white; background: linear-gradient(135deg, #168fc6, #0877ae); border-bottom-right-radius: 3px; }
.message-row.contact .message-bubble { border-bottom-left-radius: 3px; }
.message-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .91rem; line-height: 1.48; }
.message-time { display: block; margin-top: 5px; color: #7a919f; font-size: .65rem; text-align: right; }
.message-row.business .message-time { color: #c7e9f8; }
.message-media { display: grid; gap: 6px; margin-top: 6px; }
.media-card { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 7px; color: inherit; background: rgba(0,0,0,.06); text-decoration: none; font-size: .75rem; }
.message-row.business .media-card { background: rgba(255,255,255,.16); }
.media-thumbnail { width: 35px; height: 26px; display: grid; place-items: center; border-radius: 5px; color: var(--deep-sky); background: white; font-size: .78rem; }
.composer { padding: 14px 22px 17px; border-top: 1px solid var(--line); background: var(--white); }
.composer.disabled { background: #f9fafb; }
.composer-bar { display: grid; grid-template-columns: auto 1fr auto; align-items: end; gap: 9px; max-width: 1020px; margin: 0 auto; }
.composer textarea { min-height: 42px; max-height: 140px; padding: 10px 11px; resize: vertical; border: 1px solid #d4e0e6; border-radius: 9px; outline: 0; color: var(--ink); background: white; font-size: .89rem; line-height: 1.35; }
.composer textarea:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(26,156,216,.14); }
.attach-button { height: 42px; display: inline-flex; align-items: center; gap: 4px; padding: 0 9px; border: 1px solid #d5e0e7; border-radius: 8px; color: #4b687a; background: #f8fafb; font-size: .75rem; font-weight: 750; cursor: pointer; }
.attach-button input, .upload-zone input { display: none; }
.send-button { color: white; background: var(--deep-sky); }
.composer-note { max-width: 1020px; margin: 7px auto 0; color: #718791; font-size: .68rem; }
.attachment-tray { display: flex; flex-wrap: wrap; gap: 7px; max-width: 1020px; margin: 0 auto 8px; }
.attachment-chip { display: inline-flex; align-items: center; gap: 7px; max-width: 260px; padding: 6px 7px; border: 1px solid #cee2ed; border-radius: 7px; color: #22546d; background: #f1f9fd; font-size: .72rem; }
.attachment-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip button { width: 17px; height: 17px; padding: 0; border: 0; border-radius: 99px; color: #597382; background: #d5e6ee; line-height: 1; }

.campaign-drawer { position: fixed; z-index: 10; top: 0; right: 0; width: min(100%, 420px); height: 100vh; padding: 30px; overflow-y: auto; background: var(--white); box-shadow: -16px 0 50px rgba(6,27,44,.18); }
.drawer-header { display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-header h2 { margin: 0; color: var(--navy); font-size: 1.48rem; letter-spacing: -.055em; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--white); font-size: 1.4rem; line-height: 1; }
.drawer-intro { margin: 17px 0 23px; padding: 12px; border-left: 3px solid var(--orange); color: #536d7d; background: #fff9f2; font-size: .81rem; line-height: 1.5; }
.field-label { display: block; margin: 16px 0 7px; color: #385366; }
.campaign-text { width: 100%; min-height: 124px; resize: vertical; }
.text-counter { margin-top: 4px; color: #82939d; text-align: right; font-size: .68rem; }
.upload-zone { display: grid; place-items: center; min-height: 115px; padding: 15px; border: 1px dashed #99c5db; border-radius: 10px; color: #4c7185; text-align: center; background: #f7fcff; cursor: pointer; }
.upload-zone strong { margin-top: 3px; font-size: .84rem; }
.upload-zone small { margin-top: 3px; font-size: .7rem; }
.upload-icon { font-size: 1.5rem; font-weight: 400; }
.campaign-attachments { margin: 10px 0 0; }
.recipient-summary { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 0 7px; padding-top: 16px; border-top: 1px solid var(--line); color: #567080; font-size: .77rem; }
.recipient-summary strong { color: var(--navy); font-size: .82rem; }
.campaign-warning { margin: 0 0 14px; color: #8a6740; font-size: .72rem; line-height: 1.45; }

.confirm-dialog { width: min(100% - 30px, 410px); border: 0; border-radius: 17px; box-shadow: var(--shadow); }
.confirm-dialog::backdrop { background: rgba(6,27,44,.56); }
.confirm-content { padding: 10px; }
.confirm-content h2 { margin: 0 0 10px; font-size: 1.55rem; letter-spacing: -.055em; }
.confirm-content p { color: #587080; font-size: .86rem; line-height: 1.5; }
.confirm-content label { display: block; margin: 16px 0 7px; font-size: .78rem; font-weight: 750; }
.confirm-content input { width: 100%; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

@media (max-width: 830px) {
  .workspace { grid-template-columns: 270px minmax(0, 1fr); }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  .thread { padding: 24px; }
}
@media (max-width: 650px) {
  .workspace { display: block; }
  .sidebar { min-height: auto; max-height: 43vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-brand { padding-bottom: 14px; }
  .account-strip, .conversation-toolbar { display: none; }
  .conversation-list { flex: none; max-height: 175px; }
  .inbox-main { min-height: 57vh; }
  .thread-header { min-height: 76px; padding: 14px 17px; }
  .thread { padding: 20px 16px; }
  .composer { padding: 11px; }
  .composer-bar { grid-template-columns: auto 1fr; }
  .send-button { grid-column: 2; }
  .attach-button span:last-child { display: none; }
  .campaign-drawer { padding: 22px; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.quick-reply-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  width: min(100% - 32px, 390px);
  padding: 17px;
  border: 1px solid #c8dbe5;
  border-radius: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 20px 55px rgba(6, 27, 44, .24);
  animation: quick-reply-in .2s ease-out;
}
.quick-reply-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.quick-reply-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.quick-reply-title .eyebrow { margin-bottom: 3px; color: var(--orange); }
.quick-reply-title h2 { margin: 0; overflow: hidden; color: var(--navy); font-size: 1rem; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.quick-reply-platform {
  width: 30px;
  height: 30px;
  display: grid;
  flex: none;
  place-items: center;
  border-radius: 9px;
  color: var(--white);
  font-weight: 850;
}
.quick-reply-platform.instagram { background: linear-gradient(145deg, #9056c7, #dd4476, #fa9a3c); }
.quick-reply-platform.facebook { background: #2376e5; font-family: Arial, sans-serif; }
.quick-reply-preview {
  display: -webkit-box;
  margin: 14px 0;
  overflow: hidden;
  color: #405c6e;
  font-size: .88rem;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.quick-reply-compose { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.quick-reply-compose input {
  min-width: 0;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #c4d2da;
  border-radius: 9px;
  outline: none;
}
.quick-reply-compose input:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(26,156,216,.18); }
.quick-reply-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 11px; }
.quick-reply-footer span { color: #6a7f8d; font-size: .7rem; line-height: 1.3; }
.quick-reply-footer .text-button { padding: 0; color: var(--deep-sky); font-size: .76rem; font-weight: 780; }
@keyframes quick-reply-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 650px) {
  .quick-reply-toast { right: 16px; bottom: 16px; width: calc(100% - 32px); }
}

/* Official multichannel connection panel */
.channel-panel {
  margin-top: 14px;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: linear-gradient(145deg, #fbfdfe, #f2f7fa);
}
.channel-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.channel-panel-header .eyebrow { margin-bottom: 2px; color: #708391; font-size: .55rem; }
.channel-panel-header h2 { margin: 0; color: var(--navy); font-size: .79rem; letter-spacing: -.02em; }
.channel-policy { padding: 4px 6px; border-radius: 99px; color: #1a6e51; background: #e4f5eb; font-size: .58rem; font-weight: 800; white-space: nowrap; }
.channel-list { display: grid; gap: 6px; }
.channel-loading { margin: 2px 0; color: var(--muted); font-size: .7rem; }
.channel-row { padding: 7px 8px; border: 1px solid #e4edf1; border-radius: 8px; background: var(--white); }
.channel-row-top { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 6px; }
.channel-row strong { overflow: hidden; color: var(--ink); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.channel-row p { margin: 4px 0 0 26px; color: #6e818e; font-size: .63rem; line-height: 1.35; }
.channel-status { padding: 3px 5px; border-radius: 99px; font-size: .55rem; font-weight: 800; white-space: nowrap; }
.channel-status.connected { color: #17613f; background: #e5f6ed; }
.channel-status.pending { color: #8f6116; background: #fff2d8; }
.channel-status.authorization_required { color: #8d5920; background: #fff0dc; }
.channel-status.partner_required { color: #685292; background: #f0ebfb; }
.platform-icon.x { background: #101820; font-family: Arial, sans-serif; }
.platform-icon.youtube { background: #e12626; }
.platform-icon.linkedin { background: #0a66c2; font-family: Arial, sans-serif; font-size: .7rem; }
.conversation-platform.x { background: #101820; }
.conversation-platform.youtube { background: #e12626; }
.conversation-platform.linkedin { background: #0a66c2; font-family: Arial, sans-serif; font-size: .68rem; }
@media (max-height: 850px) {
  .channel-row p { display: none; }
  .channel-panel { padding-block: 9px; }
}
