:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --line: #e2e8f0;
    --text: #172033;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #15803d;
    --danger: #dc2626;
    --warning: #b45309;
    --sidebar: #111827;
    --shadow: 0 18px 40px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    color: #e5e7eb;
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 24px; }
.brand-mark {
    width: 42px; height: 42px; border-radius: 13px;
    display: grid; place-items: center;
    color: #fff; background: linear-gradient(135deg, #3b82f6, #6366f1);
    font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand small { margin-top: 3px; color: #94a3b8; font-size: 12px; }
.nav { display: grid; gap: 7px; }
.nav a { padding: 11px 13px; border-radius: 10px; color: #cbd5e1; }
.nav a:hover, .nav a.active { color: #fff; background: rgba(59, 130, 246, .18); }
.sidebar-foot {
    margin-top: auto; padding: 18px 8px 0; border-top: 1px solid rgba(255,255,255,.1);
    display: flex; justify-content: space-between; gap: 12px; color: #94a3b8; font-size: 13px;
}
.sidebar-foot a { color: #bfdbfe; }
.main { min-width: 0; padding: 32px; }
.topbar { margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; }
.topbar p { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.topbar h1 { margin: 0; font-size: 27px; }
.grid { display: grid; gap: 18px; }
.grid.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 12px; font-size: 30px; }
.stack { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.field-block { display: grid; gap: 7px; }
.field-block label { font-size: 13px; font-weight: 650; }
.field, .select, .textarea {
    width: 100%; min-height: 43px; padding: 10px 12px;
    border: 1px solid #cbd5e1; border-radius: 9px; color: var(--text); background: #fff;
    outline: none;
}
.textarea { min-height: 130px; resize: vertical; line-height: 1.65; }
.field:focus, .select:focus, .textarea:focus { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.helper { color: var(--muted); font-size: 12px; line-height: 1.6; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.btn {
    min-height: 40px; padding: 9px 15px;
    border: 0; border-radius: 9px; cursor: pointer; font-weight: 650;
    display: inline-flex; align-items: center; justify-content: center;
}
.btn.primary { color: #fff; background: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.soft { color: #334155; background: #eaf0f8; }
.btn.danger { color: #fff; background: var(--danger); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 13px; }
th { color: var(--muted); background: var(--surface-soft); font-weight: 650; }
td strong { font-weight: 700; }
.mono, code { font-family: "SFMono-Regular", Consolas, monospace; }
.badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: #e2e8f0; font-size: 12px; }
.badge.success { color: #166534; background: #dcfce7; }
.badge.warning { color: #92400e; background: #fef3c7; }
.badge.danger { color: #991b1b; background: #fee2e2; }
.notice, .token-notice {
    margin-bottom: 18px; padding: 14px 16px; border-radius: 11px; border: 1px solid;
}
.notice.success { color: #166534; background: #f0fdf4; border-color: #bbf7d0; }
.notice.error { color: #991b1b; background: #fef2f2; border-color: #fecaca; }
.token-notice { color: #713f12; background: #fffbeb; border-color: #fde68a; }
.token-notice p { margin: 5px 0 10px; font-size: 13px; }
.token-notice code { display: block; padding: 11px; color: #172033; background: #fff; border-radius: 8px; overflow-wrap: anywhere; }
.empty { padding: 34px; color: var(--muted); text-align: center; }
.login-page, .install-page {
    min-height: 100vh; padding: 30px;
    display: grid; place-items: center;
    background: radial-gradient(circle at top left, #dbeafe, transparent 36%), var(--bg);
}
.auth-card { width: min(100%, 560px); }
.auth-card h1 { margin: 0 0 8px; }
.auth-card > p { margin: 0 0 22px; color: var(--muted); line-height: 1.7; }
.install-card { width: min(100%, 860px); }
.requirements { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.requirement { padding: 12px; border-radius: 10px; background: var(--surface-soft); border: 1px solid var(--line); font-size: 13px; }
.requirement.ok { color: var(--success); }
.requirement.fail { color: var(--danger); }
.code-box { padding: 14px; border-radius: 10px; color: #dbeafe; background: #0f172a; overflow-x: auto; font: 12px/1.7 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; }
.section-gap { margin-top: 18px; }
.note-list { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.85; font-size: 13px; }

@media (max-width: 1000px) {
    .grid.metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: static; height: auto; padding: 16px; }
    .brand { padding-bottom: 14px; }
    .nav { display: flex; overflow-x: auto; }
    .nav a { white-space: nowrap; }
    .sidebar-foot { display: none; }
    .main { padding: 20px 14px 30px; }
    .grid.metrics, .grid.two, .form-grid, .requirements { grid-template-columns: 1fr; }
    .form-grid .wide { grid-column: auto; }
    .topbar h1 { font-size: 23px; }
}
