:root {
  color: #1c2d45;
  background: #f4f7fb;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, #52a7e9, #2870bd);
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  box-shadow: 0 12px 24px #12487a33;
  margin: 0 auto 18px;
}

.login-page {
  min-height: 100vh;
  background: radial-gradient(circle at 18% 15%, #285681 0, #17355a 42%, #102743 100%);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.login-card {
  width: min(440px, 100%);
  padding: 42px 48px 38px;
  border: 1px solid #ffffff55;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 24px 70px #09192c66;
  text-align: center;
}

.login-card h1 { margin: 0; color: #17355a; font-size: 34px; letter-spacing: .02em; }
.login-subtitle { margin: 10px 0 34px; color: #667085; }
.login-card form { text-align: left; }
.login-card label { display: block; margin: 16px 0 7px; color: #263b56; font-weight: 700; }
.login-card input {
  width: 100%;
  border: 1px solid #cbd7e5;
  border-radius: 10px;
  padding: 13px 14px;
  color: #1c2d45;
  background: #f8fafc;
  outline: none;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.login-card input:focus { border-color: #2870bd; background: #fff; box-shadow: 0 0 0 4px #2870bd1c; }
.login-card select {
  width: 100%;
  border: 1px solid #cbd7e5;
  border-radius: 10px;
  padding: 13px 14px;
  color: #1c2d45;
  background: #f8fafc;
  outline: none;
}
.login-card select:focus { border-color: #2870bd; background: #fff; box-shadow: 0 0 0 4px #2870bd1c; }
.login-hint { margin: 8px 0 0; color: #718096; font-size: 12px; line-height: 1.5; }
.login-card button {
  width: 100%;
  margin-top: 24px;
  border: 0;
  border-radius: 10px;
  padding: 13px 18px;
  background: #2870bd;
  color: #fff;
  font-weight: 700;
  transition: background .16s, opacity .16s;
}
.login-card button:hover { background: #1f5f9f; }
.login-card button:disabled { cursor: wait; opacity: .7; }
.form-status {
  min-height: 42px;
  margin: 14px 0 0;
  padding: 11px 12px;
  border-radius: 9px;
  color: #5f7186;
  background: #f2f6fa;
  font-size: 13px;
  line-height: 1.5;
}
.form-status.error { color: #a33a3a; background: #fff1f1; }
.form-status.success { color: #176b4b; background: #ecfbf3; }

.admin-page { height: 100vh; overflow: hidden; background: #f4f7fb; }
.admin-shell {
  width: 100%;
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  min-height: 0;
  overflow-y: auto;
  padding: 24px 14px;
  color: #dce9f7;
  background: linear-gradient(180deg, #17355a, #102743);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 28px; }
.brand-mark-small { width: 42px; height: 42px; flex: 0 0 auto; margin: 0; border-radius: 12px; font-size: 23px; box-shadow: none; }
.sidebar-brand h1 { margin: 0; color: #fff; font-size: 23px; }
.sidebar-brand p { margin: 3px 0 0; color: #9db7d1; font-size: 12px; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav button {
  width: 100%;
  border: 0;
  border-radius: 9px;
  padding: 12px 13px;
  color: inherit;
  background: transparent;
  text-align: left;
  font-size: 15px;
}
.sidebar nav button:hover, .sidebar nav button.active { color: #fff; background: #2870bd; }
.sidebar nav .logout-button { margin-top: 20px; color: #ffced0; background: #8e3b4b44; }
.sidebar nav .logout-button:hover { background: #a84958; }

.content {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 28px clamp(18px, 4vw, 46px) 42px;
}
.content-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 22px;
  margin: -28px 0 26px;
  padding: 28px 0 18px;
  background: linear-gradient(#f4f7fb 76%, #f4f7fb00);
}
.eyebrow { margin: 0 0 6px; color: #2870bd; font-size: 11px; font-weight: 800; letter-spacing: .16em; }
.content h2 { margin: 0; color: #182b43; font-size: 29px; }
.header-right { display: flex; align-items: center; gap: 14px; color: #718096; font-size: 13px; text-align: right; }
.header-status { color: #2870bd; }
.header-status.error { color: #b04a4a; }
.header-status.success { color: #176b4b; }
.security-note { white-space: nowrap; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 15px; }
.card, .panel {
  border: 1px solid #e2e9f1;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 5px 18px #102a430b;
}
.card { min-height: 122px; padding: 20px; color: #657a91; }
.card strong { display: block; margin-top: 12px; color: #1b4c80; font-size: 30px; }
.panel { margin-top: 18px; padding: 20px; }
.panel > b { color: #284663; }
.notice { margin: 12px 0; padding: 13px 15px; border-radius: 9px; color: #155d9b; background: #eef7ff; line-height: 1.55; }
.notice.error { color: #a33a3a; background: #fff1f1; }

.content button {
  border: 0;
  border-radius: 8px;
  padding: 10px 15px;
  color: #fff;
  background: #2870bd;
  font-weight: 700;
}
.content button:hover { background: #1f5f9f; }
.content button:disabled { cursor: wait; opacity: .55; }
.content button.danger-button { background: #a84958; }
.content button.danger-button:hover { background: #893a49; }
form.inline { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 0 0 16px; }
form.inline label { display: grid; gap: 6px; color: #36526f; font-size: 13px; font-weight: 700; }
form.inline input { min-width: 125px; padding: 9px 10px; border: 1px solid #cad6e2; border-radius: 7px; color: #1c2d45; background: #f8fafc; }
form.inline select { min-width: 125px; padding: 9px 10px; border: 1px solid #cad6e2; border-radius: 7px; color: #1c2d45; background: #f8fafc; }
.table-scroll { width: 100%; overflow-x: auto; border-radius: 10px; }
table { width: 100%; min-width: 600px; border-collapse: collapse; background: #fff; }
th, td { padding: 12px; border-bottom: 1px solid #e8edf4; text-align: left; font-size: 13px; vertical-align: top; }
th { color: #36526f; background: #edf4fb; font-weight: 700; }
td code { font-size: 11px; word-break: break-all; }
.invite-table { min-width: 1040px; }
.invite-code-cell { min-width: 225px; }
.invite-code { color: #1c2d45; font-size: 13px; letter-spacing: .02em; white-space: nowrap; word-break: normal; }
.muted { color: #8998a9; white-space: nowrap; }
.invite-cell-editor { display: flex; align-items: center; gap: 8px; min-width: 205px; }
.invite-cell-editor input { padding: 7px 8px; border: 1px solid #cad6e2; border-radius: 7px; color: #1c2d45; background: #f8fafc; }
.invite-cell-editor input[name="usageLimit"] { width: 72px; min-width: 72px; }
.invite-cell-editor input[name="expiresAt"] { width: 190px; min-width: 190px; }
.invite-cell-editor button { padding: 7px 11px; white-space: nowrap; }
.used-count { white-space: nowrap; color: #36526f; }
.status-chip { display: inline-block; padding: 4px 8px; border-radius: 999px; color: #36526f; background: #edf4fb; white-space: nowrap; }
.status-chip.active { color: #176b4b; background: #e7f8ef; }
.status-chip.expired, .status-chip.exhausted { color: #9a5b12; background: #fff4df; }
.status-chip.revoked { color: #a33a3a; background: #fff1f1; }
.invite-result { display: grid; gap: 12px; }
.invite-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.invite-actions button { padding: 9px 14px; }
.invite-result textarea { width: 100%; min-height: 126px; resize: vertical; border: 1px solid #cad6e2; border-radius: 7px; padding: 10px; color: #1c2d45; background: #f8fafc; font: 14px Consolas, monospace; line-height: 1.55; }

@media (max-width: 850px) {
  .admin-shell { grid-template-columns: 190px minmax(0, 1fr); }
  .sidebar-brand { padding-left: 6px; }
  .sidebar-brand h1 { font-size: 20px; }
  .content-header { align-items: start; flex-direction: column; gap: 8px; }
  .header-right { text-align: left; }
}

@media (max-width: 640px) {
  .admin-shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { max-height: 122px; padding: 12px 12px 8px; overflow: hidden; }
  .sidebar-brand { padding: 0 4px 10px; }
  .brand-mark-small { width: 32px; height: 32px; border-radius: 9px; font-size: 18px; }
  .sidebar-brand h1 { font-size: 18px; }
  .sidebar-brand p { display: none; }
  .sidebar nav { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 4px; }
  .sidebar nav button { width: auto; flex: 0 0 auto; white-space: nowrap; padding: 9px 12px; }
  .sidebar nav .logout-button { margin-top: 0; }
  .content { padding: 20px 16px 30px; }
  .content-header { margin: -20px 0 20px; padding: 20px 0 14px; }
  .content h2 { font-size: 25px; }
  .header-right { display: grid; gap: 4px; }
  .security-note { white-space: normal; }
  .panel { padding: 15px; }
  form.inline { align-items: stretch; flex-direction: column; }
  form.inline label, form.inline input, form.inline button { width: 100%; }
  .invite-actions { flex-direction: column; }
}
