/* ============================================================
 * 阿拉丁 API · 空回补偿 —— 前端样式
 * 设计基调：纯白底 + 黑灰文 + 金色点缀，极简边框，无装饰图形
 * ============================================================ */

:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-soft: #fafaf9;
    --border: #e7e5e4;
    --border-strong: #d6d3d1;
    --text: #0c0a09;
    --text-soft: #57534e;
    --text-mute: #a8a29e;
    --accent: #c79e3f;       /* 阿拉丁金 */
    --accent-soft: #fdf6e3;
    --accent-strong: #a47e22;
    --danger: #b91c1c;
    --danger-soft: #fef2f2;
    --success: #15803d;
    --success-soft: #f0fdf4;
    --shadow-sm: 0 1px 2px rgba(12, 10, 9, 0.04);
    --shadow-md: 0 6px 18px rgba(12, 10, 9, 0.06);
    --radius: 10px;
    --radius-lg: 14px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--text); }
img { max-width: 100%; }

/* ============ 容器 ============ */
.view-container {
    width: 100%;
    min-height: 100vh;
    padding: 32px 24px 64px;
}
.view-login {
    max-width: 460px;
    margin: 0 auto;
    padding-top: 56px;
}
.dashboard-view {
    max-width: 1180px;
    margin: 0 auto;
}

/* ============ 登录头部 ============ */
.view-login .header {
    text-align: center;
    margin-bottom: 28px;
}
.view-login .header img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    margin-bottom: 12px;
}
.view-login .header h1 {
    margin: 0 0 6px;
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}
.view-login .header p {
    margin: 0;
    color: var(--text-soft);
    font-size: 0.9rem;
}
.brand-sub {
    color: var(--accent);
    font-weight: 700;
    font-size: 0.95em;
    margin-left: 6px;
}

/* ============ 卡片 ============ */
.main-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
}

/* ============ 登录卡片 ============ */
.login-card-title { margin-bottom: 4px; }
.login-card-title h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}
.login-card-subtitle {
    color: var(--text-soft);
    margin: 6px 0 22px;
    font-size: 0.88rem;
}

.input-group { margin-bottom: 14px; }
.input-group label {
    display: block;
    color: var(--text-soft);
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 6px;
}
.custom-input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}
.custom-input::placeholder { color: var(--text-mute); }
.custom-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(199, 158, 63, 0.15);
}

/* ============ 按钮 ============ */
.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 9px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
    background: var(--text);
    color: #fff;
    border-color: var(--text);
}
.btn-primary:hover:not(:disabled) {
    background: #1c1917;
    border-color: #1c1917;
}
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--surface-soft);
}
.btn-block { width: 100%; }
.btn-large { padding: 11px 22px; font-size: 0.95rem; }

.detail-btn {
    appearance: none;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    border-radius: 8px;
    padding: 5px 11px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
}
.detail-btn:hover:not(:disabled) {
    background: var(--accent-soft);
    border-color: var(--accent);
}
.detail-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.rule-link {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 6px;
}
.rule-link:hover { color: var(--accent); background: var(--accent-soft); }

/* ============ FAQ / 折叠 ============ */
.faq-box {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-soft);
    overflow: hidden;
}
.faq-box summary {
    cursor: pointer;
    padding: 12px 14px;
    font-size: 0.88rem;
    color: var(--text);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}
.faq-box summary::-webkit-details-marker { display: none; }
.summary-arrow {
    color: var(--text-mute);
    transition: transform 0.2s;
}
.faq-box[open] .summary-arrow { transform: rotate(180deg); }
.faq-content { padding: 4px 14px 14px; }
.steps { display: flex; flex-direction: column; gap: 8px; }
.step-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    color: var(--text-soft);
    font-size: 0.85rem;
}
.step-num {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* ============ 登录页特性条 ============ */
.login-feature-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 22px;
}
.feature-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    gap: 10px;
    align-items: center;
}
.feature-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
}
.feature-item b {
    display: block;
    font-size: 0.86rem;
    font-weight: 600;
}
.feature-item small {
    color: var(--text-mute);
    font-size: 0.75rem;
}

/* ============ Dashboard 头 ============ */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding-bottom: 20px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.dashboard-title {
    display: flex;
    gap: 14px;
    align-items: center;
}
.brand-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    flex-shrink: 0;
}
.dashboard-title h1 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}
.dashboard-title p {
    margin: 2px 0 0;
    color: var(--text-soft);
    font-size: 0.85rem;
}
.dashboard-title p b { color: var(--text); font-weight: 600; }
.dashboard-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ============ 规则面板 ============ */
.rules-panel {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    margin-bottom: 24px;
}
.rules-title {
    font-weight: 700;
    margin-bottom: 12px;
}
.rules-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.rule-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
}
.rule-item b {
    display: block;
    margin-bottom: 4px;
    font-size: 0.86rem;
    color: var(--accent-strong);
    font-weight: 700;
}
.rule-item span {
    font-size: 0.82rem;
    color: var(--text-soft);
}
.rules-note {
    margin: 14px 0 0;
    font-size: 0.8rem;
    color: var(--text-mute);
}

/* ============ 统计 ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.stat-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    display: flex;
    gap: 14px;
    align-items: center;
}
.stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    font-weight: 700;
    flex-shrink: 0;
}
.stat-label {
    color: var(--text-soft);
    font-size: 0.8rem;
    margin-bottom: 2px;
}
.stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.01em;
}
.stat-value.money { color: var(--accent-strong); }
.stat-unit {
    color: var(--text-soft);
    font-size: 0.85rem;
    font-weight: 500;
}
.stat-hint {
    color: var(--text-mute);
    font-size: 0.74rem;
    margin-top: 2px;
}

/* ============ 列表头 ============ */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}
.list-header h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}
.list-header p {
    margin: 2px 0 0;
    color: var(--text-soft);
    font-size: 0.82rem;
}

/* ============ 主表格 ============ */
.dashboard-card { padding: 20px; }
.cooldown-alert {
    margin-bottom: 14px;
    padding: 9px 14px;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    color: #92400e;
    font-size: 0.85rem;
}

.record-list {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.record-row {
    display: grid;
    grid-template-columns: 56px 1.5fr 1.4fr 1.2fr 1fr 1fr 1fr;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    background: var(--surface);
}
.record-row:last-child { border-bottom: none; }
.record-row.table-head {
    background: var(--surface-soft);
    color: var(--text-soft);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.record-row.compensated { background: #fbfaf9; color: var(--text-mute); }

.status-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}
.custom-checkbox {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    cursor: pointer;
    background: var(--surface);
    position: relative;
    transition: border-color 0.15s, background 0.15s;
}
.custom-checkbox:checked {
    background: var(--accent);
    border-color: var(--accent);
}
.custom-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.confirmed-dot {
    color: var(--success);
    font-weight: 700;
}

.order-cell strong {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
}
.order-cell small {
    color: var(--text-mute);
    font-size: 0.72rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.time-cell { color: var(--text-soft); font-size: 0.82rem; }
.token-badge {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    color: var(--text-soft);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.record-price {
    font-weight: 700;
    color: var(--accent-strong);
}
.refund-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 0.76rem;
    font-weight: 600;
}
.refund-badge.done {
    background: var(--success-soft);
    color: var(--success);
}

/* ============ 空状态 ============ */
.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-mute);
    font-size: 0.9rem;
}
.empty-state.compact-empty { padding: 24px; }

/* ============ 操作栏 ============ */
.action-bar {
    margin-top: 16px;
    padding: 14px 16px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.total-txt { color: var(--text-soft); font-size: 0.88rem; }
.total-txt b { color: var(--text); font-weight: 700; }
.total-money {
    color: var(--accent-strong);
    font-weight: 800;
    margin-left: 4px;
}

/* ============ Toast ============ */
.toast-msg {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    z-index: 2000;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.18s ease;
}
.toast-msg.toast-error {
    background: var(--danger);
}

/* ============ 历史卡片 ============ */
.history-card { padding: 20px; }
.history-section { margin-top: 0; }
.history-toggle { cursor: pointer; user-select: none; }

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}
.history-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: none;
}
.history-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 10px;
}
.history-card-title h3 {
    margin: 0 0 2px;
    font-size: 0.95rem;
    font-weight: 700;
}
.history-card-meta {
    color: var(--text-mute);
    font-size: 0.78rem;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 0;
}
.history-card-amount {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--accent-strong);
    white-space: nowrap;
}
.badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    font-size: 0.74rem;
    color: var(--text-soft);
    margin-left: 4px;
}

.history-code-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: var(--accent-soft);
    border: 1px dashed rgba(199, 158, 63, 0.45);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 10px;
}
.history-code-row label {
    font-size: 0.76rem;
    color: var(--accent-strong);
    font-weight: 600;
}
.history-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.86rem;
    color: var(--text);
    flex: 1 1 auto;
    min-width: 0;
    word-break: break-all;
}
.history-sublogs {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.history-sublog {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 10px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.82rem;
}
.history-sublog .record-price { margin-left: auto; }

/* ============ 兑换码弹层 ============ */
.code-modal-mask {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(12, 10, 9, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeIn 0.18s ease;
}
.code-modal {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(12, 10, 9, 0.18);
    animation: slideDown 0.22s ease;
    border: 1px solid var(--border);
}
.code-modal-head h2 {
    margin: 0 0 6px;
    font-size: 1.15rem;
    font-weight: 700;
}
.code-modal-message {
    color: var(--text-soft);
    font-size: 0.88rem;
    margin: 0 0 16px;
}
.code-modal-amount {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    background: var(--accent-soft);
    border: 1px solid rgba(199, 158, 63, 0.25);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 14px;
}
.code-modal-amount-label {
    color: var(--text-soft);
    font-size: 0.85rem;
}
.code-modal-amount-value {
    color: var(--accent-strong);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}
.code-modal-code-wrap {
    border: 1px dashed var(--accent);
    background: var(--accent-soft);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 16px;
}
.code-modal-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.95rem;
    color: var(--text);
    word-break: break-all;
    user-select: all;
}
.code-modal-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.code-modal-actions .btn { flex: 1 1 180px; }
.code-modal-tip {
    color: var(--text-mute);
    font-size: 0.78rem;
    margin: 14px 0 0;
    text-align: center;
}

/* ============ 动画 ============ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, -8px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============ 响应式 ============ */
@media (max-width: 1000px) {
    .stats-grid,
    .rules-grid,
    .login-feature-bar { grid-template-columns: repeat(2, 1fr); }
    .record-row {
        grid-template-columns: 40px 1.4fr 1.2fr 1fr 1fr;
        font-size: 0.82rem;
    }
    .record-row > div:nth-child(6),
    .record-row > div:nth-child(7) { display: none; }
}
@media (max-width: 640px) {
    .view-container { padding: 20px 14px 40px; }
    .dashboard-header { flex-direction: column; align-items: stretch; }
    .stats-grid,
    .rules-grid,
    .login-feature-bar { grid-template-columns: 1fr; }
    .record-row {
        grid-template-columns: 32px 1fr 1fr;
        gap: 6px;
    }
    .record-row > div:nth-child(3),
    .record-row > div:nth-child(4),
    .record-row > div:nth-child(6),
    .record-row > div:nth-child(7) { display: none; }
    .code-modal { padding: 20px; }
    .code-modal-amount-value { font-size: 1.25rem; }
    .history-card-head { flex-direction: column; align-items: flex-start; }
}
