/* ===================== XAPI · 用户端（注册 / 登录 / 控制台） ===================== */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --dark: #0f172a;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f5f7fa;
    --success: #10b981;
    --danger: #ef4444;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===================== 通用控件 ===================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: all .2s;
}

.btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

.btn-lg {
    height: 42px;
    width: 100%;
    font-size: 14px;
}

.btn-sm {
    height: 30px;
    padding: 0 12px;
    font-size: 12px;
}

.btn-danger:hover {
    border-color: var(--danger);
    color: var(--danger);
}

input,
select,
textarea {
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
}

.form-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.form-item label {
    font-size: 13px;
    color: var(--muted);
}

.form-item input,
.form-item select {
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    outline: none;
    transition: border-color .2s;
}

.form-item input:focus,
.form-item select:focus {
    border-color: var(--primary);
}

.hint {
    font-size: 12px;
    color: #9ca3af;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    background: #f1f5f9;
    color: var(--muted);
}

.tag-success {
    background: #ecfdf5;
    color: var(--success);
}

.tag-danger {
    background: #fef2f2;
    color: var(--danger);
}

/* ===================== 登录 / 注册 ===================== */

.auth-page {
    min-height: 100vh;
    display: flex;
}

.auth-brand {
    flex: 1;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    color: #fff;
    padding: 64px 56px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-brand .logo {
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 40px;
}

.logo-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.auth-brand h1 {
    font-size: 30px;
    line-height: 1.4;
    margin-bottom: 16px;
}

.auth-brand p {
    color: rgba(255, 255, 255, .78);
    max-width: 340px;
}

.auth-brand ul {
    list-style: none;
    margin-top: 28px;
    color: rgba(255, 255, 255, .85);
    font-size: 14px;
}

.auth-brand ul li {
    padding: 6px 0;
}

.auth-panel {
    width: 460px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.auth-box {
    width: 100%;
    max-width: 340px;
}

.auth-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 6px;
}

.auth-sub {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 26px;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-top: 16px;
}

.auth-error {
    display: none;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    font-size: 13px;
    padding: 9px 12px;
    border-radius: 8px;
    margin-bottom: 14px;
}

.auth-error.show {
    display: block;
}

/* ===================== 控制台 ===================== */

.portal-top {
    background: #fff;
    border-bottom: 1px solid var(--border);
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.portal-top .logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.portal-top .logo-mark {
    width: 28px;
    height: 28px;
    font-size: 13px;
}

.top-right {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    color: var(--muted);
}

.top-user {
    color: var(--dark);
    font-weight: 600;
}

.portal-body {
    display: flex;
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    align-items: flex-start;
}

.portal-menu {
    width: 200px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    position: sticky;
    top: 84px;
}

.portal-menu a {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
}

.portal-menu a:hover {
    background: var(--primary-light);
    text-decoration: none;
}

.portal-menu a.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.portal-content {
    flex: 1;
    min-width: 0;
}

.panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin-bottom: 20px;
    display: none;
}

.panel.active {
    display: block;
}

.panel-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 4px;
}

.panel-desc {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 18px;
}

/* 概览卡片 */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}

.stat-card .label {
    font-size: 13px;
    color: var(--muted);
}

.stat-card .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
    margin-top: 6px;
    word-break: break-all;
}

.stat-card .unit {
    font-size: 13px;
    color: var(--muted);
    font-weight: 400;
}

/* 表格 */
.portal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.portal-table th,
.portal-table td {
    border-bottom: 1px solid var(--border);
    padding: 11px 10px;
    text-align: left;
    vertical-align: middle;
}

.portal-table thead th {
    background: #f8fafc;
    color: var(--dark);
    font-weight: 600;
    white-space: nowrap;
}

.portal-table .key-cell {
    font-family: Consolas, monospace;
    color: var(--muted);
}

.portal-table .amount-out {
    color: var(--danger);
    font-weight: 600;
}

.portal-table .amount-in {
    color: var(--success);
    font-weight: 600;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 40px 0;
}

.code-preview {
    background: #0f172a;
    color: #e2e8f0;
    font-family: Consolas, Menlo, monospace;
    font-size: 13px;
    padding: 14px 16px;
    border-radius: 10px;
    overflow-x: auto;
}

code {
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 13px;
    font-family: Consolas, Menlo, monospace;
}

/* 工具栏 */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
}

.toolbar input,
.toolbar select {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    background: #fff;
}

.toolbar .spacer {
    flex: 1;
}

/* 分页 */
.pager {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    font-size: 13px;
    color: var(--muted);
}

.pager button {
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
}

.pager button:disabled {
    color: #cbd5e1;
    cursor: not-allowed;
}

/* ===================== 轻提示 ===================== */

.portal-toast {
    position: fixed;
    left: 50%;
    top: 24px;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, .92);
    color: #fff;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: 8px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}

.portal-toast.show {
    opacity: 1;
}

/* ===================== 弹窗 ===================== */

.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-mask.show {
    display: flex;
}

.modal {
    width: 520px;
    max-width: 92vw;
    background: #fff;
    border-radius: 12px;
    padding: 22px;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 14px;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.copy-box {
    display: flex;
    gap: 8px;
}

.copy-box input {
    flex: 1;
    min-width: 0;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    font-family: Consolas, Menlo, monospace;
    font-size: 13px;
}

.copy-box input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
}

.copy-box .btn {
    height: 38px;
    white-space: nowrap;
}

/* ===================== 响应式 ===================== */

@media (max-width: 900px) {
    .auth-brand {
        display: none;
    }

    .auth-panel {
        width: 100%;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .portal-body {
        flex-direction: column;
        padding: 16px;
    }

    .portal-menu {
        width: 100%;
        display: flex;
        gap: 8px;
        position: static;
    }

    .portal-menu a {
        padding: 8px 14px;
    }
}
