:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #172033;
  background: #f3f5f9;
  font-synthesis: none;
  --ink: #172033;
  --muted: #6c7588;
  --line: #e2e6ee;
  --panel: #ffffff;
  --brand: #2448c8;
  --brand-soft: #eef2ff;
  --teal: #0c8276;
  --amber: #b66a00;
  --danger: #c3394a;
  --shadow: 0 18px 50px rgba(25, 38, 72, 0.11);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.loading-screen,
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 15% 8%, rgba(36, 72, 200, 0.15), transparent 32%),
    radial-gradient(circle at 87% 88%, rgba(12, 130, 118, 0.13), transparent 30%),
    #f5f7fb;
}

.loading-mark { color: var(--brand); font-weight: 800; letter-spacing: 0.08em; }
.login-card {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.login-story {
  min-height: 560px;
  padding: 54px 48px;
  color: white;
  background: linear-gradient(145deg, #182b73, #2448c8 56%, #2674bd);
  position: relative;
  overflow: hidden;
}
.login-story::after {
  content: "";
  position: absolute;
  width: 320px;
  height: 320px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  right: -140px;
  bottom: -120px;
  box-shadow: 0 0 0 54px rgba(255,255,255,.05), 0 0 0 108px rgba(255,255,255,.04);
}
.brand-line { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: .03em; }
.brand-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: #203a9d; background: white; font-size: 14px; }
.login-story h1 { margin: 88px 0 20px; max-width: 360px; font-size: clamp(34px, 4vw, 50px); line-height: 1.08; letter-spacing: -.04em; }
.login-story p { max-width: 340px; color: rgba(255,255,255,.78); line-height: 1.8; }
.story-metrics { display: flex; gap: 28px; margin-top: 64px; }
.story-metrics strong { display: block; font-size: 24px; }
.story-metrics span { display: block; margin-top: 6px; color: rgba(255,255,255,.64); font-size: 12px; }
.login-form { padding: 62px 54px; display: flex; flex-direction: column; justify-content: center; }
.eyebrow { color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.login-form h2 { margin: 10px 0 8px; font-size: 30px; letter-spacing: -.03em; }
.login-form > p { margin: 0 0 34px; color: var(--muted); line-height: 1.7; }
.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field label { font-size: 13px; font-weight: 700; color: #3b4354; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: .18s ease;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #7890e3; box-shadow: 0 0 0 3px rgba(36,72,200,.1); }
.primary-button, .secondary-button, .ghost-button, .danger-button {
  border: 0;
  border-radius: 11px;
  padding: 10px 15px;
  font-weight: 750;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
}
.primary-button { color: white; background: var(--brand); box-shadow: 0 8px 20px rgba(36,72,200,.22); }
.secondary-button { color: var(--brand); background: var(--brand-soft); }
.ghost-button { color: #4f596c; background: #f3f5f8; }
.danger-button { color: var(--danger); background: #fff0f2; }
.primary-button:hover, .secondary-button:hover, .ghost-button:hover, .danger-button:hover { transform: translateY(-1px); }
.primary-button:disabled, button:disabled { cursor: not-allowed; opacity: .48; transform: none; }
.login-button { width: 100%; margin-top: 8px; padding: 13px 18px; }
.login-note { margin-top: 18px; color: var(--muted); font-size: 12px; line-height: 1.6; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { background: #111b38; color: white; padding: 24px 18px; display: flex; flex-direction: column; }
.sidebar .brand-line { padding: 0 8px 24px; }
.sidebar .brand-icon { color: white; background: #3458d4; }
.tenant-card { margin: 8px 0 24px; padding: 14px; border-radius: 14px; background: rgba(255,255,255,.07); }
.tenant-card span { display: block; color: rgba(255,255,255,.55); font-size: 11px; }
.tenant-card strong { display: block; margin-top: 6px; font-size: 14px; }
.nav-button { width: 100%; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 11px; padding: 11px 13px; color: rgba(255,255,255,.68); background: transparent; text-align: left; }
.nav-button.active { color: white; background: rgba(86,119,236,.24); }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.sidebar-footer { margin-top: auto; padding: 14px 8px 4px; border-top: 1px solid rgba(255,255,255,.09); }
.user-mini { display: flex; align-items: center; gap: 10px; }
.avatar { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: white; background: linear-gradient(145deg,#5673dd,#26a59a); font-weight: 800; }
.user-mini strong { display: block; font-size: 13px; }
.user-mini span { display: block; margin-top: 3px; color: rgba(255,255,255,.5); font-size: 11px; }
.logout-button { width: 100%; margin-top: 12px; border: 0; background: transparent; color: rgba(255,255,255,.55); text-align: left; padding: 7px 0; font-size: 12px; }

.workspace { min-width: 0; display: grid; grid-template-columns: 350px minmax(0, 1fr); height: 100vh; overflow: hidden; }
.list-panel { min-width: 0; background: #f8f9fc; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.list-header { padding: 26px 24px 18px; background: rgba(255,255,255,.72); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.list-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list-title-row h1 { margin: 0; font-size: 22px; letter-spacing: -.025em; }
.list-subtitle { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.presence-control { display: flex; gap: 5px; margin-top: 16px; padding: 4px; border-radius: 10px; background: #edf0f5; }
.presence-button { flex: 1; border: 0; border-radius: 8px; padding: 7px 4px; color: var(--muted); background: transparent; font-size: 12px; }
.presence-button.active { color: #12685e; background: white; box-shadow: 0 2px 8px rgba(27,46,84,.09); }
.conversation-list { padding: 12px; overflow: auto; }
.conversation-card { width: 100%; border: 1px solid transparent; border-radius: 15px; padding: 15px; margin-bottom: 8px; background: transparent; text-align: left; transition: .16s ease; }
.conversation-card:hover { background: white; border-color: #e7eaf1; }
.conversation-card.active { background: white; border-color: #cad4f9; box-shadow: 0 7px 24px rgba(35,57,105,.08); }
.conversation-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.conversation-card strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.conversation-card p { margin: 9px 0 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { display: flex; align-items: center; gap: 7px; margin-top: 12px; color: #7d8595; font-size: 11px; }
.status-pill, .channel-pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 750; }
.status-waiting { color: var(--amber); background: #fff6e6; }
.status-open { color: var(--teal); background: #e9f8f5; }
.status-resolved { color: #6d7481; background: #eef0f4; }
.channel-pill { color: #3554bc; background: #eef2ff; }

.chat-panel { min-width: 0; display: flex; flex-direction: column; background: white; }
.empty-panel { flex: 1; display: grid; place-items: center; padding: 30px; text-align: center; color: var(--muted); }
.empty-illustration { width: 86px; height: 86px; margin: 0 auto 20px; display: grid; place-items: center; border-radius: 28px; color: var(--brand); background: var(--brand-soft); font-size: 32px; }
.empty-panel h2 { margin: 0 0 8px; color: var(--ink); font-size: 20px; }
.chat-header { min-height: 86px; padding: 17px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.chat-heading { min-width: 0; }
.chat-heading h2 { margin: 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-heading p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.chat-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.message-stream { flex: 1; min-height: 0; overflow: auto; padding: 28px clamp(24px, 5vw, 70px); background: linear-gradient(180deg, #fbfcfe, #fff); }
.message-row { display: flex; gap: 10px; margin-bottom: 18px; }
.message-row.mine { flex-direction: row-reverse; }
.message-content { max-width: min(620px, 74%); }
.message-author { margin: 0 0 6px 3px; color: var(--muted); font-size: 11px; }
.message-row.mine .message-author { text-align: right; margin-right: 3px; }
.message-bubble { padding: 11px 14px; border-radius: 4px 15px 15px 15px; color: #273044; background: #f0f2f6; line-height: 1.65; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.message-row.mine .message-bubble { color: white; background: var(--brand); border-radius: 15px 4px 15px 15px; }
.message-time { margin: 6px 3px 0; color: #9aa0ac; font-size: 10px; }
.message-row.mine .message-time { text-align: right; }
.system-message { display: flex; justify-content: center; margin: 15px 0; }
.system-message span { border-radius: 999px; padding: 6px 10px; color: #778092; background: #f3f5f8; font-size: 11px; }
.composer { padding: 16px 24px 22px; border-top: 1px solid var(--line); background: white; }
.composer form { display: flex; align-items: flex-end; gap: 10px; border: 1px solid var(--line); border-radius: 15px; padding: 8px; }
.composer textarea { flex: 1; min-height: 42px; max-height: 140px; border: 0; padding: 10px; resize: none; outline: none; color: var(--ink); }
.composer button { flex: 0 0 auto; }
.composer-hint { margin: 8px 4px 0; color: #9aa0ac; font-size: 10px; }
.voice-strip { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 12px 24px 0; padding: 11px 14px; border: 1px solid #b9ddd8; border-radius: 13px; color: #12685e; background: #effaf8; font-size: 12px; }
.voice-pulse { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #16a694; box-shadow: 0 0 0 6px rgba(22,166,148,.12); }

.seat-view { grid-column: 1 / -1; overflow: auto; padding: 32px; }
.seat-view-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; }
.seat-view h1 { margin: 0; font-size: 26px; }
.seat-view p { margin: 7px 0 0; color: var(--muted); }
.seat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.seat-card { padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: white; box-shadow: 0 8px 24px rgba(34,49,83,.05); }
.seat-card-top { display: flex; align-items: center; gap: 12px; }
.seat-card h3 { margin: 0; font-size: 15px; }
.seat-card p { margin: 5px 0 0; font-size: 11px; }
.seat-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.seat-stat { padding: 11px; border-radius: 11px; background: #f6f7fa; }
.seat-stat strong { display: block; font-size: 17px; }
.seat-stat span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.seat-action { width: 100%; margin-top: 14px; }
.presence-dot { width: 9px; height: 9px; border-radius: 50%; background: #aab0bc; }
.presence-dot.online { background: #19a68f; }
.presence-dot.busy { background: #e1a13a; }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(12,21,45,.48); backdrop-filter: blur(4px); }
.modal { width: min(520px, 100%); max-height: 88vh; overflow: auto; padding: 26px; border-radius: 20px; background: white; box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal h2 { margin: 0; font-size: 21px; }
.icon-button { width: 34px; height: 34px; border: 0; border-radius: 10px; color: var(--muted); background: #f2f4f7; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.checkbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.checkbox-row { display: flex; align-items: center; gap: 7px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; color: #465064; font-size: 13px; }
.empty-list { padding: 36px 16px; color: var(--muted); text-align: center; font-size: 13px; }
.toast-region { position: fixed; z-index: 50; right: 22px; bottom: 22px; display: grid; gap: 10px; }
.toast { min-width: 260px; max-width: 420px; padding: 12px 15px; border-radius: 12px; color: white; background: #1e2a46; box-shadow: var(--shadow); font-size: 13px; animation: toast-in .2s ease; }
.toast.error { background: #a72e40; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 900px) {
  .shell { grid-template-columns: 74px minmax(0,1fr); }
  .sidebar { padding: 20px 11px; }
  .sidebar .brand-line span, .tenant-card, .nav-button span, .user-mini div, .logout-button { display: none; }
  .sidebar .brand-line { padding: 0 7px 24px; }
  .nav-button { justify-content: center; }
  .workspace { grid-template-columns: 300px minmax(0,1fr); }
}

@media (max-width: 680px) {
  .login-card { grid-template-columns: 1fr; }
  .login-story { display: none; }
  .login-form { padding: 42px 26px; }
  .shell { display: block; }
  .sidebar { min-height: auto; height: 66px; flex-direction: row; align-items: center; gap: 10px; padding: 10px 14px; }
  .sidebar .brand-line { padding: 0; }
  .sidebar nav { margin-left: auto; display: flex; }
  .sidebar-footer { display: none; }
  .workspace { height: calc(100vh - 66px); grid-template-columns: 1fr; }
  .list-panel.hidden-mobile { display: none; }
  .chat-panel { position: absolute; inset: 66px 0 0; z-index: 4; }
  .chat-header { padding: 12px 14px; }
  .chat-actions button { padding: 8px 10px; font-size: 11px; }
  .message-stream { padding: 20px 14px; }
  .composer { padding: 10px 12px 14px; }
  .message-content { max-width: 86%; }
}
