:root {
  font-family: Inter, "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  color: #17263a;
  background: #f4f6fa;
  font-synthesis: none;
  --ink: #17263a;
  --muted: #526278;
  --line: #dce3ee;
  --accent: #2449bd;
  --accent-hover: #17379e;
  --surface: #fff;
  --radius: .8rem;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-size: 1rem; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .58; cursor: wait; }
:focus-visible { outline: 3px solid #5784ff; outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.85rem, 4vw, 2.65rem); letter-spacing: -.045em; line-height: 1.18; }
h2 { font-size: 1.12rem; letter-spacing: -.025em; }
p { color: var(--muted); line-height: 1.6; }
.brand { display: inline-flex; align-items: center; gap: .7rem; width: max-content; font-weight: 760; letter-spacing: -.03em; }
.mark { width: 2.25rem; height: 2.25rem; border-radius: .58rem; display: grid; place-items: center; color: #fff; background: var(--accent); font-size: 1.12rem; font-weight: 830; }
.header-link { color: var(--muted); font-weight: 640; padding: .5rem .1rem; }
.header-link:hover, .inline-link:hover { color: var(--accent-hover); text-decoration: underline; }
.button { min-height: 2.65rem; padding: .62rem .9rem; border: 1px solid transparent; border-radius: .5rem; display: inline-flex; place-content: center; align-items: center; font-size: .9375rem; font-weight: 680; line-height: 1.35; text-align: center; }
.primary { color: white; background: var(--accent); }
.primary:hover { background: var(--accent-hover); }
.secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.secondary:hover { background: #f0f4fb; }
.text-button { border: 0; background: transparent; color: var(--accent); padding: .45rem .15rem; font-size: .875rem; font-weight: 660; }
.text-button:hover { text-decoration: underline; }
.danger { color: #9d1d32; }
.portal { min-height: 100svh; display: grid; grid-template-rows: auto 1fr; background: radial-gradient(ellipse at 85% 17%, #cedafa 0%, transparent 52%), linear-gradient(150deg, #f3f6fd, #e6edf9); }
.portal-header { display: flex; justify-content: space-between; align-items: center; padding: 1.4rem clamp(1.25rem, 5vw, 4rem); }
.portal-main { display: grid; align-items: center; justify-items: center; padding: 2rem 1.25rem max(4rem, 14vh); }
.portal-card { width: min(100%, 32rem); background: white; border: 1px solid #dce5f5; border-top: 4px solid var(--accent); border-radius: 1rem; padding: clamp(1.6rem, 5vw, 3rem); box-shadow: 0 1.25rem 4rem #18356a15; }
.portal-card h1 { margin-bottom: .8rem; }
.portal-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.8rem; }
.portal-actions > a { flex: 1 1 8rem; }
.logout-actions { display: flex; flex-wrap: wrap; gap: .5rem .8rem; }
.username { overflow-wrap: anywhere; }
.admin-page { display: grid; grid-template-columns: 14rem minmax(0, 1fr); min-height: 100svh; }
.sidebar { background: #111f36; color: #e8effa; padding: 1.35rem 1rem; }
.sidebar .brand { padding-inline: .35rem; }
.sidebar .mark { background: #436ce2; }
.sidebar nav { display: grid; gap: .38rem; margin-top: 2.3rem; }
.sidebar nav a { display: block; padding: .75rem .9rem; border-radius: .5rem; color: #c8d4e6; font-size: .93rem; font-weight: 550; }
.sidebar nav a:hover { color: white; background: #1c304f; }
.sidebar nav a[aria-current="page"] { color: #fff; background: #2b4168; box-shadow: inset 3px 0 #88a6ff; }
.admin-header { min-height: 4.4rem; padding: .75rem clamp(1rem, 4vw, 3rem); display: flex; align-items: center; justify-content: space-between; gap: .8rem; background: #fff; border-bottom: 1px solid var(--line); font-weight: 680; }
.admin-header .username { max-width: 16rem; }
.workspace { max-width: 90rem; margin: 0 auto; padding: clamp(1.25rem, 4vw, 3rem); }
.status { margin-bottom: 1.1rem; padding: .75rem 1rem; border: 1px solid #bcd1fb; border-radius: .45rem; color: #17367d; background: #edf3ff; }
.status.error { color: #861d30; border-color: #f3bbc6; background: #fff1f3; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-heading p { margin-top: .45rem; }
.metric-grid, .pair-grid, .form-grid { display: grid; gap: 1rem; align-items: start; margin-bottom: 1.1rem; }
.metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pair-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 .2rem .6rem #1c385009; }
.metric { padding: 1.2rem; display: grid; gap: .65rem; }
.metric:hover { border-color: #9bb1e6; }
.metric span { color: var(--muted); font-size: .875rem; }
.metric strong { font-size: 2rem; font-variant-numeric: tabular-nums; font-weight: 720; letter-spacing: -.035em; }
.table-card { margin-bottom: 1.1rem; }
.pair-grid > .table-card { margin-bottom: 0; }
.table-card > header { padding: 1rem 1.15rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.inline-link { color: var(--accent); font-size: .875rem; font-weight: 670; }
.table-scroll { overflow: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: .875rem; }
th, td { padding: .68rem 1.15rem; border-top: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 670; background: #f7f9fc; }
.empty { padding: 1rem 1.15rem 1.2rem; border-top: 1px solid var(--line); }
.form-card { padding: 1.03rem 1.15rem; }
form.form-card, .advanced-form { display: grid; gap: .85rem; }
.advanced-form { margin-top: 1rem; }
form.form-card > .button, .advanced-form > .button { justify-self: start; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
label { display: grid; gap: .38rem; font-size: .875rem; font-weight: 650; }
input, select, textarea { min-width: 0; max-width: 100%; padding: .58rem .65rem; border: 1px solid #c9d4e3; border-radius: .45rem; background: white; color: var(--ink); font-size: .95rem; }
textarea { resize: vertical; }
.checkbox { display: flex; gap: .5rem; align-items: center; }
.checkbox input { margin: 0; accent-color: var(--accent); }
.form-card summary { font-weight: 680; cursor: pointer; }
.audit-details { max-width: 32rem; overflow-wrap: anywhere; white-space: pre-wrap; font-size: .875rem; margin: .55rem 0; }
@media (max-width: 65rem) {
  .metric-grid, .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 49rem) {
  .admin-page { grid-template-columns: minmax(0, 1fr); }
  .sidebar { padding: 1rem; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .8rem; }
  .sidebar nav a { padding: .55rem .65rem; }
  .admin-header { min-height: 3.3rem; }
  .form-grid, .pair-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 26rem) {
  .fields { grid-template-columns: minmax(0, 1fr); }
  .metric { padding: .85rem; }
}
