:root {
  color-scheme: dark;
  --bg: #080c12;
  --panel: #0d131d;
  --panel-2: #111925;
  --panel-3: #151e2b;
  --line: rgba(145, 174, 207, .13);
  --line-strong: rgba(145, 174, 207, .28);
  --ink: #e2e9f3;
  --muted: #8290a3;
  --accent: #8cafd2;
  --success: #5bc58d;
  --warn: #d7aa53;
  --danger: #e07878;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; background: linear-gradient(rgba(140,175,210,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(140,175,210,.025) 1px, transparent 1px); background-size: 48px 48px; mask-image: linear-gradient(to bottom, #000, transparent 70%); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.kicker { margin: 0 0 7px; font-family: var(--mono); font-size: 9px; letter-spacing: .18em; color: #617083; text-transform: uppercase; }
.muted { color: var(--muted); line-height: 1.7; }
.stack { display: grid; gap: 14px; }

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 28px; position: relative; }
.auth-card { width: min(460px, 100%); padding: 42px; border: 1px solid var(--line); border-radius: 5px; background: rgba(12,18,27,.9); box-shadow: 0 35px 100px rgba(0,0,0,.35); backdrop-filter: blur(20px); }
.auth-mark { display: flex; align-items: center; gap: 11px; margin-bottom: 40px; font-family: var(--mono); color: #91a3b8; font-size: 11px; letter-spacing: .14em; }
.auth-mark i { width: 32px; height: 1px; background: var(--line-strong); }
.auth-card h1 { margin: 0 0 9px; font-size: 25px; font-weight: 500; }
.auth-card > .muted { margin: 0 0 24px; }
.auth-status { min-height: 18px; margin-top: 14px; color: var(--danger); font-size: 12px; line-height: 1.6; }
.back-site { display: inline-block; margin-top: 26px; text-decoration: none; font-family: var(--mono); font-size: 10px; color: #596778; }
.back-site:hover { color: var(--accent); }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); position: relative; }
.sidebar { position: sticky; top: 0; height: 100vh; z-index: 80; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: rgba(9,14,21,.95); }
.sidebar__brand { height: 78px; display: flex; flex-direction: column; justify-content: center; padding: 0 24px; border-bottom: 1px solid var(--line); }
.brand-cn { font-size: 18px; letter-spacing: .3em; }
.brand-cms { margin-top: 5px; font-family: var(--mono); color: #4c5a6a; font-size: 8px; letter-spacing: .15em; }
.side-nav { flex: 1; display: grid; align-content: start; gap: 3px; padding: 17px 11px; overflow-y: auto; }
.side-nav button { width: 100%; height: 42px; padding: 0 12px; display: flex; align-items: center; gap: 11px; border: 1px solid transparent; border-radius: 3px; background: transparent; color: #78879a; cursor: pointer; text-align: left; transition: .18s ease; }
.side-nav button span { width: 18px; color: #536377; font-family: var(--mono); text-align: center; }
.side-nav button:hover { background: rgba(140,175,210,.055); color: #b7c3d2; }
.side-nav button.is-active { border-color: var(--line); background: rgba(140,175,210,.085); color: #d3dde9; }
.side-nav button.is-active span { color: var(--accent); }
.sidebar__bottom { margin-top: auto; padding: 17px 22px 20px; display: grid; gap: 9px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 9px; }
.sidebar__bottom a, .sidebar__bottom button { padding: 0; border: 0; background: none; text-align: left; text-decoration: none; color: #586779; cursor: pointer; }
.sidebar__bottom a:hover, .sidebar__bottom button:hover { color: #a6b5c6; }

.admin-main { min-width: 0; }
.topbar { min-height: 78px; position: sticky; top: 0; z-index: 60; display: flex; align-items: center; gap: 18px; padding: 12px 30px; border-bottom: 1px solid var(--line); background: rgba(8,12,18,.88); backdrop-filter: blur(20px); }
.topbar h1 { margin: 0; font-size: 20px; font-weight: 500; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.mobile-menu { display: none; border: 1px solid var(--line); background: var(--panel); width: 38px; height: 38px; border-radius: 3px; cursor: pointer; }
.workspace { width: min(1180px, calc(100% - 60px)); margin: 0 auto; padding: 34px 0 70px; }
.loading { padding: 80px 0; text-align: center; font-family: var(--mono); color: #506075; font-size: 10px; letter-spacing: .15em; }

.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 13px; border: 1px solid var(--line-strong); border-radius: 3px; background: rgba(140,175,210,.11); color: #d4deea; cursor: pointer; text-decoration: none; font-size: 12px; transition: .16s ease; }
.button:hover { border-color: rgba(140,175,210,.48); background: rgba(140,175,210,.16); }
.button.primary { background: #8cafd2; border-color: #8cafd2; color: #101722; font-weight: 600; }
.button.primary:hover { background: #a1bfdb; }
.button.secondary { background: transparent; color: #8d9bae; }
.button.danger { color: #f0a0a0; border-color: rgba(224,120,120,.28); background: rgba(224,120,120,.08); }
.button.small { min-height: 30px; padding: 4px 9px; font-size: 11px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 28px; }
.stat-card { min-height: 124px; padding: 20px; border: 1px solid var(--line); border-radius: 4px; background: rgba(13,19,29,.78); }
.stat-card small { display: block; margin-bottom: 18px; font-family: var(--mono); color: #607084; font-size: 9px; letter-spacing: .12em; }
.stat-card strong { display: block; font-family: var(--mono); font-size: 32px; font-weight: 300; }
.stat-card span { color: #5d6c7e; font-size: 11px; }
.panel-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .7fr); gap: 12px; }
.panel { border: 1px solid var(--line); border-radius: 4px; background: rgba(13,19,29,.74); overflow: hidden; }
.panel__head { min-height: 56px; padding: 13px 17px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.panel__head h2 { margin: 0; font-size: 14px; font-weight: 500; }
.panel__body { padding: 18px; }
.quick-list { display: grid; gap: 10px; }
.quick-item { display: flex; justify-content: space-between; gap: 18px; padding-bottom: 10px; border-bottom: 1px solid rgba(140,175,210,.07); }
.quick-item:last-child { border: 0; padding-bottom: 0; }
.quick-item strong { font-size: 12px; font-weight: 500; }
.quick-item span { font-size: 11px; color: #667588; }
.health-row { display: flex; align-items: center; gap: 9px; margin: 9px 0; color: #8594a6; font-size: 12px; }
.health-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.health-dot.ok { background: var(--success); }

.table-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.table-toolbar .input { flex: 1 1 260px; }
.data-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 4px; background: rgba(13,19,29,.72); }
.data-table { width: 100%; min-width: 780px; border-collapse: collapse; }
.data-table th { height: 40px; padding: 0 13px; text-align: left; font-family: var(--mono); font-weight: 400; font-size: 9px; color: #536276; letter-spacing: .09em; border-bottom: 1px solid var(--line); background: rgba(140,175,210,.025); }
.data-table td { padding: 12px 13px; border-bottom: 1px solid rgba(140,175,210,.07); color: #8d9caf; font-size: 12px; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: rgba(140,175,210,.025); }
.data-table td strong { color: #c6d1de; font-weight: 500; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 99px; color: #738399; font-size: 10px; white-space: nowrap; }
.pill.green { color: #69c795; border-color: rgba(91,197,141,.18); }
.pill.gray { color: #768294; }
.empty-box { padding: 60px 20px; text-align: center; color: #657489; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }

.editor { max-width: 920px; }
.editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.editor-head h2 { margin: 0 0 6px; font-size: 22px; font-weight: 500; }
.editor-head p { margin: 0; color: #6d7b8d; line-height: 1.7; }
.form-section { margin-bottom: 14px; padding: 22px; border: 1px solid var(--line); border-radius: 4px; background: rgba(13,19,29,.72); }
.form-section > h3 { margin: 0 0 18px; font-size: 13px; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-grid.one { grid-template-columns: 1fr; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { color: #8c9aad; font-size: 12px; }
.required { color: #db8888; margin-left: 3px; }
.hint { color: #536275; font-size: 10px; line-height: 1.6; }
.input, .textarea, .select { width: 100%; border: 1px solid var(--line); border-radius: 3px; background: #0a1018; color: #c9d4e1; outline: none; transition: border-color .15s ease; }
.input, .select { height: 40px; padding: 0 11px; }
.textarea { min-height: 118px; resize: vertical; padding: 10px 11px; line-height: 1.7; }
.textarea.tall { min-height: 330px; }
.input:focus, .textarea:focus, .select:focus { border-color: rgba(140,175,210,.48); }
.input::placeholder, .textarea::placeholder { color: #394657; }
.input:disabled { opacity: .5; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 11px 0; border-bottom: 1px solid rgba(140,175,210,.07); }
.switch-row:last-child { border: 0; }
.switch-row strong { display: block; margin-bottom: 3px; font-size: 12px; font-weight: 500; }
.switch-row p { margin: 0; color: #5d6c7f; font-size: 10px; }
.switch { position: relative; width: 42px; height: 23px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: absolute; inset: 0; border: 1px solid var(--line-strong); border-radius: 99px; background: #0a1018; cursor: pointer; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 15px; height: 15px; top: 3px; left: 3px; border-radius: 50%; background: #5a6879; transition: .15s; }
.switch input:checked + span { background: rgba(140,175,210,.18); border-color: rgba(140,175,210,.5); }
.switch input:checked + span::after { transform: translateX(19px); background: var(--accent); }
.form-actions { display: flex; gap: 8px; align-items: center; position: sticky; bottom: 12px; z-index: 10; padding: 11px; border: 1px solid var(--line); border-radius: 4px; background: rgba(8,12,18,.92); backdrop-filter: blur(16px); }
.form-actions .spacer { flex: 1; }
.image-preview { width: 160px; height: 110px; object-fit: cover; border: 1px solid var(--line); border-radius: 3px; background: #080c12; }
.image-preview[hidden] { display: none; }
.avatar-preview { width: 88px; height: 88px; object-fit: cover; border: 1px solid var(--line-strong); border-radius: 50%; background: #080c12; }
.avatar-preview[hidden] { display: none; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-input { width: 46px; height: 40px; padding: 3px; border: 1px solid var(--line); border-radius: 3px; background: #0a1018; }
.range-row { display: grid; grid-template-columns: 1fr 62px; gap: 12px; align-items: center; }
.range-row input[type="range"] { accent-color: var(--accent); }
.font-upload-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.wide-editor { max-width: 1080px; }
.switch-stack { margin-top: 14px; }

.inbox-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.inbox-tabs button { min-height: 40px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 3px; background: var(--panel); color: #718196; cursor: pointer; }
.inbox-tabs button span { display: inline-grid; min-width: 20px; min-height: 20px; margin-left: 5px; place-items: center; border-radius: 99px; background: rgba(140,175,210,.08); font-family: var(--mono); font-size: 9px; }
.inbox-tabs button.is-active { border-color: rgba(140,175,210,.42); background: rgba(140,175,210,.11); color: #cbd6e3; }
.inbox-list { display: grid; gap: 10px; }
.inbox-card { padding: 18px; border: 1px solid var(--line); border-radius: 4px; background: rgba(13,19,29,.72); }
.inbox-card.is-pending { border-left: 3px solid var(--accent); }
.inbox-card > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.inbox-card > header > div { display: flex; align-items: center; gap: 10px; }
.inbox-card time, .inbox-card code { color: #59687a; font-family: var(--mono); font-size: 9px; }
.inbox-card dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 13px 0; border: 1px solid rgba(140,175,210,.08); }
.inbox-card dl > div { min-width: 0; padding: 11px 12px; border-bottom: 1px solid rgba(140,175,210,.07); }
.inbox-card dt { margin-bottom: 5px; color: #58687b; font-family: var(--mono); font-size: 9px; }
.inbox-card dd { margin: 0; color: #a4b0bf; font-size: 12px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.inbox-card > footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.message-preview { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; max-width: 430px; white-space: pre-wrap; }
.reply-preview { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; margin-top: 6px; max-width: 430px; color: #71839a; }
.message-full { color: #b4c0ce; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; }
.guestbook-table { min-width: 980px; }

.field-builder { margin-top: 24px; padding-top: 19px; border-top: 1px solid var(--line); }
.field-builder__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.field-builder__head strong { color: #aab7c7; font-size: 12px; font-weight: 500; }
.field-builder__head p { margin: 4px 0 0; color: #526174; font-size: 10px; }
.field-builder__list { display: grid; gap: 10px; }
.form-field-row { padding: 16px; border: 1px solid rgba(140,175,210,.11); border-radius: 3px; background: rgba(7,12,18,.48); }
.form-field-row__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.form-field-row__top strong { color: #78899d; font-family: var(--mono); font-size: 9px; font-weight: 400; letter-spacing: .1em; }
.code-textarea { font-family: var(--mono); font-size: 10px; line-height: 1.6; }

.section-editor { display: grid; gap: 10px; }
.section-card { padding: 18px; border: 1px solid var(--line); border-radius: 4px; background: rgba(13,19,29,.72); }
.section-card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.section-card__head h3 { margin: 0; font-size: 14px; font-weight: 500; }
.section-card__head code { color: #5d6e82; font-family: var(--mono); font-size: 9px; }

.notice { margin-bottom: 14px; padding: 13px 15px; border: 1px solid rgba(215,170,83,.22); border-left: 3px solid var(--warn); background: rgba(215,170,83,.055); color: #a99777; font-size: 11px; line-height: 1.7; }
.notice.success { border-color: rgba(91,197,141,.22); border-left-color: var(--success); background: rgba(91,197,141,.05); color: #83a895; }
.code-box { display: block; padding: 12px; border: 1px solid var(--line); background: #080d14; color: #91a2b7; font-family: var(--mono); font-size: 10px; line-height: 1.7; overflow-x: auto; }

.dialog { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; padding: 20px; }
.dialog__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(6px); }
.dialog__panel { position: relative; width: min(430px, 100%); padding: 26px; border: 1px solid var(--line-strong); border-radius: 5px; background: #0d141e; box-shadow: 0 25px 80px rgba(0,0,0,.5); }
.dialog__panel h2 { margin: 0 0 9px; font-size: 18px; }
.dialog__panel p { margin: 0; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 23px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 500; max-width: 360px; padding: 11px 14px; transform: translateY(16px); opacity: 0; pointer-events: none; border: 1px solid var(--line-strong); border-radius: 4px; background: #101824; color: #cad5e2; box-shadow: 0 16px 50px rgba(0,0,0,.4); font-size: 12px; transition: .2s ease; }
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast.is-error { border-color: rgba(224,120,120,.35); color: #e7a0a0; }

@media (max-width: 1000px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .admin-shell { display: block; }
  .sidebar { position: fixed; left: 0; width: 240px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 16px 0 60px rgba(0,0,0,.4); }
  .sidebar.is-open { transform: translateX(0); }
  .mobile-menu { display: block; }
  .topbar { padding-inline: 16px; }
  .workspace { width: calc(100% - 30px); padding-top: 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .inbox-card dl { grid-template-columns: 1fr; }
  .field-builder__head { align-items: flex-start; flex-direction: column; }
  .topbar__actions .button.secondary { display: none; }
}
@media (max-width: 520px) {
  .auth-screen { padding: 12px; }
  .auth-card { padding: 28px 21px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { min-height: 105px; padding: 15px; }
  .stat-card strong { font-size: 26px; }
  .form-section { padding: 17px; }
  .form-actions { flex-wrap: wrap; }
}
