:root {
  --bg: #111217;
  --surface: #1b1d25;
  --surface-2: #242735;
  --line: #383c4d;
  --text: #f4f0e8;
  --muted: #aaa2b7;
  --accent: #9f7aea;
  --accent-2: #e4b45c;
  --good: #55c596;
  --danger: #ee6b73;
  --info: #64b5d9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: linear-gradient(135deg, #14151b 0%, #211b2d 48%, #161a21 100%);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.topbar,
.toolbar,
.panel,
.activity-card,
.record-card,
.detail-header {
  border: 1px solid var(--line);
  background: rgba(27, 29, 37, 0.88);
  border-radius: 8px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 12px;
  letter-spacing: 0;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 6vw, 52px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 6px;
  font-size: 24px;
}

h3 {
  margin-bottom: 6px;
  font-size: 18px;
}

.tagline,
.toolbar p,
.quota-head p,
.muted {
  color: var(--muted);
}

.tagline,
.toolbar p,
.quota-head p {
  margin-bottom: 0;
}

.topbar .tagline {
  color: var(--text);
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1.15;
  font-weight: 900;
}

.admin-contact {
  display: inline-flex;
  margin: 14px 0 0;
  padding: 8px 10px;
  border: 1px solid rgba(228, 180, 92, 0.36);
  border-radius: 8px;
  color: #ffe1a0;
  background: rgba(228, 180, 92, 0.1);
  font-size: 14px;
  font-weight: 700;
}

.profile-contact {
  color: #ffe1a0;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.user-pill {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 8px;
}

.user-pill-info {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.user-pill strong {
  color: var(--accent-2);
}

.user-pill .muted {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-pill-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.user-pill-actions .secondary {
  min-height: 34px;
  padding: 0 10px;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  margin: 18px 0;
}

.nav-tab,
.primary,
.secondary,
.danger {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  color: var(--text);
}

.nav-tab {
  background: var(--surface);
  border-color: var(--line);
}

.nav-tab.active {
  background: var(--accent);
  color: #111217;
  font-weight: 800;
}

.primary {
  background: var(--accent);
  color: #111217;
  font-weight: 800;
}

.secondary {
  background: var(--surface-2);
  border-color: var(--line);
}

.danger {
  background: rgba(238, 107, 115, 0.16);
  border-color: rgba(238, 107, 115, 0.5);
  color: #ffdadd;
}

.icon-btn {
  width: 40px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.compact {
  white-space: nowrap;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.wide {
  width: 100%;
  margin-top: 20px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  margin-bottom: 14px;
}

.toolbar > .auth-actions:only-child {
  margin-left: auto;
}

.panel {
  padding: 18px;
  margin-bottom: 14px;
}

.filter-block label,
label {
  display: grid;
  gap: 8px;
  color: #d7d0e4;
  font-size: 14px;
  font-weight: 700;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.segmented button,
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--text);
  background: var(--surface-2);
}

.segmented button.active,
.chip.active {
  background: var(--accent-2);
  color: #171717;
  border-color: transparent;
}

.filter-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  background: #12141b;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.2);
  opacity: 0.92;
}

input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.2);
  opacity: 0.92;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  filter: invert(1) brightness(1.2);
  opacity: 0.92;
}

textarea {
  min-height: 118px;
  resize: vertical;
  line-height: 1.55;
}

.filter-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
}

.activity-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.activity-card,
.record-card {
  padding: 16px;
}

.activity-card {
  padding: 13px 14px;
}

.activity-card {
  display: grid;
  gap: 9px;
  text-align: left;
  color: inherit;
}

.activity-card h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.activity-card .meter {
  height: 8px;
}

.activity-card .meta-grid {
  gap: 5px 10px;
  font-size: 12px;
}

.card-rule-preview {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #d9d2e4;
  font-size: 12px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-title-row,
.stat-row,
.detail-actions,
.quota-head,
.profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(100, 181, 217, 0.15);
  color: #beeaff;
  font-size: 12px;
  white-space: nowrap;
}

.badge.gold {
  background: rgba(228, 180, 92, 0.16);
  color: #ffe1a0;
}

.badge.red {
  background: rgba(238, 107, 115, 0.16);
  color: #ffc0c4;
}

.meter {
  height: 10px;
  overflow: hidden;
  background: #101218;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.meter span {
  display: block;
  height: 100%;
  width: var(--value);
  background: linear-gradient(90deg, var(--good), var(--accent-2));
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.form-panel {
  display: grid;
  gap: 16px;
}

.system-warning {
  padding: 12px 14px;
  border: 1px solid rgba(228, 180, 92, 0.42);
  border-radius: 8px;
  background: rgba(228, 180, 92, 0.12);
  color: #ffe1a0;
  font-weight: 800;
}

.publish-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.publish-actions .primary {
  min-width: 180px;
}

.publish-quota-summary-bottom {
  margin-left: auto;
}

.quota-summary {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--accent-2);
  font-weight: 800;
}

.quota-summary.over {
  color: #ffdadd;
  background: rgba(238, 107, 115, 0.18);
}

.quota-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.quota-class {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151821;
}

.quota-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.boss-quota-inputs {
  grid-template-columns: minmax(0, 2fr) minmax(90px, 1fr);
}

.quota-inputs input {
  min-height: 36px;
  color: var(--accent-2);
  font-weight: 800;
}

.edit-quota-input {
  color: var(--accent-2);
  font-weight: 800;
}

.quota-inputs .boss-talent-name {
  color: var(--text);
  font-weight: 600;
}

.quota-inputs input.is-zero,
.edit-quota-input.is-zero {
  color: var(--text);
  font-weight: 600;
}

.detail-header {
  padding: 18px;
  margin-bottom: 14px;
}

.rule-box {
  white-space: pre-wrap;
  line-height: 1.7;
  color: #eee8f5;
}

.rule-edit-trigger {
  margin: 12px 0 0;
  color: var(--accent-2);
  font-weight: 800;
}

.rule-editor {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.requirements {
  display: grid;
  gap: 10px;
}

.requirement-edit-trigger {
  margin: 0 0 12px;
  color: var(--accent-2);
  font-weight: 800;
}

.requirement-editor {
  display: grid;
  gap: 14px;
}

.edit-total-slots {
  max-width: 220px;
}

.edit-quota-grid {
  margin-top: 0;
}

.edit-quota-summary-bottom {
  margin-left: auto;
}

.requirement-row {
  display: grid;
  grid-template-columns: 150px 1fr 72px;
  gap: 12px;
  align-items: center;
}

.requirement-row .full-count {
  color: var(--accent-2);
  font-weight: 800;
}

.requirement-row .zero-count {
  color: #ffffff;
  font-weight: 800;
}

.signup-box {
  display: grid;
  gap: 12px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-2);
  font-weight: 700;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
}

.profile-head {
  padding: 18px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: var(--accent-2);
  color: #161616;
  font-size: 28px;
  font-weight: 900;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.stat-card {
  padding: 16px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  color: var(--accent-2);
}

.records {
  display: grid;
  gap: 10px;
}

.signup-records .record-card strong,
.published-records .record-card strong {
  color: #ffffff;
}

.published-record-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.published-record-card > div {
  min-width: 0;
}

.admin-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 10px 0 12px;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 8, 12, 0.72);
}

.auth-overlay[hidden] {
  display: none;
}

.auth-dialog {
  width: min(520px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1b1d25;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.auth-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.auth-form {
  display: none;
  gap: 12px;
}

.auth-form.active {
  display: grid;
}

.verify-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.auth-note {
  min-height: 22px;
  margin-bottom: 0;
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  transform: translateX(-50%) translateY(24px);
  max-width: min(520px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: 8px;
  background: #f4f0e8;
  color: #151515;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 860px) {
  .topbar,
  .toolbar,
  .card-title-row,
  .detail-actions,
  .profile-head {
    align-items: stretch;
    flex-direction: column;
  }

  .user-pill {
    justify-content: space-between;
    width: 100%;
  }

  .user-pill-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .filter-grid,
  .form-grid,
  .activity-list,
  .quota-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .quota-inputs {
    grid-template-columns: 1fr;
  }

  .requirement-row {
    grid-template-columns: 1fr;
  }

  .admin-form {
    grid-template-columns: 1fr;
  }

  .published-record-card {
    align-items: stretch;
    flex-direction: column;
  }

  .publish-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .publish-actions .primary {
    width: 100%;
  }

  .publish-quota-summary-bottom {
    margin-left: 0;
  }

  .verify-row {
    grid-template-columns: 1fr;
  }
}
