/* ============================================================
   智蝶AI · AI智能获客助手
   视觉主题：深空玻璃（Deep Space Glass）
   —— 深空底 + 冷色光晕 + 网格底纹 + 半透明玻璃层
   ============================================================ */

/* ============ 1. 设计变量 ============ */

:root {
    /* 背景层 */
    --bg-deep: #05070E;
    --bg-base: #0A0F1C;
    --bg-elevated: #0E1526;

    /* 玻璃层 */
    --glass: rgba(255, 255, 255, 0.042);
    --glass-hover: rgba(255, 255, 255, 0.072);
    --glass-strong: rgba(255, 255, 255, 0.07);
    --line: rgba(255, 255, 255, 0.085);
    --line-strong: rgba(255, 255, 255, 0.16);

    /* 文字 */
    --text: #EAF1FF;
    --text-muted: #93A5BF;
    --text-dim: #5E6F8A;

    /* 强调色 */
    --cyan: #22D3EE;
    --blue: #6366F1;
    --accent: linear-gradient(135deg, #22D3EE 0%, #6366F1 100%);
    --accent-soft: rgba(34, 211, 238, 0.12);

    /* 语义色 */
    --success: #34D399;
    --warning: #FBBF24;
    --danger: #F87171;
    --success-bg: rgba(52, 211, 153, 0.10);
    --warning-bg: rgba(251, 191, 36, 0.10);
    --danger-bg: rgba(248, 113, 113, 0.10);
    --info-bg: rgba(34, 211, 238, 0.10);

    /* 尺寸 */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;

    /* 阴影 */
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    --glow: 0 0 24px rgba(34, 211, 238, 0.18);

    --font-mono: 'SF Mono', 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
}

/* ============ 2. 基础与背景 ============ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    min-height: 100vh;
    color: var(--text);
    line-height: 1.6;
    background-color: var(--bg-deep);
    background-image:
        radial-gradient(ellipse 70% 45% at 50% -8%, rgba(34, 211, 238, 0.14), transparent 70%),
        radial-gradient(ellipse 55% 38% at 82% 2%, rgba(99, 102, 241, 0.13), transparent 72%);
    background-attachment: fixed;
    background-repeat: no-repeat;
}

/* 细网格底纹，顶部渐隐 */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px);
    background-size: 30px 30px;
    -webkit-mask-image: radial-gradient(ellipse 96% 58% at 50% 0%, #000 28%, transparent 74%);
    mask-image: radial-gradient(ellipse 96% 58% at 50% 0%, #000 28%, transparent 74%);
}

.container,
.container * {
    position: relative;
}

.container {
    z-index: 1;
}

/* ============ 3. 布局 ============ */

.container {
    max-width: 940px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container.wide {
    max-width: 1180px;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

footer {
    text-align: center;
    padding: 28px 0 22px;
    color: var(--text-dim);
    font-size: 14px;
}

/* ============ 4. 顶部：品牌 / 顶栏 / 导航 ============ */

header {
    text-align: center;
    padding: 44px 0 28px;
}

header h1 {
    font-size: 1.95rem;
    font-weight: 600;
    letter-spacing: -0.4px;
    color: var(--text);
    margin-bottom: 10px;
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

/* 品牌几何标识 */
header h1::before {
    content: '';
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--accent);
    box-shadow: 0 0 22px rgba(34, 211, 238, 0.45);
    flex: 0 0 auto;
}

.subtitle {
    font-size: 0.88rem;
    color: var(--text-dim);
    letter-spacing: 2.4px;
    text-transform: uppercase;
}

.header-compact {
    padding: 30px 0 20px;
}

.header-compact h1 {
    font-size: 1.5rem;
}

.header-compact h1::before {
    width: 24px;
    height: 24px;
    border-radius: 7px;
}

/* 顶栏 */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 16px;
    margin-bottom: 16px;
    font-size: 0.84rem;
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.topbar-left {
    display: flex;
    align-items: baseline;
    gap: 9px;
}

.topbar-brand {
    font-weight: 600;
    letter-spacing: 0.4px;
    background: var(--accent);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.topbar-sub {
    color: var(--text-dim);
    font-size: 0.78rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-chip {
    color: var(--text);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.quota-chip {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    padding: 3px 11px;
    border-radius: 50px;
    font-size: 0.76rem;
    font-family: var(--font-mono);
}

.topbar-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: 3px 9px;
    border-radius: 6px;
    transition: background 0.16s, color 0.16s;
}

.topbar-link:hover {
    background: var(--glass-hover);
    color: var(--cyan);
}

/* 主导航 */
.nav-menu {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 22px;
    flex-wrap: wrap;
    padding: 6px;
    border-radius: 50px;
    background: var(--glass);
    border: 1px solid var(--line);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.nav-item {
    padding: 9px 19px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 50px;
    transition: color 0.18s, background 0.18s;
    font-size: 0.87rem;
    font-weight: 500;
}

.nav-item:hover {
    color: var(--text);
    background: var(--glass-hover);
}

.nav-item.active {
    color: #06121F;
    background: var(--accent);
    box-shadow: 0 3px 14px rgba(34, 211, 238, 0.28);
}

/* ============ 5. 聊天页 ============ */

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
}

.chat-header {
    padding: 16px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(34, 211, 238, 0.06), transparent);
}

.chat-header span {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.chat-header span::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 10px var(--cyan);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 24px 22px;
    max-height: 548px;
    background: rgba(0, 0, 0, 0.14);
}

.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.13);
    border-radius: 3px;
}

.message {
    margin-bottom: 18px;
    display: flex;
    align-items: flex-start;
    animation: fadeIn 0.32s ease;
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 80%;
    padding: 13px 17px;
    border-radius: 14px;
    line-height: 1.75;
    font-size: 0.93rem;
}

.message.assistant .message-content {
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid var(--line);
    border-bottom-left-radius: 5px;
    color: var(--text);
}

.message.user .message-content {
    background: var(--accent);
    color: #06121F;
    border-bottom-right-radius: 5px;
    font-weight: 500;
}

.message-content ul {
    margin: 6px 0 0 18px;
}

.chat-input {
    padding: 16px 20px;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.btn-voice {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--glass);
    font-size: 1.1rem;
    cursor: pointer;
    transition: border-color 0.18s, box-shadow 0.18s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-voice:hover {
    border-color: var(--cyan);
    box-shadow: var(--glow);
}

.btn-voice.recording {
    border-color: var(--danger);
    background: var(--danger-bg);
    animation: pulse 1.1s infinite;
}

#messageInput {
    flex: 1;
    padding: 12px 18px;
    border: 1px solid var(--line);
    border-radius: 24px;
    font-size: 0.93rem;
    outline: none;
    transition: border-color 0.18s, box-shadow 0.18s;
    background: rgba(255, 255, 255, 0.035);
    color: var(--text);
    font-family: inherit;
}

#messageInput::placeholder {
    color: var(--text-dim);
}

#messageInput:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

/* 快捷建议 */
.suggestions {
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.suggestions span {
    color: var(--text-dim);
    font-size: 0.8rem;
}

.suggestion-btn {
    padding: 7px 14px;
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: 50px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.18s, color 0.18s, background 0.18s;
    color: var(--text-muted);
    font-family: inherit;
}

.suggestion-btn:hover {
    border-color: var(--cyan);
    color: var(--cyan);
    background: var(--accent-soft);
}

/* ============ 6. 表单页 ============ */

.form-page {
    overflow: hidden;
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
}

.form-header {
    padding: 22px 24px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.08), rgba(99, 102, 241, 0.05));
}

.form-header h2 {
    font-size: 1.15rem;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text);
}

.form-header p {
    font-size: 0.83rem;
    color: var(--text-muted);
}

.form-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 7px;
    color: var(--text-muted);
    font-size: 0.82rem;
    letter-spacing: 0.4px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 0.93rem;
    transition: border-color 0.18s, box-shadow 0.18s;
    background: rgba(255, 255, 255, 0.035);
    color: var(--text);
    font-family: inherit;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-dim);
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 8l3-3.5' fill='none' stroke='%2393A5BF' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-group select option {
    background: var(--bg-elevated);
    color: var(--text);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.form-group textarea {
    resize: vertical;
    min-height: 104px;
    line-height: 1.65;
}

/* 生成结果 */
.result-card {
    margin-top: 22px;
    padding: 20px;
    border-radius: var(--radius);
    background: rgba(52, 211, 153, 0.055);
    border: 1px solid rgba(52, 211, 153, 0.22);
}

.result-card.error {
    background: var(--danger-bg);
    border-color: rgba(248, 113, 113, 0.24);
}

.result-title {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--success);
    margin-bottom: 13px;
    display: flex;
    align-items: center;
    gap: 9px;
    letter-spacing: 0.3px;
}

.result-title::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 9px currentColor;
}

.result-content {
    white-space: pre-wrap;
    line-height: 1.85;
    font-size: 0.92rem;
    color: var(--text);
    word-break: break-word;
    overflow-wrap: anywhere;
}

.result-actions {
    margin-top: 18px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-copy,
.btn-regenerate {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.87rem;
    transition: all 0.18s;
    border: 1px solid transparent;
    font-family: inherit;
}

.btn-copy {
    background: var(--accent);
    color: #06121F;
    font-weight: 500;
    box-shadow: 0 3px 14px rgba(34, 211, 238, 0.22);
}

.btn-copy:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 18px rgba(34, 211, 238, 0.32);
}

.btn-regenerate {
    background: var(--glass);
    border-color: var(--line);
    color: var(--text-muted);
}

.btn-regenerate:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}

/* ============ 7. 认证页 ============ */

.auth-container {
    justify-content: flex-start;
}

.auth-card {
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
    padding: 32px;
    max-width: 428px;
    width: 100%;
    margin: 0 auto;
}

.auth-card.center {
    text-align: center;
}

.auth-card h2 {
    font-size: 1.15rem;
    font-weight: 500;
    margin-bottom: 20px;
    color: var(--text);
}

.auth-card label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 7px;
    margin-top: 16px;
    letter-spacing: 0.4px;
}

.auth-card input[type="text"],
.auth-card input[type="password"] {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 0.95rem;
    color: var(--text);
    background: rgba(255, 255, 255, 0.035);
    font-family: inherit;
    transition: border-color 0.18s, box-shadow 0.18s;
}

.auth-card input::placeholder {
    color: var(--text-dim);
}

.auth-card input:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    cursor: pointer;
}

.checkbox-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--cyan);
    cursor: pointer;
}

.btn-block {
    display: block;
    width: 100%;
    margin-top: 22px;
    text-align: center;
    box-sizing: border-box;
}

.link-btn {
    text-decoration: none;
}

.auth-footer {
    margin-top: 20px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.auth-footer a {
    color: var(--cyan);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ============ 8. 用户管理 ============ */

.panel {
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 22px;
    margin-bottom: 18px;
}

.panel h2 {
    font-size: 0.98rem;
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.panel h2::before {
    content: '';
    width: 3px;
    height: 15px;
    border-radius: 2px;
    background: var(--accent);
}

.inline-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.inline-form input,
.inline-form select {
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.035);
    color: var(--text);
    font-family: inherit;
}

.inline-form input::placeholder {
    color: var(--text-dim);
}

.inline-form select option {
    background: var(--bg-elevated);
    color: var(--text);
}

.inline-form input:focus,
.inline-form select:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.data-table th,
.data-table td {
    padding: 11px 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.data-table th {
    color: var(--text-dim);
    font-weight: 500;
    font-size: 0.76rem;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.data-table tbody tr {
    transition: background 0.15s;
}

.data-table tbody tr:hover {
    background: var(--glass-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table strong {
    color: var(--text);
    font-weight: 500;
}

.data-table .muted {
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.76rem;
}

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

.actions form {
    display: flex;
    gap: 4px;
    align-items: center;
}

.mini-input {
    width: 82px;
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.035);
    color: var(--text);
    font-family: var(--font-mono);
}

.mini-input:focus {
    outline: none;
    border-color: var(--cyan);
}

.btn-mini {
    padding: 5px 11px;
    font-size: 0.75rem;
    border: 1px solid var(--line);
    background: var(--glass);
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.16s, color 0.16s, background 0.16s;
}

.btn-mini:hover {
    border-color: var(--cyan);
    color: var(--cyan);
    background: var(--accent-soft);
}

.btn-mini.btn-danger {
    color: var(--danger);
    border-color: rgba(248, 113, 113, 0.3);
}

.btn-mini.btn-danger:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
}

/* ============ 9. 通用组件 ============ */

.btn-primary {
    padding: 12px 24px;
    background: var(--accent);
    color: #06121F;
    border: none;
    border-radius: 50px;
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.18s, box-shadow 0.18s;
    box-shadow: 0 4px 18px rgba(34, 211, 238, 0.26);
    font-family: inherit;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(34, 211, 238, 0.38);
}

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

.btn-secondary {
    padding: 8px 16px;
    background: var(--glass);
    color: var(--text-muted);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.18s, color 0.18s;
    font-size: 0.83rem;
    font-family: inherit;
}

.btn-secondary:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}

/* 状态标签 */
.tag {
    display: inline-block;
    font-size: 0.68rem;
    padding: 2px 9px;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.tag-admin {
    background: var(--accent-soft);
    color: var(--cyan);
    border: 1px solid rgba(34, 211, 238, 0.28);
}

.tag-on {
    background: var(--success-bg);
    color: var(--success);
}

.tag-off {
    background: var(--danger-bg);
    color: var(--danger);
}

/* 提示消息 */
.flash {
    padding: 11px 15px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 16px;
    border: 1px solid transparent;
    border-left-width: 3px;
}

.flash-error {
    background: var(--danger-bg);
    color: #FCA5A5;
    border-color: rgba(248, 113, 113, 0.22);
    border-left-color: var(--danger);
}

.flash-success {
    background: var(--success-bg);
    color: #6EE7B7;
    border-color: rgba(52, 211, 153, 0.22);
    border-left-color: var(--success);
}

.flash-info {
    background: var(--info-bg);
    color: #67E8F9;
    border-color: rgba(34, 211, 238, 0.22);
    border-left-color: var(--cyan);
}

.flash-warning {
    background: var(--warning-bg);
    color: #FCD34D;
    border-color: rgba(251, 191, 36, 0.22);
    border-left-color: var(--warning);
}

/* 错误页 */
.error-code {
    font-size: 3.2rem;
    font-weight: 600;
    line-height: 1;
    margin-bottom: 14px;
    background: var(--accent);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.error-message {
    color: var(--text-muted);
    margin-bottom: 26px;
    font-size: 0.93rem;
}

.muted {
    color: var(--text-dim);
    font-size: 0.85rem;
}

code {
    background: rgba(255, 255, 255, 0.07);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.85em;
    color: var(--cyan);
    font-family: var(--font-mono);
}

/* ============ 10. 动画 ============ */

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.4); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.loading-spinner {
    display: flex;
    gap: 6px;
    padding: 14px;
    justify-content: center;
}

.loading-spinner span {
    width: 9px;
    height: 9px;
    background: var(--cyan);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
    box-shadow: 0 0 8px rgba(34, 211, 238, 0.6);
}

.loading-spinner span:nth-child(1) { animation-delay: -0.32s; }
.loading-spinner span:nth-child(2) { animation-delay: -0.16s; }

.typing-indicator {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 3px 0;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cyan);
    animation: bounce 1.3s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.3s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.15s; }

/* ============ 11. 线索中心 ============ */

.stat-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stat-card {
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.stat-num {
    font-size: 1.7rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--text);
    font-family: var(--font-mono);
}

.stat-num.accent {
    background: var(--accent);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    margin-top: 6px;
    font-size: 0.76rem;
    color: var(--text-dim);
    letter-spacing: 0.6px;
}

.lead-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.empty-hint {
    padding: 34px 16px;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.87rem;
    line-height: 1.7;
}

.lead-card {
    border: 1px solid var(--line);
    border-left: 3px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.028);
    transition: border-color 0.18s, background 0.18s;
}

.lead-card:hover {
    background: rgba(255, 255, 255, 0.05);
}

.lead-card.level-high { border-left-color: var(--cyan); }
.lead-card.level-mid  { border-left-color: var(--blue); }
.lead-card.level-low  { border-left-color: var(--text-dim); }

.lead-head {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.score-badge {
    min-width: 40px;
    text-align: center;
    padding: 3px 9px;
    border-radius: 50px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: var(--font-mono);
    background: var(--accent-soft);
    color: var(--cyan);
    border: 1px solid rgba(34, 211, 238, 0.3);
}

.level-mid .score-badge {
    background: rgba(99, 102, 241, 0.12);
    color: #A5B4FC;
    border-color: rgba(99, 102, 241, 0.3);
}

.level-low .score-badge {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border-color: var(--line);
}

.lead-user {
    font-weight: 500;
    color: var(--text);
    font-size: 0.92rem;
}

.lead-quote {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--line);
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.7;
    word-break: break-word;
}

.lead-meta {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--text-dim);
}

.lead-script {
    margin-top: 12px;
    padding: 14px;
    border-radius: var(--radius-sm);
    background: rgba(34, 211, 238, 0.05);
    border: 1px solid rgba(34, 211, 238, 0.2);
}

.script-label {
    font-size: 0.74rem;
    letter-spacing: 1px;
    color: var(--cyan);
    margin-bottom: 8px;
}

.script-body {
    font-size: 0.9rem;
    line-height: 1.8;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

.script-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.lead-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============ 12. 移动端适配 ============ */
/* 断点：768px 平板 · 640px 手机 · 400px 小屏手机 */

@supports (min-height: 100dvh) {
    .container {
        min-height: 100dvh;
    }
}

@media (max-width: 768px) {
    /* 输入控件字号必须 ≥16px，否则 iOS Safari 聚焦时会自动缩放页面 */
    #messageInput,
    .form-group input,
    .form-group textarea,
    .form-group select,
    .auth-card input[type="text"],
    .auth-card input[type="password"],
    .inline-form input,
    .inline-form select {
        font-size: 16px;
    }

    .container {
        padding: 14px;
    }
}

@media (max-width: 640px) {
    header {
        padding: 20px 0 16px;
    }

    header h1 {
        font-size: 1.28rem;
        gap: 9px;
    }

    header h1::before {
        width: 24px;
        height: 24px;
        border-radius: 7px;
    }

    .subtitle {
        font-size: 0.72rem;
        letter-spacing: 1.6px;
    }

    /* 导航横向滚动：入口单行排列，不换行挤压 */
    .nav-menu {
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 5px;
        padding: 5px;
        border-radius: 14px;
        margin-bottom: 16px;
    }

    .nav-menu::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        padding: 10px 15px;
        min-height: 44px;
        font-size: 0.84rem;
        white-space: nowrap;
    }

    /* 顶栏两行堆叠 */
    .topbar {
        padding: 10px 12px;
        gap: 8px;
    }

    .topbar-left,
    .topbar-right {
        width: 100%;
    }

    .topbar-right {
        justify-content: space-between;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        gap: 8px;
    }

    .topbar-right::-webkit-scrollbar {
        display: none;
    }

    /* 聊天页 */
    .chat-header {
        padding: 14px 16px;
    }

    .chat-history {
        max-height: 55vh;
        padding: 16px;
    }

    .chat-input {
        position: sticky;
        bottom: 0;
        z-index: 5;
        gap: 8px;
        padding: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    /* 输入区按钮不压缩、不换行，否则窄屏下文字被挤成两行、按钮被撑高 */
    .chat-input .btn-primary,
    .chat-input .btn-secondary {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .message-content {
        max-width: 88%;
        padding: 12px 14px;
        font-size: 0.91rem;
    }

    /* 手机端：放弃固定视口，改回自然滚动
       —— 之前锁死整页滚动导致「看不到回复下半部分、找不到输入框」，
       现在整页可正常上下滑动，输入区 sticky 固定在视口底部，随时能继续对话 */
    .container.chat-page {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow: visible;
    }

    /* 手机上隐藏页脚与快捷建议，把有限的高度全部让给对话区 */
    .chat-page > footer,
    .chat-page > .suggestions {
        display: none;
    }

    .chat-page .chat-container {
        min-height: 0;
    }

    /* 消息区自然撑开，交给整页滚动 */
    .chat-page .chat-history {
        flex: none;
        min-height: 0;
        max-height: none;
        overflow-y: visible;
    }

    /* 输入区固定在视口底部 */
    .chat-page .chat-input {
        position: sticky;
        bottom: 0;
        z-index: 20;
        margin-bottom: 0;
        background: var(--bg-elevated);
        border-top: 1px solid var(--line);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
    }

    /* 表单页 */
    .form-header {
        padding: 16px;
    }

    .form-header h2 {
        font-size: 1.05rem;
    }

    .form-body {
        padding: 16px;
    }

    .form-group {
        margin-bottom: 16px;
    }

    /* 可点元素保证 ≥44px 触控高度 */
    .btn-primary,
    .btn-secondary,
    .btn-copy,
    .btn-regenerate,
    .btn-voice {
        min-height: 44px;
    }

    .suggestions {
        padding: 12px 16px;
        gap: 6px;
    }

    .suggestion-btn {
        padding: 9px 13px;
        font-size: 0.78rem;
    }

    .result-card {
        padding: 16px;
    }

    .result-content {
        font-size: 0.89rem;
        line-height: 1.75;
    }

    .result-actions {
        gap: 8px;
    }

    .btn-copy,
    .btn-regenerate {
        flex: 1 1 auto;
    }

    /* 认证页 */
    .auth-card {
        padding: 24px 20px;
    }

    /* 用户管理页 */
    .panel {
        padding: 16px;
        border-radius: var(--radius);
    }

    /* 线索中心：统计卡片改两列，卡片内边距收紧 */
    .stat-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .stat-card {
        padding: 13px 14px;
    }

    .stat-num {
        font-size: 1.4rem;
    }

    .lead-card {
        padding: 14px;
    }

    .lead-meta {
        gap: 10px;
    }

    .lead-actions .btn-mini,
    .script-actions .btn-mini {
        flex: 1 1 auto;
        min-height: 36px;
    }

    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-form input,
    .inline-form select {
        width: 100%;
    }

    .header-compact {
        padding: 18px 0 14px;
    }

    .header-compact h1 {
        font-size: 1.12rem;
    }

    .data-table th,
    .data-table td {
        padding: 9px 10px;
    }

    footer {
        padding: 18px 0 20px;
        font-size: 13px;
    }

    code {
        word-break: break-all;
    }
}

@media (max-width: 400px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 1.14rem;
    }

    .nav-item {
        padding: 9px 13px;
        font-size: 0.78rem;
    }

    .topbar {
        font-size: 0.76rem;
        padding: 8px 10px;
    }

    .quota-chip {
        padding: 3px 8px;
    }

    .message-content {
        max-width: 92%;
        font-size: 0.89rem;
    }

    .btn-secondary {
        padding: 8px 12px;
        font-size: 0.78rem;
    }
}

/* ============ 12. PWA 安装引导条 ============ */
.pwa-bar {
    position: fixed;
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom));
    transform: translate(-50%, 145%);
    z-index: 9999;
    width: calc(100% - 32px);
    max-width: 420px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(13, 18, 32, 0.93);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(34, 211, 238, 0.06);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    opacity: 0;
    transition: transform 0.32s cubic-bezier(0.22, 0.9, 0.3, 1), opacity 0.32s ease;
    pointer-events: none;
}

.pwa-bar.show {
    transform: translate(-50%, 0);
    opacity: 1;
    pointer-events: auto;
}

.pwa-bar-icon {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: rgba(34, 211, 238, 0.1);
    border: 1px solid rgba(34, 211, 238, 0.22);
}

.pwa-bar-body {
    flex: 1;
    min-width: 0;
}

.pwa-bar-title {
    font-size: 0.86rem;
    font-weight: 600;
    color: #E6EDF7;
    margin-bottom: 3px;
}

.pwa-bar-desc {
    font-size: 0.74rem;
    color: #8A96A8;
    line-height: 1.5;
}

.pwa-bar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.pwa-bar-btn {
    padding: 7px 13px;
    border: none;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    background: linear-gradient(135deg, #22d3ee, #6366f1);
    color: #04121a;
    white-space: nowrap;
}

.pwa-bar-btn:hover {
    filter: brightness(1.1);
}

.pwa-bar-close {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.06);
    color: #7C889B;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-bar-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #C3CCDB;
}

/* 窄屏：隐藏图标，给文字留空间 */
@media (max-width: 400px) {
    .pwa-bar {
        gap: 10px;
        padding: 11px 12px;
    }

    .pwa-bar-icon {
        display: none;
    }

    .pwa-bar-desc {
        font-size: 0.72rem;
    }
}

/* 已安装（独立窗口）模式：内容避开 iPhone 顶部状态栏 */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
    }
}
