:root {
  --primary: #22c55e;
  --primary-dark: #16a34a;
  --primary-light: #dcfce7;
  --bg: #f4f6f8;
  --card: #fff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #ef4444;
  --shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); }
button, input, textarea { font: inherit; }
a { color: var(--primary-dark); text-decoration: none; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f0ffe0 0%, #f8fafc 50%, #eef7ff 100%);
}

.login-card {
  width: min(420px, 92vw);
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-card h1 { margin: 0 0 8px; font-size: 24px; }
.login-card p { margin: 0 0 24px; color: var(--muted); }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 14px; color: var(--muted); }
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  cursor: pointer;
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 88%, #fff) 0%, var(--primary) 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover:not(:disabled) {
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary-dark) 82%, #fff) 0%, var(--primary-dark) 100%);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 28%, transparent);
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn.secondary:hover:not(:disabled) {
  background: var(--primary-light);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  color: var(--primary-dark);
  box-shadow: none;
}
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  box-shadow: none;
}
.btn.ghost:hover:not(:disabled) {
  background: #f8fafc;
  color: var(--text);
  border-color: var(--border);
  box-shadow: none;
}
.btn.tool,
.btn.btn-tool {
  background: #fff;
  color: var(--primary-dark);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--border));
  box-shadow: none;
}
.btn.tool:hover:not(:disabled),
.btn.btn-tool:hover:not(:disabled) {
  background: var(--primary-light);
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
  color: var(--primary-dark);
  box-shadow: none;
}
.btn.warning,
.btn.btn-warning {
  background: #fff;
  color: #b45309;
  border: 1px solid #fcd34d;
  box-shadow: none;
}
.btn.warning:hover:not(:disabled),
.btn.btn-warning:hover:not(:disabled) {
  background: #fffbeb;
  border-color: #f59e0b;
  color: #92400e;
  box-shadow: none;
}
.btn.warning.active,
.btn.btn-warning.active {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}
.btn.danger,
.btn.btn-danger {
  background: linear-gradient(180deg, #f87171 0%, var(--danger) 100%);
  border: none;
  color: #fff;
}
.btn.danger:hover:not(:disabled),
.btn.btn-danger:hover:not(:disabled) {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.28);
}
.btn.busy-on {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fcd34d;
  box-shadow: none;
}
.btn.busy-on:hover:not(:disabled) {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}
.btn.quick-action {
  background: #fff;
  border: 1px dashed color-mix(in srgb, var(--primary) 35%, var(--border));
  color: var(--primary-dark);
  box-shadow: none;
}
.btn.quick-action:hover:not(:disabled) {
  background: var(--primary-light);
  border-style: solid;
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.is-loading { position: relative; pointer-events: none; }
.hint { margin-top: 16px; font-size: 13px; color: var(--muted); }

.landing-card .landing-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.landing-card .landing-links .btn {
  text-align: center;
  text-decoration: none;
}
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin-bottom: 8px; }

.agent-app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 0 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.status-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  font-size: 12px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
  white-space: nowrap;
}
.status-pill.off { background: #fee2e2; color: #b91c1c; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-agent-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-btn-group .btn,
.topbar-actions .btn {
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  border-radius: 8px;
  white-space: nowrap;
}

.topbar-btn-group .btn.ghost {
  color: var(--muted);
}

.topbar-btn-group .btn.busy-on {
  height: 36px;
  padding: 0 14px;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 300px 1fr 300px;
}

.panel {
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel:last-child { border-right: none; border-left: 1px solid var(--border); }
.panel-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  flex-shrink: 0;
}
.panel-body { flex: 1; overflow: auto; padding: 12px; }

.panel.guests {
  min-height: 0;
}

.guest-panel-head .guest-count-total {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.guest-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  flex-shrink: 0;
}

.guest-page-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.guest-page-size select {
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}

.guest-stat {
  display: inline-flex;
  align-items: center;
  height: 28px;
  font-size: 12px;
  font-weight: 600;
  padding: 0 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.guest-stat.online {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, #fff);
}

.guest-stat.offline {
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid #d1d5db;
}

.guest-list-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px !important;
}

.guest-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  flex-shrink: 0;
}

.guest-pagination .btn {
  min-width: 72px;
}

.guest-pagination[hidden] { display: none; }

.guest-pagination .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.guest-page-info {
  font-size: 12px;
  color: var(--muted);
  min-width: 56px;
  text-align: center;
}

.guest-item {
  position: relative;
  padding: 11px 11px 11px 13px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  margin-bottom: 8px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.guest-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 4px;
}
.guest-item.online {
  background: linear-gradient(90deg, #f0fdf4 0%, #fafafa 28%);
  border-color: #bbf7d0;
}
.guest-item.online::before {
  background: var(--primary);
  box-shadow: 0 0 0 2px rgba(93, 191, 3, 0.15);
}
.guest-item.offline {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  opacity: 0.92;
}
.guest-item.offline::before {
  background: #94a3b8;
}
.guest-item.online:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 18%, transparent);
}
.guest-item.offline:hover {
  border-color: #94a3b8;
  background: #f1f5f9;
}
.guest-item.active.online {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 22%, transparent);
}
.guest-item.active.offline {
  border-color: #64748b;
  border-style: solid;
  background: #e2e8f0;
  opacity: 1;
}
.guest-status-tag {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.guest-item.online .guest-status-tag {
  background: var(--primary);
  color: #fff;
}
.guest-item.offline .guest-status-tag {
  background: #94a3b8;
  color: #fff;
}
.guest-item.offline .name,
.guest-item.offline .preview {
  color: #64748b;
}
.guest-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}
.guest-item-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.guest-item .name {
  font-weight: 600;
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.guest-item .connect-time {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}
.guest-item .preview {
  font-size: 12px;
  color: #64748b;
  line-height: 1.45;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.guest-item .preview.empty-preview { color: #cbd5e1; font-style: italic; }
.guest-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}
.guest-item .region {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.guest-item .last-time { flex-shrink: 0; }
.badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  text-align: center;
}

.chat-area {
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}
.chat-back-btn {
  display: none;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.chat-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #fff;
  flex-shrink: 0;
  min-height: 64px;
}
.chat-head-main { min-width: 0; flex: 1; }
.chat-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.chat-guest-name {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-subline {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.guest-status-pill {
  flex-shrink: 0;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.guest-status-pill.online { background: var(--primary-light); color: var(--primary-dark); }
.guest-status-pill.offline { background: #f3f4f6; color: #6b7280; }
.guest-status-pill.banned { background: #fee2e2; color: #b91c1c; }

.guest-item.banned {
  border-color: #fecaca;
  background: #fff7f7;
}

.guest-item.banned .guest-status-tag {
  background: #ef4444;
  color: #fff;
}
.chat-head .toolbar,
.chat-head .chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex-shrink: 0;
}

.chat-head .chat-toolbar .btn {
  height: 32px;
  min-width: 68px;
  padding: 0 12px;
}

.chat-action-warn {
  color: #b45309 !important;
  border-color: #fcd34d !important;
  background: #fff !important;
  box-shadow: none !important;
}

.chat-action-warn:hover:not(:disabled) {
  background: #fffbeb !important;
  border-color: #f59e0b !important;
  color: #92400e !important;
}

.chat-action-warn.active {
  background: #fef3c7 !important;
  border-color: #f59e0b !important;
  color: #92400e !important;
}

.btn-sm {
  padding: 0 12px;
  height: 32px;
  font-size: 13px;
  border-radius: 8px;
}
.guest-compose textarea {
  min-height: 64px;
}
.chat-messages {
  flex: 1;
  overflow: auto;
  padding: 18px;
  background: var(--chat-messages-bg, linear-gradient(180deg, #fafafa, #fff));
}
.chat-input {
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  background: #fff;
  flex-shrink: 0;
}

.guest-compose .btn,
.chat-input .btn {
  height: 44px;
  min-width: 72px;
  padding: 0 18px;
  align-self: end;
}
.chat-input textarea {
  min-height: 72px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: var(--chat-input-radius, 12px);
  padding: 12px;
  outline: none;
}
.chat-input textarea:focus { border-color: var(--primary); }

.msg {
  display: flex;
  margin-bottom: 16px;
  max-width: 78%;
}
.msg-me { margin-left: auto; justify-content: flex-end; }
.msg-them { justify-content: flex-start; }
.msg.system { margin: 0 auto 14px; max-width: 100%; justify-content: center; }
.msg-inner { max-width: 100%; }
.msg-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.msg-me .msg-label { text-align: right; color: var(--primary-dark); }
.msg-them .msg-label { text-align: left; }
.bubble {
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.5;
  word-break: break-word;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.msg-me .bubble {
  background: var(--bubble-agent, var(--primary));
  color: var(--bubble-agent-text, #fff);
  border-color: transparent;
  border-radius: var(--bubble-me-radius, 14px 14px 4px 14px);
}
.msg-them .bubble {
  background: var(--bubble-guest, #f8fafc);
  color: var(--bubble-guest-text, inherit);
  border-color: var(--bubble-guest-border, #dbe3ee);
  border-radius: var(--bubble-them-radius, 14px 14px 14px 4px);
}
.msg.system .bubble { background: #f3f4f6; color: var(--muted); font-size: 13px; box-shadow: none; }
.msg-time { font-size: 11px; color: var(--muted); margin-top: 4px; }
.msg-me .msg-time { text-align: right; }

.team-msg { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--border); }
.team-msg .who { font-size: 13px; color: var(--muted); }
.team-msg .who strong { color: var(--text); }
.team-msg.me .who strong { color: var(--primary-dark); }

.agent-list li, .phrase-list li {
  list-style: none;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  background: #fafafa;
  cursor: pointer;
}
.agent-list li:hover, .phrase-list li:hover { background: var(--primary-light); }
.phrase-list li { position: relative; padding-right: 28px; }
.phrase-list .del {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  cursor: pointer;
}
.tabs {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  flex-shrink: 0;
}

.tab {
  flex: 1;
  text-align: center;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab:hover {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.tab.active {
  background: #fff;
  color: var(--primary-dark);
  border-color: var(--border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.panel.team {
  min-height: 0;
}

.team-panel-body,
.phrase-panel-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px;
  gap: 0;
}

.team-messages {
  flex: 1;
  min-height: 120px;
  overflow: auto;
  margin-bottom: 0;
}

.panel-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-compose textarea {
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  width: 100%;
}

.panel-compose textarea:focus {
  border-color: var(--primary);
}

.panel-compose .btn {
  height: 44px;
  min-width: 64px;
  padding: 0 16px;
  align-self: end;
}

.panel-subhead {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding: 14px 0 8px;
  margin: 0;
  border: none;
}

.team-agents-section {
  flex-shrink: 0;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.agent-list {
  margin: 0;
  padding: 0;
}

.phrase-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 0;
}
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar .btn { padding: 8px 12px; font-size: 13px; }

.guest-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #f0ffe0, #fff);
}
.guest-card {
  width: min(480px, 96vw);
  height: min(720px, 92vh);
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}
.guest-header {
  padding: 18px 20px;
  background: var(--primary);
  color: #fff;
}
.guest-header h2 { margin: 0; font-size: 18px; }
.guest-header p { margin: 6px 0 0; opacity: 0.9; font-size: 13px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10050;
}
.toast.show { opacity: 1; }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  z-index: 9999;
  padding: 20px;
}

.modal-mask[hidden] { display: none; }

.modal {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: hidden;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.faq-modal {
  width: min(720px, 96vw);
}

.faq-modal .modal-body {
  flex: 1;
  min-height: 0;
  max-height: min(70vh, 560px);
  overflow: auto;
}

.settings-modal {
  width: min(840px, 94vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 13px;
}

.settings-modal .modal-head {
  padding: 12px 16px;
}

.settings-modal .modal-head h3 {
  font-size: 15px;
  font-weight: 700;
}

.settings-modal .modal-close {
  font-size: 22px;
  line-height: 1;
}

.settings-layout {
  display: grid;
  grid-template-columns: 168px 1fr;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  border-right: 1px solid var(--border);
  background: #f8fafc;
  overflow: auto;
}

.settings-nav-item {
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.settings-nav-item:hover {
  background: #eef2f7;
}

.settings-nav-item.active {
  background: var(--primary-light, #dcfce7);
  color: var(--primary-dark, #16a34a);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--primary);
}

.settings-panes {
  overflow: auto;
  padding: 14px 16px 16px;
  min-height: 0;
  max-height: calc(88vh - 50px);
}

.settings-pane {
  display: none;
  max-width: 640px;
}

.settings-pane.active {
  display: block;
}

.settings-modal-head {
  flex-shrink: 0;
}

.settings-pane#settingsPane-accounts,
.settings-pane#settingsPane-appearance,
.settings-pane#settingsPane-guest {
  max-width: none;
}

.settings-modal .settings-pane > .btn {
  margin-top: 2px;
}

.settings-modal .settings-pane > .btn + .settings-subsection,
.settings-modal .settings-pane > .settings-subsection + .btn {
  margin-top: 10px;
}

.settings-modal .settings-pane > .field + .btn {
  margin-top: 4px;
}

.settings-pane-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.settings-modal .session-hint {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.settings-modal .check-row {
  margin-bottom: 6px;
  font-size: 13px;
  gap: 6px;
}

.settings-modal .field {
  margin-bottom: 0;
}

.settings-modal .field label {
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.settings-modal .field input,
.settings-modal .field select,
.settings-modal .field textarea {
  padding: 7px 10px;
  font-size: 13px;
  border-radius: 8px;
  line-height: 1.4;
}

.settings-modal .field textarea {
  min-height: 0;
  resize: vertical;
}

.settings-modal .field input:focus,
.settings-modal .field select:focus,
.settings-modal .field textarea:focus {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 16%, transparent);
}

.settings-modal .btn {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: 8px;
  font-weight: 600;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 16px;
  margin-bottom: 12px;
}

.settings-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  margin-bottom: 12px;
}

.settings-form-grid .full-width {
  grid-column: 1 / -1;
}

.settings-subsection {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfc;
}

.settings-subsection .settings-subsection {
  margin-top: 10px;
  padding: 10px;
  background: #fff;
}

.settings-subsection h5 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.settings-subsection .session-hint {
  margin-bottom: 8px;
}

.settings-pane-actions {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.settings-pane-actions .btn {
  min-width: 96px;
}

.settings-quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-quick-btns .btn {
  min-width: 120px;
}

.notify-sound-section {
  margin-top: 12px;
}

.notify-sound-section + .notify-sound-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.notify-sound-section-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.notify-sound-grid {
  margin-bottom: 0;
}

.notify-sound-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notify-sound-row select {
  flex: 1;
  min-width: 0;
}

.notify-sound-row .btn {
  flex-shrink: 0;
  min-width: 56px;
}

.settings-modal .contact-editor-item,
.settings-modal .faq-editor-item {
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 10px;
}

.contact-locale-block {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border, #e5e7eb);
}

.contact-locale-block:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.contact-locale-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted, #6b7280);
}

.settings-modal .faq-editor-item .field {
  margin-bottom: 8px;
}

.settings-modal .faq-editor-item .field:last-child {
  margin-bottom: 0;
}

.account-toolbar {
  margin-bottom: 10px;
}

.account-toolbar .btn {
  min-width: 108px;
}

.account-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.account-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.account-table th,
.account-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.account-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.account-table tr:last-child td {
  border-bottom: none;
}

.account-table .account-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.account-table .btn-sm {
  height: 28px;
  padding: 0 8px;
  font-size: 11px;
}

.account-form {
  margin-top: 12px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid var(--border);
}

@media (max-width: 768px) {
  .settings-modal {
    width: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-nav {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px;
  }

  .settings-nav-item {
    flex: 1 1 auto;
    min-width: 96px;
    text-align: center;
  }

  .settings-form-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-panes {
    max-height: calc(100dvh - 120px);
    padding: 12px;
  }

  .settings-pane {
    max-width: none;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 { margin: 0; }
.modal-close {
  border: none;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
}

.modal-body { padding: 18px; }
.settings-section + .settings-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.settings-section h4 { margin: 0 0 12px; }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 14px;
}

.field select,
.field textarea,
.field input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.field select { background: #fff; }

.session-hint {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.7;
}

.session-info {
  margin: 0 0 16px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: #334155;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
  background: #fafafa;
  flex-shrink: 0;
}

.modal-actions .btn {
  min-width: 88px;
}

.session-card .modal-actions {
  justify-content: center;
  border-top: none;
  background: transparent;
  padding: 0;
  margin-top: 20px;
}

.session-overlay {
  position: fixed;
  inset: 0;
  background: rgba(248, 250, 252, 0.97);
  z-index: 9998;
  display: grid;
  place-items: center;
  padding: 24px;
}

.session-overlay[hidden] { display: none; }

.session-card {
  width: min(440px, 100%);
  text-align: center;
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.session-card h3 { margin: 0 0 12px; }
.session-card p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.7;
}

.guest-detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.25);
  z-index: 20;
}
.guest-detail-backdrop[hidden] { display: none; }

.guest-detail-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: min(360px, 92%);
  height: 100%;
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 30px rgba(15, 23, 42, 0.08);
  z-index: 21;
  display: flex;
  flex-direction: column;
}
.guest-detail-drawer[hidden] { display: none; }

.guest-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.guest-detail-head h3 { margin: 0; font-size: 16px; }

.guest-detail-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

.detail-group { margin-bottom: 18px; }
.detail-group h4 {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.detail-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
  line-height: 1.5;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--muted); }
.detail-row .value {
  word-break: break-all;
  color: var(--text);
}
.detail-row .value a { color: var(--primary-dark); }

.empty-hint {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  margin: 40px 0;
}

.transfer-modal {
  width: min(480px, 100%);
}

.transfer-agent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(50vh, 360px);
  overflow: auto;
  margin-bottom: 8px;
}

.transfer-agent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.transfer-agent-item:hover:not(:disabled) {
  border-color: var(--primary, #5dbf03);
  background: var(--primary-light, #e8f8d8);
  box-shadow: 0 2px 8px rgba(93, 191, 3, 0.12);
}

.transfer-agent-item:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #f8fafc;
}

.transfer-agent-name {
  font-weight: 600;
  color: var(--text);
}

.transfer-agent-post {
  flex: 1;
  color: var(--muted);
  font-size: 13px;
}

.transfer-agent-busy {
  font-size: 12px;
  color: #b45309;
  background: #fffbeb;
  padding: 2px 8px;
  border-radius: 999px;
}

.faq-editor-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fafafa;
}

.faq-editor-item .field {
  margin-bottom: 10px;
}

.faq-editor-item .field:last-child {
  margin-bottom: 0;
}

.faq-editor-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.agent-mobile-nav {
  display: none;
}

@media (max-width: 900px) {
  .topbar {
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .brand span:last-child {
    font-size: 15px;
  }

  .topbar-agent-name,
  #agentName {
    display: none;
  }

  .topbar-actions {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .topbar-btn-group {
    gap: 6px;
  }

  .topbar-actions .btn,
  .topbar-btn-group .btn {
    padding: 0 10px;
    height: 34px;
    font-size: 12px;
  }

  .status-pill {
    font-size: 11px;
    padding: 3px 8px;
  }

  .agent-app.agent-mobile {
    grid-template-rows: auto 1fr auto;
  }

  .agent-app.agent-mobile .agent-mobile-nav {
    display: flex;
    border-top: 1px solid var(--border);
    background: #fff;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    gap: 6px;
    flex-shrink: 0;
  }

  .agent-mobile-nav-item {
    flex: 1;
    border: none;
    background: transparent;
    border-radius: 10px;
    padding: 10px 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
  }

  .agent-mobile-nav-item.active {
    background: var(--primary-light);
    color: var(--primary-dark);
  }

  .agent-app.agent-mobile .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    display: block;
    min-height: 0;
    overflow: hidden;
  }

  .agent-app.agent-mobile .workspace > .panel.guests,
  .agent-app.agent-mobile .workspace > .chat-area,
  .agent-app.agent-mobile .workspace > .panel.team {
    display: none;
    height: 100%;
    max-height: none;
    border: none;
    min-height: 0;
  }

  .agent-app.agent-mobile.mobile-tab-guests .workspace > .panel.guests {
    display: flex;
  }

  .agent-app.agent-mobile.mobile-tab-chat .workspace > .chat-area {
    display: flex;
  }

  .agent-app.agent-mobile.mobile-tab-team .workspace > .panel.team {
    display: flex;
  }

  .chat-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .chat-head {
    padding: 10px 12px;
    align-items: flex-start;
  }

  .chat-head .toolbar {
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
  }

  .chat-head .toolbar .btn-sm {
    padding: 6px 10px;
    font-size: 12px;
  }

  .guest-compose textarea,
  .chat-input textarea {
    min-height: 44px;
    font-size: 16px;
  }

  .guest-detail-drawer {
    width: 100%;
    max-width: 100%;
  }

  .settings-modal {
    width: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }

  .settings-panes {
    max-height: calc(100dvh - 120px);
  }

  .modal-mask {
    padding: 0;
    align-items: stretch;
  }

  .modal:not(.settings-modal) {
    width: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }
}

/* Appearance settings (settings modal) */
.settings-modal .appearance-section {
  margin-bottom: 12px;
}

.settings-modal .appearance-section-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.settings-modal .style-gallery {
  margin-bottom: 0;
}

.settings-modal .style-card-grid {
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 8px;
}

.settings-modal .style-card,
.settings-modal .color-card,
.settings-modal .theme-card {
  gap: 6px;
  padding: 8px;
  border-width: 1px;
  border-radius: 10px;
}

.settings-modal .style-card-preview {
  padding: 6px;
  border-radius: 8px;
}

.settings-modal .style-card-header {
  height: 14px;
}

.settings-modal .style-card-body {
  padding: 6px;
  gap: 4px;
}

.settings-modal .style-card-bubble {
  height: 8px;
}

.settings-modal .style-card-desc {
  font-size: 10px;
  line-height: 1.35;
}

.settings-modal .color-card-swatches span {
  height: 28px;
  border-radius: 6px;
}

.settings-modal .color-gallery {
  max-height: none;
}

.settings-modal .theme-gallery {
  gap: 12px;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.settings-modal .theme-category-title {
  margin: 0 0 6px;
  font-size: 11px;
}

.settings-modal .theme-card-grid,
.settings-modal .color-card-grid {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.settings-modal .theme-card-preview {
  padding: 6px;
  min-height: 72px;
  border-radius: 8px;
}

.settings-modal .theme-card-header {
  height: 16px;
  padding: 0 6px;
}

.settings-modal .theme-card-footer {
  gap: 4px;
}

.settings-modal .theme-card-name {
  font-size: 11px;
}

.settings-modal .theme-card-badge {
  font-size: 10px;
  padding: 1px 6px;
}

.style-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.style-card,
.color-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.style-card:hover,
.color-card:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.style-card.active,
.color-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}

.style-card-preview {
  background: #f1f5f9;
  border-radius: 10px;
  padding: 8px;
}

.style-card-window {
  background: #fff;
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.style-card-header {
  height: 18px;
  background: linear-gradient(90deg, #94a3b8, #64748b);
}

.style-card-header.style-header-solid {
  background: #64748b;
}

.style-card-header.style-header-glass {
  background: color-mix(in srgb, #64748b 70%, transparent);
}

.style-card-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.style-card-bubble {
  height: 10px;
  background: #e2e8f0;
}

.style-card-bubble.me {
  width: 58%;
  margin-left: auto;
  background: #64748b;
}

.style-card-bubble.them {
  width: 72%;
}

.style-card-desc {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.color-card-swatches {
  display: flex;
  gap: 6px;
  padding: 4px 0;
}

.color-card-swatches span {
  flex: 1;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.color-gallery {
  max-height: min(40vh, 400px);
}

/* Theme gallery */
.theme-gallery {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: min(52vh, 520px);
  overflow: auto;
  padding-right: 4px;
}

.theme-category-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.theme-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
}

.theme-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.theme-card:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.theme-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}

.theme-card-preview {
  border-radius: 10px;
  padding: 8px;
  min-height: 96px;
}

.theme-card-window {
  background: #fff;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.theme-card-header {
  height: 22px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.theme-card-header span {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
}

.theme-card-header span:first-child { width: 42%; }
.theme-card-header span:last-child { width: 18%; }

.theme-card-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.theme-card-bubble {
  height: 10px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.theme-card-bubble.them {
  width: 72%;
  border-bottom-left-radius: 3px;
}

.theme-card-bubble.me {
  width: 58%;
  margin-left: auto;
  border-bottom-right-radius: 3px;
}

.theme-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.theme-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.theme-card-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

#settingsPane-appearance .settings-pane-actions {
  position: sticky;
  bottom: 0;
  margin-top: 12px;
  padding-top: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #fff 40%);
}

/* Topbar guestbook badge */
.topbar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* Guestbook admin page */
body.guestbook-admin-page {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

.guestbook-admin-app {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.guestbook-admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.guestbook-admin-brand {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.guestbook-admin-brand .dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--primary);
}

.guestbook-admin-brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.3;
}

.guestbook-admin-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.guestbook-admin-topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.guestbook-admin-topbar-actions .btn,
.guestbook-admin-topbar-actions a.btn {
  text-decoration: none;
  white-space: nowrap;
}

.guestbook-admin-main {
  padding: 20px;
  min-width: 0;
}

.guestbook-page-nav {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.guestbook-page-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 18px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.guestbook-page-tab:hover {
  color: var(--text);
}

.guestbook-page-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.guestbook-page-section {
  max-width: 1120px;
  margin: 0 auto;
  width: 100%;
}

.guestbook-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.guestbook-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.guestbook-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.guestbook-filter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  margin: 0;
}

.guestbook-filter-label {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.guestbook-filter select {
  min-width: 140px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
  background: #fff;
  color: var(--text);
}

.guestbook-pending-stat {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--primary-light);
  white-space: nowrap;
}

.guestbook-table-wrap {
  overflow: auto;
}

.guestbook-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.guestbook-table th,
.guestbook-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.guestbook-table th {
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.guestbook-table tbody tr:hover {
  background: #fafafa;
}

.guestbook-table tr:last-child td {
  border-bottom: none;
}

.guestbook-table .empty-hint {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
}

.gb-col-actions {
  width: 96px;
  text-align: center !important;
}

.guestbook-table td.gb-col-actions {
  vertical-align: middle;
}

.guestbook-table .gb-view-btn {
  min-width: 64px;
}

.gb-contact-type {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}

.gb-contact-value {
  font-weight: 600;
  word-break: break-all;
}

.gb-content-cell {
  max-width: 320px;
  line-height: 1.45;
}

.gb-source-cell .muted {
  font-size: 12px;
  color: var(--muted);
}

.gb-status {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.gb-status-pending { background: #fef3c7; color: #92400e; }
.gb-status-read { background: #e0e7ff; color: #3730a3; }
.gb-status-done { background: #dcfce7; color: #166534; }

.guestbook-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
}

.guestbook-pagination #pageInfo {
  min-width: 72px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.guestbook-detail-modal {
  width: min(560px, 96vw);
  display: flex;
  flex-direction: column;
}

.guestbook-detail-modal .modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.guestbook-detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
  background: #fafafa;
}

.guestbook-detail-actions-left,
.guestbook-detail-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.guestbook-detail-actions-right {
  margin-left: auto;
  justify-content: flex-end;
}

.guestbook-detail-list {
  margin: 0;
}

.guestbook-detail-list dt {
  font-size: 12px;
  color: var(--muted);
  margin-top: 12px;
}

.guestbook-detail-list dt:first-child {
  margin-top: 0;
}

.guestbook-detail-list dd {
  margin: 4px 0 0;
  line-height: 1.5;
  word-break: break-word;
}

.gb-detail-content {
  white-space: pre-wrap;
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.gb-detail-url {
  font-size: 13px;
  color: var(--muted);
  word-break: break-all;
}

.guestbook-detail-list textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  resize: vertical;
  min-height: 72px;
}

@media (max-width: 768px) {
  .guestbook-admin-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .guestbook-admin-topbar-actions {
    justify-content: flex-start;
  }

  .guestbook-admin-main {
    padding: 12px;
  }

  .guestbook-table th,
  .guestbook-table td {
    padding: 10px 12px;
  }

  .guestbook-detail-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .guestbook-detail-actions-left,
  .guestbook-detail-actions-right {
    width: 100%;
    margin-left: 0;
  }

  .guestbook-detail-actions-right .btn,
  .guestbook-detail-actions-left .btn {
    flex: 1;
  }
}

/* ---- Stats admin ---- */
.stats-admin-page,
.guestbook-admin-page {
  background: var(--bg);
}

.stats-admin-app,
.stats-admin-main {
  min-height: 100vh;
}

.stats-admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.stats-admin-brand {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.stats-admin-brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 6px;
  flex-shrink: 0;
}

.stats-admin-sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.stats-admin-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stats-admin-main {
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.stats-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stats-card.warn strong {
  color: var(--danger, #c0392b);
}

.stats-card-label {
  font-size: 12px;
  color: var(--muted);
}

.stats-card strong {
  font-size: 18px;
  font-weight: 600;
}

.stats-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.stats-toolbar-left,
.stats-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stats-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.stats-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.stats-filter input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
}

.stats-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.stats-table-wrap {
  overflow: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stats-table th,
.stats-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.stats-table th {
  background: var(--bg);
  font-weight: 600;
  white-space: nowrap;
}

.stats-preview {
  max-width: 320px;
  color: var(--muted);
}

.guestbook-stats-grid {
  margin-bottom: 16px;
}

.guestbook-stats-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.guestbook-stats-intro h2 {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.3;
}

.guestbook-stats-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.guestbook-stats-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.guestbook-stats-panel-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.guestbook-stats-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.guestbook-stats-tab {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.guestbook-stats-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.guestbook-stats-panel-body .guestbook-table-wrap {
  overflow: auto;
}

@media (max-width: 768px) {
  .guestbook-page-nav {
    padding: 0 12px;
  }

  .guestbook-page-tab {
    flex: 1;
    text-align: center;
    padding: 12px 10px;
  }

  .guestbook-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .guestbook-toolbar-actions {
    margin-left: 0;
    width: 100%;
  }

  .guestbook-toolbar-actions .btn {
    flex: 1;
  }
}

@media (max-width: 768px) {
  .stats-admin-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .stats-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .stats-admin-main {
    padding: 12px;
  }
}

.embed-icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
}

.embed-icon-card {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  padding: 10px 8px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.embed-icon-card:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}

.embed-icon-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 20%, transparent);
}

.embed-icon-preview {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.embed-icon-preview svg {
  width: 24px;
  height: 24px;
  display: block;
}

.embed-icon-label {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.3;
}
