:root {
  --bg: #0b0d12;
  --panel: #141820;
  --panel-2: #1a1f2a;
  --line: #2a3140;
  --line-soft: #232933;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --ok: #22c55e;
  --warn: #f59e0b;
  --input-bg: #0d1017;
  --radius: 10px;
  --nav-w: 220px;
  --shadow: 0 12px 40px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
.err { color: #f87171; min-height: 1.2em; margin: 0; }
.hint { color: var(--muted); margin: 0; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: radial-gradient(900px 420px at 50% -10%, rgba(59,130,246,.18), transparent 60%), var(--bg);
}
.login-card {
  width: 100%;
  max-width: 440px;
  padding: 40px 36px 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-brand { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.login-brand .product { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: .02em; }
.login-brand .sub { margin: 0; color: var(--muted); font-size: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input {
  background: var(--input-bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px 14px;
  font: inherit;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button[type="button"] {
  margin-top: 6px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.login-card button[type="button"]:hover { background: var(--accent-hover); }

.admin-shell {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  min-height: 100vh;
}
.admin-nav {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.nav-brand { padding: 18px 16px 14px; border-bottom: 1px solid var(--line); }
.nav-brand .name { font-weight: 700; font-size: 15px; }
.nav-brand .who { margin-top: 4px; color: var(--muted); font-size: 12px; word-break: break-all; }
.nav-list {
  list-style: none;
  margin: 0;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow: auto;
}
.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
}
.nav-item:hover { background: var(--panel-2); }
.nav-item.active {
  background: rgba(59,130,246,.14);
  border-color: rgba(59,130,246,.35);
  color: #93c5fd;
}
.nav-foot {
  padding: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nav-foot a, .nav-foot button {
  text-decoration: none;
  display: block;
  text-align: center;
  width: 100%;
}
.admin-main { min-width: 0; padding: 22px 24px 40px; overflow: auto; }
.panel-title { margin: 0 0 16px; font-size: 20px; font-weight: 650; }
.panel { display: none; }
.panel.active { display: block; }
.payment-config-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.payment-config-view[hidden] { display: none; }
.payment-config-tabs :focus-visible, .payment-config-view:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 3px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.card-desc { margin: -4px 0 14px; color: var(--muted); font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 13px; color: var(--muted); }
.field input, .field textarea, .field select,
.inline-form input, .inline-form select {
  background: var(--input-bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
  width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus,
.inline-form input:focus, .inline-form select:focus {
  outline: none;
  border-color: var(--accent);
}
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.inline-form input, .inline-form select { width: auto; min-width: 140px; flex: 1; }
button, .btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button.ghost, .btn.ghost, a.ghost {
  background: transparent !important;
  border: 1px solid var(--line) !important;
  color: var(--text) !important;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 8px;
  display: inline-block;
}
button.ghost:hover, .btn.ghost:hover, a.ghost:hover {
  border-color: #3a4456 !important;
  background: var(--panel-2) !important;
}
button.danger, .btn.danger {
  background: var(--danger) !important;
  color: #fff !important;
  border: 0 !important;
}
button.danger:hover, .btn.danger:hover { background: var(--danger-hover) !important; }
.file {
  display: inline-flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td {
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 8px;
  text-align: left;
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 550; font-size: 12px; }
td .ghost { padding: 6px 10px; font-size: 12px; margin-right: 6px; }
.identity-cell { overflow-wrap: anywhere; }
.identity-cell > .ghost { margin: 2px 0 2px 8px; white-space: nowrap; }
.identity-dialog { color: var(--text); max-height: calc(100dvh - 32px); overflow: auto; }
.identity-dialog::backdrop { background: rgba(0,0,0,.55); }
.identity-dialog .field { margin: 12px 0; }
.identity-dialog .row-actions { justify-content: flex-end; }
#identityTarget { overflow-wrap: anywhere; }
#identityRoleNote:not(:empty) { color: #fcd68a; }
#identitySaved:empty, #identityError:empty, #identityRoleNote:empty { display: none; }
.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
}
.status-pill.active {
  color: #86efac;
  border-color: rgba(34,197,94,.35);
  background: rgba(34,197,94,.12);
}
.status-pill.disabled {
  color: #fca5a5;
  border-color: rgba(239,68,68,.35);
  background: rgba(239,68,68,.1);
}
.qr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.qr-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel-2);
}
.qr-list .qr-text { min-width: 0; flex: 1; }
.qr-list .qr-title { font-weight: 600; margin-bottom: 2px; }
.qr-list .qr-body { color: var(--muted); font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.check-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.check-row input { width: auto; }


/* 会话概览：列表 + 气泡时间线 */
.conv-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  max-height: min(62vh, 640px);
  overflow: auto;
}
.conv-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--panel-2);
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  width: 100%;
}
.conv-item:hover {
  border-color: rgba(59,130,246,.45);
  background: #1c2433;
}
.conv-item-main { min-width: 0; }
.conv-item-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.conv-item-preview {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item-side {
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
  justify-content: space-between;
}
.conv-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.conv-pill.open {
  color: #86efac;
  border-color: rgba(34,197,94,.35);
  background: rgba(34,197,94,.12);
}
.conv-pill.closed {
  color: #fca5a5;
  border-color: rgba(239,68,68,.35);
  background: rgba(239,68,68,.1);
}
.conv-pill.leave {
  color: #fcd34d;
  border-color: rgba(245,158,11,.35);
  background: rgba(245,158,11,.12);
}
.conv-detail-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.conv-detail-heading { min-width: 0; flex: 1; }
.conv-detail-heading h3 { margin: 0 0 4px; }
.conv-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(68vh, 720px);
  overflow: auto;
  padding: 14px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #0e1219;
}
.admin-bubble {
  max-width: min(78%, 520px);
  padding: 8px 12px;
  border-radius: 12px;
  background: #1d2330;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  flex-shrink: 0;
  align-self: flex-start;
  position: relative;
}
.admin-bubble.staff {
  align-self: flex-end;
  background: #1e3a5f;
}
.admin-bubble.system {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  max-width: 90%;
  text-align: center;
}
.admin-bubble .meta {
  font-size: 11px;
  color: #93c5fd;
  margin-bottom: 4px;
}
.admin-bubble.visitor .meta { color: #a7f3d0; }
.admin-bubble .time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}
.admin-bubble img,
.admin-bubble video {
  max-width: 100%;
  display: block;
  border-radius: 8px;
  margin-top: 6px;
}
.admin-bubble a.file-link {
  color: #93c5fd;
  text-decoration: underline;
  word-break: break-all;
}
.conv-empty {
  padding: 24px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

html.embed-mode .admin-chrome-external { display: none !important; }
html.embed-mode .admin-nav { height: 100vh; }
html.embed-mode .login-wrap { min-height: 100vh; padding: 24px 12px; }
html.embed-mode .login-card { max-width: 400px; padding: 28px 24px; }
html.embed-mode .login-brand .product { font-size: 22px; }

@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav-list { flex-direction: row; flex-wrap: wrap; overflow: visible; }
  .nav-item { width: auto; }
}


/* password show/hide */
.pw-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.pw-wrap.inline {
  display: block;
  flex: 1;
  min-width: 140px;
  width: auto;
}
.pw-wrap input {
  width: 100%;
  padding-right: 52px !important;
}
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent !important;
  border: 0 !important;
  color: var(--muted) !important;
  padding: 4px 8px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  cursor: pointer;
  border-radius: 6px !important;
  line-height: 1.2;
  margin: 0 !important;
  width: auto !important;
  box-shadow: none !important;
}
.pw-toggle:hover {
  color: var(--text) !important;
  background: rgba(255,255,255,.06) !important;
}
.login-card .pw-toggle {
  background: transparent !important;
  color: var(--muted) !important;
  border: 0 !important;
  padding: 4px 8px !important;
  font-weight: 500 !important;
  margin-top: 0 !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
}
.modal-card h3 { margin: 0 0 8px; font-size: 16px; }
.modal-card .card-desc { margin: 0 0 14px; }

.qr-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.qr-form textarea {
  width: 100%; min-height: 72px; resize: vertical;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--text); padding: 8px 10px; font: inherit;
}
.qr-form-actions { display: flex; gap: 8px; align-items: center; }
.qr-actions { display: flex; gap: 6px; flex-shrink: 0; }
.qr-list .qr-actions .ghost { white-space: nowrap; }


.conv-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
  margin: 8px 0 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}
.conv-filter-field {
  margin-bottom: 0;
  min-width: 180px;
}
.conv-filter-field select,
.conv-filter-field input[type="date"] {
  min-width: 180px;
}
.conv-filter-actions {
  margin-top: 0;
  margin-bottom: 2px;
}



/* 修改我的账号：默认折叠，点标题展开 */
.card.card-fold { padding-top: 10px; padding-bottom: 10px; }
.card-fold-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.card-fold-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}
.card-fold-hint {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted);
}
.card-fold-toggle:hover .card-fold-hint { color: var(--accent); }
.card-fold-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
.card-fold-body { margin-top: 12px; }
.card-fold-body[hidden] { display: none !important; }
.card.card-fold.is-open { padding-bottom: 16px; }
/* layout-fix-20261117: admin history items never clip */
.conv-timeline > * { flex-shrink: 0; }
.admin-bubble img, .admin-bubble video { max-width: 100%; height: auto; display: block; }
.account-table-scroll { overflow-x: auto; }
/* img-clarity-20261110d: original-view lightbox for conversation images */
.admin-bubble img {
  cursor: pointer;
}
.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: zoom-out;
}
.img-lightbox.hidden { display: none !important; }
.img-lightbox img {
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: zoom-out;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.receipt-code-form { display: grid; justify-items: start; gap: 4px; }
.receipt-code-form .field { width: min(100%, 420px); }
.receipt-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 4px 12px;
  width: 100%;
}
.receipt-fields .field { min-width: 0; width: 100%; }
.receipt-compact-field { max-width: 320px; }
.receipt-tier-list { display: grid; gap: 9px; margin-bottom: 12px; }
.receipt-tier-remote { white-space: normal; overflow-wrap: anywhere; }
#partnerToolsFields { padding: 0; margin: 0; max-width: 600px; }
#partnerToolsRetry { margin-top: 6px; }
.receipt-code-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr));
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.receipt-code-card {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.receipt-code-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
}
.receipt-code-actions { display: flex; flex-wrap: wrap; gap: 6px; }

#packageFields { padding: 0; margin: 0; border: 0; min-width: 0; }
.package-list { display: grid; gap: 10px; min-width: 0; }
.package-row { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.package-row-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.package-row-heading h3, .package-row h4 { margin: 0; overflow-wrap: anywhere; }
.package-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#packageFields > .package-actions, .package-conflict-actions { margin-top: 12px; }
.package-row-fields { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 8px 12px; margin-top: 8px; }
.package-row-fields .field { margin: 0; min-width: 0; }
.package-description { grid-column: 1 / -1; }
.package-description textarea { font: inherit; resize: vertical; }
.package-row .package-detail { margin: 6px 0 0; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
#packageConflict[hidden], #packageRetry[hidden] { display: none; }
@media (max-width: 560px) {
  .package-row-fields { grid-template-columns: minmax(0, 1fr); }
}
