: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; }
}
