:root {
    color-scheme: light;
    --ink: #18243a;
    --muted: #52627b;
    --border: #dce4ef;
    --surface: #fff;
    --background: #f2f5fa;
    --blue: #254cd7;
    --blue-dark: #1939af;
    --danger: #af253b;
    font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
    color: var(--ink);
    background: var(--background);
}

* { box-sizing: border-box; }
body { margin: 0; line-height: 1.55; }
[hidden] { display: none !important; }
button, input { font: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.9rem, 4vw, 2.5rem); line-height: 1.18; letter-spacing: -.035em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
form { margin: 0; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.frame { width: min(1280px, calc(100% - 64px)); margin-inline: auto; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 2px 4px #18243a05; }
.button {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 42px; padding: 8px 15px; border: 1px solid var(--border);
    border-radius: 8px; background: var(--surface); color: var(--ink);
    font-size: .875rem; font-weight: 650; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.button:hover { background: #edf2fd; }
.button.small { min-height: 36px; padding: 5px 11px; }
.button.primary { background: var(--blue); border-color: var(--blue); color: white; }
.button.primary:hover { background: var(--blue-dark); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.brand-mark {
    display: inline-block; width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(#fff, #fff) 9px 9px / 7px 7px no-repeat,
        linear-gradient(#fff, #fff) 20px 9px / 7px 7px no-repeat,
        linear-gradient(#fff, #fff) 9px 20px / 7px 7px no-repeat,
        linear-gradient(#b4c3ff, #b4c3ff) 20px 20px / 7px 7px no-repeat, var(--blue);
}
.auth-page {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background: radial-gradient(ellipse at 50% 15%, #e1eaff, transparent 65%), var(--background);
}
.auth-card { width: min(100%, 420px); padding: clamp(24px, 6vw, 38px); box-shadow: 0 20px 70px #18346f15; }
.auth-card h1 { margin-top: 18px; }
.auth-card p { margin-top: 10px; }
.auth-card form { margin-top: 24px; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner, .brand, .account { display: flex; align-items: center; gap: 12px; }
.topbar-inner { min-height: 67px; justify-content: space-between; }
.brand { text-decoration: none; color: var(--ink); font-weight: 750; }
.account { color: var(--muted); font-size: .875rem; }
.account > span { overflow-wrap: anywhere; }
.workspace { padding-block: 36px 56px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 24px; }
.page-heading p { margin-top: 9px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.metric { display: grid; gap: 7px; padding: 18px 23px; }
.metric span { color: var(--muted); font-size: .875rem; }
.metric strong { font-size: clamp(1.25rem, 4vw, 2rem); line-height: 1.15; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 325px); gap: 20px; align-items: start; }
.editor, .list-header { padding: 22px; }
.editor p.muted, .qr-panel h2 + p { margin-top: 5px; }
.editor form { margin-top: 19px; }
.stack { display: grid; gap: 15px; min-width: 0; }
label { display: grid; gap: 7px; font-size: .875rem; font-weight: 650; }
input:not([type=hidden]) {
    width: 100%; min-width: 0; min-height: 42px; padding: 8px 11px;
    color: var(--ink); border: 1px solid #cbd6e6; border-radius: 8px; background: #fafcff; font-size: 1rem;
}
input::placeholder { color: #64748a; }
.list-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.search { display: flex; gap: 7px; width: min(100%, 310px); }
.search input { font-size: .875rem; }
.empty { display: grid; justify-items: center; gap: 8px; padding: 48px 20px 58px; text-align: center; border-top: 1px solid var(--border); }
.empty .brand-mark { margin-bottom: 4px; opacity: .85; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .875rem; }
th, td { padding: 13px 14px; border-top: 1px solid var(--border); }
th { font-weight: 650; background: #f6f8fd; color: var(--muted); }
th:first-child, td:first-child { padding-left: 22px; }
th:last-child, td:last-child { padding-right: 22px; }
td:not(:first-child), th { white-space: nowrap; }
.code-info { min-width: 130px; overflow-wrap: anywhere; }
.code-info span { display: block; max-width: 280px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-flex; border-radius: 999px; padding: 3px 9px; background: #edf0f5; color: #49566c; }
.badge.active { background: #dff5ed; color: #14634b; }
.actions, .row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.row-actions { flex-wrap: nowrap; gap: 11px; }
.text-action { border: 0; background: none; color: var(--blue); padding: 3px 0; text-decoration: none; cursor: pointer; }
.text-action:hover { text-decoration: underline; }
.text-action.danger { color: var(--danger); }
.notice { padding: 10px 14px; margin-bottom: 16px; border-radius: 8px; color: #125e44; background: #e4f7ef; }
.notice.error { margin-top: 12px; color: #972138; background: #ffedf0; }
.qr-panel { display: flex; align-items: center; gap: 22px; padding: 22px; margin-bottom: 20px; }
.qr-panel .stack { flex: 1; }
.qr-preview { width: 178px; height: 178px; border: 1px solid var(--border); border-radius: 10px; }
.feedback:empty { display: none; }
#qr-heading { overflow-wrap: anywhere; }
.code-types { border: 0; padding: 0; margin: 0; }
.code-types legend { padding: 0; margin-bottom: 6px; font-size: .875rem; font-weight: 650; }
.code-types label { display: inline-flex; align-items: center; gap: 5px; margin-right: 12px; }
.code-types input[type=radio] { width: 1rem; min-height: 0; height: 1rem; margin: 0; accent-color: var(--blue); }
.code-form:not(:has(input[value=wechat]:checked)) .wechat-fields,
.code-form:has(input[value=wechat]:checked) .url-field { display: none; }
.field-hint { font-size: .875rem; }
.badge.expiring { display: table; margin-top: 4px; background: #fff1d6; color: #844809; }
.background-fields { display: grid; gap: 9px; padding-top: 14px; border-top: 1px solid var(--border); }
.background-reset { display: flex; gap: 8px; align-items: center; }
.background-reset input[type=checkbox] { width: 1rem; min-height: 0; height: 1rem; margin: 0; accent-color: var(--blue); }
.wechat-page {
    min-height: 100vh; min-height: 100svh; display: grid; place-items: center;
    padding: 30px 16px; isolation: isolate;
    background: radial-gradient(ellipse at 14% 8%, #a2e5c6, transparent 55%),
        radial-gradient(ellipse at 90% 90%, #d1edb5, transparent 55%), #eaf7ef;
}
.wechat-backdrop {
    position: fixed; inset: 0; z-index: -2; width: 100%; height: 100%;
    object-fit: cover; object-position: center; pointer-events: none;
}
.wechat-page:has(.wechat-backdrop)::before {
    content: ""; position: fixed; inset: 0; z-index: -1; background: #102a1f4d;
}
.wechat-card {
    width: min(100%, 410px); padding: clamp(20px, 6vw, 32px); text-align: center;
    background: #f8fcfa; border: 1px solid #fff; border-radius: 26px;
    box-shadow: 0 20px 64px #142e2350; color: #143427;
}
.wechat-heading { display: grid; justify-items: center; gap: 10px; }
.wechat-label {
    display: inline-flex; gap: 7px; align-items: center;
    color: #21634b; font-size: .875rem; font-weight: 700;
}
.wechat-label span { width: 8px; height: 8px; background: #138657; border-radius: 50%; }
.wechat-card h1 { max-width: 100%; overflow-wrap: anywhere; font-size: clamp(1.5rem, 6vw, 2rem); }
.wechat-qr-frame { margin-block: 22px 18px; padding: 12px; border: 1px solid #d6e7de; border-radius: 18px; background: white; }
.wechat-image { display: block; margin-inline: auto; max-width: 100%; max-height: min(450px, 58vh); height: auto; object-fit: contain; }
.wechat-instructions { display: grid; gap: 5px; }
.wechat-instructions p + p { color: #486056; font-size: .875rem; }
.upgrade-link { display: flex; justify-content: end; gap: 10px; font-size: .875rem; margin-bottom: 14px; }
.upgrade-panel { margin-bottom: 20px; }

@media (max-width: 960px) {
    .columns { grid-template-columns: minmax(0, 1fr); }
    .editor { grid-row: 1; }
}
@media (max-width: 560px) {
    .frame { width: calc(100% - 32px); }
    .workspace { padding-top: 24px; }
    .account > span { display: none; }
    .metrics { gap: 8px; }
    .metric { padding: 12px 10px; }
    .page-heading { align-items: start; }
    .editor, .list-header, .qr-panel { padding: 16px; }
    .qr-panel { align-items: stretch; flex-direction: column; }
    .qr-preview { align-self: center; }
}
