:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: #111620;
  --panel-strong: #151d2a;
  --line: rgba(255, 255, 255, 0.11);
  --text: #eef3f8;
  --muted: #95a1b2;
  --soft: #c9d3df;
  --accent: #5ec7d7;
  --good: #55d08a;
  --warn: #e4b761;
  --danger: #ef7474;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(130deg, rgba(94, 199, 215, 0.1), transparent 34%),
    linear-gradient(315deg, rgba(85, 208, 138, 0.08), transparent 28%),
    var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.access-panel {
  width: min(520px, calc(100% - 32px));
  margin: 12vh auto 0;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 22, 32, 0.9);
  box-shadow: var(--shadow);
}

.access-kicker,
.admin-topbar span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.access-panel h1,
.admin-topbar h1,
.panel-head h2 {
  margin: 6px 0 0;
}

.access-panel p,
.panel-head p,
.admin-foot,
.detail-body span,
.record-meta,
.status-line,
td small {
  color: var(--muted);
}

.access-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.portal-login {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.mfa-login-heading h2 {
  margin: 5px 0 0;
  font-size: 20px;
}

.mfa-login-heading p {
  margin: 7px 0 0;
  font-size: 13px;
  line-height: 1.65;
}

.mfa-login-actions {
  display: flex;
  gap: 8px;
}

.mfa-login-actions button {
  flex: 1;
}

.portal-login label,
.portal-field label,
.agent-dialog label {
  display: grid;
  gap: 7px;
  color: var(--soft);
  font-size: 13px;
}

.portal-login input,
.agent-dialog input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  outline: none;
}

.portal-field {
  display: grid;
  gap: 7px;
}

.password-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.password-input button {
  min-width: 58px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--soft);
}

.portal-login input:focus,
.agent-dialog input:focus {
  border-color: rgba(94, 199, 215, 0.62);
}

.access-actions a,
.ghost-button,
.primary-button,
.search-form button,
.pagination button,
.table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.primary-button,
.search-form button {
  border-color: rgba(94, 199, 215, 0.42);
  background: #2b8390;
  color: #f7feff;
  font-weight: 700;
}

.ghost-button:hover,
.access-actions a:hover,
.pagination button:hover,
.table-action:hover {
  border-color: rgba(94, 199, 215, 0.55);
  background: rgba(94, 199, 215, 0.12);
}

.primary-button:disabled,
.pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.admin-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(9, 11, 15, 0.82);
  backdrop-filter: blur(18px);
}

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

.brand img {
  width: 38px;
  height: 38px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.admin-sidebar nav {
  display: grid;
  gap: 8px;
}

.admin-sidebar nav a,
.admin-sidebar nav button {
  width: 100%;
  padding: 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--soft);
  text-align: left;
}

.admin-sidebar nav a.active,
.admin-sidebar nav a:hover,
.admin-sidebar nav button.active,
.admin-sidebar nav button:hover {
  background: rgba(94, 199, 215, 0.12);
  color: var(--text);
}

.admin-foot {
  margin-top: auto;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.admin-foot p {
  margin: 0 0 10px;
}

.admin-foot button {
  padding: 0;
  background: transparent;
  color: var(--soft);
}

.admin-foot button:hover {
  color: var(--text);
}

.admin-main {
  min-width: 0;
  padding: 26px;
}

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

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

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card,
.users-panel,
.detail-panel,
.security-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 22, 32, 0.86);
  box-shadow: 0 12px 42px rgba(0, 0, 0, 0.22);
}

.summary-card {
  min-height: 94px;
  padding: 16px;
}

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

.summary-card strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
}

.summary-card small {
  color: var(--soft);
}

.operations-workspace {
  display: grid;
  gap: 16px;
}

.analytics-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.analytics-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.analytics-head .segmented-control {
  grid-template-columns: repeat(4, auto);
}

.operations-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
}

#dashboardSummary {
  grid-template-columns: repeat(6, minmax(130px, 1fr));
}

.operation-card {
  min-height: 98px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 22, 32, 0.86);
  box-shadow: 0 12px 42px rgba(0, 0, 0, 0.18);
}

.operation-card span,
.operation-card small {
  color: var(--muted);
  font-size: 12px;
}

.operation-card strong {
  display: block;
  margin: 9px 0 4px;
  color: var(--text);
  font-size: 22px;
  overflow-wrap: anywhere;
}

.operation-card.active {
  border-color: rgba(94, 199, 215, 0.3);
}

.operation-card.good {
  border-color: rgba(85, 208, 138, 0.28);
}

.operation-card.danger {
  border-color: rgba(239, 116, 116, 0.3);
}

.operations-head {
  align-items: flex-start;
}

.operations-toolbar {
  display: flex;
  max-width: 760px;
  flex: 1 1 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.operations-filter {
  display: flex;
  min-width: 0;
  justify-content: flex-end;
  gap: 8px;
}

.operations-filter input,
.operations-filter select {
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  outline: none;
}

.operations-filter input {
  width: min(280px, 32vw);
}

.operations-filter button,
.segmented-control button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--soft);
}

.operations-filter button {
  border-color: rgba(94, 199, 215, 0.42);
  background: #2b8390;
  color: #f7feff;
  font-weight: 700;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, auto);
  flex: 0 0 auto;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
}

.segmented-control button {
  min-height: 32px;
  border: 0;
  background: transparent;
}

.segmented-control button.active {
  background: rgba(94, 199, 215, 0.16);
  color: var(--text);
}

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

.operations-table td small {
  display: block;
  max-width: 260px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.analytics-grid > .analytics-panel:first-child {
  grid-column: 1 / -1;
}

.analytics-panel {
  min-width: 0;
  overflow: hidden;
}

.analytics-panel .panel-head {
  min-height: 70px;
}

.trend-chart {
  min-height: 250px;
  padding: 16px 18px 18px;
}

.trend-key {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.trend-key span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.trend-key i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.trend-key .recharge,
.trend-bar.recharge {
  background: var(--accent);
}

.trend-key .consume,
.trend-bar.consume {
  background: var(--good);
}

.trend-columns {
  display: grid;
  grid-auto-columns: minmax(38px, 1fr);
  grid-auto-flow: column;
  align-items: end;
  min-height: 196px;
  gap: 10px;
  margin-top: 12px;
  overflow-x: auto;
}

.trend-column {
  display: grid;
  grid-template-rows: 162px auto;
  min-width: 38px;
  align-items: end;
  gap: 8px;
}

.trend-values {
  display: flex;
  height: 162px;
  align-items: end;
  justify-content: center;
  gap: 5px;
  padding: 0 3px;
  border-bottom: 1px solid var(--line);
}

.trend-bar {
  width: min(16px, 38%);
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  opacity: 0.95;
}

.trend-column small {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}

.analytics-ranking {
  display: grid;
  min-height: 184px;
}

.ranking-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.ranking-row:first-child {
  border-top: 0;
}

.ranking-index {
  color: var(--accent);
  font-family: Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
}

.ranking-row strong,
.ranking-row small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-row strong {
  font-size: 13px;
}

.ranking-row small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.ranking-value {
  min-width: 104px;
  text-align: right;
}

.conversion-grid {
  grid-template-columns: minmax(260px, 0.65fr) minmax(0, 1.35fr);
}

.conversion-grid > .analytics-panel:first-child {
  grid-column: auto;
}

.conversion-funnel {
  display: grid;
  gap: 18px;
  min-height: 214px;
  padding: 18px;
}

.funnel-step {
  display: grid;
  gap: 8px;
}

.funnel-step-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.funnel-step-head span {
  color: var(--soft);
  font-family: Consolas, monospace;
}

.funnel-track {
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.18);
}

.funnel-track span {
  display: block;
  height: 100%;
  min-width: 4px;
  border-radius: 3px;
  background: var(--accent);
}

.conversion-source-panel {
  min-width: 0;
}

.conversion-table {
  min-width: 720px;
}

.customer-segment {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.customer-segment.paying {
  border-color: rgba(85, 208, 138, 0.34);
  color: var(--good);
}

.customer-segment.active {
  border-color: rgba(94, 199, 215, 0.34);
  color: var(--accent);
}

.customer-segment.new {
  border-color: rgba(228, 183, 97, 0.34);
  color: var(--warn);
}

.customer-segment.exhausted,
.customer-segment.inactive {
  border-color: rgba(239, 116, 116, 0.3);
  color: var(--danger);
}

.status-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--soft);
  font-size: 12px;
  white-space: nowrap;
}

.status-badge.queued,
.status-badge.submitting,
.status-badge.running,
.status-badge.created,
.status-badge.reserved {
  border-color: rgba(228, 183, 97, 0.34);
  color: var(--warn);
}

.status-badge.success,
.status-badge.paid {
  border-color: rgba(85, 208, 138, 0.34);
  color: var(--good);
}

.status-badge.partial {
  border-color: rgba(94, 199, 215, 0.34);
  color: var(--accent);
}

.status-badge.failed,
.status-badge.refunded,
.status-badge.closed {
  border-color: rgba(239, 116, 116, 0.34);
  color: var(--danger);
}

.error-copy {
  color: var(--danger);
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.75fr);
  gap: 16px;
  align-items: start;
}

.security-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.7fr) minmax(440px, 1.3fr);
  gap: 16px;
  align-items: start;
}

.security-panel {
  min-width: 0;
  overflow: hidden;
}

.security-activity-panel {
  grid-column: 1 / -1;
}

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

.security-panel-head span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

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

.security-panel-head .security-badge {
  padding: 6px 9px;
  border: 1px solid rgba(85, 208, 138, 0.35);
  border-radius: 6px;
  background: rgba(85, 208, 138, 0.09);
  color: var(--good);
  white-space: nowrap;
}

.security-facts {
  display: grid;
  margin: 0;
}

.security-facts div {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

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

.security-facts dd {
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.session-policy {
  display: flex;
  gap: 11px;
  margin: 16px 18px 18px;
  padding: 13px;
  border: 1px solid rgba(94, 199, 215, 0.2);
  border-radius: 6px;
  background: rgba(94, 199, 215, 0.07);
}

.session-policy-mark {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(94, 199, 215, 0.12);
}

.session-policy strong {
  font-size: 13px;
}

.session-policy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

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

.session-actions strong {
  display: block;
  font-size: 13px;
}

.session-actions p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.security-form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.two-factor-section {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(94, 199, 215, 0.035);
}

.two-factor-heading,
.two-factor-actions,
.two-factor-facts div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.two-factor-heading span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.two-factor-heading h3 {
  margin: 4px 0 0;
  font-size: 16px;
}

.two-factor-heading .security-badge.is-disabled {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.two-factor-summary strong {
  display: block;
  font-size: 14px;
}

.two-factor-summary p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.two-factor-facts {
  display: grid;
  gap: 8px;
  margin: 0;
}

.two-factor-facts div {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.16);
}

.two-factor-facts dt,
.two-factor-facts dd {
  margin: 0;
  font-size: 12px;
}

.two-factor-facts dt {
  color: var(--muted);
}

.two-factor-facts dd {
  color: var(--soft);
  font-weight: 700;
}

.two-factor-actions {
  justify-content: flex-end;
}

.security-form label {
  display: grid;
  gap: 7px;
  color: var(--soft);
  font-size: 13px;
}

.security-form input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  outline: none;
}

.security-form input:focus {
  border-color: rgba(94, 199, 215, 0.62);
}

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

.password-strength {
  display: grid;
  gap: 7px;
}

.password-strength > div {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.password-strength span {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.09);
}

.password-strength[data-level="1"] span:nth-child(-n + 1),
.password-strength[data-level="2"] span:nth-child(-n + 2),
.password-strength[data-level="3"] span:nth-child(-n + 3),
.password-strength[data-level="4"] span:nth-child(-n + 4) {
  background: var(--accent);
}

.password-strength[data-level="1"] span:nth-child(-n + 1) {
  background: var(--danger);
}

.password-strength[data-level="2"] span:nth-child(-n + 2) {
  background: var(--warn);
}

.password-strength[data-level="4"] span:nth-child(-n + 4) {
  background: var(--good);
}

.password-strength p,
.security-form footer p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.security-form footer {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 2px;
}

.security-form footer p.error {
  color: var(--danger);
}

.security-form footer p.success {
  color: var(--good);
}

.mfa-login-heading h2 {
  margin: 6px 0 0;
  font-size: 22px;
}

.mfa-login-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.mfa-login-actions,
.two-factor-actions,
.two-factor-manage-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mfa-login-actions .ghost-button {
  flex: 1 1 0;
}

.two-factor-dialog {
  width: min(560px, calc(100% - 32px));
}

.totp-setup-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
  gap: 18px;
}

.totp-setup-grid img {
  width: 220px;
  aspect-ratio: 1;
  padding: 8px;
  border-radius: 6px;
  background: #ffffff;
  image-rendering: pixelated;
}

.totp-setup-grid > div {
  display: grid;
  gap: 14px;
}

.totp-setup-grid label {
  display: grid;
  gap: 8px;
}

.totp-setup-grid code {
  display: block;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--soft);
  font-family: Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.recovery-codes-dialog {
  width: min(580px, calc(100% - 32px));
}

.recovery-code-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
}

.recovery-code-list code {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  font-family: Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  text-align: center;
}

.danger-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(239, 116, 116, 0.35);
  border-radius: 6px;
  background: rgba(239, 116, 116, 0.1);
  color: var(--danger);
}

.danger-button:hover {
  background: rgba(239, 116, 116, 0.17);
}

.security-events {
  display: grid;
}

.security-event {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(110px, 0.45fr) 90px 132px;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.security-event:last-child {
  border-bottom: 0;
}

.security-event-main {
  min-width: 0;
}

.security-event-main strong {
  display: block;
  font-size: 13px;
}

.security-event-main small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.security-event code,
.security-event time {
  color: var(--soft);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.security-event-result {
  justify-self: start;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--soft);
  font-size: 12px;
}

.security-event-result.success {
  border-color: rgba(85, 208, 138, 0.3);
  color: var(--good);
}

.security-event-result.failed,
.security-event-result.blocked {
  border-color: rgba(239, 116, 116, 0.3);
  color: var(--danger);
}

.agents-workspace {
  min-width: 0;
}

.agents-table {
  min-width: 920px;
}

.agent-name strong,
.agent-name small {
  display: block;
}

.domain-stack {
  display: grid;
  gap: 4px;
}

.domain-stack code {
  color: var(--soft);
  font-family: Consolas, monospace;
  font-size: 12px;
}

.status-action {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--soft);
}

.commission-action {
  min-height: 32px;
  padding: 0 10px;
  margin-right: 6px;
  color: var(--cyan);
}

.status-action.danger {
  color: var(--danger);
}

.status-action.good {
  color: var(--good);
}

.users-panel,
.detail-panel {
  min-width: 0;
  overflow: hidden;
}

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

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

.panel-head p {
  margin: 4px 0 0;
  font-size: 13px;
}

.search-form {
  display: flex;
  width: min(420px, 52%);
  gap: 8px;
}

.search-form input,
.search-form select,
.adjust-dialog input,
.adjust-dialog textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  outline: none;
}

.search-form input {
  min-width: 0;
  height: 38px;
  padding: 0 12px;
}

.search-form select {
  width: 132px;
  min-width: 132px;
  height: 38px;
  padding: 0 10px;
}

.search-form input:focus,
.search-form select:focus,
.adjust-dialog input:focus,
.adjust-dialog textarea:focus {
  border-color: rgba(94, 199, 215, 0.6);
}

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

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

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td {
  color: var(--soft);
  font-size: 14px;
}

td strong {
  display: block;
  color: var(--text);
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--soft);
  font-size: 12px;
}

.badge.admin {
  background: rgba(94, 199, 215, 0.15);
  color: #9ee7f0;
}

.amount-pos {
  color: var(--good);
}

.amount-neg {
  color: var(--danger);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px;
}

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

.detail-panel {
  position: sticky;
  top: 18px;
}

.detail-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 16px;
}

.detail-body div {
  min-width: 0;
  padding: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.045);
}

.detail-body span,
.detail-body strong {
  display: block;
}

.detail-body span {
  margin-bottom: 6px;
  font-size: 12px;
}

.detail-body strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.detail-panel h3 {
  margin: 4px 16px 12px;
  font-size: 15px;
}

.record-list {
  display: grid;
  gap: 8px;
  max-height: 430px;
  overflow: auto;
  padding: 0 16px 16px;
}

.record-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.record-row strong {
  overflow-wrap: anywhere;
}

.director-record {
  border-color: rgba(94, 199, 215, 0.22);
}

.director-detail {
  grid-column: 1 / -1;
  margin-top: 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}

.director-detail summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  cursor: pointer;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.director-detail summary::-webkit-details-marker {
  display: none;
}

.director-detail summary::after {
  content: "展开";
  min-width: 38px;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(94, 199, 215, 0.12);
  color: #9ee7f0;
  font-size: 12px;
  text-align: center;
}

.director-detail[open] summary::after {
  content: "收起";
}

.director-detail summary small {
  color: var(--muted);
  font-weight: 500;
}

.director-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.detail-cell,
.director-formula,
.attempt-row {
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
}

.detail-cell {
  min-width: 0;
  padding: 9px 10px;
}

.detail-cell span,
.attempt-row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-cell strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 13px;
}

.director-formula {
  margin-top: 8px;
  padding: 10px;
  color: var(--soft);
  font-size: 13px;
}

.director-detail h4 {
  margin: 12px 0 8px;
  color: var(--soft);
  font-size: 13px;
}

.director-attempts {
  display: grid;
  gap: 6px;
}

.attempt-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  padding: 9px 10px;
}

.attempt-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.attempt-row small {
  grid-column: 1 / -1;
}

.attempt-row .ok {
  color: var(--good);
}

.attempt-row .fail {
  color: var(--danger);
}

.empty-detail {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

.record-meta {
  display: block;
  margin-top: 5px;
  font-size: 12px;
}

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

.status-line {
  min-height: 22px;
  margin: 14px 2px 0;
  font-size: 13px;
}

.status-line.error {
  color: var(--danger);
}

.adjust-dialog {
  width: min(460px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.adjust-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.adjust-dialog form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

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

.adjust-dialog h2 {
  margin: 0;
  font-size: 18px;
}

.dialog-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.dialog-status {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.dialog-status.error {
  color: var(--danger);
}

.danger-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid rgba(239, 116, 116, 0.38);
  border-radius: 6px;
  background: rgba(239, 116, 116, 0.1);
  color: #ff9d9d;
}

.two-factor-dialog {
  width: min(720px, calc(100% - 28px));
}

.totp-setup-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  align-items: center;
  gap: 20px;
}

.totp-setup-grid img {
  width: 260px;
  height: 260px;
  border-radius: 6px;
  background: #fff;
}

.totp-setup-grid > div {
  display: grid;
  gap: 16px;
}

.totp-setup-grid code {
  display: block;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--soft);
  font-family: Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
  user-select: all;
}

.two-factor-manage-actions {
  flex-wrap: wrap;
}

.recovery-codes-dialog {
  width: min(520px, calc(100% - 28px));
  padding: 18px;
}

.recovery-codes-dialog > p {
  margin-top: 14px;
}

.recovery-codes-dialog > footer {
  margin-top: 18px;
  justify-content: flex-end;
}

.recovery-code-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.recovery-code-list code {
  padding: 10px;
  border: 1px solid rgba(94, 199, 215, 0.2);
  border-radius: 6px;
  background: rgba(94, 199, 215, 0.07);
  color: var(--text);
  font-family: Consolas, monospace;
  font-size: 13px;
  text-align: center;
  user-select: all;
}

.impact-preview {
  padding: 11px 12px;
  border: 1px solid rgba(94, 199, 215, 0.2);
  border-radius: 6px;
  background: rgba(94, 199, 215, 0.07);
  color: var(--soft);
  font-size: 13px;
}

.impact-preview.danger {
  border-color: rgba(239, 116, 116, 0.32);
  background: rgba(239, 116, 116, 0.08);
  color: var(--danger);
}

.agent-dialog {
  width: min(720px, calc(100% - 28px));
}

.agents-table td:last-child {
  white-space: nowrap;
}

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

.adjust-dialog label {
  display: grid;
  gap: 8px;
  color: var(--soft);
  font-size: 13px;
}

.adjust-dialog input,
.adjust-dialog textarea {
  padding: 10px 12px;
  resize: vertical;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

@media (max-width: 1180px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

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

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

  .operations-summary {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  #dashboardSummary {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

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

  .operations-toolbar {
    max-width: none;
    align-items: stretch;
    flex-direction: column;
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 820px) {
  .admin-app {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

  .admin-sidebar nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-main {
    padding: 16px;
  }

  .admin-topbar,
  .panel-head,
  .analytics-head,
  .search-form,
  .operations-filter {
    align-items: stretch;
    flex-direction: column;
  }

  .search-form {
    width: 100%;
  }

  .summary-grid,
  .detail-body,
  .director-detail-grid,
  .form-grid,
  .security-password-grid,
  .totp-setup-grid,
  .recovery-code-list {
    grid-template-columns: 1fr;
  }

  .totp-setup-grid img {
    width: min(260px, 100%);
    height: auto;
    aspect-ratio: 1;
    justify-self: center;
  }

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

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

  .analytics-head .segmented-control {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-grid,
  .conversion-grid {
    grid-template-columns: 1fr;
  }

  .analytics-grid > .analytics-panel:first-child,
  .conversion-grid > .analytics-panel:first-child {
    grid-column: auto;
  }

  .trend-chart {
    padding-inline: 12px;
  }

  .ranking-row {
    padding-inline: 12px;
  }

  .search-form select {
    width: 100%;
  }

  .security-form footer {
    align-items: stretch;
    flex-direction: column;
  }

  .mfa-login-actions,
  .two-factor-actions,
  .two-factor-manage-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .two-factor-facts,
  .recovery-code-list,
  .totp-setup-grid {
    grid-template-columns: 1fr;
  }

  .totp-setup-grid img {
    width: min(220px, 100%);
  }

  .operations-filter input {
    width: 100%;
  }

  .operations-toolbar {
    width: 100%;
  }

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

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

  .security-event {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
  }

  .security-event code,
  .security-event time {
    grid-column: 1 / -1;
  }
}
