:root {
  --ink: #181916;
  --muted: #62665d;
  --line: #d9ddd1;
  --paper: #f7f8f3;
  --panel: #ffffff;
  --panel-soft: #eef6ee;
  --green: #0f7b5f;
  --green-dark: #09513f;
  --blue: #1f5fbf;
  --amber: #a56300;
  --red: #b42318;
  --shadow: 0 16px 40px rgba(24, 25, 22, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(15, 123, 95, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(15, 123, 95, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 36px 36px;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

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

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

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

.side {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 22px;
  color: #f8faf5;
  background: #1f211d;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: #e8f3dc;
  color: #182018;
  font-weight: 800;
}

.brand h1,
.panel-head h2,
.module h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 6px;
  color: inherit;
  opacity: 0.62;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.tool-nav {
  display: grid;
  gap: 10px;
}

.tool-tab {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
  cursor: pointer;
}

.tool-tab span {
  color: rgba(255, 255, 255, 0.45);
  font-size: 13px;
  font-weight: 800;
}

.tool-tab strong {
  font-size: 15px;
}

.tool-tab.is-active {
  color: #172018;
  background: #dff0cf;
  border-color: #dff0cf;
}

.tool-tab.is-active span {
  color: var(--green-dark);
}

.side-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
}

.dot.ok {
  background: #48d597;
}

.dot.bad {
  background: #ff6b61;
}

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

.tool-panel {
  display: none;
}

.tool-panel.is-active {
  display: block;
}

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

.panel-head h2 {
  font-size: 28px;
  line-height: 1.1;
}

.recharge-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
}

.module,
.result-console {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.module {
  padding: 18px;
}

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

.module h3 {
  font-size: 17px;
}

.badge {
  max-width: 52%;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #f7f9f4;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.provider-option {
  min-height: 56px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  text-align: left;
  cursor: pointer;
}

.provider-option strong,
.provider-option span {
  display: block;
}

.provider-option span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.provider-option.is-active {
  border-color: var(--green);
  background: var(--panel-soft);
  box-shadow: inset 0 0 0 1px var(--green);
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 168px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: #fbfcf8;
  font-family: Consolas, "Microsoft YaHei UI", monospace;
  font-size: 13px;
  line-height: 1.55;
}

input[type="text"] {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: #fbfcf8;
}

input[type="text"]:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 123, 95, 0.14);
}

textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 123, 95, 0.14);
}

.field.tall textarea {
  min-height: 246px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.card-status-panel {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.status-counters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.status-counter {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf5;
}

.status-counter span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-counter strong {
  font-size: 18px;
  line-height: 1;
}

.card-state-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}

.card-state-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.card-state-row.status-used {
  background: #f7f3ed;
}

.card-state-row.status-unavailable,
.card-state-row.status-invalid,
.card-state-row.status-disabled {
  background: #fff5f4;
}

.card-state-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.card-state-main strong,
.card-state-main span {
  overflow-wrap: anywhere;
}

.card-state-main span {
  color: var(--muted);
  font-size: 12px;
}

.card-state-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.card-state-actions button,
.state-pill {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  color: var(--green-dark);
  background: var(--panel-soft);
}

.empty-state {
  margin: 0;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
}

.copy-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(360px, 1.15fr);
  gap: 16px;
}

.copy-product-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  margin-bottom: 14px;
  overflow: auto;
}

.copy-product-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.copy-product-item.is-active {
  border-color: var(--green);
  background: var(--panel-soft);
  box-shadow: inset 0 0 0 1px var(--green);
}

.copy-product-item strong,
.copy-product-item span {
  overflow-wrap: anywhere;
}

.copy-product-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.copy-current-box {
  display: grid;
  gap: 8px;
}

.copy-current-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

#copyCurrentText {
  min-height: 180px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  color: #102018;
  background: #f8faf5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: Consolas, "Microsoft YaHei UI", monospace;
  font-size: 15px;
  line-height: 1.6;
}

.copy-main-button {
  min-height: 48px;
  font-size: 16px;
}

.copy-history-panel {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.copy-history-panel h3 {
  margin: 0;
}

.copy-preview-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.copy-preview-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.copy-preview-item.is-current {
  border-color: var(--green);
  background: var(--panel-soft);
}

.copy-preview-index {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.copy-preview-text {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.5;
}

.primary-button,
.secondary-button,
.quiet-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  padding: 0 15px;
  color: #fff;
  background: var(--green);
}

.primary-button:hover {
  background: var(--green-dark);
}

.primary-button.danger {
  background: var(--red);
}

.primary-button.danger:hover {
  background: #8f1d14;
}

.secondary-button,
.quiet-button {
  padding: 0 13px;
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.quiet-button {
  min-height: 34px;
  color: var(--green-dark);
  text-decoration: none;
}

.link-button {
  display: inline-flex;
  align-items: center;
}

.result-console {
  margin-top: 16px;
  padding: 16px;
}

#resultBox {
  min-height: 180px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  color: #dcebe1;
  background: #20231f;
  font-family: Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tool-frame {
  width: 100%;
  height: calc(100vh - 118px);
  min-height: 640px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #1f211d;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
    padding: 18px;
  }

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

  .side-status {
    margin-top: 0;
  }

  .main {
    padding: 18px;
  }

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

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

@media (max-width: 620px) {
  .brand {
    align-items: flex-start;
  }

  .tool-nav,
  .provider-group {
    grid-template-columns: 1fr;
  }

  .status-counters,
  .card-state-row,
  .copy-product-item,
  .copy-preview-item {
    grid-template-columns: 1fr;
  }

  .card-state-actions {
    justify-content: stretch;
  }

  .card-state-actions button,
  .state-pill {
    justify-content: center;
    width: 100%;
  }

  .panel-head,
  .module-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .badge {
    max-width: 100%;
  }

  .main {
    padding: 14px 10px;
  }

  .side {
    gap: 16px;
    padding: 16px 12px;
  }

  .module,
  .result-console {
    padding: 14px;
  }

  .action-row,
  .panel-head {
    width: 100%;
  }

  .primary-button,
  .secondary-button,
  .quiet-button {
    width: 100%;
  }

  textarea {
    min-height: 150px;
    font-size: 12px;
  }

  .field.tall textarea {
    min-height: 220px;
  }

  .tool-frame {
    height: 76vh;
    min-height: 620px;
  }
}
