:root {
  color-scheme: light;
  --forest: #123c35;
  --green: #246956;
  --deep: #192e28;
  --muted: #5b6e63;
  --line: #dfe6df;
  --paper: #fff;
  --tint: #e7f1ea;
  --canvas: #f4f5ef;
  --clay: #a1442c;
  background: var(--paper);
  color: var(--deep);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 2px solid #357b67; outline-offset: 3px; }
h1, h2, p { margin: 0; }

.workspace { height: 100dvh; display: grid; grid-template-columns: 72px 340px minmax(0,1fr) auto; overflow: hidden; }
.rail { background: var(--forest); color: #eaf6ec; display: flex; flex-direction: column; align-items: center; padding: 24px 0 18px; gap: 28px; }
.identity-mark { display: block; width: 42px; height: 42px; flex: 0 0 auto; }
.rail-actions, .rail-end { display: grid; justify-items: center; gap: 13px; }
.rail-end { margin-top: auto; }
.rail-button { display: grid; place-items: center; font-size: 22px; height: 44px; width: 44px; border: 0; border-radius: 13px; background: transparent; color: inherit; }
.rail-button:hover, .rail-selected { background: #286054; }
.rail-button:focus-visible { outline-color: #eaf6ec; }
.agent-avatar { display: grid; place-items: center; background: #edcdb1; color: #493b29; border-radius: 50%; width: 37px; height: 37px; font-size: .78rem; font-weight: 750; }

.icon { display: inline-block; position: relative; color: inherit; vertical-align: middle; flex: 0 0 auto; }
.icon-chat { width: 20px; height: 16px; border: 1.65px solid; border-radius: 5px; }
.icon-chat::after { content: ""; width: 6px; height: 6px; position: absolute; bottom: -5px; left: 3px; border-left: 1.65px solid; border-bottom: 1.65px solid; transform: skewY(-30deg); background: inherit; }
.icon-search { width: 14px; height: 14px; border: 1.6px solid; border-radius: 50%; margin-right: 4px; color: var(--muted); }
.icon-search::after { content: ""; width: 6px; height: 1.5px; background: currentColor; position: absolute; top: 10px; left: 10px; transform: rotate(45deg); transform-origin: left; }
.icon-bell { width: 16px; height: 16px; border: 1.6px solid; border-radius: 8px 8px 4px 4px; }
.icon-bell::after { content: ""; width: 4px; height: 2px; position: absolute; bottom: -5px; left: 4.5px; border-radius: 0 0 3px 3px; background: currentColor; }
.icon-info { border-radius: 50%; border: 1.4px solid; display: grid; place-items: center; width: 17px; height: 17px; font: bold 12px Georgia, serif; }

.list-panel { display: grid; grid-template-rows: auto minmax(0,1fr) auto; border-right: 1px solid var(--line); min-width: 0; }
.list-header { padding: 25px 20px 16px; border-bottom: 1px solid var(--line); }
.workspace-name { font-size: .78rem; color: var(--green); font-weight: 740; margin-bottom: 8px; }
.list-header h1 { font-size: 2.1rem; font-weight: 740; letter-spacing: -.9px; display: flex; align-items: center; gap: 10px; }
.inbox-count { font: 700 .82rem/1 system-ui; background: var(--tint); color: var(--forest); padding: 6px 8px; border-radius: 99px; letter-spacing: 0; }
.search { display: flex; padding: 0 12px; align-items: center; gap: 7px; background: #f3f6f2; border: 1px solid #e6ebe4; border-radius: 10px; margin: 18px 0 13px; }
.search input { min-width: 0; width: 100%; border: 0; color: var(--deep); background: transparent; height: 40px; outline: none; }
.search:focus-within { border-color: #679985; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { background: var(--paper); border: 1px solid var(--line); border-radius: 99px; padding: 7px 10px; font-size: .77rem; font-weight: 650; color: var(--muted); white-space: nowrap; }
.filters button:hover, .filters .selected { color: var(--forest); background: var(--tint); border-color: var(--tint); }
.chat-list { overflow: auto; padding: 7px 9px; }
.chat-row { text-align: left; display: grid; grid-template-columns: 43px minmax(0,1fr) auto; align-items: center; gap: 11px; width: 100%; min-height: 75px; border: 0; border-bottom: 1px solid #f0f1ed; background: transparent; color: inherit; border-radius: 9px; padding: 10px 9px; }
.chat-row:hover { background: #f5f7f3; }
.chat-row.current { background: #e8f0e9; border-color: transparent; }
.avatar { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 50%; font-size: .84rem; font-weight: 750; background: #d8e9df; color: #285c4a; flex: 0 0 auto; }
.avatar[data-tone="1"] { background: #f5e2cf; color: #7f4b29; }
.avatar[data-tone="2"] { background: #e7e3f3; color: #5c4b7b; }
.avatar[data-tone="3"] { background: #e2edf0; color: #285a67; }
.row-copy, .row-meta { display: grid; gap: 5px; align-content: center; min-width: 0; }
.row-name, .row-preview { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-name { font-weight: 730; }
.row-preview { font-size: .79rem; color: var(--muted); }
.row-meta { justify-items: end; color: var(--muted); font-size: .71rem; }
.unread-badge { background: var(--green); color: white; padding: 2px 6px; border-radius: 99px; font-weight: 730; min-width: 18px; text-align: center; }
.priority { border-radius: 99px; font-weight: 720; font-size: .71rem; padding: 3px 7px; background: #eef1ec; color: var(--muted); width: fit-content; white-space: nowrap; }
.priority.hot { background: #f7e5dc; color: #943e28; }
.priority.warm { background: #f7edd6; color: #775518; }
.priority.cold { background: #e6edf3; color: #365b74; }
.list-footer { border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; padding: 14px 18px; font-size: .75rem; color: var(--muted); }
.connected-dot { width: 7px; height: 7px; border-radius: 50%; background: #4e9877; }
.list-footer.offline .connected-dot { background: #c0755c; }
.list-empty { color: var(--muted); text-align: center; padding: 30px 8px; font-size: .88rem; }
.load-button { display: block; margin: 12px auto; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--green); }

.chat-panel { display: grid; grid-template-rows: auto minmax(0,1fr) auto; min-width: 0; min-height: 0; background-color: var(--canvas); background-image: radial-gradient(#dde4d8 0.8px, transparent 0.8px); background-size: 18px 18px; }
.chat-empty { grid-row: 1 / -1; display: grid; justify-items: center; align-content: center; padding: 25px; text-align: center; gap: 9px; }
.chat-empty h2 { font-size: 1.55rem; font-weight: 700; }
.chat-empty p { color: var(--muted); }
.empty-mark { display: grid; place-items: center; width: 63px; height: 63px; border-radius: 20px; color: var(--green); background: #dae9df; margin-bottom: 10px; }
.chat-header { display: flex; height: 82px; background: var(--paper); align-items: center; gap: 12px; padding: 0 22px; border-bottom: 1px solid var(--line); }
.chat-heading { min-width: 0; margin-right: auto; }
.chat-heading h2 { font-size: 1.18rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-heading p { color: var(--muted); font-size: .82rem; margin-top: 3px; }
.header-mode { display: flex; align-items: center; gap: 6px; border-radius: 99px; padding: 6px 9px; color: var(--forest); background: var(--tint); white-space: nowrap; font-size: .75rem; font-weight: 700; }
.header-mode::before { content: ""; width: 6px; height: 6px; background: currentColor; border-radius: 50%; }
.header-mode[data-mode="ignore"], .header-mode[data-mode="takeover"], .header-mode[data-mode="hybrid"] { background: #f3ece1; color: #775431; }
.details-toggle, .icon-button { background: var(--paper); color: var(--green); border: 1px solid var(--line); border-radius: 8px; min-height: 36px; padding: 0 9px; display: flex; align-items: center; justify-content: center; gap: 7px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.icon-button { min-width: 36px; font-size: 1.3rem; }
.details-toggle:hover, .icon-button:hover { background: var(--tint); }
.mobile-back { display: none; }
.messages { overflow: auto; padding: 18px clamp(18px, 4vw, 64px) 25px; scrollbar-gutter: stable; }
.day-divider { display: table; margin: 14px auto; padding: 5px 10px; border-radius: 99px; background: #e7eae1; color: #52665a; font-size: .72rem; font-weight: 650; }
.message { display: flex; flex-direction: column; align-items: flex-start; margin: 9px 0; }
.message.outbound { align-items: flex-end; }
.bubble { max-width: min(80%, 560px); border-radius: 3px 13px 13px 13px; padding: 10px 12px 8px; border: 1px solid #e3e8df; background: #fff; box-shadow: 0 1px 1px #243d3010; overflow-wrap: anywhere; }
.outbound .bubble { background: #dfede4; border-color: #d5e6da; border-radius: 13px 3px 13px 13px; }
.outbound.agent .bubble { background: #e8f1ec; }
.message-author { font-size: .71rem; color: var(--green); font-weight: 740; margin-bottom: 4px; }
.message-body { line-height: 1.5; white-space: pre-wrap; }
.message-meta { display: flex; justify-content: flex-end; gap: 7px; align-items: center; margin-top: 4px; font-size: .68rem; color: var(--muted); }
.message-status { color: #336c59; font-weight: 750; }
.message-status.problem { color: var(--clay); }
.message-attachment { display: block; font-weight: 650; color: var(--green); margin: 3px 0 4px; }
.message-attachment img { max-width: min(100%,260px); max-height: 240px; display: block; border-radius: 9px; }
.message-attachment video, .message-attachment audio { display: block; max-width: 100%; margin: 6px 0; }

.chat-footer { padding: 12px 20px max(13px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--paper); }
.mode-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.mode-description { font-size: .78rem; color: var(--muted); line-height: 1.4; }
.mode-controls { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.mode-controls button { border: 1px solid var(--line); min-height: 35px; padding: 0 10px; border-radius: 8px; background: #fff; color: var(--deep); font-size: .76rem; font-weight: 660; white-space: nowrap; }
.mode-controls button:hover, .mode-controls .active { border-color: #96b7a7; color: var(--forest); background: var(--tint); }
.mode-controls .resume, .primary { border: 1px solid var(--forest); background: var(--forest); color: white; }
.mode-controls .resume:hover, .primary:hover { border-color: var(--green); background: var(--green); color: white; }
.reply-window { margin-top: 8px; color: #805632; font-size: .76rem; }
.composer { display: flex; gap: 10px; align-items: flex-end; margin-top: 10px; }
.composer textarea { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--deep); background: #f7f8f5; resize: vertical; max-height: 160px; }
.primary { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 42px; padding: 0 14px; border-radius: 9px; font-weight: 680; }
.error { color: #9a3625; margin: 0 0 9px; line-height: 1.4; }

.details-panel { min-width: 0; width: 268px; overflow: auto; border-left: 1px solid var(--line); background: #fff; padding: 21px 17px; }
.details-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.details-header h2 { font-size: 1.08rem; }
.lead-details { display: grid; gap: 14px; }
.lead-details dl { margin: 0; display: grid; gap: 11px; }
.lead-details dt, .assignment label { font-size: .75rem; color: var(--muted); font-weight: 650; }
.lead-details dd { margin: 2px 0 0; line-height: 1.4; overflow-wrap: anywhere; }
.detail-subheading { font-size: .91rem; font-weight: 740; }
.lead-details ul { margin: 0; padding-left: 16px; color: var(--muted); line-height: 1.45; font-size: .8rem; }
.lead-review { margin-top: 15px; }
.lead-review form { display: grid; gap: 9px; margin-top: 10px; }
.lead-review label { display: grid; gap: 3px; min-width: 0; color: var(--muted); font-size: .75rem; font-weight: 650; }
.lead-review input, .lead-review select { min-width: 0; width: 100%; padding: 7px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--deep); }
.inline-fields { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.lead-review .primary { justify-self: start; min-height: 36px; font-size: .82rem; }
.assignment { display: grid; gap: 5px; border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.assignment select { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--deep); padding: 8px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--forest); color: white; border-radius: 10px; z-index: 5; max-width: calc(100% - 30px); padding: 10px 15px; }

.login-view { display: grid; place-items: center; min-height: 100dvh; background: var(--canvas); background-image: radial-gradient(#dce6dd 0.8px, transparent 0.8px); background-size: 18px 18px; padding: 24px; }
.login-card { width: min(100%,390px); padding: 28px; background: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 22px 55px #1b352215; }
.login-card .identity-mark { margin-bottom: 16px; }
.login-card h1 { font-size: 1.85rem; }
.login-card p { color: var(--muted); margin: 8px 0 16px; line-height: 1.45; }
.login-card .error { color: var(--clay); }
.login-card label { display: grid; gap: 6px; margin: 12px 0; font-weight: 650; }
.login-card input { border: 1px solid var(--line); padding: 10px; border-radius: 8px; width: 100%; background: #fbfcfa; }
.login-card .remember-me { display: flex; align-items: center; gap: 8px; }
.login-card .remember-me input { width: 16px; height: 16px; margin: 0; accent-color: var(--green); }
.login-card .primary { width: 100%; margin-top: 18px; }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: 62px 292px minmax(0,1fr); }
  .details-panel { position: fixed; z-index: 4; right: 0; top: 0; bottom: 0; box-shadow: -12px 0 32px #16352824; width: min(320px,100%); }
}

@media (max-width: 720px) {
  .workspace { grid-template-columns: 52px minmax(0,1fr); }
  .rail { padding-top: 16px; gap: 20px; }
  .rail .identity-mark { width: 36px; height: 36px; border-radius: 10px; }
  .rail-button { width: 38px; height: 39px; }
  .list-header { padding-top: 17px; }
  .chat-panel { display: none; }
  .workspace.thread-open { display: block; }
  .workspace.thread-open .chat-panel { height: 100dvh; display: grid; }
  .workspace.thread-open .list-panel, .workspace.thread-open .rail { display: none; }
  .mobile-back { display: grid; }
  .chat-header { height: 66px; padding: 0 9px; gap: 7px; }
  .chat-avatar { width: 33px; height: 33px; }
  .chat-heading h2 { font-size: 1rem; }
  .chat-heading p { font-size: .71rem; }
  .details-toggle > span:last-child { display: none; }
  .chat-footer { padding-left: 10px; padding-right: 10px; }
  .mode-bar { flex-direction: column; align-items: flex-start; gap: 6px; }
  .mode-controls { justify-content: flex-start; }
  .mode-controls button { padding: 0 8px; min-height: 39px; }
  .messages { padding: 12px; }
  .bubble { max-width: 87%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}

.chat-context {
  position: fixed;
  z-index: 20;
  width: 154px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 8px 30px #192e2829;
}
.chat-context button { display: block; width: 100%; padding: 8px 10px; text-align: left; color: inherit; background: transparent; border: 0; border-radius: 5px; }
.chat-context button:hover, .chat-context button:focus-visible { background: var(--tint); }
.chat-context .delete-chat { color: var(--clay); }
