﻿:root { color-scheme: light; font-family: Inter, "Microsoft YaHei", system-ui, sans-serif; }
* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body { margin: 0; height: 100vh; background: #f5f7fb; color: #1f2937; }
.hidden { display: none !important; }
.app-view { height: 100vh; display: grid; grid-template-columns: 340px minmax(0, 1fr); overflow: hidden; min-height: 0; }
.login-view { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg,#eff6ff,#f5f3ff); }
.login-card { width: min(380px, calc(100vw - 32px)); display: grid; gap: 12px; padding: 28px; border-radius: 22px; background: #fff; box-shadow: 0 24px 80px rgba(15,23,42,.16); }
.login-card h1 { margin: 0 0 8px; }
.login-card input { padding: 13px; border: 1px solid #d1d5db; border-radius: 12px; font: inherit; }
.login-card p { margin: 0; color: #6b7280; font-size: 13px; }
.auth-step { display: grid; gap: 12px; }
.auth-instruction { color: #334155 !important; line-height: 1.6; }
.totp-setup { display: grid; justify-items: center; gap: 9px; padding: 13px; border: 1px solid #dbeafe; border-radius: 16px; background: #f8fbff; color: #64748b; font-size: 12px; text-align: center; }
.totp-setup img { width: 190px; height: 190px; max-width: 100%; border-radius: 12px; background: #fff; }
.totp-setup code { max-width: 100%; padding: 6px 8px; border-radius: 8px; background: #eef2ff; color: #312e81; word-break: break-all; user-select: all; letter-spacing: .1em; }
#totpCodeInput { text-align: center; font-size: 21px; letter-spacing: .3em; font-variant-numeric: tabular-nums; }
.sidebar { border-right: 1px solid #e5e7eb; background: #fff; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.sidebar header { flex: 0 0 auto; padding: 20px; border-bottom: 1px solid #edf0f5; display: grid; gap: 10px; }
.conversation-section { display: flex; flex-direction: column; flex: 1 1 0; min-height: 0; overflow: hidden; }
.conversation-section > h2 { flex: 0 0 auto; }
h1 { margin: 0 0 12px; font-size: 22px; }
h2 { margin: 18px 20px 10px; font-size: 14px; color: #6b7280; }
select, textarea, button { font: inherit; }
select { width: 100%; padding: 10px; border: 1px solid #d1d5db; border-radius: 10px; background: white; }
.conversation-list { flex: 1 1 0; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; padding: 0 12px 16px; overscroll-behavior: contain; }
.conversation { width: 100%; border: 0; text-align: left; padding: 14px; margin: 6px 0; border-radius: 14px; background: #f9fafb; cursor: pointer; color: #1f2937; }
.conversation:hover, .conversation.active { background: #e8f0ff; }
.conversation strong { display: block; margin-bottom: 6px; }
.conversation span { color: #6b7280; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.workbench { min-width: 0; min-height: 0; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) 340px; height: 100vh; }
.chat { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; overflow: hidden; }
.chat-header { padding: 18px 24px; border-bottom: 1px solid #e5e7eb; background: #fff; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.messages { min-height: 0; padding: 24px; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.message { max-width: 70%; padding: 12px 14px; border-radius: 16px; background: #fff; box-shadow: 0 6px 18px rgba(15, 23, 42, .06); }
.message.agent { align-self: flex-end; background: #2563eb; color: #fff; }
.message .meta { font-size: 12px; opacity: .65; margin-bottom: 6px; }
.message .translation { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(127,127,127,.35); font-size: 13px; opacity: .82; }
.composer-wrap { border-top: 1px solid #e5e7eb; background: #fff; }
.translate-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px 0; color: #64748b; font-size: 13px; }
.translate-bar label { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.translate-bar select { width: 180px; padding: 8px 10px; }
.composer { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 12px; padding: 12px 16px 16px; background: #fff; }
textarea { resize: none; min-height: 52px; max-height: 120px; padding: 12px; border: 1px solid #d1d5db; border-radius: 14px; }
button { border: 0; border-radius: 12px; padding: 12px 18px; background: #111827; color: #fff; cursor: pointer; }
button.secondary { background: #6b7280; }
.empty { color: #6b7280; padding: 20px; }
.empty.compact { padding: 10px 0; margin: 0; }
.admin-link { display: block; text-align: center; text-decoration: none; border-radius: 12px; padding: 11px 16px; background: #eef2ff; color: #3730a3; }
.agent-profile { padding: 11px 12px; border-radius: 12px; background: #f3f4f6; font-weight: 700; }
.status-row { display: grid; gap: 6px; color: #6b7280; font-size: 13px; }
.status-row select { color: #111827; }
.customer-panel { border-left: 1px solid #e5e7eb; background: #fff; min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.customer-panel > header { position: sticky; top: 0; z-index: 1; background: #fff; border-bottom: 1px solid #edf0f5; padding: 18px 18px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.customer-panel h2 { margin: 0; color: #111827; font-size: 18px; }
.customer-panel header span { color: #64748b; font-size: 13px; }
.customer-info { display: grid; gap: 12px; padding: 16px; }
.customer-card { border: 1px solid #edf0f5; border-radius: 18px; padding: 14px; background: #fbfdff; display: grid; gap: 10px; }
.customer-card.primary { display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, #eff6ff, #f8fafc); }
.customer-card.primary strong { display: block; font-size: 16px; }
.customer-card.primary span { color: #64748b; font-size: 13px; }
.avatar { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: #2563eb; color: #fff; font-weight: 800; }
.customer-card h3 { margin: 0; font-size: 14px; color: #334155; }
.info-row { display: grid; gap: 4px; }
.info-row span { color: #64748b; font-size: 12px; }
.info-row strong { color: #0f172a; font-size: 13px; line-height: 1.45; word-break: break-all; font-weight: 650; }
.info-row.mono strong { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
button:disabled, textarea:disabled { opacity: .5; cursor: not-allowed; }
.error-message { color: #dc2626; background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; padding: 9px 10px; font-size: 13px; }
button:disabled { opacity: .65; cursor: not-allowed; }
@media (max-width: 1280px) { .workbench { grid-template-columns: minmax(0, 1fr) 300px; } .app-view { grid-template-columns: 300px minmax(0, 1fr); } }
@media (max-width: 980px) { .app-view { grid-template-columns: 1fr; } .sidebar { display: none; } .workbench { grid-template-columns: 1fr; } .customer-panel { display: none; } }
@media (max-width: 720px) { .translate-bar { display: grid; align-items: stretch; } .translate-bar label { justify-content: space-between; } .translate-bar select { width: 190px; } .composer { grid-template-columns: 1fr; } .message { max-width: 88%; } }
.customer-edit label { display: grid; gap: 6px; color: #64748b; font-size: 12px; font-weight: 700; }
.customer-edit input, .customer-edit textarea { width: 100%; border: 1px solid #dbe3ef; border-radius: 12px; padding: 9px 10px; font: inherit; color: #0f172a; background: #fff; }
.customer-edit textarea { resize: vertical; min-height: 86px; }
.customer-edit button { justify-self: start; padding: 10px 14px; border-radius: 10px; }
.message.agent .translation { border-color: rgba(255,255,255,.35); }
.message.recalled { opacity: .72; font-style: italic; }
.message.agent .recall-btn { margin-top: 8px; padding: 4px 9px; border-radius: 999px; background: rgba(255,255,255,.18); color: #fff; font-size: 12px; }
.message:not(.agent) .recall-btn { display: none; }


.profile-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.profile-form input { min-width: 0; border: 1px solid #d1d5db; border-radius: 10px; padding: 9px 10px; font: inherit; }
.profile-form button { border-radius: 10px; padding: 0 10px; }
.conversation strong { position: relative; padding-right: 34px; }
.conversation.has-unread { background: #fff7ed; box-shadow: inset 0 0 0 1px #fdba74; }
.unread-badge { position: absolute; right: 0; top: 0; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: #ef4444; color: #fff; font-size: 12px; font-style: normal; line-height: 22px; text-align: center; }
.message-row { display: flex; gap: 10px; align-items: flex-end; margin: 10px 0; }
.message-row.agent { flex-direction: row-reverse; }
.avatar { width: 34px; height: 34px; border-radius: 999px; object-fit: cover; flex: 0 0 auto; border: 1px solid #e2e8f0; background: #fff; }
.avatar.fallback { display: inline-grid; place-items: center; background: #dbeafe; color: #1d4ed8; font-size: 12px; font-weight: 800; }
.message-attachment { display: inline-grid; place-items: center; margin-top: 8px; padding: 0; border: 0; border-radius: 12px; background: rgba(255,255,255,.28); color: inherit; cursor: zoom-in; overflow: hidden; }
.message-attachment.image img { width: 180px; max-width: min(36vw, 240px); max-height: 160px; border-radius: 10px; object-fit: cover; display: block; }
.message-attachment.file { width: 56px; height: 56px; font-size: 24px; }
.file-icon { font-size: 24px; }
.attachment-preview { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 8px; color: #475569; font-size: 13px; }
.attachment-preview span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: #eef2ff; }
.attachment-preview button { border: 0; background: transparent; color: #ef4444; cursor: pointer; }

.avatar.fallback { overflow: hidden; padding: 0; }
.avatar.fallback svg { width: 100%; height: 100%; display: block; }

.preview-modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 24px; background: rgba(15,23,42,.72); }
.preview-modal.hidden { display: none; }
.preview-body { max-width: min(92vw, 1080px); max-height: 88vh; display: grid; place-items: center; }
.preview-body img { max-width: 100%; max-height: 88vh; border-radius: 14px; box-shadow: 0 24px 80px rgba(0,0,0,.32); }
.preview-body a { width: 96px; height: 96px; display: grid; place-items: center; border-radius: 24px; background: #fff; font-size: 42px; text-decoration: none; }
.preview-close { position: fixed; right: 24px; top: 24px; width: 42px; height: 42px; border: 0; border-radius: 999px; background: rgba(255,255,255,.92); color: #0f172a; font-size: 28px; cursor: pointer; }
