:root {
  --brand: #0abab5;
  --brand2: #3ec4bd;
  --brand3: #81d8d0;
  --brand-ink: #057a76;
  --grad: linear-gradient(135deg, #0abab5 0%, #3ec4bd 52%, #81d8d0 100%);
  --grad-soft: linear-gradient(180deg, #0abab5 0%, #81d8d0 100%);
  --bg: #eef8f7;
  --card: #ffffff;
  --text: #173b39;
  --muted: #6f8b89;
  --line: #e2efee;
  --ok: #18a97a;
  --warn: #f0a020;
  --bad: #e5534b;
  --shadow: 0 12px 40px rgba(10, 186, 181, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ---------- 顶部 Hero ---------- */
.hero {
  background:
    radial-gradient(900px 320px at 12% -8%, rgba(255,255,255,.28), transparent 55%),
    radial-gradient(700px 260px at 92% 0%, rgba(255,255,255,.18), transparent 55%),
    var(--grad);
  color: #fff;
  padding: 34px 22px 54px;
  text-align: center;
  border-radius: 0 0 30px 30px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  left: 50%; top: 18px;
  transform: translateX(-50%);
  width: 54px; height: 6px;
  border-radius: 6px;
  background: rgba(255,255,255,.5);
}
.hero .mark {
  width: 60px; height: 60px; margin: 6px auto 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  backdrop-filter: blur(4px);
}
.hero .logo { font-size: 25px; font-weight: 700; letter-spacing: 2px; }
.hero .slogan { font-size: 13px; opacity: .94; margin-top: 8px; letter-spacing: 1px; }
.hero .sub { font-size: 13px; opacity: .85; margin-top: 4px; }

.container { max-width: 640px; margin: -34px auto 0; padding: 0 16px 48px; position: relative; z-index: 1; }
.admin { max-width: 1080px; }

/* ---------- 卡片 ---------- */
.card, .panel {
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.card { padding: 26px 22px; margin-top: 0; }
.card h1 { font-size: 21px; margin: 0 0 4px; }
.card .sub { color: var(--muted); font-size: 14px; margin: 0 0 20px; line-height: 1.6; }

label { display: block; font-size: 14px; color: #34514f; margin: 15px 0 4px; font-weight: 600; }
label em { color: var(--bad); font-style: normal; }
input, select, textarea {
  width: 100%; padding: 13px 14px; font-size: 16px; border: 1.5px solid var(--line);
  border-radius: 12px; background: #f6fbfb; margin-top: 6px; font-family: inherit; color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236f8b89' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 3px rgba(10, 186, 181, .14);
}

.btn {
  width: 100%; padding: 14px; font-size: 16px; font-weight: 600; border: none; border-radius: 13px;
  cursor: pointer; margin-top: 22px; background: var(--grad); color: #fff;
  box-shadow: 0 8px 20px rgba(10, 186, 181, .34);
  transition: transform .08s, box-shadow .15s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--line); box-shadow: none; margin-top: 10px; }
.btn.small { width: auto; padding: 9px 16px; font-size: 14px; margin-top: 0; }
.btn.danger { background: var(--bad); box-shadow: none; }

/* ---------- 聊天 ---------- */
.chat {
  background: var(--card); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden;
  margin-top: 0; display: flex; flex-direction: column;
  height: calc(100vh - 120px); min-height: 520px;
}
.chat-header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(8px); }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 600; flex: none; box-shadow: 0 4px 12px rgba(10,186,181,.32); }
.chat-header .name { font-weight: 600; font-size: 15px; }
.chat-header .online { font-size: 12px; color: var(--ok); margin-top: 2px; }
.chat-header .online::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 5px; }

.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; background: #f5fbfa; }
.msg { display: flex; gap: 9px; max-width: 86%; align-items: flex-end; }
.msg .av { width: 32px; height: 32px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: #fff; }
.msg.ai .av { background: var(--grad); }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.user .av { background: #9db4b3; }
.msg .bubble { padding: 11px 14px; border-radius: 15px; font-size: 15px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.msg.ai .bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.msg.user .bubble { background: var(--grad); color: #fff; border-bottom-right-radius: 5px; }
.typing { align-self: flex-start; color: var(--muted); font-size: 13px; padding-left: 41px; display: flex; gap: 4px; align-items: center; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #b8cfcd; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.chat-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); align-items: flex-end; background: #fff; }
.chat-input textarea { flex: 1; margin: 0; border-radius: 14px; min-height: 44px; max-height: 120px; resize: none; }
.chat-input button { width: auto; margin: 0; padding: 12px 20px; border-radius: 14px; }
.end-btn { text-align: center; padding: 8px 12px 12px; }
.end-btn button { margin: 0; width: auto; padding: 7px 16px; font-size: 13px; }

.done-icon { text-align: center; margin: 6px 0 10px; }
.done-icon svg { width: 64px; height: 64px; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,40,40,.42); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 24px; }
.modal { background: #fff; border-radius: 18px; padding: 22px; width: 100%; max-width: 340px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal h3 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.modal .mbtns { display: flex; gap: 10px; }
.modal .mbtns button { flex: 1; margin: 0; }

/* ---------- 后台 ---------- */
.admin-hero { text-align: left; padding: 6px 18px 8px; }
.admin-hero .row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.brand-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-hero .logo { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.admin-hero .slogan { font-size: 13px; }
.hero-meta { font-size: 13px; opacity: .92; margin-top: 8px; line-height: 1.7; text-align: right; }

.topbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.topbar h1 { font-size: 20px; margin: 0; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.tab { padding: 5px 13px; border-radius: 16px; font-size: 13px; cursor: pointer; background: rgba(255,255,255,.18); color: #fff; border: none; transition: background .15s; }
.tab.active { background: #fff; color: var(--brand-ink); font-weight: 600; box-shadow: 0 4px 12px rgba(0,0,0,.10); }
.logout-btn { padding: 6px 14px; border-radius: 18px; font-size: 13px; cursor: pointer; color: #fff; border: 1px solid rgba(255,255,255,.55); background: transparent; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.stat { background: var(--card); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.stat .num { font-size: 28px; font-weight: 700; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat .lbl { font-size: 13px; color: var(--muted); margin-top: 3px; }

.panel { padding: 20px; margin-top: 16px; }
.panel h3 { margin: 0 0 14px; font-size: 16px; }
.row2 { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.col { flex: 1; min-width: 300px; }
.qr-box { text-align: center; padding: 24px; }
.qr-box canvas { border-radius: 8px; }
.qr-url { font-size: 13px; color: var(--muted); word-break: break-all; margin-top: 12px; }

.filter-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding: 14px 16px; }
.filter-bar label { flex: 1; min-width: 130px; margin: 0; font-size: 13px; }
.filter-bar input, .filter-bar select { padding: 9px 12px; font-size: 14px; margin-top: 4px; }
.filter-actions { display: flex; gap: 8px; }
.filter-actions .btn { margin: 0; padding: 12px 20px; width: auto; }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.list-head h3 { margin: 0; }
.status-inline { font-size: 12px; color: var(--muted); font-weight: normal; margin-left: 10px; }
.qr-modal { max-width: 360px; }
.drawer-mask { position: fixed; inset: 0; background: rgba(15,40,40,.42); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .25s ease; }
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(520px, 94vw); background: #fff; z-index: 41; box-shadow: -12px 0 40px rgba(0,0,0,.16); transform: translateX(105%); transition: transform .28s cubic-bezier(.4,0,.2,1); display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); flex: none; }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-close { background: none; border: none; font-size: 28px; cursor: pointer; color: var(--muted); line-height: 1; padding: 0 4px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px 44px; }
.form-modal { max-width: 460px; width: 100%; max-height: 88vh; overflow-y: auto; text-align: left; }
.form-modal h3 { text-align: left; }
.form-modal .mbtns { margin-top: 18px; }
.drawer-body h3 { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 22px 0 10px; color: var(--text); font-weight: 600; }
.drawer-body h3:first-child { margin-top: 0; }
.drawer-body h3::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--grad); flex: none; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.info-item { background: #f6fbfb; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.info-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.info-value { font-size: 14px; font-weight: 600; color: var(--text); word-break: break-all; }
.transcript { display: flex; flex-direction: column; gap: 14px; }
.t-msg { display: flex; flex-direction: column; max-width: 92%; }
.t-msg.ai { align-self: flex-start; align-items: flex-start; }
.t-msg.user { align-self: flex-end; align-items: flex-end; }
.t-role { font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.t-msg.ai .t-role { color: var(--brand-ink); }
.t-bubble { padding: 10px 13px; border-radius: 12px; font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.t-msg.ai .t-bubble { background: #eef8f7; border: 1px solid #d9efed; border-top-left-radius: 4px; }
.t-msg.user .t-bubble { background: #f4f6f7; border: 1px solid #e8ecec; border-top-right-radius: 4px; }
.brand-logo { width: auto; height: auto; max-height: 92px; max-width: 320px; object-fit: contain; display: block; margin: 6px auto 14px; }
.brand-logo.small { width: auto; height: 56px; max-width: 240px; margin: 0; display: inline-block; vertical-align: middle; }
.logo-preview { width: 84px; height: 84px; border-radius: 16px; object-fit: contain; border: 1px solid var(--line); background: #f6fbfb; padding: 6px; margin-top: 10px; }
.logo-row { display: flex; gap: 16px; align-items: flex-start; }
.logo-row .logo-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; background: #f6fbfb; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f6fbfb; }
.cell-sub { font-size: 12px; color: var(--muted); font-weight: normal; }
.tag { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag.done { background: #e4f7ef; color: #0f8f63; }
.tag.doing { background: #e1f4f3; color: #0a8f8a; }
.tag.reg { background: #eef1f1; color: #6b7a79; }
a.view, a.link { color: var(--brand); text-decoration: none; cursor: pointer; font-weight: 500; }
a.danger { color: var(--bad); cursor: pointer; }

.qa { border-left: 3px solid #cfe7e5; margin: 12px 0; padding: 4px 0 4px 13px; }
.qa .q { color: var(--brand-ink); font-weight: 600; font-size: 14px; }
.qa .a { color: #33494a; margin-top: 3px; white-space: pre-wrap; }
.back { display: inline-block; margin-bottom: 12px; color: var(--brand); cursor: pointer; font-size: 14px; font-weight: 500; }

/* 登录 */
.login-wrap { max-width: 400px; margin: 0 auto; padding-top: 24px; }
.login-wrap .hero { margin-bottom: 0; }

/* 管理表单行 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.item-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 4px; border-bottom: 1px solid var(--line); gap: 10px; }
.item-row:last-child { border-bottom: none; }
.item-row .tt { flex: 1; }
.item-row .tt .n { font-weight: 600; font-size: 14px; }
.item-row .tt .d { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: pre-wrap; }
.empty { text-align: center; color: var(--muted); padding: 26px; font-size: 14px; }

/* 报告 Markdown */
.report { line-height: 1.75; font-size: 14px; }
.report h1, .report h2, .report h3 { margin: 18px 0 8px; line-height: 1.4; }
.report h1 { font-size: 20px; }
.report h2 { font-size: 17px; }
.report h3 { font-size: 15px; }
.report p { margin: 8px 0; }
.report table { border-collapse: collapse; margin: 12px 0; width: 100%; }
.report th, .report td { border: 1px solid var(--line); padding: 8px 10px; font-size: 13px; }
.report th { background: #f0f9f8; }
.report blockquote { border-left: 3px solid var(--brand2); margin: 10px 0; padding: 4px 14px; color: #4a5d5c; background: #f4fbfa; border-radius: 0 8px 8px 0; }
.report ul, .report ol { margin: 8px 0; padding-left: 22px; }
.report code { background: #eef5f4; padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.report hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
