:root {
  color-scheme: dark;
  font: 100%/1.5 "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Noto Sans CJK SC", sans-serif;
  font-variant-numeric: tabular-nums;
  --text-small: .875rem;
  --canvas: #101820;
  --panel: #17232e;
  --input: #101b24;
  --line: #2d4050;
  --text: #edf5f8;
  --muted: #a6bac8;
  --green: #77e5bc;
  --green-dark: #10251f;
  --danger: #ffb0aa;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--text); background: var(--canvas); min-height: 100vh; }
button, input, select, option, textarea, table, code { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1, h2, strong { font-weight: 700; }
h1 { font-size: clamp(1.875rem, 4vw, 2.5rem); line-height: 1.25; }
h2 { font-size: 1.25rem; }
small, .brand div > span, .dashboard-header p, .metrics span, th, td time, .status-tag,
.connection-help, .form-error, .table-note { font-size: var(--text-small); }
form label, .button, .view-tab, th { font-weight: 600; }

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: #131e28;
}
.brand { display: flex; align-items: center; gap: .8rem; }
.brand > div { display: grid; }
.brand div > span { color: var(--muted); }
.brand-icon { display: grid; place-items: center; width: 42px; height: 42px; color: var(--green); background: #213e3a; border: 1px solid #335f55; border-radius: 8px; flex-shrink: 0; }
.brand-icon svg { width: 27px; height: 27px; }

.login-layout {
  width: min(100% - 3rem, 1020px);
  min-height: min(680px, calc(100vh - 76px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  align-items: center;
  gap: clamp(1.5rem, 7vw, 6rem);
  padding: 3rem 0 4rem;
}
.login-intro { padding: 1.7rem 0; }
.login-intro p { max-width: 23rem; margin-top: 1rem; color: var(--muted); }
.login-panel { background: var(--panel); border: 1px solid var(--line); padding: clamp(1.2rem, 4vw, 2.1rem); border-radius: 14px; box-shadow: 0 20px 60px #080e136b; }
form { display: grid; gap: .65rem; }
form label:not(:first-child) { margin-top: .4rem; }
input, select, textarea {
  min-height: 44px;
  border: 1px solid #3b4f60;
  border-radius: 7px;
  padding: .58rem .75rem;
  background: var(--input);
  color: var(--text);
  width: 100%;
}
input::placeholder, textarea::placeholder { color: #9aafbe; opacity: 1; }
textarea { resize: vertical; min-height: 90px; }
.button { min-height: 42px; padding: .52rem .95rem; border: 1px solid var(--line); border-radius: 7px; color: var(--text); background: #243644; white-space: nowrap; }
a.button { display: inline-flex; align-items: center; text-decoration: none; }
.button:hover { background: #31495b; }
.button.primary { background: var(--green); color: var(--green-dark); border-color: var(--green); }
.button.primary:hover { background: #a0f3d5; }
.button.quiet { background: transparent; }
.button.quiet:hover { background: #253949; }
.button.danger { color: var(--danger); border-color: #79534e; }
.button.full { width: 100%; margin-top: .8rem; }
.button:disabled { opacity: .55; cursor: not-allowed; }
.account-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.account-actions .button { padding-inline: .65rem; }
dialog:has(.points-history) { width: min(calc(100% - 1.5rem), 800px); }
.points-history table { min-width: 550px; }
.points-history { max-height: 55vh; margin-bottom: .65rem; }
.connection-help { border-top: 1px solid var(--line); margin-top: 1.25rem; padding-top: .95rem; }
.form-error { margin: .35rem 0 0; color: var(--danger); }

.dashboard { width: min(100% - 3rem, 1320px); margin: 0 auto; padding: 2.1rem 0 3rem; }
.dashboard-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.6rem; }
.dashboard-header p { color: var(--muted); margin-top: .45rem; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; margin-bottom: 1.35rem; }
.metrics > div { display: grid; gap: .2rem; padding: .78rem 1rem; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.metrics span { color: var(--muted); }
.metrics strong { font-size: 1.5rem; }
.work-panel { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); overflow: hidden; }
.view-tabs { display: flex; padding: 0 .9rem; border-bottom: 1px solid var(--line); }
.view-tab { min-height: 50px; background: transparent; border: 0; border-bottom: 2px solid transparent; padding: .55rem .8rem; color: var(--muted); }
.view-tab:hover { color: var(--text); }
.view-tab[aria-pressed="true"] { color: var(--green); border-bottom-color: var(--green); }
.toolbar { padding: 1rem; display: flex; align-items: center; gap: .65rem; }
.toolbar p { color: var(--muted); flex: 1; }
.toolbar-actions { margin-left: auto; display: flex; gap: .5rem; }
.search-field { position: relative; width: min(100%, 20rem); }
.search-field svg { position: absolute; left: .75rem; top: .7rem; width: 1.3rem; height: 1.3rem; color: var(--muted); pointer-events: none; }
.search-field input { padding-left: 2.3rem; }
.select-field { position: relative; }
.select-field select { appearance: none; padding-right: 2rem; }
.select-field::after { content: ""; width: .45rem; height: .45rem; position: absolute; top: 45%; right: .85rem; border: solid var(--muted); border-width: 0 1px 1px 0; transform: rotate(45deg); pointer-events: none; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; min-width: 700px; }
th { color: var(--muted); background: #101d28; }
th, td { padding: .65rem 1rem; border-top: 1px solid var(--line); vertical-align: middle; }
td { overflow-wrap: anywhere; }
td small { display: block; color: var(--muted); }
td time { color: var(--muted); white-space: nowrap; }
.status-tag { display: inline-flex; padding: .14rem .48rem; border-radius: 5px; white-space: nowrap; }
.status-active { color: #aaf3d7; background: #1d453e; }
.status-pending { color: #ffe0a8; background: #473b2b; }
.status-transfer { color: #badbff; background: #2d425a; }
.status-disabled { color: #ffbdb6; background: #4b3536; }
.table-empty { color: var(--muted); padding: 2rem 1rem; text-align: center; }
.table-note { border-top: 1px solid var(--line); color: var(--muted); padding: .7rem 1rem; }
.work-notice { margin: .8rem 1rem 0; padding: .6rem .75rem; border-radius: 7px; color: var(--green); background: #1c3837; }
.work-notice[data-error="true"] { color: var(--danger); background: #493236; }

dialog { width: min(calc(100% - 1.5rem), 520px); background: var(--panel); color: var(--text); border: 1px solid #45596a; border-radius: 12px; padding: 1.2rem; }
dialog::backdrop { background: #050b10c7; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.close { width: 38px; min-height: 38px; padding: 0; font-size: 1.35rem; }
.dialog-copy { color: var(--muted); }
.dialog-actions { margin-top: .9rem; display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; }
.action-list { display: grid; gap: .5rem; margin-top: 1rem; }
.action-list .button { text-align: left; }
.code-output { display: block; margin: .9rem 0; background: var(--input); border: 1px solid var(--line); border-radius: 7px; padding: .75rem; font-size: 1.25rem; color: var(--green); overflow-wrap: anywhere; user-select: all; }

@media (max-width: 680px) {
  .login-layout { grid-template-columns: 1fr; min-height: 0; align-items: start; width: calc(100% - 2rem); gap: 1.2rem; padding-top: 1.4rem; }
  .login-intro { padding: .1rem 0; }
  .dashboard { width: calc(100% - 2rem); padding-top: 1.4rem; }
  .toolbar { flex-wrap: wrap; }
  .search-field { flex: 1; min-width: 12rem; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 365px) {
  .topbar { align-items: start; flex-direction: column; }
  .dashboard-header { align-items: start; }
}
