:root {
  color-scheme: dark;
  --bg: #101222;
  --panel: #191c31;
  --panel-raised: #202440;
  --line: #333755;
  --text: #f2effc;
  --muted: #b7b8d3;
  --accent: #d2b8ff;
  --accent-ink: #241638;
  --green: #83e8c1;
  --pink: #ffb4d1;
  --radius: 18px;
  font: 16px/1.55 system-ui, "Microsoft YaHei UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { min-width: 280px; min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { color: #f1e6ff; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.18; overflow-wrap: anywhere; }
h1 { font-size: clamp(2rem, 4vw, 3.25rem); font-weight: 760; letter-spacing: -.035em; }
h2 { font-size: 1.25rem; }
small, .muted { color: var(--muted); }
.shell { width: min(1120px, calc(100% - 48px)); margin-inline: auto; }
.masthead { border-bottom: 1px solid var(--line); background: #15182b; }
.masthead-inner { min-height: 70px; display: flex; align-items: center; gap: clamp(20px, 4vw, 50px); }
.wordmark { display: inline-flex; align-items: center; gap: .65rem; color: var(--text); text-decoration: none; white-space: nowrap; font-size: 1.14rem; font-weight: 790; }
#main-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
#main-nav a { padding: .45rem .72rem; border-radius: .55rem; text-decoration: none; color: var(--muted); white-space: nowrap; }
#main-nav a:hover, #main-nav a[aria-current="page"] { background: var(--panel-raised); color: var(--text); }
#account-nav { margin-left: auto; min-width: 0; }
#account-nav a { display: block; max-width: min(24ch, 30vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#app { flex: 1; min-height: 420px; padding-block: clamp(1.6rem, 4vw, 3.2rem); }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .6rem; padding-block: 1.25rem 2rem; color: var(--muted); border-top: 1px solid var(--line); font-size: .9rem; }
.footer span:first-child { color: var(--text); font-weight: 680; }
.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; padding: .55rem .9rem; border: 1px solid transparent; border-radius: .65rem; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; text-decoration: none; }
.button:hover { background: #e6d4ff; color: var(--accent-ink); }
.button.subtle { border-color: #53577e; background: transparent; color: var(--text); }
.button.subtle:hover { background: var(--panel-raised); }
.button.danger { border-color: #ab5877; background: #552a40; color: #ffe3ee; }
.button.danger:hover { background: #71354f; color: #fff1f7; }
.button:disabled { cursor: wait; opacity: .65; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; }
.hero { position: relative; isolation: isolate; overflow: hidden; display: grid; grid-template-columns: 1.45fr 1fr; min-height: 350px; border: 1px solid #50446f; border-radius: 24px; background: linear-gradient(120deg, #292045, #211b3e 60%, #242044); }
.hero-content { padding: clamp(1.4rem, 5vw, 3.7rem); }
.eyebrow { display: inline-block; color: var(--accent); font-size: .78rem; font-weight: 760; letter-spacing: .16em; text-transform: uppercase; }
.hero h1 { margin-block: .65rem .9rem; font-size: clamp(2.4rem, 5.6vw, 4.8rem); }
.hero p { color: #e0d9f0; max-width: 34ch; }
.hero .actions { margin-top: 1.65rem; }
.lanes { margin: 2rem 2.3rem 0 0; display: grid; grid-template-columns: repeat(4, 1fr); align-self: end; height: 86%; opacity: .93; border: 1px solid #7c67aa; border-bottom: 0; border-radius: 18px 18px 0 0; background: linear-gradient(180deg, #514378 0%, #231c41 100%); transform: perspective(700px) rotateX(20deg) rotateZ(-8deg); transform-origin: center bottom; }
.lanes span { position: relative; border-right: 1px solid #8172ae55; }
.lanes span:last-child { border: 0; }
.lanes span::before, .lanes span::after { content: ""; position: absolute; width: 70%; left: 15%; height: 14px; border-radius: 5px; top: var(--position); background: #e0cbff; box-shadow: 0 0 24px #d1adff6f; }
.lanes span::after { top: auto; bottom: 16%; background: #9d8bc755; box-shadow: none; border: 1px solid #c5b6ed70; }
.lanes span:nth-child(1) { --position: 53%; }
.lanes span:nth-child(2) { --position: 27%; }
.lanes span:nth-child(2)::before { height: 72px; background: linear-gradient(180deg, #81e5d455, #a8f1e3); }
.lanes span:nth-child(3) { --position: 16%; }
.lanes span:nth-child(4) { --position: 43%; }
.lanes span:nth-child(4)::before { background: #eeb6de; }
.section { margin-top: clamp(1.3rem, 4vw, 2.2rem); }
.section-heading { display: flex; gap: .8rem; align-items: baseline; justify-content: space-between; flex-wrap: wrap; margin-bottom: .85rem; }
.panel, .notice { padding: clamp(.95rem, 2.5vw, 1.4rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.notice { color: var(--muted); }
.notice[role="alert"], .error { color: var(--pink); }
.notice .actions { margin-top: .8rem; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 148px), 1fr)); gap: .8rem; margin: 0; }
.metric { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: .18rem; }
.metric dt { color: var(--muted); font-size: .85rem; }
.metric dd { margin: 0; font-size: 1.42rem; font-weight: 740; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.online { color: var(--green); }
.offline { color: var(--pink); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.stack { display: grid; gap: .85rem; }
.page-head { display: grid; gap: .45rem; margin-bottom: 1.35rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .85rem; }
.tabs a { padding: .48rem .85rem; border-radius: .62rem; border: 1px solid var(--line); text-decoration: none; color: var(--muted); }
.tabs a:hover, .tabs a[aria-current="page"] { border-color: #8b70b6; background: #30264c; color: var(--text); }
.table-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .75rem .85rem; white-space: nowrap; }
th { color: var(--muted); background: var(--panel-raised); font-size: .83rem; font-weight: 690; }
tr + tr td { border-top: 1px solid var(--line); }
td { font-variant-numeric: tabular-nums; }
td a { text-decoration-thickness: .07em; }
.rank { color: var(--accent); font-weight: 750; }
.pagination { margin-top: 1rem; align-items: center; justify-content: end; }
.profile-head {
  display: flex;
  align-items: flex-start;
  gap: clamp(.9rem, 4vw, 1.65rem);
  margin-bottom: 1rem;
  padding: clamp(1rem, 4vw, 2rem);
  border-color: #50446f;
  background: radial-gradient(ellipse at 100% 0%, #3c3060, transparent 66%), #211b38;
}
.profile-identity { min-width: 0; display: grid; gap: .35rem; }
.profile-identity .muted { overflow-wrap: anywhere; }
.avatar { position: relative; display: grid; place-items: center; flex: 0 0 96px; height: 96px; color: var(--accent); background: #30264c; border: 1px solid #544776; border-radius: 20px; font-size: 2.2rem; font-weight: 760; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.profile-avatar-edit { margin-top: .35rem; }
.profile-avatar-edit summary { display: inline-flex; }
.profile-avatar-edit summary::-webkit-details-marker { display: none; }
.profile-avatar-form { max-width: 340px; margin-top: .75rem; }
.profile-avatar-form label { display: grid; gap: .3rem; }
.profile-overview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; gap: 1.15rem; }
.profile-overview > .section { margin-top: 0; }
.profile-stats .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.profile-trend-value { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .9rem; }
.profile-trend-value strong { color: var(--accent); font-size: 1.55rem; font-variant-numeric: tabular-nums; }
.profile-trend svg { display: block; width: 100%; height: clamp(100px, 17vw, 150px); }
.trend-gridline { stroke: var(--line); vector-effect: non-scaling-stroke; }
.trend-area { fill: var(--accent); opacity: .1; }
.trend-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.trend-cursor { stroke: var(--muted); stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.trend-dot { fill: var(--green); }
.profile-trend-dates { display: flex; justify-content: space-between; gap: .5rem; font-size: .8rem; }
.profile-trend-dates > :last-child { text-align: end; }
.profile-trend-picker { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem 1rem; }
.profile-trend-picker input { width: min(100%, 16rem); padding: 0; accent-color: var(--accent); }
.profile-trend-selected { font-size: .85rem; }
.profile-score-count { margin: .2rem 0 .85rem; font-size: .87rem; }
.profile-scores { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.profile-score {
  display: grid;
  grid-template-columns: 4.35rem minmax(0, 1fr) minmax(18rem, auto) auto;
  align-items: center;
  gap: .4rem .9rem;
  padding: .75rem .95rem;
  border-radius: .85rem;
}
.profile-score-index { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.profile-score-index .label { padding: .1rem .35rem; }
.profile-score-map { display: grid; min-width: 0; gap: .08rem; overflow-wrap: anywhere; }
.profile-score-map > span { color: var(--muted); font-size: .87rem; }
.profile-score-map > small { font-size: .76rem; }
.profile-score-title { color: var(--text); font-weight: 720; text-decoration: none; }
.profile-score-title:hover { text-decoration: underline; }
.profile-score-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .35rem .8rem; margin: 0; }
.profile-score-stats dt { color: var(--muted); font-size: .72rem; }
.profile-score-stats dd { margin: .1rem 0 0; font-size: .88rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.profile-score-stats .label { padding: .05rem .3rem; white-space: normal; }
.profile-score-stats .profile-score-pp { color: var(--green); font-weight: 750; }
.profile-score-detail { font-size: .84rem; }
.label { display: inline-block; color: var(--accent); background: #33274e; border-radius: .45rem; padding: .2rem .5rem; font-size: .82rem; white-space: nowrap; }
.label.online { color: var(--green); }
.label.history { color: #ffe09a; }
.history { color: #ffe09a; }
.form-card { width: min(100%, 480px); }
.form-card label, .admin-action label { display: grid; gap: .3rem; }
input, select, textarea { width: 100%; padding: .6rem .75rem; border: 1px solid #5d6080; border-radius: .6rem; background: #11152a; color: var(--text); }
input[type="file"]::file-selector-button { padding: .25rem .5rem; margin-right: .65rem; border: 1px solid var(--line); border-radius: .35rem; background: var(--panel-raised); color: var(--text); cursor: pointer; }
textarea { resize: vertical; }
.lookup { display: flex; flex-wrap: wrap; gap: .55rem; align-items: end; }
.lookup label { min-width: min(100%, 180px); display: grid; gap: .25rem; }
.map-list { display: grid; list-style: none; gap: .7rem; margin: 0; padding: 0; }
.map-list a { min-height: 76px; display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .85rem 1rem; color: var(--text); text-decoration: none; }
.map-list a:hover { border-color: #8b70b6; background: var(--panel-raised); }
.map-list small { display: block; }
.form-message:empty { display: none; }
.lookup + .form-message:not(:empty) { margin-top: .8rem; }
.admin-results { grid-template-columns: minmax(0, 1fr); }
.admin-action { width: min(100%, 520px); align-content: start; }
.grid > .admin-action { width: 100%; }
.admin-action h3 { font-size: 1.06rem; }
.import-result:empty { display: none; }
.import-list { display: grid; list-style: none; gap: .55rem; margin: 0; padding: 0; }
.import-list li { border-top: 1px solid var(--line); padding-top: .55rem; overflow-wrap: anywhere; }
.import-list small { display: block; }
.admin-action .check-line { display: flex; align-items: baseline; gap: .55rem; overflow-wrap: anywhere; }
.check-line input { width: auto; flex: 0 0 auto; accent-color: var(--accent); }
.audit-details summary { color: var(--accent); cursor: pointer; }
.audit-details[open] > :not(summary) { margin-top: .7rem; }
.audit-details .admin-action { min-width: 215px; }
.audit-notes, .audit-details .admin-action { white-space: normal; overflow-wrap: anywhere; }
.audit-notes { min-width: 11rem; max-width: 28rem; }
.audit-notes p { white-space: pre-wrap; }
.dan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 215px), 1fr)); gap: .8rem; list-style: none; padding: 0; margin: 0; }
.dan-badge { display: grid; gap: .35rem; border-inline-start: 3px solid #8b70b6; }
.dan-rank { font-size: 1.45rem; line-height: 1.25; overflow-wrap: anywhere; }
.dan-meta { display: flex; flex-wrap: wrap; gap: .2rem .75rem; color: var(--muted); font-size: .85rem; }
code { color: #e4d3ff; background: #292240; border-radius: .35rem; padding: .15rem .3rem; overflow-wrap: anywhere; }

@media (max-width: 880px) {
  .profile-overview { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .shell { width: calc(100% - 30px); }
  .masthead-inner { gap: .45rem; flex-wrap: wrap; padding-block: .65rem; }
  #main-nav { order: 3; flex: 0 0 100%; }
  #main-nav a { padding-inline: .65rem; }
  #account-nav a { max-width: 32vw; }
  .hero { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .hero-content { padding: 1.45rem; }
  .lanes { height: 106px; width: 53%; margin: 0 1.35rem 0 auto; }
  .lanes span:nth-child(2)::before { height: 38px; }
  .grid { grid-template-columns: 1fr; }
  th, td { padding: .65rem .7rem; }
  .profile-head .avatar { flex-basis: 64px; height: 64px; border-radius: 14px; font-size: 1.55rem; }
  .profile-stats .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-score { grid-template-columns: 3.1rem minmax(0, 1fr); }
  .profile-score-stats { grid-column: 1 / -1; }
  .profile-score-detail { grid-column: 1 / -1; justify-self: end; }
}

@media (max-width: 380px) {
  .profile-score-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
