:root {
    --bg-1: #eef2ff;
    --bg-2: #fdf4ff;
    --bg-3: #ecfeff;
    --glass: rgba(255, 255, 255, 0.82);
    --glass-strong: rgba(255, 255, 255, 0.94);
    --border: rgba(255, 255, 255, 0.7);
    --border-soft: rgba(99, 102, 241, 0.12);
    --text: #1e1b4b;
    --text-dim: #6b7280;
    --accent: #6366f1;
    --accent-2: #a855f7;
    --accent-grad: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --success: #10b981;
    --error: #ef4444;
    --warn: #f59e0b;
    --info: #0ea5e9;
    --radius: 22px;
    --radius-sm: 12px;
    --shadow-lg: 0 24px 60px rgba(99, 102, 241, 0.16);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    background:
        radial-gradient(at 15% 20%, rgba(165, 180, 252, 0.55) 0, transparent 52%),
        radial-gradient(at 85% 12%, rgba(240, 171, 252, 0.5) 0, transparent 48%),
        radial-gradient(at 78% 88%, rgba(165, 243, 252, 0.55) 0, transparent 50%),
        linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-3) 100%);
    background-attachment: fixed;
}

.page-center {
    min-height: 100vh;
    display: flex;
    padding: 32px 16px;
    min-width: 0;
}

.container {
    width: 100%;
    max-width: 520px;
    margin: auto;
    min-width: 0;
}

.card {
    background: var(--glass);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 36px 32px 28px;
    min-width: 0;
    container-type: inline-size;
}

.card h1 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 0.2px;
    background: var(--accent-grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
    text-align: center;
}

.card .subtitle {
    color: var(--text-dim);
    font-size: 13px;
    margin-bottom: 22px;
    text-align: center;
}

.key-display {
    background: var(--glass-strong);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 12px 16px 14px;
    margin-bottom: 12px;
    word-break: break-all;
}

.key-display .label {
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 2px;
}

.key-display .key-value {
    font-family: "Cascadia Code", "SF Mono", "Fira Code", Consolas, monospace;
    font-size: 15px;
    color: #4f46e5;
    font-weight: 700;
    line-height: 1.45;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 22px;
}

.info-item {
    background: var(--glass-strong);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 12px 8px 10px;
    text-align: center;
    min-width: 0;
}

.info-item .ilabel {
    font-size: 12px;
    color: #9ca3af;
}

.info-item .ivalue {
    font-size: 16px;
    font-weight: 800;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #111827;
}

.info-item .ivalue.balance {
    color: var(--success);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
}

.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.6;
}

.status-active,
.status-success {
    background: rgba(16, 185, 129, 0.14);
    color: var(--success);
}

.status-failed { background: rgba(239, 68, 68, 0.12); color: var(--error); }
.status-running { background: rgba(99, 102, 241, 0.12); color: var(--accent); }
.status-pending { background: rgba(245, 158, 11, 0.14); color: var(--warn); }
.status-cancelled,
.status-timeout,
.status-disabled { background: rgba(107, 114, 128, 0.14); color: var(--text-dim); }
.status-exhausted { background: rgba(239, 68, 68, 0.12); color: var(--error); }

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 11px 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.form-group input:disabled { opacity: 0.55; cursor: not-allowed; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 13px 18px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
}

.btn-primary {
    background: var(--accent-grad);
    color: #fff;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.28);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 26px rgba(99, 102, 241, 0.4);
}

.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-ghost {
    margin-top: 10px;
    background: #fff;
    color: var(--text-dim);
    border: 1px solid #e5e7eb;
}

.btn-ghost:hover:not(:disabled) { border-color: #c7d2fe; color: var(--accent); }

.btn-ghost:disabled { opacity: 0.6; cursor: not-allowed; }

.btn[hidden] { display: none; }

.progress-section { margin-top: 18px; display: none; }
.progress-section.active { display: block; }

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
}

.progress-bar {
    height: 8px;
    background: rgba(99, 102, 241, 0.12);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-grad);
    border-radius: 999px;
    transition: width 0.35s ease;
}

.message-area { margin-top: 14px; min-height: 0; }

.msg {
    font-size: 14px;
    font-weight: 600;
    padding: 11px 14px;
    border-radius: 10px;
}

.msg-info { background: rgba(14, 165, 233, 0.1); color: var(--info); }
.msg-success { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.msg-error { background: rgba(239, 68, 68, 0.1); color: var(--error); }
.msg-warn { background: rgba(245, 158, 11, 0.12); color: var(--warn); }

.history-section { margin-top: 22px; display: none; }
.history-section.active { display: block; }

.history-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eef0f4;
}

.history-item {
    display: grid;
    grid-template-columns: 1.1fr 0.6fr auto 1.3fr;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    background: rgba(99, 102, 241, 0.05);
}

.history-item .h-code { font-weight: 800; color: #111827; }
.history-item .h-count { color: #374151; text-align: center; }
.history-item .h-time { color: #9ca3af; font-size: 13px; text-align: right; }
.history-item .status-badge { justify-self: center; }

@container (max-width: 400px) {
    .card { padding: 26px 16px 22px; }
    .info-item .ivalue { font-size: 14px; }
    .history-item {
        display: flex;
        flex-wrap: wrap;
        gap: 6px 10px;
    }
    .history-item .h-code { margin-right: auto; }
    .history-item .h-count { text-align: left; }
    .history-item .h-time {
        flex: 1 0 100%;
        text-align: right;
        font-size: 12px;
    }
}
