/* 落地页管理后台 - 通用样式 */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #16181d;
    --muted: #69707d;
    --border: #e6e8ee;
    --primary: #17181c;
    --primary-hover: #000000;
    --brand: #0e9f6e;
    --brand-soft: #e7f8f1;
    --brand-text: #067a53;
    --danger: #d92d20;
    --danger-soft: #fee4e2;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-md: 0 8px 28px rgba(16, 24, 40, .10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ---------- 顶栏 ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 20px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: .01em;
}

.brand-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--brand);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--muted);
    font-size: 13px;
}

.link {
    color: var(--muted);
    cursor: pointer;
    transition: color .15s;
}

.link:hover {
    color: var(--text);
}

.back-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-title {
    font-size: 14px;
    font-weight: 600;
}

/* ---------- 布局 ---------- */
.container {
    max-width: 1080px;
    margin: 22px auto 60px;
    padding: 0 20px;
    display: grid;
    gap: 14px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px;
}

.card-title {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 600;
}

.card-sub {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 12px;
}

/* ---------- 统计 ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
}

.stat-val {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -.02em;
}

.stat-lbl {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

/* ---------- 表单 ---------- */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field label {
    font-size: 12px;
    color: var(--muted);
}

.input {
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 12px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    outline: none;
    background: #fafafb;
    transition: border-color .15s, box-shadow .15s, background .15s;
    width: 100%;
}

.input:focus {
    border-color: var(--brand);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(14, 159, 110, .13);
}

textarea.input {
    height: auto;
    min-height: 180px;
    padding: 10px 12px;
    font-family: ui-monospace, Consolas, "SF Mono", Menlo, monospace;
    font-size: 12px;
    line-height: 1.7;
    resize: vertical;
}

.form-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-row .field {
    flex: 1 1 180px;
}

.form-row .btn {
    flex: 0 0 auto;
}

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s, color .15s, opacity .15s;
    background: #f1f2f4;
    color: var(--text);
    white-space: nowrap;
}

.btn:hover {
    background: #e8e9ec;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-sm {
    height: 28px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 12px;
}

.btn-danger-ghost {
    background: transparent;
    color: var(--danger);
}

.btn-danger-ghost:hover {
    background: var(--danger-soft);
}

.btn:disabled {
    opacity: .6;
    cursor: not-allowed;
}

.btn-block {
    width: 100%;
    height: 44px;
    font-size: 14px;
}

/* ---------- 表格 ---------- */
.table-wrap {
    overflow-x: auto;
    margin: 0 -20px;
    padding: 0 20px;
}

/* 长列表限高滚动，表头固定 */
.table-wrap.scroll-table {
    max-height: 460px;
    overflow-y: auto;
}

/* collapse 会使 sticky 表头失效，此处改用 separate */
.table-wrap.scroll-table .table {
    border-collapse: separate;
    border-spacing: 0;
}

.table-wrap.scroll-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th {
    text-align: left;
    color: var(--muted);
    font-weight: 500;
    font-size: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover td {
    background: #fafafb;
}

.table .sub {
    color: var(--muted);
    font-size: 12px;
}

.table td.actions {
    white-space: nowrap;
}

.table td.actions .btn {
    margin-right: 6px;
}

.table td.actions .btn:last-child {
    margin-right: 0;
}

.empty-row {
    text-align: center;
    color: var(--muted);
    padding: 30px 0 !important;
}

.ellipsis {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.edit-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.edit-row .input {
    flex: 1;
    min-width: 200px;
}

/* ---------- 徽标 ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap;
}

.badge-dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-on {
    background: var(--brand-soft);
    color: var(--brand-text);
}

.badge-off {
    background: #f1f2f4;
    color: var(--muted);
}

/* ---------- Token ---------- */
code.token {
    font-family: ui-monospace, Consolas, "SF Mono", Menlo, monospace;
    font-size: 12px;
    background: #f4f5f7;
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color .15s, color .15s;
    word-break: break-all;
}

code.token:hover {
    border-color: var(--brand);
    color: var(--brand-text);
}

/* ---------- 账号信息卡 ---------- */
.info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.info-item {
    min-width: 0;
}

.info-lbl {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

.info-val {
    font-size: 13px;
    font-weight: 500;
    word-break: break-all;
}

.info-token {
    grid-column: 1 / -1;
}

.pixel-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(16px);
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 13px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 100;
    max-width: 80vw;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%);
}

.toast-ok {
    background: #111318;
    color: #fff;
}

.toast-err {
    background: var(--danger);
    color: #fff;
}

/* ---------- 密钥弹窗 ---------- */
.secret-mask {
    position: fixed;
    inset: 0;
    background: rgba(15, 18, 25, .45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 120;
    padding: 20px;
}

.secret-mask.show {
    display: flex;
}

.secret-box {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    width: min(500px, 100%);
    box-shadow: var(--shadow-md);
}

.secret-title {
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 600;
}

.secret-list {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.secret-label {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

.secret-valrow {
    display: flex;
    align-items: center;
    gap: 8px;
}

.secret-code {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, Consolas, "SF Mono", Menlo, monospace;
    font-size: 12px;
    background: #f4f5f7;
    border: 1px solid var(--border);
    padding: 8px 10px;
    border-radius: 8px;
    word-break: break-all;
}

.secret-foot {
    display: flex;
    justify-content: flex-end;
}

/* ---------- 登录页 ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(600px 300px at 20% 0%, rgba(14, 159, 110, .07), transparent 60%),
        radial-gradient(600px 300px at 90% 100%, rgba(59, 91, 219, .06), transparent 60%),
        var(--bg);
}

.login-card {
    width: min(400px, 100%);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    padding: 36px 32px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 22px;
}

.login-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 4px;
    letter-spacing: -.01em;
}

.login-sub {
    color: var(--muted);
    font-size: 13px;
    margin: 0 0 24px;
}

.form-field {
    margin-bottom: 14px;
}

.form-field label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.form-field input {
    width: 100%;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: #fafafb;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.form-field input:focus {
    border-color: var(--brand);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(14, 159, 110, .13);
}

.login-error {
    display: none;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 13px;
    padding: 10px 12px;
    border-radius: var(--radius);
    margin-bottom: 14px;
}

.login-foot {
    text-align: center;
    color: #a4a9b3;
    font-size: 12px;
    margin-top: 22px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
