:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --text: #1d2320;
  --muted: #69736d;
  --line: #dce2dc;
  --field: #fbfcfa;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --warning: #9a5a00;
  --warning-bg: #fff7df;
  --success: #136c3a;
  --success-bg: #eaf7ee;
  --error: #a32222;
  --error-bg: #fff0f0;
  --shadow: 0 24px 70px rgba(33, 44, 39, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.09), transparent 38%),
    linear-gradient(260deg, rgba(154, 90, 0, 0.1), transparent 36%),
    var(--bg);
  font-family:
    Inter, "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

[hidden] {
  display: none !important;
}

button,
input,
textarea {
  font: inherit;
}

.page-shell {
  width: min(100% - 32px, 760px);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-items: center;
  padding: 40px 0;
}

.recharge-panel {
  width: 100%;
  background: var(--panel);
  border: 1px solid rgba(29, 35, 32, 0.08);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 4vw, 42px);
}

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

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

h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.15;
  letter-spacing: 0;
}

.summary {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

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

.field-group {
  display: grid;
  gap: 8px;
}

label {
  font-size: 14px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

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

textarea {
  resize: vertical;
  min-height: 146px;
  padding: 12px 14px;
  line-height: 1.55;
}

input:focus,
textarea:focus {
  border-color: rgba(15, 118, 110, 0.72);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

input:disabled,
textarea:disabled {
  color: #8a928c;
  background: #eff2ef;
  cursor: not-allowed;
}

.inline-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 10px;
}

button {
  height: 46px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

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

#verify-btn {
  color: #ffffff;
  background: #2f554e;
}

#verify-btn:not(:disabled):hover {
  background: #23463f;
}

.primary-btn {
  width: 100%;
  color: #ffffff;
  background: var(--accent);
}

.primary-btn:not(:disabled):hover {
  background: var(--accent-dark);
}

.hint,
.submit-result {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

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

.char-counter {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.char-counter[data-state="warning"] {
  color: var(--warning);
  font-weight: 700;
}

.status-box {
  min-height: 52px;
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #f8faf7;
  line-height: 1.5;
}

.status-box[data-state="success"] {
  color: var(--success);
  border-color: rgba(19, 108, 58, 0.25);
  background: var(--success-bg);
}

.status-box[data-state="error"] {
  color: var(--error);
  border-color: rgba(163, 34, 34, 0.25);
  background: var(--error-bg);
}

.status-box[data-state="warning"] {
  color: var(--warning);
  border-color: rgba(154, 90, 0, 0.28);
  background: var(--warning-bg);
}

.submit-result[data-state="success"] {
  color: var(--success);
}

.submit-result[data-state="error"] {
  color: var(--error);
}

.self-service {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.compact-header {
  margin-bottom: 16px;
}

h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0;
}

.wide-action {
  grid-template-columns: minmax(0, 1fr) 88px 120px;
}

.new-cdk-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 76px;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(19, 108, 58, 0.25);
  border-radius: 8px;
  background: var(--success-bg);
}

.new-cdk-box span {
  color: var(--success);
  font-size: 13px;
  font-weight: 700;
}

.new-cdk-box code {
  overflow-wrap: anywhere;
  color: var(--success);
  font-weight: 700;
}

.new-cdk-box button {
  height: 34px;
  color: #ffffff;
  background: var(--success);
}

.admin-shell {
  width: min(100% - 32px, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 34px 0;
}

.admin-panel,
.admin-dashboard {
  width: 100%;
  background: var(--panel);
  border: 1px solid rgba(29, 35, 32, 0.08);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(22px, 3vw, 34px);
}

.admin-panel {
  max-width: 520px;
  margin: 10vh auto 0;
}

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

.admin-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 18px;
  border-bottom: 1px solid var(--line);
}

.tab-btn {
  height: 40px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border-bottom: 2px solid transparent;
  border-radius: 0;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.toolbar-actions,
.mini-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-actions button,
.mini-btn {
  height: 34px;
  padding: 0 12px;
  color: var(--text);
  background: #e8eee9;
}

.toolbar-actions button:hover,
.mini-btn:hover {
  background: #dce5df;
}

.copy-session-btn {
  color: #ffffff;
  background: var(--accent);
}

.copy-session-btn:hover {
  background: var(--accent-dark);
}

.ghost-btn {
  color: var(--muted);
  background: #f0f3f1;
}

.danger-btn {
  color: var(--error);
  background: var(--error-bg);
}

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

.stat-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.stat-item strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.stat-item span,
.muted-line {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.records-table {
  width: 100%;
  min-width: 1020px;
  border-collapse: collapse;
  background: #ffffff;
}

.submissions-table {
  min-width: 1240px;
}

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

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

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

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

.records-table th,
.records-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.records-table th {
  color: var(--muted);
  background: #f7f9f7;
  font-weight: 700;
}

.records-table tr:last-child td {
  border-bottom: 0;
}

.session-value {
  display: block;
  max-width: 320px;
  margin-bottom: 8px;
  padding: 8px;
  overflow-wrap: anywhere;
  border-radius: 6px;
  background: #f3f5f2;
  color: #28322d;
  white-space: pre-wrap;
}

.session-cell .mini-actions {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 76px;
  max-width: 320px;
}

.account-line {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.b-zone-cell strong,
.b-zone-cell .muted-line {
  display: block;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.b-zone-actions {
  margin-top: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-bottom: 8px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pending {
  color: var(--warning);
  background: var(--warning-bg);
}

.status-success {
  color: var(--success);
  background: var(--success-bg);
}

.status-failed {
  color: var(--error);
  background: var(--error-bg);
}

.status-select,
.status-note {
  width: 100%;
  height: 34px;
  margin-bottom: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
}

.save-status {
  width: 100%;
}

.save-status.saved-status {
  color: #ffffff;
  background: var(--success);
}

.status-save-feedback[data-state="success"] {
  color: var(--success);
  font-weight: 700;
}

.status-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.shortcut-btn {
  width: auto;
  min-height: 34px;
  padding: 6px 10px;
  text-align: left;
  white-space: normal;
}

.generate-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) 132px;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.library-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.library-form .span-2 {
  grid-column: span 2;
}

.checkbox-row {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

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

.library-table {
  min-width: 1180px;
}

.generated-codes {
  width: 100%;
  min-height: 160px;
  font-family: Consolas, "Courier New", monospace;
}

.generated-codes-box {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.generated-codes-box .mini-btn {
  justify-self: start;
}

.compact-code {
  max-width: 320px;
  margin-bottom: 0;
}

.cdk-state-unused {
  color: var(--success);
  background: var(--success-bg);
}

.cdk-state-submitting,
.cdk-state-retryable,
.cdk-state-exchanged {
  color: var(--warning);
  background: var(--warning-bg);
}

.cdk-state-used,
.cdk-state-disabled,
.cdk-state-expired,
.cdk-state-not_found {
  color: var(--error);
  background: var(--error-bg);
}

.empty-cell {
  height: 120px;
  color: var(--muted);
  text-align: center !important;
  vertical-align: middle !important;
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 20px, 760px);
    align-items: start;
    padding: 18px 0;
  }

  .recharge-panel {
    padding: 22px 18px;
  }

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

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

  .new-cdk-box {
    grid-template-columns: 1fr;
  }

  #verify-btn {
    width: 100%;
  }

  .admin-shell {
    width: min(100% - 20px, 1180px);
    padding: 18px 0;
  }

  .admin-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .admin-tabs {
    overflow-x: auto;
  }

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

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

  .library-form .span-2 {
    grid-column: auto;
  }
}
