:root {
  color-scheme: light;
  --bg: #eef4f8;
  --panel: #ffffff;
  --panel-soft: #f7fafc;
  --text: #172033;
  --muted: #778198;
  --line: #dde5ee;
  --primary: #3159e8;
  --primary-2: #6b7df4;
  --green: #14a36f;
  --amber: #c9830c;
  --danger: #d74444;
  --shadow: 0 22px 60px rgba(42, 55, 87, 0.14);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(236, 244, 255, 0.78)),
    linear-gradient(160deg, #e9f7f5 0%, #edf1ff 46%, #f7eef8 100%);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

a {
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.center {
  text-align: center;
}

.brand-lock {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  color: transparent;
  position: relative;
  box-shadow: 0 10px 20px rgba(49, 89, 232, 0.24);
}

.brand-lock::before {
  content: "";
  width: 13px;
  height: 11px;
  border: 2px solid #fff;
  border-radius: 2px;
  position: absolute;
  bottom: 10px;
}

.brand-lock::after {
  content: "";
  width: 13px;
  height: 12px;
  border: 2px solid #fff;
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  position: absolute;
  top: 9px;
}

.brand-name {
  color: var(--primary);
  font-weight: 800;
  font-size: 15px;
}

.client-page {
  display: flex;
  justify-content: center;
}

.client-shell {
  width: min(100%, 420px);
  min-height: 100vh;
  padding: 32px 10px;
}

.client-card {
  width: 100%;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.74);
  padding: 28px 22px;
}

.client-card .brand-lock,
.client-card .brand-name {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.client-card h1 {
  margin: 18px 0 8px;
  font-size: 26px;
  line-height: 1.22;
  text-align: center;
}

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

.form-stack.compact {
  gap: 12px;
}

label {
  display: grid;
  gap: 8px;
  color: #2e384d;
  font-weight: 700;
  font-size: 14px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  outline: 0;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input {
  height: 50px;
  padding: 0 14px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  padding: 0;
  accent-color: var(--primary);
  box-shadow: none;
}

textarea {
  min-height: 188px;
  padding: 14px;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(49, 89, 232, 0.12);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn {
  min-height: 44px;
  border-radius: 10px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  color: #fff;
  box-shadow: 0 12px 24px rgba(49, 89, 232, 0.22);
}

.secondary-btn {
  background: #fff;
  color: #30415f;
  border: 1px solid var(--line);
}

.ghost-btn {
  background: #f5f7fb;
  color: #33425f;
  border: 1px solid var(--line);
}

.danger-btn {
  background: #fff3f3;
  color: var(--danger);
  border: 1px solid #ffd0d0;
}

.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.slim {
  min-height: 38px;
}

.message {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

.message.ok {
  color: var(--green);
}

.safe-note {
  margin: 20px 0 0;
  color: #9aa4b4;
  font-size: 12px;
  text-align: center;
}

.success-text {
  margin: 18px 0 0;
  color: var(--green);
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.info-list {
  margin: 18px auto 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fbfdff;
}

.copy-row {
  min-height: 74px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.copy-row:last-child {
  border-bottom: 0;
}

.copy-row span {
  display: block;
  color: #8a95a8;
  font-size: 12px;
  margin-bottom: 5px;
}

.copy-row strong {
  display: block;
  font-size: 17px;
  line-height: 1.25;
  word-break: break-all;
}

.matrix-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
  margin-bottom: 18px;
}

.section-title,
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.section-title h2,
.panel-title h2 {
  margin: 0;
  font-size: 18px;
}

.section-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.pill {
  min-width: 48px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #edf0ff;
  color: var(--primary);
  font-weight: 800;
  font-size: 13px;
}

.matrix-wrap {
  overflow-x: auto;
}

.matrix-grid {
  display: grid;
  grid-template-columns: 24px repeat(7, minmax(0, 1fr));
  gap: 7px;
  align-items: center;
}

.matrix-head,
.matrix-row-label {
  color: #7d8798;
  font-size: 12px;
  text-align: center;
  font-weight: 800;
}

.matrix-cell {
  width: 100%;
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 8px;
  border: 1px solid #d8e0ea;
  background: #fff;
  color: #27344f;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
}

.client-matrix .matrix-cell.selected,
.client-matrix .matrix-cell.revealed {
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 7px 14px rgba(49, 89, 232, 0.22);
}

.client-matrix .matrix-cell.revealed {
  font-size: 12px;
}

.client-matrix .matrix-cell:not(:disabled):hover {
  border-color: var(--primary);
}

.admin-page {
  min-width: 1080px;
}

.admin-shell {
  min-height: 100vh;
  padding: 28px;
}

.admin-login {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
}

.login-box {
  width: min(420px, 100%);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.brand-row h1 {
  margin: 4px 0 0;
  font-size: 24px;
}

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

.admin-topbar h1 {
  margin: 4px 0 0;
  font-size: 28px;
}

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

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

.stat-box {
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 10px 30px rgba(42, 55, 87, 0.08);
  padding: 16px;
}

.stat-box span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat-box strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.stat-box.danger strong {
  color: var(--danger);
}

.stat-box.warn strong {
  color: var(--amber);
}

.admin-layout {
  display: grid;
  grid-template-columns: 300px 420px minmax(520px, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.82);
  box-shadow: 0 14px 42px rgba(42, 55, 87, 0.1);
  padding: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 19px;
}

.field-group {
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #2f3c55;
  font-size: 14px;
  font-weight: 900;
}

.group-title span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.account-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 260px);
  overflow: auto;
  padding-right: 4px;
}

.account-item {
  width: 100%;
  min-height: 58px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.account-item.active {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(49, 89, 232, 0.18);
}

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

.account-select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.account-nickname {
  min-width: 0;
  flex: 1;
  color: var(--text);
  font-size: 18px;
  line-height: 1.25;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-main strong {
  display: block;
  font-size: 16px;
  line-height: 1.35;
}

.account-extra {
  display: grid;
  gap: 4px;
  margin-top: 5px;
  color: #4c5870;
  font-size: 13px;
  line-height: 1.35;
}

.account-extra span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bulk-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -2px 0 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbff;
}

.check-control {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: #33425f;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  user-select: none;
}

.account-check span {
  color: var(--muted);
  font-size: 12px;
}

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

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
  background: #ebf8f3;
  color: var(--green);
}

.status-chip.expired {
  background: #fff0f0;
  color: var(--danger);
}

.status-chip.warning {
  background: #fff7e6;
  color: var(--amber);
}

.status-chip.unready {
  background: #eef2f7;
  color: #617087;
}

.count-pill {
  min-width: 54px;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  background: #ebf8f3;
  color: var(--green);
  border: 1px solid rgba(20, 163, 111, 0.28);
  white-space: nowrap;
}

.count-pill.expired {
  background: #fff0f0;
  color: var(--danger);
  border-color: rgba(215, 68, 68, 0.28);
}

.empty-state {
  min-height: 520px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
}

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

.detail-head h2 {
  margin: 8px 0 0;
  font-size: 30px;
  line-height: 1.1;
}

.info-grid,
.edit-grid,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr);
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fbff;
}

.edit-grid label {
  gap: 10px;
  color: #172033;
  font-size: 16px;
  font-weight: 900;
}

.edit-grid input {
  height: 58px;
  font-size: 16px;
  font-weight: 800;
}

.info-item {
  min-height: 76px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 6px;
}

.info-item.wide,
.edit-grid .wide,
.settings-grid .wide {
  grid-column: 1 / 3;
}

.info-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.info-item strong {
  min-width: 0;
  color: #26334d;
  font-size: 17px;
  line-height: 1.25;
  word-break: break-all;
}

.settings-grid button {
  grid-column: 1 / 3;
}

.inline-control {
  display: flex;
  gap: 8px;
}

.inline-control input {
  flex: 1;
}

.password-panel {
  margin: 14px 0;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.password-panel span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.password-panel strong {
  display: block;
  word-break: break-all;
}

.subsection {
  margin-top: 16px;
}

.admin-matrix-wrap {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
}

.admin-matrix input.matrix-cell {
  padding: 0 2px;
  text-align: center;
  min-height: 38px;
}

@media (max-width: 1260px) {
  .admin-page {
    min-width: 0;
  }

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

  .account-list {
    max-height: none;
  }

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

@media (max-width: 720px) {
  .admin-shell {
    padding: 18px 12px;
  }

  .admin-topbar,
  .section-title,
  .panel-title,
  .detail-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .info-grid,
  .edit-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .info-item.wide,
  .edit-grid .wide,
  .settings-grid .wide,
  .settings-grid button {
    grid-column: auto;
  }

  .client-shell {
    padding-top: 16px;
  }

  .client-card {
    border-radius: 16px;
    padding: 24px 18px;
  }
}
