:root {
  --primary: #e8927c;
  --primary-dark: #d4806a;
  --primary-light: #f5d5ca;
  --bg: #faf8f5;
  --card: #ffffff;
  --text: #2d2d2d;
  --text-secondary: #999;
  --text-light: #bbb;
  --border: #ede8e2;
  --danger: #e87c7c;
  --success: #7cb890;
  --warning: #d4a574;
  --chat-self: #f5d5ca;
  --chat-other: #ffffff;
  --header-bg: #faf8f5;
  --nav-bg: #fff;
  --nav-border: #ede8e2;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
}

.page {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

#login-page {
  background: linear-gradient(180deg, #f5e6e0 0%, var(--bg) 100%);
  justify-content: center;
  align-items: center;
}

.login-logo {
  text-align: center;
  margin-bottom: 48px;
}

.logo-circle {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
  font-size: 32px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 4px 16px rgba(232, 146, 124, 0.3);
}

.login-logo h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.login-form {
  width: 100%;
  max-width: 320px;
  padding: 0 24px;
}

.form-item {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  margin-bottom: 8px;
}

.form-icon {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  margin-right: 12px;
  flex-shrink: 0;
}

.form-item input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  color: var(--text);
  background: transparent;
}

.form-item input::placeholder { color: var(--text-light); }

.btn-login {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 28px;
  transition: background 0.2s, transform 0.15s;
  box-shadow: 0 2px 8px rgba(232, 146, 124, 0.25);
}

.btn-login:active { background: var(--primary-dark); transform: scale(0.98); }

#main-page {
  background: var(--bg);
}

.main-page {
  display: none;
  flex-direction: column;
  position: absolute;
  top: 0; left: 0; right: 0;
  bottom: 56px;
}

.main-page.active { display: flex; }

.page-header {
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  background: var(--header-bg);
  flex-shrink: 0;
}

.page-header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.scroll-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--nav-bg);
  border-top: 0.5px solid var(--nav-border);
  display: flex;
  z-index: 100;
  box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.03);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  position: relative;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.nav-item.active { color: var(--primary); }

.nav-item svg {
  width: 24px;
  height: 24px;
}

.nav-item span {
  font-size: 10px;
}

.nav-badge {
  position: absolute;
  top: 4px;
  right: 50%;
  margin-right: -20px;
  min-width: 16px;
  height: 16px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.chat-list-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--card);
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.chat-list-item:active { background: #f5f0eb; }

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 500;
  flex-shrink: 0;
  position: relative;
}

.chat-avatar .online-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--card);
}

.chat-info {
  flex: 1;
  margin-left: 12px;
  overflow: hidden;
}

.chat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.chat-name {
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-time {
  font-size: 12px;
  color: var(--text-light);
  flex-shrink: 0;
  margin-left: 8px;
}

.chat-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-last-msg {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.chat-unread {
  min-width: 18px;
  height: 18px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  margin-left: 8px;
  flex-shrink: 0;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg);
  margin: 8px 12px;
  padding: 8px 12px;
  border-radius: 6px;
}

.search-box svg {
  width: 16px;
  height: 16px;
  color: var(--text-light);
  margin-right: 8px;
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  color: var(--text);
}

.search-box input::placeholder { color: var(--text-light); }

.cell-group {
  background: var(--card);
  margin-top: 8px;
}

.cell {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.cell:active { background: #f5f0eb; }
.cell:last-child { border-bottom: none; }

.cell-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cell-icon svg {
  width: 20px;
  height: 20px;
}

.cell-body {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-left: 14px;
  font-size: 16px;
}

.cell-arrow::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-top: 1.5px solid var(--text-light);
  border-right: 1.5px solid var(--text-light);
  transform: rotate(45deg);
}

.cell-logout { justify-content: center; }

.me-header {
  display: flex;
  align-items: center;
  padding: 24px 16px 20px;
  background: var(--card);
  border-bottom: 0.5px solid var(--border);
}

.me-avatar {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 500;
  flex-shrink: 0;
}

.me-info {
  margin-left: 16px;
}

.me-name {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.me-id {
  font-size: 13px;
  color: var(--text-secondary);
}

.detail-header {
  display: flex;
  align-items: center;
  padding: 0 12px;
  height: 56px;
  background: var(--header-bg);
  flex-shrink: 0;
  border-bottom: 0.5px solid var(--border);
}

.detail-back {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.detail-back svg {
  width: 24px;
  height: 24px;
  color: var(--text);
}

.detail-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  margin: 0 8px;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.action-btn.danger { background: #fef0f0; color: var(--danger); }
.action-btn.success { background: #f0f9eb; color: var(--success); }

.chat-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px;
  background: var(--bg);
}

.msg-row {
  display: flex;
  margin-bottom: 16px;
  align-items: flex-start;
}

.msg-row.self { justify-content: flex-end; }
.msg-row.other { justify-content: flex-start; }

.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 500;
  color: #fff;
}

.msg-row.other .msg-avatar { background: #576b95; margin-right: 8px; }
.msg-row.self .msg-avatar { background: var(--primary); margin-left: 8px; order: 1; }

.msg-content-wrap {
  max-width: 65%;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

.msg-row.other .msg-bubble {
  background: var(--chat-other);
  color: var(--text);
}

.msg-row.self .msg-bubble {
  background: var(--chat-self);
  color: var(--text);
}

.msg-bubble img {
  max-width: 180px;
  border-radius: 4px;
  display: block;
}

.msg-bubble video {
  max-width: 220px;
  border-radius: 4px;
}

.msg-time-label {
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  margin: 12px 0;
}

.chat-footer {
  background: var(--card);
  border-top: 0.5px solid var(--border);
  flex-shrink: 0;
}

.chat-toolbar {
  display: flex;
  padding: 6px 12px;
  gap: 4px;
}

.tool-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border-radius: 8px;
  transition: background 0.15s;
}

.tool-btn:active { background: var(--bg); }
.tool-btn svg { width: 22px; height: 22px; color: var(--text-secondary); }

.emoji-panel {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg);
  max-height: 160px;
  overflow-y: auto;
}

.emoji-item {
  font-size: 24px;
  text-align: center;
  padding: 4px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}

.emoji-item:active { background: var(--border); }

.chat-input-row {
  display: flex;
  padding: 8px 12px;
  gap: 8px;
  align-items: flex-end;
}

.chat-input-row input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  color: var(--text);
}

.chat-input-row input::placeholder { color: var(--text-light); }

.btn-send {
  padding: 10px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

.btn-send:active { background: var(--primary-dark); transform: scale(0.97); }

.sub-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

.sub-section {
  background: var(--card);
  margin-top: 8px;
  padding: 16px;
}

.sub-section-title {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-item {
  background: var(--bg);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.sub-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 0.5px solid var(--border);
}

.sub-list-item:last-child { border-bottom: none; }

.sub-item-info { flex: 1; }
.sub-item-name { font-size: 15px; font-weight: 500; }
.sub-item-detail { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.sub-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  margin-left: 8px;
}

.sub-btn.danger { background: #fef0f0; color: var(--danger); }
.sub-btn.success { background: #f0f7f2; color: var(--success); }
.sub-btn.primary { background: #f5e6e0; color: var(--primary); }

.sub-form-item {
  margin-bottom: 12px;
}

.sub-form-item label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.sub-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  background: var(--card);
}

.sub-input:focus { border-color: var(--primary); }

.sub-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  background: var(--card);
}

.sub-textarea:focus { border-color: var(--primary); }

.sub-btn-full {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 12px;
  transition: background 0.2s, transform 0.15s;
}

.sub-btn-full:active { background: var(--primary-dark); transform: scale(0.98); }

.sub-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.sub-row .sub-input { flex: 1; }

.sub-row .sub-btn { margin-left: 0; margin-top: 0; padding: 10px 16px; }

.sub-switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
}

.sub-switch-row span { font-size: 15px; }

.switch {
  position: relative;
  width: 48px;
  height: 28px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch .slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ddd;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.3s;
}

.switch .slider::before {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
}

.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.sub-type-btns {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}

.sub-type-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.sub-type-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: #f0fff4;
}

.upload-area {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-area:active { border-color: var(--primary); background: rgba(232, 146, 124, 0.04); }

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 14px;
}

.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  animation: fadeInOut 2s ease;
  pointer-events: none;
}

@keyframes fadeInOut {
  0% { opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

.customer-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--card);
  border-bottom: 0.5px solid var(--border);
}

.customer-item:active { background: #ececec; }

.customer-avatar {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: #576b95;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  flex-shrink: 0;
}

.customer-info {
  flex: 1;
  margin-left: 12px;
}

.customer-name {
  font-size: 16px;
  font-weight: 400;
}

.customer-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.customer-actions {
  display: flex;
  gap: 6px;
}

.ip-tab-nav {
  display: flex;
  background: var(--card);
  border-bottom: 0.5px solid var(--border);
}

.ip-tab-btn {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.ip-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

select.sub-input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.video-card {
  display: flex;
  align-items: center;
  background: var(--card);
  margin: 8px 12px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.video-thumb {
  width: 100px;
  height: 70px;
  background: linear-gradient(135deg, #576b95, #07c160);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-thumb .play-icon {
  width: 32px;
  height: 32px;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  padding: 6px;
}

.video-info {
  flex: 1;
  padding: 12px;
  overflow: hidden;
}

.video-title {
  font-size: 15px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.video-delete {
  padding: 8px 14px;
  margin-right: 12px;
  background: #fef0f0;
  color: var(--danger);
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
