* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --line: #e6ebf2;
  --line-strong: #d7dee8;
  --text: #172033;
  --muted: #718096;
  --blue: #4f8ff7;
  --blue-strong: #2f73e8;
  --green: #26c06d;
  --green-strong: #17a75b;
  --orange: #f4a62a;
  --red: #ef5350;
  --shadow: 0 10px 28px rgba(25, 34, 51, 0.06);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

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

button,
a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 18px;
  background: #fff;
  color: #536176;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}

button:hover:not(:disabled),
a.button:hover {
  border-color: var(--blue);
  color: var(--blue-strong);
}

button:disabled {
  cursor: not-allowed;
  color: #c1c8d2;
  background: #f8fafc;
}

button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

button.primary:hover:not(:disabled) {
  border-color: var(--blue-strong);
  background: var(--blue-strong);
  color: #fff;
}

button.danger {
  border-color: #f3c7c4;
  color: #c43f3b;
}

button.danger:hover:not(:disabled) {
  border-color: var(--red);
  color: var(--red);
}

.admin-shell {
  min-width: 1180px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.title-nav {
  display: flex;
  align-items: baseline;
  gap: 30px;
}

.title-nav a {
  color: #56657a;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
}

.title-nav a:hover {
  color: #1d5ed0;
}

.title-nav h1 {
  color: var(--blue-strong);
}

.topbar p {
  margin: 7px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.admin-auth-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 12px;
  background: #f8fafc;
  color: #536176;
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 86px;
  height: 52px;
  padding: 0 30px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.tabs button {
  height: 52px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 0 8px;
  background: transparent;
  color: #59687c;
  font-size: 16px;
}

.tabs button.active {
  border-bottom-color: var(--blue);
  color: var(--blue-strong);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px;
  padding: 18px 28px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.filters label {
  display: grid;
  gap: 7px;
  color: #66758a;
  font-weight: 600;
}

.filters select,
.filters input {
  width: 220px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

.filters input {
  width: 320px;
}

.date-filter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #66758a;
  font-weight: 600;
}

.date-filter input {
  width: 170px;
  cursor: pointer;
}

.date-filter strong {
  color: #29384d;
  font-weight: 700;
}

.date-filter input[type="date"].is-empty::-webkit-datetime-edit {
  color: transparent;
}

.date-filter input[type="date"].is-empty::-webkit-datetime-edit-text,
.date-filter input[type="date"].is-empty::-webkit-datetime-edit-year-field,
.date-filter input[type="date"].is-empty::-webkit-datetime-edit-month-field,
.date-filter input[type="date"].is-empty::-webkit-datetime-edit-day-field {
  color: transparent;
}

.date-filter input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
}

.stat-filter,
.tier-filter,
.search-filter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.stat-filter select {
  width: 180px;
}

.tier-filter select {
  width: 130px;
}

.search-filter input {
  width: 300px;
}

.order-stats {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 28px;
  padding-left: 58px;
}

.order-stats[hidden] {
  display: none;
}

.order-stats label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #66758a;
}

.order-stats output {
  display: inline-flex;
  align-items: center;
  min-width: 180px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8fafc;
  color: #29384d;
  font-weight: 700;
}

.panel {
  margin: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 54px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.panel-head span {
  color: var(--muted);
}

.invite-settings {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
}

.invite-settings strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.invite-settings span {
  color: var(--muted);
}

.toggle-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #29384d;
  font-weight: 700;
}

.toggle-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.invite-toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.invite-toolbar label {
  display: grid;
  gap: 6px;
  color: #66758a;
  font-weight: 700;
}

.invite-toolbar input {
  width: 180px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 10px;
  color: var(--text);
}

.invite-toolbar label:nth-child(2) input {
  width: 260px;
}

.generated-invites {
  padding: 12px 18px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
}

.generated-invites[hidden] {
  display: none;
}

.generated-invites-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.generated-invites textarea {
  width: 100%;
  min-height: 104px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 10px;
  resize: vertical;
  color: #29384d;
  font-family: Consolas, "Microsoft YaHei UI", monospace;
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  max-height: 480px;
}

.invite-table-wrap {
  max-height: 260px;
}

.invite-page-table-wrap {
  max-height: 560px;
}

.users-table-wrap {
  max-height: 320px;
}

table {
  width: auto;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  height: 46px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0 10px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  position: relative;
  height: 44px;
  background: #f7f9fc;
  color: #182236;
  font-weight: 700;
  user-select: none;
}

td {
  color: #627083;
}

.buyer-phone {
  color: #29384d;
  font-weight: 700;
}

.users-table {
  width: 100%;
  min-width: 1140px;
}

.invite-table {
  width: 100%;
  min-width: 880px;
}

.invite-code {
  color: #29384d;
  font-family: Consolas, "Microsoft YaHei UI", monospace;
  font-weight: 800;
}

.user-status {
  display: inline-flex;
  align-items: center;
  min-width: 58px;
  font-weight: 700;
}

.user-status.active {
  color: var(--green-strong);
}

.user-status.blocked {
  color: var(--red);
}

.invite-status {
  display: inline-flex;
  align-items: center;
  min-width: 58px;
  font-weight: 700;
}

.invite-status.available {
  color: var(--green-strong);
}

.invite-status.used {
  color: var(--muted);
}

.invite-status.revoked,
.invite-status.expired {
  color: var(--red);
}

.order-col-resizer {
  position: absolute;
  top: 0;
  right: -6px;
  z-index: 3;
  width: 12px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.order-col-resizer::after {
  content: "";
  position: absolute;
  top: 9px;
  right: 3px;
  width: 2px;
  height: calc(100% - 18px);
  border-radius: 2px;
  background: transparent;
}

.order-col-resizer:hover::after,
th:hover .order-col-resizer::after,
.resizing-order-column .order-col-resizer::after {
  background: var(--blue);
}

.resizing-order-column,
.resizing-order-column * {
  cursor: col-resize !important;
  user-select: none !important;
}

tbody tr:hover td {
  background: #f8fbff;
}

.money,
.duration {
  color: #59687c;
  font-weight: 700;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7d8ba0;
}

.status.active {
  color: var(--green);
}

.status.active .dot {
  background: var(--green);
}

.status.done {
  color: #6780ff;
}

.status.done .dot {
  background: #5d86ff;
}

.status.service {
  color: var(--red);
}

.status.service .dot {
  background: var(--red);
}

.refund-reason {
  color: #97a3b4;
}

.refund-reason.has-reason {
  color: #29384d;
  font-weight: 700;
}

.action-cell {
  text-align: center;
}

.link-action {
  height: auto;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--blue-strong);
  font-weight: 700;
}

.link-action.green {
  color: var(--green-strong);
}

.link-action.orange {
  color: var(--orange);
}

.link-action.red {
  color: var(--red);
}

.link-action:disabled {
  background: transparent;
  color: #c4cad3;
}

.inventory-panel {
  margin-bottom: 28px;
}

.inventory-page-panel {
  margin-top: 18px;
}

.inventory-grid {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  min-height: 280px;
}

.tier-tabs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
}

.tier-tabs button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  cursor: grab;
}

.tier-tabs button.active {
  border-color: var(--blue);
  background: #eef5ff;
  color: var(--blue-strong);
}

.tier-tabs button.dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.tier-tabs button.drag-over {
  border-color: var(--green);
  background: #eefcf5;
  color: var(--green-strong);
}

.notebook {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 16px;
  padding: 16px;
}

.tier-manager {
  grid-column: 1 / -1;
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 0 0 2px;
}

.tier-manager label {
  display: grid;
  gap: 6px;
  color: #66758a;
  font-weight: 700;
}

.tier-manager input {
  width: 180px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

.tier-manager #tierNameInput {
  width: 220px;
}

textarea {
  width: 100%;
  min-height: 248px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 14px;
  background: #fff;
  color: #182236;
  line-height: 1.7;
  overflow: auto;
}

.wrap-lines {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.no-wrap-lines {
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
}

.inventory-page-panel textarea {
  min-height: 560px;
}

textarea:focus,
input:focus,
select:focus {
  outline: 2px solid rgba(79, 143, 247, 0.18);
  border-color: var(--blue);
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.actions button {
  width: 100%;
}

.empty {
  height: 92px;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  min-width: 240px;
  max-width: 460px;
  padding: 13px 16px;
  border: 1px solid #cbdcf7;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(27, 38, 64, 0.16);
  color: #22304a;
  font-weight: 600;
  white-space: pre-line;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.toast.error {
  left: 50%;
  top: 50%;
  right: auto;
  bottom: auto;
  z-index: 1000;
  min-width: 520px;
  max-width: min(760px, calc(100vw - 40px));
  padding: 24px 28px;
  border-color: #f3c4c2;
  border-width: 2px;
  border-radius: 10px;
  background: #fffdfd;
  box-shadow: 0 28px 70px rgba(81, 27, 31, 0.22);
  color: #b93f3b;
  font-size: 20px;
  line-height: 1.45;
  transform: translate(-50%, calc(-50% + 10px));
}

.toast.error.show {
  transform: translate(-50%, -50%);
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(18, 24, 34, 0.55);
}

.renew-dialog {
  position: relative;
  z-index: 1;
  width: 520px;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 70px rgba(15, 23, 42, 0.28);
}

.renew-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}

.renew-head h2 {
  margin: 0;
  font-size: 18px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 0;
  padding: 0;
  background: transparent;
  color: #9aa4b2;
  font-size: 26px;
  line-height: 1;
}

.renew-body {
  display: grid;
  gap: 14px;
  padding: 30px 64px 28px;
}

.renew-row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  align-items: center;
  gap: 10px;
  color: #4d5b70;
  font-weight: 700;
}

.renew-row > span:first-child {
  text-align: right;
}

.renew-row strong {
  color: var(--blue);
  font-size: 20px;
}

.stepper {
  display: grid;
  grid-template-columns: 38px 96px 38px;
  width: 172px;
}

.stepper button {
  height: 34px;
  margin: 0;
  padding: 0;
  border-radius: 0;
}

.stepper button:first-child {
  border-radius: 4px 0 0 4px;
}

.stepper button:last-child {
  border-radius: 0 4px 4px 0;
}

.stepper input {
  width: 96px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-left: 0;
  border-right: 0;
  padding: 0 8px;
  text-align: center;
}

.renew-shortcuts {
  display: flex;
  gap: 16px;
  padding-left: 120px;
}

.renew-shortcuts button {
  height: auto;
  border: 0;
  padding: 0;
  background: transparent;
  color: #5d93ff;
  font-weight: 800;
}

.renew-foot {
  display: grid;
  grid-template-columns: 1fr 170px;
  align-items: center;
  min-height: 58px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.renew-foot > div {
  padding-left: 22px;
  color: #30394b;
  font-weight: 700;
}

.renew-foot strong {
  margin: 0 4px 0 8px;
  color: #ff930f;
  font-size: 24px;
}

.renew-foot button {
  width: 100%;
  height: 58px;
  margin: 0;
  border-radius: 0;
  font-size: 16px;
}
