:root {
    --bg: #0f172a;
    --surface: #111c33;
    --surface-2: #17233d;
    --border: #24314d;
    --text: #e6edf7;
    --text-muted: #8fa1bd;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger-bg: #3b1d24;
    --danger-text: #fca5a5;
    --ok-bg: #14301f;
    --ok-text: #86efac;
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: radial-gradient(1200px 600px at 20% -10%, #1d2f52 0%, var(--bg) 55%);
    color: var(--text);
    line-height: 1.6;
}

/* ---------- 登录页 ---------- */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 36px 32px 28px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .45);
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    font-weight: 700;
    font-size: 22px;
    margin-bottom: 14px;
}

.brand-mark.small {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 0;
}

.auth-header h1 {
    margin: 0;
    font-size: 22px;
    letter-spacing: .5px;
}

.subtitle {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 13px;
    color: var(--text-muted);
}

.field input {
    height: 42px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .18);
}

.field input::placeholder {
    color: #5b6b85;
}

.btn-primary {
    height: 44px;
    margin-top: 6px;
    border: none;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .05s;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary:active {
    transform: translateY(1px);
}

.alert {
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid #5b2a33;
}

.alert-ok {
    background: var(--ok-bg);
    color: var(--ok-text);
    border: 1px solid #235c39;
}

.auth-footer {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px dashed var(--border);
}

.hint {
    margin: 4px 0;
    font-size: 12px;
    color: var(--text-muted);
}

.hint code {
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: 5px;
    color: #c7d6ef;
}

.hint.muted {
    color: #6b7c96;
    line-height: 1.5;
}

/* ---------- 控制台 ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, .7);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tag {
    font-size: 11px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 999px;
}

.user {
    font-size: 13px;
    color: var(--text-muted);
}

.inline-form {
    margin: 0;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--primary);
}

.console {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 20px 64px;
    display: grid;
    gap: 20px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.panel h2 {
    margin: 0 0 16px;
    font-size: 15px;
    letter-spacing: .3px;
    color: #cddaf0;
}

.kv {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 10px 16px;
    margin: 0;
}

.kv dt {
    color: var(--text-muted);
    font-size: 13px;
}

.kv dd {
    margin: 0;
    font-size: 14px;
}

.chip {
    display: inline-block;
    padding: 2px 10px;
    margin: 0 6px 6px 0;
    border-radius: 999px;
    background: rgba(59, 130, 246, .12);
    border: 1px solid rgba(59, 130, 246, .35);
    color: #93c5fd;
    font-size: 12px;
}

.endpoint-list {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.endpoint-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.endpoint-list li span {
    width: 84px;
    color: var(--text-muted);
}

.endpoint-list code {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    color: #c7d6ef;
}

.todo-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text-muted);
    font-size: 13px;
}

.todo-list li {
    margin: 6px 0;
}

.muted {
    color: var(--text-muted);
    font-size: 13px;
}

/* ---------- v0.3 认证源选择 ---------- */

.auth-card.wide {
    max-width: 480px;
}

.source-list {
    list-style: none;
    margin: 0 0 20px;
    padding: 0;
    display: grid;
    gap: 10px;
}

.source-item {
    margin: 0;
}

.source-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    text-decoration: none;
    color: var(--text);
    transition: border-color .15s, transform .05s, background .15s;
}

a.source-link:hover {
    border-color: var(--primary);
    background: #1a2a49;
}

a.source-link:active {
    transform: translateY(1px);
}

.source-item.is-disabled .source-link {
    opacity: .45;
    cursor: not-allowed;
}

.source-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
}

.source-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.source-name {
    font-size: 14px;
    font-weight: 600;
}

.source-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.source-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(59, 130, 246, .15);
    border: 1px solid rgba(59, 130, 246, .4);
    color: #93c5fd;
    white-space: nowrap;
}

.source-badge.muted {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}

.source-arrow {
    color: var(--text-muted);
    font-size: 16px;
}

/* ---------- v0.3 授权确认页 ---------- */

.consent-list {
    display: grid;
    gap: 10px;
    margin-bottom: 8px;
}

.consent-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    cursor: pointer;
}

.consent-item input[type="checkbox"] {
    margin-top: 3px;
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
}

.consent-main {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.consent-name {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.consent-name code {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    background: rgba(255, 255, 255, .05);
    padding: 1px 6px;
    border-radius: 5px;
}

.consent-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* ---------- v0.3 错误页 ---------- */

.error-card {
    text-align: center;
}

.error-code {
    font-size: 56px;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 8px 0 4px;
}

.error-card h1 {
    margin: 0 0 12px;
    font-size: 20px;
}

.error-card .muted {
    margin: 0 0 12px;
}

/* ---------- 通用 ---------- */

.btn-ghost.danger {
    color: #fca5a5;
    border-color: #5b2a33;
}

.btn-ghost.danger:hover {
    color: #fecaca;
    border-color: #7f3641;
}

.btn-primary.block {
    display: block;
    width: 100%;
    margin-top: 18px;
    line-height: 44px;
    text-align: center;
    text-decoration: none;
}

.link {
    color: #93c5fd;
    text-decoration: none;
}

.link:hover {
    text-decoration: underline;
}

.todo-list li.done {
    color: #86efac;
    text-decoration: line-through;
    text-decoration-color: rgba(134, 239, 172, .4);
}

.todo-list li.doing {
    color: #93c5fd;
    font-weight: 600;
}
