:root {
  --bg: #07111f;
  --bg-soft: #0b1728;
  --panel: rgba(15, 29, 48, .88);
  --panel-strong: #13243a;
  --line: rgba(146, 170, 202, .17);
  --line-strong: rgba(146, 170, 202, .3);
  --text: #edf5ff;
  --muted: #91a5bf;
  --cyan: #31d7c5;
  --cyan-dark: #0b9288;
  --blue: #63a4ff;
  --danger: #ff6b78;
  --warning: #f5bd53;
  --shadow: 0 22px 55px rgba(0, 0, 0, .25);
  font-family: Inter, "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

html[data-theme-period="day"] {
  color-scheme: light;
  --bg: #e8f1fb;
  --bg-soft: #f6f9fd;
  --panel: rgba(255, 255, 255, .89);
  --panel-strong: #e2edf9;
  --line: rgba(44, 75, 109, .18);
  --line-strong: rgba(44, 75, 109, .33);
  --text: #14273b;
  --muted: #567087;
  --cyan: #008e83;
  --cyan-dark: #006f68;
  --blue: #276fca;
  --danger: #ca3b50;
  --warning: #9a6200;
  --shadow: 0 22px 55px rgba(36, 67, 98, .16);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html::before {
  content: "";
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 100;
  width: 0;
  height: 3px;
  opacity: 0;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  box-shadow: 0 0 12px rgba(49, 215, 197, .75);
  transition: width .35s ease, opacity .16s ease;
}
html.is-navigating::before { width: 82vw; opacity: 1; }
body {
  margin: 0;
  min-height: 100vh;
  isolation: isolate;
  background:
    radial-gradient(circle at 15% 0%, rgba(49, 215, 197, .12), transparent 30rem),
    radial-gradient(circle at 85% 10%, rgba(99, 164, 255, .12), transparent 28rem),
    var(--bg);
}
html[data-theme-period="day"] body {
  background:
    radial-gradient(circle at 15% 0%, rgba(0, 142, 131, .11), transparent 30rem),
    radial-gradient(circle at 85% 10%, rgba(39, 111, 202, .10), transparent 28rem),
    var(--bg);
}
.theme-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  transform: scale(1.015);
  transition: opacity .35s ease, background-image .35s ease;
}
.theme-background::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(7, 17, 31, .72), rgba(7, 17, 31, .42));
}
html[data-theme-period="day"] .theme-background::after {
  background: linear-gradient(120deg, rgba(238, 246, 255, .78), rgba(238, 246, 255, .45));
}
body.has-theme-background .theme-background { opacity: 1; }
body > .page, body > footer { position: relative; z-index: 1; }
html[data-theme-period="day"] .topbar { background: rgba(243, 249, 255, .84); }
a { color: var(--cyan); text-decoration: none; }
a:hover { color: #7af5e7; }

.topbar {
  height: 68px;
  padding: 0 max(24px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 31, .82);
  backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; gap: 10px; align-items: center; color: var(--text); font-weight: 760; }
.brand span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  color: #031614;
  background: linear-gradient(135deg, var(--cyan), #89fff1);
  box-shadow: 0 0 28px rgba(49, 215, 197, .27);
}
.topbar nav { display: flex; align-items: center; gap: 14px; }
.nav-link { color: #c6d8eb; font-size: 13px; font-weight: 700; }
.account { color: var(--muted); font-size: 14px; }
.inline-form { display: inline; margin: 0; }

.page { width: min(1240px, calc(100% - 36px)); margin: 0 auto; padding: 42px 0 80px; }
footer { color: #647992; text-align: center; padding: 24px; border-top: 1px solid var(--line); font-size: 13px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(30px, 5vw, 48px); line-height: 1.05; letter-spacing: -.04em; margin-bottom: 12px; }
h2 { font-size: 21px; letter-spacing: -.02em; }
h3 { font-size: 18px; margin-bottom: 6px; }
.muted, small { color: var(--muted); }
.eyebrow { color: var(--cyan); font: 700 11px/1.2 ui-monospace, monospace; letter-spacing: .18em; margin-bottom: 12px; }

.button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 17px;
  color: var(--text);
  background: var(--panel-strong);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: .16s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
.button:disabled, fieldset:disabled .button { opacity: .42; cursor: not-allowed; }
[aria-busy="true"] { cursor: wait; }
a[aria-busy="true"] { opacity: .68; pointer-events: none; }
.button.primary { background: linear-gradient(135deg, var(--cyan-dark), #16b7aa); box-shadow: 0 8px 26px rgba(22, 183, 170, .18); }
.button.secondary { border-color: rgba(49, 215, 197, .35); color: #83f5e9; background: rgba(49, 215, 197, .08); }
.button.danger { border-color: rgba(255, 107, 120, .28); color: #ff9da6; background: rgba(255, 107, 120, .1); }
.button.ghost { border-color: var(--line); background: transparent; }
.button.small { padding: 7px 10px; font-size: 12px; }
.button.wide { width: 100%; text-align: center; display: block; }

.flash { padding: 13px 16px; border-radius: 12px; margin: 0 0 18px; border: 1px solid var(--line); background: var(--panel); }
.flash.success { color: #8af5cd; border-color: rgba(62, 224, 159, .35); }
.flash.error { color: #ffadb4; border-color: rgba(255, 107, 120, .38); }
.flash.warning { color: #ffd889; border-color: rgba(245, 189, 83, .4); }

.auth-page { min-height: calc(100vh - 145px); display: grid; place-items: center; padding: 40px 0; }
.auth-card {
  width: min(440px, 100%);
  padding: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(19, 36, 58, .97), rgba(10, 23, 40, .96));
  box-shadow: var(--shadow);
}
.register-card { width: min(680px, 100%); }
.auth-switch { text-align: center; color: var(--muted); margin: 22px 0 0; font-size: 14px; }

form { margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.form-stack, .settings-form fieldset { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: #c7d7e9; font-size: 13px; font-weight: 650; }
label small { display: block; font-weight: 400; line-height: 1.45; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 11px 12px;
  color: var(--text);
  background: rgba(5, 15, 27, .7);
  font: inherit;
  outline: 0;
}
textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: var(--cyan-dark); box-shadow: 0 0 0 3px rgba(49, 215, 197, .09); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--cyan); }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, 1fr); }
.form-grid.three { grid-template-columns: .7fr 1fr 2fr; }
.form-grid.four { grid-template-columns: 1fr 1fr 1fr .7fr; }
.verification-row { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; }
.verification-row .button { min-height: 42px; white-space: nowrap; }
.checkbox-box { display: flex; flex-direction: row; align-items: center; align-self: end; min-height: 42px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; }

.hero, .group-hero {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(120deg, rgba(19, 39, 62, .88), rgba(11, 28, 47, .73));
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}
.hero.compact h1 { font-size: 36px; }
.hero-stat { width: 120px; height: 96px; display: grid; place-items: center; align-content: center; border: 1px solid var(--line); border-radius: 16px; background: rgba(5, 15, 27, .45); }
.hero-stat strong { font-size: 32px; color: var(--cyan); }
.hero-stat span { color: var(--muted); font-size: 12px; }

.group-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.group-card { display: block; padding: 22px; border: 1px solid var(--line); border-radius: 16px; color: var(--text); background: var(--panel); transition: .16s ease; }
.group-card:hover { color: var(--text); border-color: rgba(49, 215, 197, .4); transform: translateY(-2px); }
.group-card h2 { font: 750 28px/1 ui-monospace, monospace; margin: 24px 0 8px; }
.group-card p { color: var(--muted); font-size: 13px; }
.card-topline, .card-meta, .status-line { display: flex; gap: 8px; align-items: center; }
.card-topline { color: var(--muted); font-size: 12px; }
.card-topline .pill { margin-left: auto; }
.card-meta { justify-content: space-between; color: var(--muted); font-size: 12px; padding-top: 15px; border-top: 1px solid var(--line); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-dot.online { background: var(--cyan); box-shadow: 0 0 14px var(--cyan); }
.status-dot.offline { background: var(--danger); }
.pill { display: inline-flex; border-radius: 99px; padding: 5px 9px; color: var(--muted); border: 1px solid var(--line); background: rgba(145, 165, 191, .06); font-size: 11px; white-space: nowrap; }
.pill.active { color: #75edc3; border-color: rgba(62, 224, 159, .3); background: rgba(62, 224, 159, .09); }
.pill.expired { color: #ff9da6; border-color: rgba(255, 107, 120, .3); background: rgba(255, 107, 120, .09); }

.dashboard-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 20px; }
.panel { border: 1px solid var(--line); border-radius: 16px; padding: 23px; background: var(--panel); }
.section-heading { display: flex; gap: 20px; justify-content: space-between; align-items: start; margin-bottom: 18px; }
.section-heading h2 { margin-bottom: 5px; }
.section-heading p { color: var(--muted); font-size: 13px; margin: 0; }
.audit-panel { margin-top: 18px; }
.admin-section { margin-top: 20px; }
.admin-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.admin-stats > div { display: grid; gap: 5px; padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); }
.admin-stats strong { color: var(--cyan); font-size: 27px; }
.admin-stats span { color: var(--muted); font-size: 12px; }
.admin-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.admin-workflow {
  display: grid;
  grid-template-columns: 1.18fr repeat(3, 1fr);
  gap: 12px;
  margin: 0 0 20px;
}
.workflow-intro, .workflow-step, .quick-action {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.workflow-intro { display: grid; gap: 5px; padding: 17px 18px; }
.workflow-intro .eyebrow { margin: 0; }
.workflow-intro strong { font-size: 16px; }
.workflow-intro small, .workflow-step small, .quick-action small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.workflow-step { display: flex; align-items: flex-start; gap: 10px; padding: 16px; }
.workflow-step > span, .quick-action-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 9px;
  color: #031614;
  background: linear-gradient(135deg, var(--cyan), #93fff1);
  font: 800 13px/1 ui-monospace, monospace;
}
.workflow-step div, .quick-action span:last-child { display: grid; gap: 4px; min-width: 0; }
.workflow-step strong { color: #dbeeff; font-size: 13px; }
.quick-action-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 0 0 20px; }
.quick-action { display: flex; align-items: center; gap: 12px; padding: 16px; color: var(--text); transition: .16s ease; }
.quick-action:hover { color: var(--text); border-color: rgba(49, 215, 197, .45); transform: translateY(-2px); }
.quick-action.featured { border-color: rgba(49, 215, 197, .42); background: linear-gradient(135deg, rgba(49, 215, 197, .16), rgba(99, 164, 255, .08)); }
.quick-action-icon { width: 34px; height: 34px; font-size: 17px; }
.quick-action strong { font-size: 13px; }
.create-user-form { background: linear-gradient(135deg, rgba(49, 215, 197, .075), rgba(99, 164, 255, .045)); }
.advanced-panel { padding: 0; overflow: hidden; }
.advanced-panel details { padding: 0; }
.advanced-panel summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; cursor: pointer; list-style: none; }
.advanced-panel summary::-webkit-details-marker { display: none; }
.advanced-panel summary > span:first-child { display: grid; gap: 4px; }
.advanced-panel summary strong { font-size: 15px; }
.advanced-panel summary small { font-size: 12px; }
.details-arrow { color: var(--cyan); font-size: 12px; font-weight: 700; }
.advanced-panel details[open] .details-arrow { font-size: 0; }
.advanced-panel details[open] .details-arrow::after { content: "收起"; font-size: 12px; }
.advanced-panel .management-form { margin: 0 18px 18px; }
.form-submit-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.form-submit-row small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.table-actions { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }

.back-link { display: inline-block; margin-bottom: 18px; color: var(--muted); font-size: 13px; }
.group-hero h1 { margin-bottom: 10px; font-family: ui-monospace, monospace; }
.status-line { color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.sync-flow { margin: -6px 0 22px; }
.sync-flow-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 0; margin: 0; list-style: none; }
.sync-flow-steps li { display: flex; align-items: flex-start; gap: 10px; min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(4, 14, 26, .28); }
.sync-flow-steps li > div { display: grid; gap: 4px; min-width: 0; }
.sync-flow-steps strong { font-size: 13px; color: #dbeeff; }
.sync-flow-steps small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.flow-number { display: grid; place-items: center; flex: 0 0 auto; width: 24px; height: 24px; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--muted); font: 750 12px/1 ui-monospace, monospace; }
.flow-complete .flow-number { border-color: rgba(62, 224, 159, .45); color: #75edc3; background: rgba(62, 224, 159, .1); }
.flow-current { border-color: rgba(99, 164, 255, .42) !important; }
.flow-current .flow-number { border-color: rgba(99, 164, 255, .55); color: #b8d4ff; background: rgba(99, 164, 255, .12); }
.flow-error { border-color: rgba(255, 107, 120, .42) !important; }
.flow-error .flow-number { border-color: rgba(255, 107, 120, .55); color: #ffb2ba; background: rgba(255, 107, 120, .12); }
.license-warning { display: flex; gap: 16px; align-items: center; padding: 16px 18px; margin: -8px 0 22px; border: 1px solid rgba(245, 189, 83, .34); background: rgba(245, 189, 83, .08); color: #f8d594; border-radius: 12px; }
.license-warning span { color: var(--muted); font-size: 13px; }
.license-warning.neutral { border-color: rgba(99, 164, 255, .3); color: #9ec7ff; background: rgba(99, 164, 255, .08); }
.anchor-nav { display: flex; gap: 8px; overflow-x: auto; margin: 0 0 30px; padding-bottom: 4px; }
.anchor-nav a { white-space: nowrap; color: #b7c8db; padding: 8px 12px; border: 1px solid var(--line); background: var(--panel); border-radius: 99px; font-size: 12px; }

.feature-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 17px; margin-bottom: 32px; }
.feature-card { scroll-margin-top: 88px; border: 1px solid var(--line); border-radius: 16px; padding: 22px; background: var(--panel); }
.feature-title { display: flex; align-items: start; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); padding-bottom: 15px; margin-bottom: 17px; }
.feature-title p { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0; }
.switch-row { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 20px; padding: 9px 0; }
.switch-row span { display: grid; gap: 3px; }
.settings-form fieldset:disabled { opacity: .65; }

.management-panel { scroll-margin-top: 88px; margin-bottom: 20px; }
.management-form { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: rgba(4, 14, 26, .3); margin-bottom: 18px; }
.management-form fieldset { display: grid; gap: 14px; }
.checkbox-box span { color: var(--muted); font-size: 11px; font-weight: 400; }
.permission-picker { display: grid; gap: 9px; }
.permission-picker > strong { font-size: 13px; color: #c7d7e9; }
.permission-picker > div { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.permission-picker .checkbox-box { align-self: stretch; min-height: 0; }
.permission-picker small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.code-tip { color: #9ec7ff; font: 12px ui-monospace, monospace; border: 1px solid rgba(99, 164, 255, .2); background: rgba(99, 164, 255, .07); padding: 7px 9px; border-radius: 7px; }
.item-list { display: grid; gap: 8px; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 20px; border-top: 1px solid var(--line); padding: 13px 4px 5px; min-width: 0; }
.list-item > div:first-child { min-width: 0; }
.list-item p, .list-item small { margin: 4px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.row-actions { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.inline-add { display: flex; gap: 9px; margin-bottom: 15px; }
.empty-state { grid-column: 1 / -1; padding: 38px; text-align: center; border: 1px dashed var(--line-strong); color: var(--muted); border-radius: 14px; }
.empty-state.compact { padding: 18px; }
code { color: #a9cfff; }
.license-value { font-family: ui-monospace, "Cascadia Code", monospace; color: #b9ddff; }
.email-provider-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.email-provider { border: 1px solid var(--line); border-radius: 11px; padding: 13px; background: rgba(5, 15, 27, .28); }
.email-provider strong { display: block; margin-bottom: 5px; font-size: 13px; }
.email-provider small { display: block; color: var(--muted); line-height: 1.5; font-size: 12px; }
.compact-steps { margin: 0; padding-left: 21px; color: var(--muted); font-size: 13px; line-height: 1.9; }
.permission-note { margin: 12px 0 0; font-size: 12px; }
.console-filter { align-items: center; }
.console-filter input { flex: 1 1 320px; }
.console-table td { white-space: nowrap; }
.console-table td:last-child { white-space: normal; min-width: 160px; overflow-wrap: anywhere; }

.appearance-panel { margin-bottom: 20px; }
.appearance-upload-grid label { align-content: start; }
.appearance-upload-grid input[type="file"] { padding: 9px; color: var(--muted); }
.compact-check { align-self: start; min-height: 0; margin-top: 8px; font-size: 12px; }
.theme-asset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.theme-asset-card { display: grid; gap: 12px; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(4, 14, 26, .26); }
.theme-asset-card > img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border: 1px solid var(--line); border-radius: 9px; background: var(--bg-soft); }
.theme-asset-card > div { display: grid; gap: 4px; min-width: 0; }
.theme-asset-card small { color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.theme-share-form { display: grid; gap: 8px; padding-top: 3px; border-top: 1px solid var(--line); }
.theme-share-form .switch-row { align-items: start; gap: 10px; }
.theme-share-form .switch-row strong { font-size: 12px; }
.theme-share-form .switch-row small { display: block; }
html[data-theme-period="day"] .theme-asset-card,
html[data-theme-period="day"] .management-form { background: rgba(248, 252, 255, .55); }

@media (max-width: 900px) {
  .group-grid { grid-template-columns: repeat(2, 1fr); }
  .feature-grid, .dashboard-columns { grid-template-columns: 1fr; }
  .sync-flow-steps { grid-template-columns: 1fr; }
  .form-grid.four, .form-grid.three { grid-template-columns: repeat(2, 1fr); }
  .admin-stats { grid-template-columns: repeat(3, 1fr); }
  .admin-workflow { grid-template-columns: repeat(2, 1fr); }
  .workflow-intro { grid-column: 1 / -1; }
  .quick-action-grid { grid-template-columns: repeat(2, 1fr); }
  .theme-asset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .topbar { padding: 0 18px; }
  .brand { font-size: 13px; }
  .account { display: none; }
  .page { width: min(100% - 24px, 1240px); padding-top: 24px; }
  .auth-card { padding: 24px; }
  .hero, .group-hero { align-items: flex-start; padding: 22px; }
  .hero-stat { display: none; }
  .group-grid, .form-grid.two, .form-grid.three, .form-grid.four { grid-template-columns: 1fr; }
  .verification-row, .email-provider-grid { grid-template-columns: 1fr; }
  .verification-row .button { width: 100%; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .admin-workflow, .quick-action-grid { grid-template-columns: 1fr; }
  .workflow-intro { grid-column: auto; }
  .feature-card, .panel { padding: 18px; }
  .permission-picker > div { grid-template-columns: 1fr; }
  .advanced-panel { padding: 0; }
  .advanced-panel summary { padding: 17px 18px; }
  .list-item { align-items: flex-start; flex-direction: column; }
  .row-actions { width: 100%; flex-wrap: wrap; }
  .license-warning { align-items: flex-start; flex-direction: column; gap: 5px; }
  .form-submit-row { align-items: stretch; flex-direction: column; }
  .form-submit-row .button { width: 100%; }
  .theme-asset-grid { grid-template-columns: 1fr; }
}
