:root {
    color-scheme: light;
    --bg: #f4f6fa;
    --panel: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #e4e7ec;
    --primary: #315efb;
    --primary-dark: #244bd6;
    --danger: #d92d20;
    --success: #067647;
    font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
}
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }

.topbar {
    height: 72px;
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark, .login-logo {
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, #315efb, #7f56d9);
    box-shadow: 0 8px 20px rgba(49, 94, 251, .23);
}
.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    font-size: 18px;
    font-weight: 800;
}
.brand strong { display: block; font-size: 16px; }
.brand small { display: block; margin-top: 2px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 16px; }
.admin-name { color: var(--muted); }
.link-button {
    appearance: none;
    border: 0;
    padding: 7px 10px;
    color: var(--primary);
    background: transparent;
    cursor: pointer;
}

.container { width: min(1500px, calc(100% - 40px)); margin: 28px auto 50px; }
.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}
h1, h2, p { margin-top: 0; }
.page-heading h1 { margin-bottom: 7px; font-size: 26px; }
.page-heading p, .panel-heading p { margin-bottom: 0; color: var(--muted); }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 17px;
    border: 0;
    border-radius: 9px;
    font-weight: 600;
    cursor: pointer;
    transition: .15s ease;
}
.button-primary { color: #fff; background: var(--primary); }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { color: #344054; background: #eaecf0; }
.button-secondary:hover { background: #dfe2e7; }
.button-block { width: 100%; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat-card {
    min-height: 112px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}
.stat-card span { display: block; color: var(--muted); }
.stat-card strong { display: block; margin-top: 12px; font-size: 30px; }
.stat-blue { border-top: 3px solid #315efb; }
.stat-slate { border-top: 3px solid #667085; }
.stat-green { border-top: 3px solid #12b76a; }
.stat-purple { border-top: 3px solid #7f56d9; }
.stat-orange { border-top: 3px solid #f79009; }
.stat-red { border-top: 3px solid #f04438; }

.panel {
    margin-bottom: 20px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: var(--panel);
    box-shadow: 0 2px 7px rgba(16, 24, 40, .03);
}
.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}
.panel-heading h2 { margin-bottom: 6px; font-size: 19px; }

.generate-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}
label {
    display: grid;
    gap: 7px;
    color: #344054;
    font-weight: 600;
}
input, select, textarea {
    width: 100%;
    border: 1px solid #d0d5dd;
    border-radius: 9px;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: #84adff;
    box-shadow: 0 0 0 3px rgba(49, 94, 251, .12);
}
.span-2 { grid-column: span 2; }
.span-4 { grid-column: span 4; }
.quick-values { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); }
.quick-values button {
    border: 1px solid #d0d5dd;
    border-radius: 999px;
    padding: 6px 11px;
    color: #344054;
    background: #fff;
    cursor: pointer;
}
.quick-values button:hover { border-color: var(--primary); color: var(--primary); }

.card-list-heading { align-items: flex-end; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters a {
    padding: 7px 11px;
    border-radius: 8px;
    color: var(--muted);
}
.filters a:hover, .filters a.active { color: var(--primary); background: #eef4ff; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 13px 10px; border-bottom: 1px solid #eaecf0; text-align: left; }
th { color: var(--muted); font-size: 12px; font-weight: 600; }
td { font-size: 13px; }
code { padding: 4px 6px; border-radius: 5px; color: #344054; background: #f2f4f7; }
.empty { padding: 45px; text-align: center; color: var(--muted); }
.badge {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.badge-green { color: #067647; background: #ecfdf3; }
.badge-slate { color: #475467; background: #f2f4f7; }
.badge-orange { color: #b54708; background: #fffaeb; }
.badge-red { color: #b42318; background: #fef3f2; }
.row-actions { display: flex; gap: 5px; }
.row-actions form { margin: 0; }
.row-actions button {
    border: 0;
    border-radius: 6px;
    padding: 6px 8px;
    color: #344054;
    background: #eaecf0;
    cursor: pointer;
}
.row-actions button.danger { color: #b42318; background: #fef3f2; }

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 9px;
}
.alert-success { color: #067647; background: #ecfdf3; border: 1px solid #abefc6; }
.alert-error { color: #b42318; background: #fef3f2; border: 1px solid #fecdca; }

.login-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 15%, rgba(49, 94, 251, .14), transparent 33%),
        radial-gradient(circle at 80% 80%, rgba(127, 86, 217, .12), transparent 32%),
        #f6f8fc;
}
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 25px;
}
.login-card {
    width: min(430px, 100%);
    padding: 38px;
    border: 1px solid rgba(208, 213, 221, .75);
    border-radius: 18px;
    background: rgba(255, 255, 255, .95);
    box-shadow: 0 22px 60px rgba(16, 24, 40, .12);
}
.login-logo { width: 56px; height: 56px; margin-bottom: 22px; border-radius: 16px; font-size: 25px; font-weight: 800; }
.login-card h1 { margin-bottom: 8px; font-size: 25px; }
.login-card > p { margin-bottom: 25px; color: var(--muted); line-height: 1.7; }
.stack-form { display: grid; gap: 17px; }

.generated-panel { max-width: 980px; }
.generated-summary { display: flex; flex-wrap: wrap; gap: 22px; margin-bottom: 16px; color: var(--muted); }
.generated-summary strong { color: var(--text); }
.key-output {
    min-height: 360px;
    resize: vertical;
    font: 15px/1.8 Consolas, monospace;
    color: #172033;
    background: #f8fafc;
}
.generated-actions { display: flex; gap: 10px; margin-top: 16px; }
.warning-text { margin: 15px 0 0; color: #b54708; }
.empty-state { padding: 55px 20px; text-align: center; }
.empty-state p { color: var(--muted); }

@media (max-width: 1150px) {
    .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .topbar { padding: 0 16px; }
    .brand small, .admin-name { display: none; }
    .container { width: min(100% - 22px, 1500px); margin-top: 18px; }
    .page-heading, .panel-heading { align-items: flex-start; flex-direction: column; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .generate-grid { grid-template-columns: 1fr; }
    .span-2, .span-4 { grid-column: span 1; }
    .panel { padding: 16px; }
    .login-card { padding: 27px; }
}
