/* ========== 基础 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
    --bg: #f5f5f7;
    --card: #ffffff;
    --text: #1d1d1f;
    --text-2: #86868b;
    --text-3: #d2d2d7;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --accent-light: rgba(0,113,227,0.08);
    --danger: #ff3b30;
    --success: #34c759;
    --warn: #ff9500;
    --border: #e5e5ea;
    --border-light: #f0f0f2;
    --radius: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --shadow: 0 0.5px 0 rgba(0,0,0,0.04), 0 2px 12px rgba(0,0,0,0.05);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.08), 0 0.5px 0 rgba(0,0,0,0.04);
    --shadow-focus: 0 0 0 4px rgba(0,113,227,0.12);
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --transition: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input { font-family: inherit; font-size: 16px; outline: none; }
input[type="checkbox"] { accent-color: var(--accent); width: 17px; height: 17px; cursor: pointer; }

/* ========== 布局 ========== */
.container { max-width: 960px; margin: 0 auto; padding: 40px 24px; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 36px 32px;
    border: 0.5px solid rgba(0,0,0,0.04);
}

/* ========== 页面切换 ========== */
.page { display: none; }
.page.active { display: block; animation: fadeUp 0.35s cubic-bezier(0.16,1,0.3,1); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ========== Logo ========== */
.logo { text-align: center; margin-bottom: 32px; }
.logo img { width: 72px; height: 72px; border-radius: 18px; object-fit: cover; margin: 0 auto 14px; display: block; box-shadow: 0 4px 20px rgba(0,0,0,0.12); }
.logo.sm img { width: 52px; height: 52px; border-radius: 14px; margin-bottom: 10px; }
.logo h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.logo p { color: var(--text-2); font-size: 14px; margin-top: 5px; }

/* ========== 输入框 ========== */
.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; letter-spacing: 0.1px; }
.input {
    width: 100%; padding: 12px 16px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--bg); transition: all var(--transition); font-size: 16px;
    -webkit-appearance: none;
}
.input:focus { border-color: var(--accent); background: #fff; box-shadow: var(--shadow-focus); }
.input::placeholder { color: var(--text-3); }
.input-row { display: flex; gap: 10px; }
.input-row .input { flex: 1; }
textarea.input { resize: vertical; min-height: 96px; font-family: inherit; line-height: 1.6; }
select.input { cursor: pointer; }

/* ========== 按钮 ========== */
.btn {
    width: 100%; padding: 13px 20px; border-radius: var(--radius-sm); font-size: 16px;
    font-weight: 600; transition: all var(--transition); display: flex; align-items: center; justify-content: center; gap: 6px;
    letter-spacing: 0.1px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 2px 16px rgba(0,113,227,0.35); }
.btn-primary:active { transform: scale(0.98); box-shadow: none; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:active { transform: scale(0.98); }
.btn-danger:disabled { opacity: 0.4; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 7px; width: auto; }
.btn-text { color: var(--text-2); font-size: 14px; padding: 4px 8px; width: auto; transition: color var(--transition); }
.btn-text:hover { color: var(--accent); }

/* ========== Tab ========== */
.tabs {
    display: flex; background: var(--bg); border-radius: var(--radius-sm); padding: 3px; margin-bottom: 24px;
}
.tab {
    flex: 1; padding: 8px; text-align: center; font-size: 14px; font-weight: 500; color: var(--text-2);
    border-radius: var(--radius-xs); transition: all var(--transition);
}
.tab.active { background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

/* ========== 用户栏 ========== */
.user-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; background: var(--card); border-radius: var(--radius);
    margin-bottom: 12px; box-shadow: var(--shadow); border: 0.5px solid rgba(0,0,0,0.04);
}
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--bg); }
.avatar-fallback { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0071e3, #42a5f5); color: #fff; font-weight: 600; font-size: 18px; }
.user-info { flex: 1; min-width: 0; }
.user-info .name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-info .uid { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.card-badge { font-size: 11px; color: var(--success); background: rgba(52,199,89,0.1); padding: 4px 10px; border-radius: 20px; font-weight: 500; flex-shrink: 0; }
.card-badge.expired { color: var(--danger); background: rgba(255,59,48,0.1); }

/* ========== IM状态 ========== */
.im-status {
    font-size: 13px; color: var(--text-2); text-align: center; margin-bottom: 12px;
    padding: 10px 16px; background: var(--card); border-radius: var(--radius-sm);
    box-shadow: var(--shadow); border: 0.5px solid rgba(0,0,0,0.04);
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.im-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); animation: pulse 1.5s infinite; }
.im-status.connected .dot { background: var(--success); animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ========== 批量发送 ========== */
.batch-card {
    background: var(--card); border-radius: var(--radius); padding: 22px;
    box-shadow: var(--shadow); border: 0.5px solid rgba(0,0,0,0.04); margin-top: 12px;
}
.batch-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.batch-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.batch-head .batch-title { margin-bottom: 0; white-space: nowrap; }
.batch-progress { flex: 1; max-width: 420px; min-width: 0; }
.batch-row { display: flex; gap: 10px; margin-bottom: 12px; }
.batch-row .input { flex: 1; }
.batch-options { margin-bottom: 12px; }
.batch-options > label { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 8px; cursor: pointer; }
.batch-types { display: flex; gap: 16px; font-size: 14px; margin-bottom: 14px; }
.batch-types label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.section-toggle { padding-top: 14px; border-top: 1px solid var(--border-light); margin-top: 14px; }
.section-toggle:first-child { border-top: none; padding-top: 0; margin-top: 0; }

/* ========== 进度条 ========== */
.progress-header { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
.progress-track { background: var(--bg); border-radius: 6px; height: 6px; overflow: hidden; }
.progress-bar { background: linear-gradient(90deg, var(--accent), #42a5f5); height: 100%; width: 0%; transition: width 0.3s; border-radius: 6px; }

/* ========== 日志 ========== */
.log-box {
    margin-top: 14px; max-height: 200px; overflow-y: auto;
    font-size: 12px; font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    background: var(--bg); border-radius: var(--radius-xs); padding: 10px 12px;
    line-height: 1.7; color: var(--text-2);
}
.log-box .log-ok { color: var(--success); }
.log-box .log-err { color: var(--danger); }
/* 左右分栏: 左日志 右配置 */
.batch-layout { display: flex; gap: 18px; align-items: flex-start; }
.batch-log-col {
    flex: 0 0 40%; min-width: 0; position: sticky; top: 12px;
    background: var(--card); border: 0.5px solid var(--border);
    border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.batch-form-col { flex: 1; min-width: 0; }
.batch-col-title {
    font-size: 13px; font-weight: 700; margin-bottom: 12px; color: var(--text);
    display: flex; align-items: center; gap: 8px;
}
.batch-col-title::before {
    content: ''; width: 8px; height: 8px; border-radius: 50%;
    background: var(--success); box-shadow: 0 0 0 3px rgba(52,199,89,0.18);
}
.batch-log-col .log-box {
    margin-top: 0; max-height: calc(100vh - 180px); min-height: 320px;
    background: #fafafa; border: 1px solid var(--border-light); padding: 10px;
}
.batch-log-col .log-box::-webkit-scrollbar { width: 6px; }
.batch-log-col .log-box::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.batch-log-col .log-box::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
.batch-log-col .log-box::-webkit-scrollbar-track { background: transparent; }
@media (max-width: 760px) {
    .batch-layout { flex-direction: column; }
    .batch-log-col { position: static; flex: 1 1 auto; width: 100%; }
    .batch-log-col .log-box { max-height: 240px; min-height: 0; }
}

/* ========== 验证码 ========== */
.captcha-row { display: flex; align-items: center; gap: 10px; }
.captcha-row .input { flex: 1; min-width: 0; }
.captcha-img { cursor: pointer; border-radius: var(--radius-xs); height: 48px; flex-shrink: 0; background: var(--bg); border: 0.5px solid var(--border); transition: opacity var(--transition); }
.captcha-img:hover { opacity: 0.8; }

/* ========== Toast ========== */
.toast {
    position: fixed; top: 24px; left: 50%; transform: translateX(-50%) translateY(-20px);
    background: rgba(29,29,31,0.92); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    color: #fff; padding: 12px 24px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
    z-index: 200; box-shadow: 0 8px 32px rgba(0,0,0,0.2); opacity: 0; transition: all 0.3s var(--transition);
    pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: rgba(255,59,48,0.92); }
.toast.success { background: rgba(52,199,89,0.92); }

/* ========== 弹窗 ========== */
.modal-mask { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 100; align-items: center; justify-content: center; }
.modal-mask.show { display: flex; animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--card); border-radius: 18px; padding: 28px; width: 90%; max-width: 400px; box-shadow: 0 24px 80px rgba(0,0,0,0.2); }
.modal h3 { font-size: 18px; margin-bottom: 16px; }
.modal .btn-group { display: flex; gap: 10px; margin-top: 20px; }

/* ========== 管理后台 ========== */
.container-wide { max-width: 1100px; margin: 0 auto; padding: 32px 20px; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.admin-header h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.admin-toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.admin-toolbar .input { width: auto; flex: 1; min-width: 200px; }
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border-light); font-size: 14px; }
th { background: var(--bg); font-weight: 600; color: var(--text-2); font-size: 13px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,0,0,0.015); }
.status-tag { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.status-unused { background: var(--accent-light); color: var(--accent); }
.status-bound { background: rgba(52,199,89,0.1); color: var(--success); }
.status-expired { background: rgba(255,149,0,0.1); color: var(--warn); }
.status-banned { background: rgba(255,59,48,0.1); color: var(--danger); }
.op-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.op-btns button { padding: 4px 8px; font-size: 12px; border-radius: 6px; }

/* ========== 滚动条 ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-3); border-radius: 3px; }

/* ========== 响应式 ========== */
@media (max-width: 600px) {
    .container { padding: 16px; }
    .card { padding: 24px 20px; }
    table { font-size: 12px; }
    th, td { padding: 8px; }
}
