:root {
  color-scheme: dark;
  --bg: #0a0a13;
  --panel: #11111d;
  --raised: #171726;
  --line: #2b2a41;
  --text: #f5f4ff;
  --muted: #a7a5bb;
  --violet: #b8a9ff;
  --aqua: #89f4e2;
  --danger: #ffacba;
  --radius: 18px;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; min-height: 100vh; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
:focus-visible { outline: 2px solid var(--aqua); outline-offset: 4px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); letter-spacing: -.04em; line-height: 1.25; }
h2 { font-size: 1.35rem; }
p { color: var(--muted); line-height: 1.65; }

.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 clamp(1rem, 4vw, 3rem); border-bottom: 1px solid var(--line); background: #0e0e19; }
.brand, .top-actions { display: flex; align-items: center; gap: .75rem; }
.brand strong, .brand small { display: block; white-space: nowrap; }
.brand strong { font-size: 1rem; line-height: 1.1; }
.brand small { margin-top: .3rem; color: var(--muted); font-size: .72rem; }
.brand-mark { display: grid; place-items: center; position: relative; width: 39px; height: 39px; flex: none; border-radius: 12px; border: 1px solid #47405f; background: #19152d; }
.brand-mark i { position: absolute; display: block; width: 15px; height: 15px; border: 1px solid var(--violet); border-radius: 50%; box-shadow: 0 0 7px #b8a9ff66; }
.brand-mark i:first-child { transform: translate(-4px, 3px); }
.brand-mark i:nth-child(2) { transform: translate(4px, -3px); border-color: var(--aqua); box-shadow: 0 0 7px #89f4e277; }
.brand-mark i:nth-child(3) { width: 5px; height: 5px; transform: translate(-6px, -8px); background: var(--violet); }
.top-actions { font-size: .88rem; }
.plain-link { color: var(--muted); padding: .55rem .2rem; white-space: nowrap; }
.plain-link:hover { color: var(--text); }
.button, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--raised); min-height: 42px; padding: .55rem .85rem; font-size: .9rem; font-weight: 650; white-space: nowrap; }
.button:hover, .icon-button:hover { background: #222236; border-color: #48445f; }
.button.primary { background: var(--aqua); color: #101e22; border-color: var(--aqua); }
.button.primary:hover { background: #b4fff3; }
.button.quiet { background: transparent; color: var(--muted); }
.button.danger { background: #3a1f30; border-color: #683a50; color: var(--danger); }
.button.full { width: 100%; }
.icon-button { min-width: 42px; padding: .2rem; font-size: 1.4rem; line-height: 1; }

.auth-shell { display: grid; place-items: center; min-height: calc(100vh - 72px); padding: 2rem 1rem; background: radial-gradient(ellipse at 50% 30%, #1c1536 0%, #0a0a1300 50%); }
.auth-card { width: min(100%, 414px); padding: clamp(1.4rem, 6vw, 2.5rem); border: 1px solid var(--line); border-radius: 23px; background: #12111deb; box-shadow: 0 22px 88px #0007; }
.auth-card h1 { margin: 1rem 0 .45rem; }
.auth-card form { display: grid; gap: .95rem; margin-top: 1.35rem; }
.auth-card form .button { margin-top: .2rem; }
.auth-card > .button, .auth-card .feedback { margin-top: 1rem; }
.auth-ring { position: relative; width: 52px; height: 52px; border-radius: 50%; border: 1px solid #a298ff; background: radial-gradient(circle at 33% 26%, #89f4e255, transparent 46%), radial-gradient(ellipse at 70% 85%, #8e75ed55, transparent 60%); box-shadow: inset 0 0 12px #a58aff4d, 0 0 18px #7f62e94a; }
.auth-ring span { position: absolute; top: 10px; left: 13px; width: 12px; height: 5px; border-radius: 50%; transform: rotate(-35deg); background: #d8fff9; opacity: .85; filter: blur(1px); }
label { display: grid; gap: .55rem; font-size: .88rem; font-weight: 610; }
input:not([type="checkbox"]):not([type="file"]), textarea { min-width: 0; width: 100%; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: #0d0d18; color: var(--text); line-height: 1.45; }
input::placeholder, textarea::placeholder { color: #87859d; }
textarea { resize: vertical; }

.dashboard { display: grid; grid-template-columns: minmax(170px, 225px) minmax(0, 1fr); min-height: calc(100vh - 72px); max-width: 1510px; margin-inline: auto; }
.sidebar { padding: 1.8rem .9rem; border-right: 1px solid var(--line); }
.sidebar nav { display: grid; gap: .45rem; }
.nav-button { display: flex; align-items: center; gap: .7rem; min-height: 45px; width: 100%; padding: .6rem .85rem; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted); text-align: left; white-space: nowrap; }
.nav-button span { color: var(--violet); font-size: 1.2rem; }
.nav-button:hover { background: var(--panel); color: var(--text); }
.nav-button[aria-current] { background: #22203a; border-color: #393451; color: var(--text); font-weight: 650; }
.main-panel { min-width: 0; padding: clamp(1rem, 3.7vw, 3rem); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.45rem; }
.panel-heading p { margin-top: .45rem; }
.panel-heading .button { align-self: flex-end; }
.panel-actions, .row-actions { display: flex; justify-content: flex-end; gap: .35rem; }
.panel-actions { flex-wrap: wrap; gap: .55rem; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; margin-bottom: 1.1rem; }
.stats > div { display: grid; gap: .45rem; min-height: 98px; align-content: center; padding: .7rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: radial-gradient(ellipse at 100% 0%, #2d28533d, transparent 75%), var(--panel); }
.stats span { color: var(--muted); font-size: .82rem; }
.stats strong { font-size: 1.55rem; }
.stats .sms-state { font-size: 1.05rem; }
.sms-state[data-ready="true"] { color: var(--aqua); }
.sms-state[data-ready="false"] { color: #ffd7a3; }
.data-card, .option-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.data-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .7rem; padding: .8rem 1rem; }
.search-label { position: relative; align-items: center; width: min(65%, 290px); }
.search-label > span[aria-hidden] { position: absolute; left: .75rem; color: var(--muted); font-size: 1.3rem; pointer-events: none; }
.search-label input:not([type="checkbox"]) { padding-left: 2rem; }
.muted { color: var(--muted); font-size: .83rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .88rem; }
th, td { padding: .72rem 1rem; border-top: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: #151525; }
td:last-child, th:last-child { text-align: right; }
td .button { min-height: 34px; padding: .25rem .65rem; font-size: .79rem; }
.badge { display: inline-block; width: max-content; max-width: 100%; padding: .25rem .55rem; border: 1px solid #46405b; border-radius: 15px; background: #242038; color: #e0d7ff; font-size: .74rem; }
.badge[data-state="on"] { color: var(--aqua); background: #142b2d; border-color: #31595e; }
.badge[data-state="off"] { color: #bdbaab; background: #272532; border-color: #44414f; }
.empty { padding: 2.2rem .9rem; text-align: center; }
.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.option-card { display: grid; gap: .8rem; padding: 1.2rem; }
.option-card h2 { color: var(--violet); font-size: 1rem; }
.checkbox-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.checkbox-row label { display: flex; align-items: center; gap: .35rem; }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--aqua); }
.moderation-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .7rem; padding: .85rem 1rem; border-top: 1px solid var(--line); }
.moderation-entry h2 { display: inline; margin-right: .55rem; font-size: 1rem; overflow-wrap: anywhere; }
.moderation-entry p { margin-top: .3rem; font-size: .83rem; overflow-wrap: anywhere; }

dialog { width: min(calc(100% - 2rem), 530px); max-height: calc(100% - 2rem); padding: 0; border: 1px solid #4a425f; border-radius: var(--radius); background: #151423; color: var(--text); box-shadow: 0 26px 80px #000a; }
dialog::backdrop { background: #05050cbb; backdrop-filter: blur(5px); }
dialog form { display: grid; gap: .95rem; padding: 1.35rem; }
.invitation-body { display: grid; gap: .95rem; padding: 1.35rem; }
.invitation-table { max-height: min(48vh, 400px); overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.invitation-table thead { position: sticky; top: 0; }
.invitation-table code { color: var(--aqua); letter-spacing: .06em; user-select: all; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; }
.dialog-heading p { margin-top: .35rem; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: .6rem; }
.upload-label { justify-self: start; cursor: pointer; }
.upload-label:has(+ input:focus-visible) { outline: 2px solid var(--aqua); outline-offset: 4px; }
.feedback { color: var(--danger); font-size: .85rem; }
.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 2; max-width: min(390px, calc(100% - 2rem)); padding: .8rem .95rem; border: 1px solid #3d5d62; border-radius: 10px; background: #17272d; color: var(--aqua); box-shadow: 0 8px 26px #0009; font-size: .88rem; }
.toast[data-error="true"] { border-color: #613c52; background: #302032; color: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }

@media (max-width: 780px) {
  .dashboard { grid-template-columns: minmax(0, 1fr); }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: .6rem clamp(.75rem, 3vw, 1.5rem); }
  .sidebar nav { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .25rem; }
  .nav-button { justify-content: center; padding: .45rem .3rem; gap: .25rem; font-size: clamp(.78rem, 2.4vw, .95rem); }
  .nav-button span { font-size: 1rem; }
}
@media (max-width: 540px) {
  .top-actions { gap: .5rem; font-size: .78rem; }
  .top-actions button { font-size: .75rem; padding-inline: .45rem; }
  .stats { gap: .45rem; }
  .stats > div { min-height: 75px; padding: .55rem; }
  .stats span, .stats .sms-state { font-size: .78rem; }
  .stats strong { font-size: 1.3rem; }
  .option-grid { grid-template-columns: minmax(0, 1fr); }
  th, td { padding: .6rem .58rem; }
  .data-toolbar { padding: .65rem .58rem; }
}
