:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  background: #f3f5f8;
  color: #1f2937;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

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

button,
a {
  border: 0;
  border-radius: 6px;
  background: #1677ff;
  color: #fff;
  cursor: pointer;
  padding: 9px 14px;
  text-decoration: none;
}

button.secondary {
  background: #6b7280;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.danger {
  background: #dc2626;
}

button.warning {
  background: #f59e0b;
}

button.icon {
  background: transparent;
  color: #4b5563;
  padding: 4px 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #111827;
  padding: 9px 10px;
}

label {
  display: grid;
  gap: 6px;
  color: #374151;
  font-size: 14px;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto;
}

.hidden {
  display: none !important;
}

.login {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  margin: 90px auto;
  padding: 28px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.08);
}

.loading {
  display: grid;
  place-items: center;
  width: min(420px, 100%);
  min-height: 160px;
  margin: 90px auto;
  padding: 28px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #64748b;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.08);
}

.loading p {
  margin: 0;
}

.login h1,
.topbar h1 {
  margin: 0;
  font-size: 22px;
}

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

.topbar p {
  margin: 8px 0 0;
  color: #6b7280;
}

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

.stats-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.stats-item b {
  font-size: 16px;
}

.stats-item.blue {
  background: #dbeafe;
  color: #1e40af;
}

.stats-item.red {
  background: #fee2e2;
  color: #991b1b;
}

.stats-item.orange {
  background: #ffedd5;
  color: #9a3412;
}

.stats-item.gray {
  background: #e5e7eb;
  color: #374151;
}

.stats-item.green {
  background: #dcfce7;
  color: #166534;
}

.stats-item.purple {
  background: #ede9fe;
  color: #5b21b6;
}

.actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar {
  margin-bottom: 12px;
}

.toolbar input {
  max-width: 360px;
}

.settings-strip {
  display: flex;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.settings-strip label {
  width: 220px;
}

.settings-strip .sub-url-setting {
  flex: 1;
  min-width: 360px;
}

.settings-strip .message {
  min-height: auto;
  margin: 0;
}

.tabs {
  display: flex;
  gap: 10px;
  margin: 18px 0;
}

.tab {
  background: #e5e7eb;
  color: #374151;
}

.tab.active {
  background: #1677ff;
  color: #fff;
}

.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.segmented {
  display: inline-flex;
  gap: 0;
  overflow: hidden;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
}

.segmented button {
  border-radius: 0;
  background: #fff;
  color: #374151;
}

.segmented button + button {
  border-left: 1px solid #d1d5db;
}

.segmented button.active {
  background: #1677ff;
  color: #fff;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.panel {
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 20px;
}

.section-head p {
  margin: 6px 0 0;
  color: #6b7280;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.user-panel {
  overflow-x: hidden;
}

.user-table {
  min-width: 0;
  table-layout: fixed;
}

.user-table th:nth-child(1),
.user-table td:nth-child(1) {
  width: 42px;
}

.user-table th:nth-child(2),
.user-table td:nth-child(2) {
  width: 92px;
}

.user-table th:nth-child(3),
.user-table td:nth-child(3) {
  width: 100px;
}

.user-table th:nth-child(4),
.user-table td:nth-child(4) {
  width: 70px;
}

.user-table th:nth-child(5),
.user-table td:nth-child(5) {
  width: 66px;
}

.user-table th:nth-child(6),
.user-table td:nth-child(6) {
  width: 184px;
}

.user-table th:nth-child(7),
.user-table td:nth-child(7) {
  width: 164px;
}

.user-table th:nth-child(8),
.user-table td:nth-child(8) {
  width: 84px;
}

.user-table th:nth-child(9),
.user-table td:nth-child(9) {
  width: 96px;
}

.user-table th:nth-child(10),
.user-table td:nth-child(10) {
  width: 98px;
}

.user-table th:nth-child(11),
.user-table td:nth-child(11) {
  width: 176px;
}

.fixed-text {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.account-text,
.email-text,
.ip-text {
  width: 100%;
}

.location-text {
  width: 100%;
}

.copy-link {
  display: inline-block;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #0f172a;
  padding: 0;
  text-align: left;
}

.copy-link:hover {
  color: #1677ff;
  text-decoration: underline;
}

.data-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 28px;
  border-radius: 6px;
  padding: 4px 7px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.expire-pill {
  width: 168px;
  min-width: 168px;
  background: #e0f2fe;
  color: #075985;
}

.expire-pill.expired {
  background: #fee2e2;
  color: #991b1b;
}

.traffic-pill {
  background: #dcfce7;
  color: #166534;
}

.balance-pill {
  background: #ffedd5;
  color: #9a3412;
}

.announcement-table {
  min-width: 860px;
}

.plan-table {
  min-width: 960px;
}

.redeem-table {
  min-width: 1100px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 2px 0;
  color: #4b5563;
}

.pager div {
  display: flex;
  gap: 8px;
}

th,
td {
  border-bottom: 1px solid #eef2f7;
  padding: 11px 10px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.user-table th,
.user-table td {
  padding-inline: 8px;
}

th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
}

td .row-actions {
  display: flex;
  gap: 5px;
}

.row-actions button {
  padding-inline: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 1000;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 9px 16px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
}

.announcement-content {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code {
  color: #111827;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
}

.status.enabled {
  background: #dcfce7;
  color: #166534;
}

.status.disabled {
  background: #fee2e2;
  color: #991b1b;
}

.message {
  min-height: 20px;
  margin: 0;
  color: #dc2626;
}

dialog {
  width: min(760px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

dialog form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

dialog header,
dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

dialog h2 {
  margin: 0;
  font-size: 20px;
}

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

@media (max-width: 720px) {
  .topbar,
  .toolbar,
  .section-head,
  dialog header,
  dialog footer {
    align-items: stretch;
    flex-direction: column;
  }

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