:root {
    color-scheme: dark;
    font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    --background: #09101f;
    --sidebar: #0d1728;
    --panel: #111d31;
    --panel-soft: #16243a;
    --border: #263650;
    --text: #f2f5f9;
    --muted: #94a3b8;
    --primary: #f59e0b;
    --primary-strong: #d97706;
    --success: #34d399;
    --danger: #fb7185;
    --blue: #60a5fa;
    --purple: #c084fc;
}

* { box-sizing: border-box; }

/*
 * login-screen 和 app-shell 都显式声明了 display:grid。部分浏览器中该声明会
 * 覆盖 hidden 属性的默认样式，造成登录成功后节点状态已切换、画面却不切换。
 */
[hidden] { display: none !important; }

body {
    margin: 0;
    min-width: 1080px;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 80% 0%, rgba(37, 99, 235, .12), transparent 34%),
        var(--background);
}

.login-screen { display: grid; min-height: 100vh; place-items: center; padding: 32px; }
.login-card { display: grid; gap: 16px; width: min(430px, 100%); padding: 34px; border: 1px solid var(--border); border-radius: 18px; background: rgba(17,29,49,.97); box-shadow: 0 30px 100px rgba(0,0,0,.4); }
.login-card .brand-mark { margin-bottom: 4px; }
.login-card p { margin: 0; color: var(--muted); line-height: 1.6; }
.login-card label { display: grid; gap: 7px; color: #d8e1ed; font-size: 13px; font-weight: 700; }
.login-card input { min-height: 44px; padding: 10px 12px; color: var(--text); border: 1px solid var(--border); border-radius: 8px; background: #0d1728; }
.login-card .form-error { margin: 0; }
.admin-identity { align-self: center; color: var(--muted); font-size: 12px; }
.publish-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 0; }
.publish-controls > strong { flex-basis: 100%; }
.publish-controls > label { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }
.publish-controls input:not([type="checkbox"]) { min-width: 150px; padding: 8px 10px; color: var(--text); border: 1px solid var(--border); border-radius: 7px; background: #0d1728; }

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 28px 18px;
    background: rgba(13, 23, 40, .96);
    border-right: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: #1b1202;
    font-size: 20px;
    font-weight: 900;
    border-radius: 12px;
    background: linear-gradient(135deg, #fbbf24, #f97316);
    box-shadow: 0 8px 30px rgba(245, 158, 11, .22);
}
.brand strong, .brand span { display: block; }
.brand strong { font-size: 16px; letter-spacing: .02em; }
.brand span { margin-top: 3px; color: var(--muted); font-size: 12px; }

nav { display: grid; gap: 8px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    color: #b8c4d6;
    text-align: left;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
}
.nav-item span { width: 20px; color: #64748b; font-size: 18px; text-align: center; }
.nav-item:hover { color: white; background: rgba(255,255,255,.04); }
.nav-item.active {
    color: #fff6d8;
    border-color: rgba(245, 158, 11, .35);
    background: rgba(245, 158, 11, .12);
}
.nav-item.active span { color: var(--primary); }

.sidebar-note {
    margin-top: auto;
    padding: 14px;
    color: #cbd5e1;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255,255,255,.025);
}
.sidebar-note small { display: block; margin: 6px 0 0 16px; color: var(--muted); }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 12px var(--success); }

.main-content { padding: 34px 38px 48px; overflow: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 7px; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2 { margin: 0; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
#pageDescription { margin: 8px 0 0; color: var(--muted); }
.topbar-actions { display: flex; gap: 10px; }

.button {
    min-height: 40px;
    padding: 9px 16px;
    color: white;
    font-weight: 700;
    border: 1px solid transparent;
    border-radius: 8px;
}
.button.primary { color: #231604; background: linear-gradient(135deg, #fbbf24, var(--primary-strong)); }
.button.primary:hover { filter: brightness(1.08); }
.button.secondary { color: #dbe4f1; border-color: var(--border); background: #17243a; }
.button.secondary:hover { border-color: #415574; background: #1c2c45; }
.button.danger { color: #fecdd3; border-color: rgba(251,113,133,.35); background: rgba(190,24,93,.13); }
.button.reward { color: #d8b4fe; border-color: rgba(192,132,252,.38); background: rgba(126,34,206,.15); }
.button.small { min-height: 32px; padding: 5px 10px; font-size: 12px; font-weight: 600; }
.button:disabled { cursor: not-allowed; opacity: .55; }

.dashboard { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card {
    padding: 17px 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: linear-gradient(145deg, rgba(22,36,58,.94), rgba(14,27,46,.94));
}
.metric-card span { color: var(--muted); font-size: 13px; }
.metric-card strong { display: block; margin-top: 8px; font-size: 26px; }
.metric-card small { color: #6ee7b7; }

.panel { border: 1px solid var(--border); border-radius: 14px; background: rgba(17,29,49,.93); box-shadow: 0 20px 70px rgba(0,0,0,.16); overflow: hidden; }
.toolbar { display: flex; align-items: center; gap: 10px; min-height: 68px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.toolbar #createButton { margin-left: auto; }
.search-box { display: flex; align-items: center; gap: 8px; width: min(340px, 35vw); padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: #0d1728; }
.search-box span { color: var(--muted); font-size: 20px; }
.search-box input { width: 100%; height: 40px; color: var(--text); border: 0; outline: 0; background: transparent; }
select, .field input, .field textarea {
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    background: #0d1728;
}
select { height: 42px; padding: 0 34px 0 12px; }
select:focus, .field input:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(245,158,11,.1); }
.extra-filters { display: flex; gap: 10px; }

.table-wrap { position: relative; min-height: 430px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 15px; text-align: left; border-bottom: 1px solid rgba(38,54,80,.72); white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; color: #8fa0b7; font-size: 12px; font-weight: 700; letter-spacing: .04em; background: #101b2e; }
td { color: #dce5f1; font-size: 13px; }
tr:hover td { background: rgba(255,255,255,.018); }
tr.disabled-row td { opacity: .55; }
.primary-cell strong, .primary-cell small { display: block; }
.primary-cell strong { color: white; }
.primary-cell small { margin-top: 4px; color: var(--muted); font-family: ui-monospace, monospace; font-size: 11px; }
.description-cell { max-width: 270px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 7px; }

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; color: #dbeafe; font-size: 11px; font-weight: 800; border: 1px solid #334155; border-radius: 999px; background: #1e293b; }
.badge.success { color: #a7f3d0; border-color: rgba(52,211,153,.3); background: rgba(16,185,129,.1); }
.badge.off { color: #cbd5e1; background: #253044; }
.badge.n, .badge.common { color: #e2e8f0; }
.badge.r, .badge.rare { color: #93c5fd; border-color: rgba(96,165,250,.35); background: rgba(37,99,235,.12); }
.badge.sr, .badge.epic { color: #d8b4fe; border-color: rgba(192,132,252,.35); background: rgba(126,34,206,.12); }
.badge.ssr, .badge.legendary { color: #fde68a; border-color: rgba(251,191,36,.35); background: rgba(217,119,6,.12); }

.empty-state { position: absolute; inset: 120px 0 auto; color: var(--muted); text-align: center; }
.empty-state div { margin-bottom: 7px; color: #d4ddea; font-size: 17px; }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 10px; min-height: 58px; padding: 10px 16px; color: var(--muted); font-size: 13px; }

.dialog { width: min(920px, calc(100vw - 60px)); max-height: calc(100vh - 60px); padding: 0; color: var(--text); border: 1px solid #3a4d6c; border-radius: 14px; background: #111d31; box-shadow: 0 30px 100px rgba(0,0,0,.58); }
.dialog::backdrop { background: rgba(2,6,15,.76); backdrop-filter: blur(4px); }
.dialog-header, .dialog-actions { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; }
.dialog-header { border-bottom: 1px solid var(--border); }
.dialog-actions { justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border); }
.icon-button { width: 36px; height: 36px; color: var(--muted); font-size: 25px; border: 0; border-radius: 8px; background: transparent; }
.icon-button:hover { color: white; background: rgba(255,255,255,.06); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; max-height: calc(100vh - 260px); padding: 22px 24px; overflow-y: auto; }
.field { display: grid; align-content: start; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { color: #d8e1ed; font-size: 13px; font-weight: 700; }
.field input, .field textarea { width: 100%; min-height: 42px; padding: 10px 12px; }
.field textarea { min-height: 88px; resize: vertical; }
.field small { color: var(--muted); font-size: 11px; line-height: 1.5; }
.field.checkbox { display: flex; align-items: center; gap: 10px; padding-top: 24px; }
.field.checkbox input { width: 18px; min-height: 18px; accent-color: var(--primary); }
.field.checkbox label { cursor: pointer; }
.nested-manager { padding: 15px; border: 1px solid var(--border); border-radius: 10px; background: rgba(8,16,30,.38); }
.nested-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.nested-heading label, .nested-heading small { display: block; }
.nested-heading small { margin-top: 5px; }
.nested-row { display: grid; gap: 9px; margin-top: 12px; padding: 12px; border: 1px solid #2c3d58; border-radius: 9px; background: #101a2c; }
.nested-row input, .nested-row textarea, .nested-row select { width: 100%; min-height: 38px; padding: 8px 10px; color: var(--text); border: 1px solid var(--border); border-radius: 7px; background: #0a1322; }
.nested-row textarea { resize: vertical; }
.code-suffix { display: flex; align-items: stretch; min-width: 0; }
.code-suffix span { display: flex; align-items: center; padding: 0 9px; color: #fbbf24; font-family: ui-monospace, monospace; font-size: 12px; white-space: nowrap; border: 1px solid var(--border); border-right: 0; border-radius: 7px 0 0 7px; background: #17243a; }
.code-suffix input { min-width: 0; border-radius: 0 7px 7px 0; }
.sequence-control { display: grid; grid-template-columns: 150px 1fr; gap: 12px; }
.code-previews { display: grid; gap: 5px; padding: 8px 11px; color: var(--muted); font-size: 11px; border: 1px solid var(--border); border-radius: 8px; background: #0a1322; }
.code-previews strong { color: #fbbf24; font-family: ui-monospace, monospace; font-size: 12px; }
.issued-count-display { display: flex; align-items: center; min-height: 42px; padding: 8px 12px; color: #6ee7b7; font-family: ui-monospace, monospace; font-size: 20px; font-weight: 800; border: 1px solid rgba(52,211,153,.28); border-radius: 8px; background: rgba(16,185,129,.08); }
.category-stats { padding: 15px; border: 1px solid rgba(96,165,250,.28); border-radius: 10px; background: rgba(37,99,235,.06); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stats-grid div { padding: 11px; border: 1px solid var(--border); border-radius: 8px; background: #0d1728; }
.stats-grid span, .stats-grid strong, .stats-grid small { display: block; }
.stats-grid span { color: var(--muted); font-size: 11px; }
.stats-grid strong { margin-top: 5px; color: #f8fafc; font-size: 18px; }
.probability-input { display: inline-flex; align-items: center; width: 180px; border: 1px solid var(--border); border-radius: 8px; background: #0d1728; overflow: hidden; }
.probability-input input { width: 140px; min-height: 40px; padding: 8px 10px; color: var(--text); border: 0; outline: 0; background: transparent; }
.probability-input span { color: var(--muted); }
.probability-valid { color: var(--success); }
.probability-invalid { color: var(--danger); font-weight: 700; }
.probability-editor { display: grid; grid-template-columns: 180px 1fr; align-items: center; gap: 14px; }
.probability-editor > input { width: 100%; }
.series-row { grid-template-columns: 1.2fr 1.2fr 90px 80px auto; }
.series-row textarea { grid-column: 1 / 5; }
.series-stats { grid-column: 1 / -1; padding-top: 8px; color: #93c5fd; font-size: 11px; border-top: 1px dashed var(--border); }
.bond-row { grid-template-columns: 1.2fr 1fr 1fr 100px; }
.bond-row .wide { grid-column: 1 / -1; }
.mini-check { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.mini-check input { width: 16px; min-height: 16px; accent-color: var(--primary); }
.nested-empty { margin: 14px 0 2px; color: var(--muted); font-size: 12px; }
.form-error { margin: 0 24px 18px; padding: 10px 12px; color: #fecdd3; border: 1px solid rgba(251,113,133,.3); border-radius: 8px; background: rgba(190,24,93,.1); }
.reward-tip { padding: 11px 13px; color: #fde68a; font-size: 12px; line-height: 1.6; border: 1px solid rgba(251,191,36,.28); border-radius: 8px; background: rgba(217,119,6,.08); }

.audit-dialog { width: min(1000px, calc(100vw - 60px)); }
.audit-dialog-content { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-height: calc(100vh - 220px); padding: 20px 24px; overflow: auto; }
.audit-summary { grid-column: 1 / -1; margin: 0; padding: 13px 15px; color: #dbeafe; line-height: 1.7; border-left: 3px solid var(--primary); border-radius: 0 8px 8px 0; background: rgba(37,99,235,.1); }
.audit-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; grid-column: 1 / -1; margin: 0; padding: 15px; border: 1px solid var(--border); border-radius: 10px; background: #0d1728; }
.audit-meta div { display: grid; grid-template-columns: 80px 1fr; gap: 8px; }
.audit-meta .full { grid-column: 1 / -1; }
.audit-meta dt { color: var(--muted); font-size: 12px; }
.audit-meta dd { margin: 0; color: var(--text); font-size: 13px; overflow-wrap: anywhere; }
.audit-text-block { min-width: 0; }
.audit-text-block h3 { margin: 0 0 8px; color: #d8e1ed; font-size: 14px; }
.audit-readable-fields { margin: 0; padding: 4px 14px; border: 1px solid var(--border); border-radius: 8px; background: #0d1728; }
.audit-readable-fields > div { display: grid; grid-template-columns: minmax(96px, 34%) 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(51,65,85,.72); }
.audit-readable-fields > div:last-child { border-bottom: 0; }
.audit-readable-fields dt { color: var(--muted); font-size: 12px; line-height: 1.6; }
.audit-readable-fields dd { min-width: 0; margin: 0; color: var(--text); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.audit-readable-fields .audit-readable-fields { padding: 0 10px; }
.audit-value-list { margin: 0; padding-left: 22px; }
.audit-value-list li { padding: 3px 0; }
.audit-empty-value { margin: 0; color: var(--muted); font-size: 13px; font-style: italic; }
.toast { position: fixed; right: 26px; bottom: 26px; z-index: 20; max-width: 420px; padding: 13px 18px; color: white; border: 1px solid rgba(52,211,153,.36); border-radius: 9px; background: #064e3b; box-shadow: 0 15px 45px rgba(0,0,0,.35); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(251,113,133,.42); background: #7f1d1d; }

@media (max-width: 1200px) {
    .main-content { padding-inline: 24px; }
    .dashboard { grid-template-columns: repeat(2, 1fr); }
    .audit-dialog-content { grid-template-columns: 1fr; }
    .audit-summary, .audit-meta { grid-column: 1; }
}
