:root {
  --navy: #10416c;
  --brand: #e2231a;
  --blue: #2f6bff;
  --blue-soft: #eef3ff;
  --page: #f5f6fa;
  --green: #16a34a;
  --green-soft: #eafaf0;
  --gray-soft: #f1f2f6;
  --line: #e6e8ee;
  --text: #1f2430;
  --muted: #8a90a0;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(16, 65, 108, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: var(--page);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ============ 登錄頁 ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #10416c, #2f6bff);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 36px 30px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}

.login-card .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.login-card .logo b {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.login-card h1 {
  font-size: 20px;
  margin: 14px 0 4px;
}

.login-card p.sub {
  color: var(--muted);
  margin: 0 0 22px;
  font-size: 13px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.field input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus {
  border-color: var(--blue);
}

.field textarea {
  width: 100%;
  min-height: 60px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
}
.field textarea:focus {
  border-color: var(--blue);
}

.field-section {
  margin: 4px 0 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
}
.field-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.filter-select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
}
.filter-select:focus {
  border-color: var(--blue);
}

/* 列表頁篩選欄：搜索框 + 下拉篩選 + 重置按鈕 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.filter-input {
  height: 36px;
  min-width: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
}
.filter-input:focus {
  border-color: var(--blue);
}

.btn {
  width: 100%;
  height: 46px;
  border: none;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  transition: opacity 0.15s;
}

.btn:hover {
  opacity: 0.92;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  width: auto;
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-ghost {
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--line);
}

.btn-danger {
  background: var(--brand);
}

.btn-blue {
  background: var(--blue);
}

/* ============ 後台佈局 ============ */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: #fff;
  color: var(--text);
  border-right: 1px solid var(--line);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--line);
}

.sidebar .brand b {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--blue), #7c5cff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.nav {
  flex: 1;
  padding: 10px 10px;
  overflow-y: auto;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
}

.nav a .i,
.nav-group__head .i {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav a .i svg,
.nav-group__head .i svg {
  width: 18px;
  height: 18px;
}

.nav a:hover {
  background: var(--gray-soft);
  color: var(--text);
}

.nav a.active {
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 600;
}

.nav-group__head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  border: none;
  background: none;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.nav-group__head span:nth-child(2) { flex: 1; }
.nav-group__head:hover { background: var(--gray-soft); color: var(--text); }
.nav-group__head.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.nav-group__chevron { transition: transform 0.15s; font-size: 11px; color: var(--muted); }
.nav-group.is-open .nav-group__chevron { transform: rotate(180deg); }

.sub-nav {
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.nav-group.is-open .sub-nav { display: flex; }
.sub-nav__item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 30px 9px 12px;
  margin-bottom: 2px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
/* 徽標改為絕對定位釘在右側，避免用 margin-left:auto 在 justify-content:center 的容器裡把文字擠向左邊 */
.sub-nav__item .nav-badge {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 0;
}
.sub-nav__item:hover { background: var(--gray-soft); color: var(--text); }
.sub-nav__item.active {
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 600;
}

.sidebar .foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

/* 實時訂單頁的備注單元格：過長時省略顯示，完整內容見 title 提示 */
.note-cell {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 分頁控制條 */
.pager {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.pager__total {
  color: var(--muted);
  font-size: 13px;
  margin-right: auto;
}
.pager__btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  font-size: 13px;
  color: var(--navy);
  cursor: pointer;
}
.pager__btn:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.pager__btn.is-active { background: var(--blue); border-color: var(--blue); color: #fff; }
.pager__btn:disabled { color: var(--muted); cursor: not-allowed; opacity: .5; }
.pager__dots { color: var(--muted); padding: 0 2px; }

/* 側邊欄未讀/待處理徽標 */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: auto;
  border-radius: 999px;
  background: #ff4d4f;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
/* display:inline-flex 会覆盖 [hidden] 属性默认的 display:none，须显式声明避免 count=0 时仍显示空徽标 */
.nav-badge[hidden] {
  display: none;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 58px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 20;
  gap: 16px;
}

.topbar .title {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
}

.topbar .who {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
  margin-left: auto;
}

.topbar__notice {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--gray-soft);
  white-space: nowrap;
}
.topbar__notice .i { width: 16px; height: 16px; flex-shrink: 0; color: var(--blue); display: inline-flex; }
.topbar__notice .i svg { width: 16px; height: 16px; }
.topbar__notice b { color: var(--text); font-weight: 700; }
.topbar__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #7c5cff);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.content {
  padding: 18px;
  flex: 1;
}

/* ============ 卡片 / 統計 ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat--wide {
  grid-column: span 2;
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon--blue { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.stat-icon--teal { background: linear-gradient(135deg, #2dd4bf, #0d9488); }
.stat-icon--red { background: linear-gradient(135deg, #f87171, #dc2626); }
.stat-icon--green { background: linear-gradient(135deg, #4ade80, #16a34a); }
.stat-icon--purple { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.stat-icon--orange { background: linear-gradient(135deg, #fbbf24, #d97706); }

.stat-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat-text .k { color: var(--muted); font-size: 13px; white-space: nowrap; }
.stat-text .v { font-size: 24px; font-weight: 700; color: var(--text); }

.stat-multi { display: flex; gap: 28px; flex: 1; flex-wrap: wrap; }
.stat-multi__item { display: flex; flex-direction: column; gap: 6px; }
.stat-multi__item .k { color: var(--muted); font-size: 12px; white-space: nowrap; }
.stat-multi__item .v { font-size: 22px; font-weight: 700; color: var(--text); }

@media (max-width: 720px) {
  .stat--wide { grid-column: span 1; }
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.card-head h2 {
  font-size: 16px;
  margin: 0;
  padding-left: 12px;
  position: relative;
}
.card-head h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: var(--blue);
}

.card-body {
  padding: 4px 0;
}

/* ============ 表格 ============ */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: center;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 600;
  background: #fafbfd;
  border: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  vertical-align: middle;
  text-align: center;
}

tbody tr:hover {
  background: #fafbfd;
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--blue-soft);
  color: var(--blue);
}

.pill-yes {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--green-soft);
  color: var(--green);
}

.pill-no {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--gray-soft);
  color: var(--muted);
}

.sub-text {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
  justify-content: center;
}

.row-actions.row-actions--wrap {
  display: flex;
  flex-wrap: wrap;
  white-space: normal;
  gap: 6px;
  justify-content: center;
}

.row-actions .action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.action-btn {
  border: none;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.action-btn:hover {
  opacity: 0.9;
}

.action-btn.danger {
  background: var(--brand);
}

.link-btn {
  border: none;
  background: none;
  color: var(--blue);
  font-size: 13px;
  padding: 0;
}

.link-btn.danger {
  color: var(--brand);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

/* ============ 彈窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .16s ease;
}

.modal-mask.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  transform: scale(.96);
  transition: transform .16s ease;
}

.modal-mask.show .modal {
  transform: scale(1);
}

.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  padding: 18px 22px;
}

.modal-foot {
  padding: 14px 22px 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal .field input:not([type='checkbox']),
.modal .field textarea,
.modal .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.modal .field textarea {
  min-height: 84px;
  resize: vertical;
}

.modal .field input:focus,
.modal .field textarea:focus {
  border-color: var(--blue);
}

.modal-image-frame {
  width: 100%;
  height: 220px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f1f3f7;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.modal-image-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.switch-line input {
  width: 18px;
  height: 18px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 14px;
  max-height: 220px;
  overflow-y: auto;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.check-item input {
  width: 16px;
  height: 16px;
  flex: none;
}

.perm-tree {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 10px;
  max-height: 280px;
  overflow-y: auto;
}

.perm-node {
  padding: 4px 0;
}

.perm-group__head {
  display: flex;
  align-items: center;
  gap: 4px;
}

.perm-toggle {
  width: 20px;
  height: 20px;
  flex: none;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.perm-children {
  margin-left: 24px;
  padding-left: 10px;
  border-left: 1px dashed var(--line);
}

.perm-children[hidden] {
  display: none;
}

.perm-leaf-child {
  padding: 4px 0;
}

/* ============ Toast ============ */
.toast-box {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  background: rgba(31, 36, 48, 0.94);
  color: #fff;
  padding: 10px 18px;
  border-radius: 22px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  animation: toast-in 0.2s ease;
}

.toast.ok {
  background: var(--green);
}

.toast.err {
  background: var(--brand);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============ 響應式 ============ */
@media (max-width: 820px) {
  .sidebar {
    width: 60px;
  }
  .sidebar .brand span,
  .nav a span,
  .sidebar .foot {
    display: none;
  }
  .nav a {
    justify-content: center;
    padding: 12px 0;
  }
}

/* ============ 在線客服工作台 ============ */
.cs {
  display: grid;
  grid-template-columns: 300px 1fr 280px;
  gap: 0;
  height: calc(100vh - 130px);
  min-height: 480px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.cs__side {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.cs__side-head {
  padding: 14px 16px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cs__conn {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.cs__conn.is-ok {
  color: var(--green);
}

.cs__threads {
  flex: 1;
  overflow-y: auto;
}

.cs__empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

.cs__thread {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
  transition: background 0.15s;
}

.cs__thread:hover {
  background: #f5f7fb;
}

.cs__thread.is-active {
  background: #eaf0f8;
}

.cs__avatar {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10416c, #2f6bff);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  position: relative;
}

.cs__avatar--online::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--card);
}

.cs__thread-mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cs__thread-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs__thread-last {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs__thread-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.cs__thread-time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.cs__badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cs__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.cs__head {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 61px;
}

.cs__head-name {
  font-weight: 700;
}

.cs__head-sub,
.cs__head-tip {
  font-size: 13px;
  color: var(--muted);
}

.cs__body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}

.cs__msg {
  display: flex;
}

.cs__msg--me {
  justify-content: flex-end;
}

.cs__bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 66%;
}

.cs__msg--me .cs__bubble-wrap {
  align-items: flex-end;
}

.cs__bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  background: #fff;
  border: 1px solid var(--line);
  border-top-left-radius: 4px;
}

.cs__msg--me .cs__bubble {
  background: var(--blue);
  color: #fff;
  border: 0;
  border-radius: 14px;
  border-top-right-radius: 4px;
}

.cs__msg-time {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  padding: 0 4px;
}

.cs__input {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  align-items: flex-end;
}

.cs__input input,
.cs__input textarea {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

.cs__input textarea {
  resize: none;
  font-family: inherit;
  line-height: 1.4;
  max-height: 110px;
  min-height: 40px;
}

.cs__input input:focus,
.cs__input textarea:focus {
  border-color: var(--blue);
}

.cs__input .btn {
  width: auto;
  padding: 0 22px;
  height: 40px;
}

.cs__attach {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}

.cs__attach:hover:not(:disabled) {
  color: var(--blue);
  border-color: var(--blue);
}

.cs__attach:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cs__bubble--media {
  padding: 4px;
  background: #fff;
}

.cs__msg--me .cs__bubble--media {
  background: #fff;
  border: 1px solid var(--line);
}

.cs__media {
  display: block;
  max-width: 260px;
  max-height: 300px;
  border-radius: 8px;
  cursor: pointer;
}

video.cs__media {
  cursor: default;
  width: 300px;
}

.cs-lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(10, 14, 24, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}

.cs-lightbox[hidden] {
  display: none;
}

.cs-lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}

@media (max-width: 820px) {
  .cs {
    grid-template-columns: 200px 1fr;
  }
  .cs__user { display: none; }
}

.cs__user {
  border-left: 1px solid var(--line);
  padding: 16px;
  overflow-y: auto;
  min-height: 0;
  font-size: 13px;
}
.cs__user-empty { color: var(--muted); text-align: center; padding: 40px 0; }
.cs__user-title { font-weight: 700; margin-bottom: 12px; font-size: 14px; }
.cs__user-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.cs__user-row:last-child { border-bottom: 0; }
.cs__user-row span:first-child { color: var(--muted); flex: 0 0 auto; }
.cs__user-row span:last-child { text-align: right; word-break: break-all; }

/* ============ 用戶詳情頁 ============ */
.detail-profile {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.detail-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #7c5cff);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}
.detail-profile__main { flex: 1; min-width: 160px; }
.detail-profile__name {
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-profile__sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.detail-profile__stats { display: flex; gap: 28px; }
.detail-profile__stat .k { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.detail-profile__stat .v { font-size: 18px; font-weight: 700; color: var(--navy); }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px 20px;
}
.detail-cell .k { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.detail-cell .v { font-size: 14px; word-break: break-all; }

