:root {
  color-scheme: dark;
  --bg: #080f20;
  --bg-soft: #0b172b;
  --panel: #0e1c33;
  --panel-raised: #122440;
  --line: rgba(116, 157, 231, .16);
  --line-strong: rgba(104, 154, 255, .34);
  --text: #eff4ff;
  --muted: #9bb0d1;
  --faint: #7188af;
  --blue: #1684ff;
  --cyan: #25d0ff;
  --green: #39dbad;
  --red: #ff718b;
  font-family: "Segoe UI Variable", "Segoe UI", "Microsoft YaHei UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--text); background: radial-gradient(ellipse at 15% 0%, rgba(32, 83, 152, .2), transparent 40%), var(--bg); }
button, input, textarea, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
[hidden] { display: none !important; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 420px); padding: 38px; border: 1px solid var(--line-strong); border-radius: 22px; background: linear-gradient(145deg, rgba(18, 36, 64, .94), rgba(9, 20, 38, .96)); box-shadow: 0 28px 90px rgba(0, 4, 18, .48); }
.brand { display: inline-flex; align-items: baseline; gap: 7px; color: var(--text); font-size: 19px; font-weight: 800; letter-spacing: .16em; text-decoration: none; }
.brand span { color: var(--cyan); }
.eyebrow { margin: 0; color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.login-card .eyebrow { margin-top: 34px; }
h1, h2, h3, p { margin-top: 0; }
.login-card h1 { margin: 8px 0; font-size: 26px; }
.muted { color: var(--muted); }
.login-card label, .field { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
.login-card label { margin-top: 20px; }
input, textarea, select { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--text); background: rgba(6, 15, 31, .76); }
textarea { min-height: 100px; resize: vertical; }
input[type="checkbox"] { width: 18px; min-height: 18px; accent-color: var(--blue); }
input[type="color"] { width: 56px; padding: 4px; }
.button { min-height: 40px; padding: 0 15px; border: 1px solid transparent; border-radius: 10px; font-weight: 700; transition: background-color .18s ease, border-color .18s ease, transform .18s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: linear-gradient(115deg, #1266e7, #258dff); box-shadow: 0 8px 22px rgba(22, 132, 255, .2); }
.button.primary:hover { background: linear-gradient(115deg, #2076f3, #39a3ff); }
.button.subtle { border-color: var(--line); color: var(--muted); background: rgba(255, 255, 255, .03); }
.button.subtle:hover { border-color: var(--line-strong); color: var(--text); background: rgba(255, 255, 255, .07); }
.button.full { width: 100%; margin-top: 24px; }
.form-error { min-height: 18px; margin: 12px 0 0; color: var(--red); font-size: 13px; }

.admin-app { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 3; display: flex; width: 236px; flex-direction: column; padding: 28px 18px 20px; border-right: 1px solid var(--line); background: rgba(8, 17, 34, .92); backdrop-filter: blur(18px); }
.sidebar-caption { margin: 44px 10px 12px; color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.side-nav { display: grid; gap: 6px; }
.nav-button { display: flex; min-height: 44px; align-items: center; gap: 13px; padding: 0 12px; border: 1px solid transparent; border-radius: 11px; color: var(--muted); text-align: left; background: transparent; }
.nav-button:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.nav-button.is-active { border-color: rgba(37, 128, 255, .18); color: var(--text); background: linear-gradient(90deg, rgba(22, 132, 255, .2), rgba(22, 132, 255, .06)); }
.nav-mark { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--faint); }
.nav-button.is-active .nav-mark { background: var(--cyan); box-shadow: 0 0 12px rgba(37, 208, 255, .7); }
.sidebar-bottom { display: flex; align-items: center; gap: 9px; margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(57, 219, 173, .6); }
.workspace { min-height: 100vh; margin-left: 236px; }
.topbar { display: flex; min-height: 100px; align-items: center; justify-content: space-between; gap: 20px; padding: 20px clamp(22px, 4vw, 56px); border-bottom: 1px solid var(--line); background: rgba(9, 19, 37, .74); }
.topbar h1 { margin: 5px 0 0; font-size: 24px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.admin-name { color: var(--muted); font-size: 13px; }
.page-content { max-width: 1480px; margin: 0 auto; padding: 30px clamp(22px, 4vw, 56px) 60px; }
.notice { position: fixed; top: 18px; left: 50%; z-index: 10; max-width: min(90vw, 520px); padding: 12px 18px; border: 1px solid var(--line-strong); border-radius: 12px; color: var(--text); background: var(--panel-raised); box-shadow: 0 14px 40px rgba(0, 0, 0, .35); transform: translateX(-50%); }
.notice.error { border-color: rgba(255, 113, 139, .46); }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-heading h2 { margin: 0 0 6px; font-size: 21px; }
.page-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric-card, .panel { border: 1px solid var(--line); border-radius: 15px; background: linear-gradient(145deg, rgba(14, 28, 51, .92), rgba(10, 21, 39, .9)); }
.metric-card { min-height: 118px; padding: 20px; }
.metric-card span { display: block; color: var(--muted); font-size: 13px; }
.metric-card strong { display: block; margin-top: 14px; font-size: 27px; letter-spacing: -.03em; }
.panel { padding: 20px; }
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.panel p { color: var(--muted); line-height: 1.6; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; min-width: 700px; border-collapse: collapse; text-align: left; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: .08em; background: rgba(255, 255, 255, .025); }
tr:last-child td { border-bottom: 0; }
td { color: var(--muted); }
td strong { color: var(--text); font-weight: 650; }
.table-actions { display: flex; justify-content: end; gap: 7px; }
.table-actions .button { min-height: 32px; padding: 0 10px; font-size: 12px; }
.badge { display: inline-flex; align-items: center; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.badge.on { border-color: rgba(57, 219, 173, .24); color: var(--green); background: rgba(57, 219, 173, .07); }
.badge.off { border-color: rgba(255, 113, 139, .24); color: var(--red); background: rgba(255, 113, 139, .06); }
.cover-thumb { width: 46px; height: 34px; border-radius: 6px; object-fit: cover; background: var(--bg-soft); }
.empty-row { padding: 36px 12px; color: var(--faint); text-align: center; }
.loading { padding: 30px; color: var(--muted); }
.editor-dialog { width: min(640px, calc(100vw - 28px)); max-height: min(88vh, 850px); padding: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 18px; color: var(--text); background: #0b172b; box-shadow: 0 24px 90px rgba(0, 0, 0, .55); }
.editor-dialog::backdrop { background: rgba(0, 4, 14, .72); backdrop-filter: blur(5px); }
.editor-dialog form { max-height: inherit; display: flex; flex-direction: column; }
.dialog-header { display: flex; justify-content: space-between; align-items: start; padding: 22px 24px 16px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 4px 0 0; font-size: 20px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 23px; background: rgba(255, 255, 255, .03); }
.editor-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 20px 24px; overflow: auto; }
.field.wide { grid-column: 1 / -1; }
.field.checkbox { display: flex; min-height: 42px; align-items: center; gap: 10px; padding-top: 18px; }
.field input[type="file"] { min-height: auto; padding: 8px; }
.requirements-field { min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.requirements-field legend { padding: 0 7px; color: var(--muted); font-size: 13px; }
.requirements-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.requirements-grid .field:last-child { grid-column: 1 / -1; }
.field small { color: var(--faint); line-height: 1.5; }
.category-picker-trigger { width: fit-content; min-width: 150px; text-align: left; }
.category-picker-options { display: grid; max-height: min(58vh, 430px); gap: 8px; padding: 20px 24px; overflow: auto; }
.category-option { display: flex; min-height: 48px; align-items: center; gap: 12px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: rgba(255, 255, 255, .025); cursor: pointer; }
.category-option:has(input:checked) { border-color: var(--line-strong); background: rgba(22, 132, 255, .1); }
.category-option input { width: 18px; min-height: 18px; flex: 0 0 auto; margin: 0; accent-color: var(--blue); }
.category-picker-empty { margin: 8px 0; color: var(--muted); }
.category-picker-dialog { width: min(460px, calc(100vw - 28px)); max-height: min(82vh, 620px); padding: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 16px; color: var(--text); background: #0b172b; box-shadow: 0 24px 90px rgba(0, 0, 0, .58); }
.category-picker-dialog::backdrop { background: rgba(0, 4, 14, .76); backdrop-filter: blur(5px); }
.category-picker-dialog .dialog-header { padding: 19px 21px 15px; }
.category-picker-dialog .dialog-actions { padding: 14px 21px; }
.storage-settings-form { max-width: 920px; padding: 24px; }
.storage-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; margin: 20px 0; }
.storage-fields .field.wide { grid-column: 1 / -1; }
.storage-status { padding: 13px 15px; border: 1px solid rgba(255, 194, 99, .26); border-radius: 10px; color: #f0c985; background: rgba(255, 194, 99, .06); }
.storage-status.is-ready { border-color: rgba(57, 219, 173, .24); color: var(--green); background: rgba(57, 219, 173, .06); }
.dialog-actions { display: flex; justify-content: end; gap: 9px; padding: 16px 24px; border-top: 1px solid var(--line); }
.toast-empty { min-height: 46px; padding: 15px; color: var(--faint); }

@media (max-width: 960px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar { width: 205px; }
  .workspace { margin-left: 205px; }
}
@media (max-width: 680px) {
  .sidebar { position: static; width: auto; padding: 14px 16px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-caption, .sidebar-bottom { display: none; }
  .side-nav { display: flex; gap: 4px; margin-top: 13px; overflow-x: auto; }
  .nav-button { min-height: 40px; flex: 0 0 auto; padding: 0 11px; font-size: 12px; }
  .nav-mark { display: none; }
  .workspace { margin-left: 0; }
  .topbar { min-height: 78px; padding: 15px 18px; }
  .topbar h1 { font-size: 20px; }
  .admin-name { display: none; }
  .page-content { padding: 22px 16px 42px; }
  .page-heading { align-items: start; flex-direction: column; }
  .metric-grid { gap: 9px; }
  .metric-card { min-height: 100px; padding: 14px; }
  .metric-card strong { font-size: 23px; }
  .editor-fields { grid-template-columns: 1fr; padding: 18px; }
  .field.wide { grid-column: auto; }
  .requirements-grid { grid-template-columns: 1fr; }
  .requirements-grid .field:last-child { grid-column: auto; }
  .storage-settings-form { padding: 18px; }
  .storage-fields { grid-template-columns: 1fr; }
  .storage-fields .field.wide { grid-column: auto; }
  .login-card { padding: 28px 23px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
