:root {
  color-scheme: light;
  --ink: #173f42;
  --muted: #6b7d7f;
  --brand: #0e5658;
  --brand-soft: #e9f4f1;
  --accent: #e59f66;
  --line: #dbe5e4;
  --paper: #ffffff;
  --background: #f3f6f5;
  --danger: #a1453f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--background); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.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; }
.eyebrow { margin: 0 0 5px; color: #7b918f; font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.operator-logo { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 18px; color: white; background: linear-gradient(145deg, #0e5658, #2b8b82); box-shadow: 0 12px 28px rgba(14,86,88,.2); font-size: 25px; }
.operator-logo.small { display: inline-grid; width: 30px; height: 30px; border-radius: 10px; font-size: 14px; vertical-align: middle; margin-right: 5px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 10% 0%, #d9ece7 0, transparent 38%), var(--background); }
.login-card { width: min(430px, 100%); padding: 38px; border: 1px solid rgba(14,86,88,.12); border-radius: 28px; background: rgba(255,255,255,.94); box-shadow: 0 28px 70px rgba(19,63,66,.12); }
.login-card h1 { margin: 18px 0 8px; font-size: 30px; letter-spacing: -.03em; }
.login-copy { margin: 0 0 28px; color: var(--muted); line-height: 1.5; }
.login-card label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 750; }
.login-card input { width: 100%; height: 50px; padding: 0 14px; border: 1px solid #becdcb; border-radius: 13px; outline: none; }
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(14,86,88,.1); }
.login-card button { width: 100%; height: 50px; margin-top: 13px; border: 0; border-radius: 13px; color: white; background: var(--brand); font-weight: 800; }
.login-card button:disabled { opacity: .55; }
.form-status { min-height: 20px; margin: 10px 0 0; color: var(--danger); font-size: 13px; }
.security-note { margin: 25px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: #7b8d8d; font-size: 12px; line-height: 1.5; }

.operator-shell { display: grid; grid-template-columns: 390px minmax(0,1fr); height: 100vh; overflow: hidden; }
.inbox-panel { display: flex; min-width: 0; flex-direction: column; background: var(--paper); border-right: 1px solid var(--line); }
.inbox-header { display: flex; align-items: center; justify-content: space-between; padding: 22px 20px 16px; }
.inbox-header h1 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.ghost-button { border: 1px solid var(--line); border-radius: 11px; padding: 9px 12px; color: var(--muted); background: white; }
.filters { display: grid; grid-template-columns: 1fr 122px; gap: 8px; padding: 0 16px 12px; }
.filters input, .filters select, .status-control select { min-width: 0; height: 40px; padding: 0 11px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: white; outline: none; }
.filters input:focus, .filters select:focus, .status-control select:focus { border-color: var(--brand); }
.inbox-summary { padding: 10px 18px; border-block: 1px solid var(--line); color: var(--muted); background: #fafcfb; font-size: 12px; font-weight: 700; }
.conversation-list { flex: 1; overflow-y: auto; }
.conversation-item { width: 100%; padding: 15px 17px; border: 0; border-bottom: 1px solid #edf1f0; text-align: left; color: inherit; background: white; }
.conversation-item:hover { background: #f8fbfa; }
.conversation-item.selected { background: var(--brand-soft); box-shadow: inset 3px 0 var(--brand); }
.conversation-top, .conversation-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.conversation-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.conversation-top time { flex: none; color: #899796; font-size: 11px; }
.conversation-item p { margin: 7px 0 10px; overflow: hidden; color: var(--muted); font-size: 13px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { display: inline-flex; align-items: center; min-height: 23px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-new { color: #8a4715; background: #fff0df; }
.status-in_work { color: #126d68; background: #ddf3ee; }
.status-bot { color: #647170; background: #edf1f0; }
.status-closed { color: #7a7d7d; background: #f3f3f3; }
.unread-badge { display: grid; place-items: center; min-width: 23px; height: 23px; padding: 0 6px; border-radius: 12px; color: white; background: var(--brand); font-size: 11px; }
.no-results { padding: 30px 18px; color: var(--muted); text-align: center; font-size: 13px; }

.dialog-panel { min-width: 0; height: 100vh; background: #eef3f1; }
.empty-state { height: 100%; display: grid; place-content: center; justify-items: center; padding: 40px; text-align: center; }
.empty-state h2 { margin: 18px 0 8px; }
.empty-state p { max-width: 490px; margin: 0; color: var(--muted); line-height: 1.6; }
.dialog { height: 100%; display: grid; grid-template-rows: auto auto minmax(0,1fr) auto; }
.dialog-header { display: flex; align-items: center; gap: 16px; padding: 17px 24px; border-bottom: 1px solid var(--line); background: white; }
.dialog-title { flex: 1; min-width: 0; }
.dialog-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog-title a { display: inline-block; margin-top: 4px; overflow: hidden; color: var(--brand); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.status-control { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.status-control select { height: 38px; }
.mobile-back { display: none; border: 0; color: var(--ink); background: transparent; font-size: 22px; }
.dialog-meta { padding: 8px 24px; border-bottom: 1px solid var(--line); color: #788886; background: #fafcfb; font-size: 11px; }
.operator-messages { overflow-y: auto; padding: 24px max(24px, 8vw); }
.operator-message { width: fit-content; max-width: min(680px, 78%); margin: 0 0 14px; padding: 12px 15px; border-radius: 17px; background: white; box-shadow: 0 4px 14px rgba(30,70,68,.05); }
.operator-message.role-user { margin-left: auto; border-bottom-right-radius: 5px; background: #daf0eb; }
.operator-message.role-operator { border-bottom-left-radius: 5px; color: white; background: var(--brand); }
.operator-message.role-assistant { border-bottom-left-radius: 5px; }
.operator-message header { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 5px; }
.operator-message header strong { font-size: 11px; letter-spacing: .03em; }
.operator-message header time { opacity: .62; font-size: 10px; }
.operator-message p { margin: 0; white-space: pre-wrap; font-size: 14px; line-height: 1.45; }
.reply-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px 10px; padding: 15px 24px 18px; border-top: 1px solid var(--line); background: white; }
.reply-form textarea { min-height: 58px; max-height: 130px; resize: vertical; padding: 12px 14px; border: 1px solid #bdccca; border-radius: 14px; outline: none; }
.reply-form textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(14,86,88,.08); }
.reply-form > button { min-width: 118px; border: 0; border-radius: 14px; color: white; background: var(--brand); font-weight: 800; }
.reply-form > button:disabled { opacity: .5; }
.reply-form .form-status { margin: 0; color: var(--brand); }
.reply-form small { grid-column: 1/-1; color: #81908f; font-size: 11px; }

@media (max-width: 760px) {
  .operator-shell { display: block; }
  .inbox-panel, .dialog-panel { width: 100%; height: 100vh; }
  .dialog-panel { display: none; }
  .dialog-open .inbox-panel { display: none; }
  .dialog-open .dialog-panel { display: block; }
  .mobile-back { display: block; }
  .dialog-header { padding: 13px 12px; }
  .status-control span { display: none; }
  .operator-messages { padding: 16px 12px; }
  .operator-message { max-width: 88%; }
  .reply-form { padding: 11px 12px; }
  .reply-form > button { min-width: 90px; }
}

/* Manager workspace v2 */
.operator-page { height: 100vh; overflow: hidden; }
.inbox-panel { min-height: 0; overflow: hidden; }
.workspace-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin: 0 16px 14px; padding: 4px; border-radius: 13px; background: #eef3f1; }
.workspace-tab { min-width: 0; padding: 9px 6px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 800; }
.workspace-tab:hover { color: var(--brand); }
.workspace-tab.active { color: white; background: var(--brand); box-shadow: 0 4px 12px rgba(14,86,88,.16); }
.sidebar-view { display: flex; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; }
.single-filter { grid-template-columns: 1fr; }
.scroll-list { flex: 1; min-height: 0; overflow-y: scroll; overscroll-behavior: contain; scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: #89a7a4 #edf3f1; }
.visible-scrollbar { scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: #89a7a4 #edf3f1; }
.scroll-list::-webkit-scrollbar, .visible-scrollbar::-webkit-scrollbar { width: 11px; }
.scroll-list::-webkit-scrollbar-track, .visible-scrollbar::-webkit-scrollbar-track { background: #edf3f1; }
.scroll-list::-webkit-scrollbar-thumb, .visible-scrollbar::-webkit-scrollbar-thumb { border: 3px solid #edf3f1; border-radius: 999px; background: #89a7a4; }
.contact-item { width: 100%; padding: 15px 17px; border: 0; border-bottom: 1px solid #edf1f0; text-align: left; color: inherit; background: white; }
.contact-item:hover { background: #f8fbfa; }
.contact-item.selected { background: var(--brand-soft); box-shadow: inset 3px 0 var(--brand); }
.contact-item p { margin: 6px 0; overflow: hidden; color: var(--brand); text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.contact-metrics { color: #849392; font-size: 11px; }
.analytics-sidebar { padding: 0 16px; gap: 18px; }
.analytics-period > span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 800; }
.period-buttons { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.period-buttons button { padding: 10px 4px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: white; font-size: 12px; font-weight: 750; }
.period-buttons button.active { border-color: var(--brand); color: white; background: var(--brand); }
.privacy-card { padding: 17px; border: 1px solid #d8e7e3; border-radius: 16px; background: linear-gradient(145deg,#eff8f5,#fff); }
.privacy-card strong { font-size: 14px; }
.privacy-card p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.detail-view { height: 100%; min-height: 0; background: var(--background); }
.contact-detail { display: grid; grid-template-rows: auto auto minmax(0,1fr); }
.analytics-view { display: grid; grid-template-rows: auto minmax(0,1fr); }
.detail-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 24px 30px; border-bottom: 1px solid var(--line); background: white; }
.detail-header h2 { margin: 0; font-size: 25px; letter-spacing: -.03em; }
.detail-header a { display: inline-block; margin-top: 5px; color: var(--brand); font-size: 13px; }
.primary-button { padding: 12px 16px; border: 0; border-radius: 12px; color: white; background: var(--brand); font-weight: 800; }
.stat-grid { display: grid; grid-template-columns: repeat(4,minmax(130px,1fr)); gap: 12px; padding: 22px 30px; }
.stat-grid.compact { border-bottom: 1px solid var(--line); background: #f8fbfa; }
.stat-card { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 7px 20px rgba(22,63,62,.04); }
.stat-card strong { display: block; overflow: hidden; color: var(--brand); font-size: 24px; letter-spacing: -.03em; text-overflow: ellipsis; }
.stat-card span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-card small { display: block; margin-top: 6px; color: #96a3a2; font-size: 10px; }
.detail-content, .analytics-content { min-height: 0; overflow-y: auto; padding: 24px 30px 40px; }
.detail-content h3, .data-card h3 { margin: 0; font-size: 18px; }
.section-copy, .data-card-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.visit-timeline { margin-top: 20px; }
.visit-row { position: relative; display: grid; grid-template-columns: 14px minmax(0,1fr); gap: 13px; padding: 0 0 22px; }
.visit-row:not(:last-child)::before { content: ""; position: absolute; left: 6px; top: 14px; bottom: -1px; width: 1px; background: #cdddda; }
.visit-marker { position: relative; z-index: 1; width: 13px; height: 13px; margin-top: 3px; border: 3px solid #d8ebe6; border-radius: 50%; background: var(--brand); }
.visit-row a, .page-row a { color: var(--ink); font-size: 14px; font-weight: 800; text-decoration: none; }
.visit-row a:hover, .page-row a:hover { color: var(--brand); text-decoration: underline; }
.visit-row p, .page-row p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.analytics-content > .stat-grid { padding: 0 0 22px; grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); }
.data-card { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: white; }
.data-card-header { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.page-row { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 12px; padding: 15px 22px; border-bottom: 1px solid #edf1f0; }
.page-row:last-child { border-bottom: 0; }
.page-row > b { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; color: var(--brand); background: var(--brand-soft); font-size: 12px; }

@media (max-width: 1050px) {
  .operator-shell { grid-template-columns: 340px minmax(0,1fr); }
  .stat-grid { grid-template-columns: repeat(2,minmax(130px,1fr)); }
}

@media (max-width: 760px) {
  .operator-page { overflow: hidden; }
  .inbox-header { padding-top: 16px; }
  .detail-open .inbox-panel { display: none; }
  .detail-open .dialog-panel { display: block; }
  .detail-header { padding: 16px 13px; align-items: flex-start; }
  .detail-header h2 { font-size: 20px; }
  .detail-header .primary-button { max-width: 145px; padding: 9px 10px; font-size: 11px; }
  .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); padding: 14px 12px; gap: 8px; }
  .stat-card { padding: 13px; }
  .stat-card strong { font-size: 18px; }
  .detail-content, .analytics-content { padding: 18px 12px 30px; }
}
