:root {
  color-scheme: light;
  --bg: #f6faff;
  --surface: #ffffff;
  --surface-soft: #f7faff;
  --ink: #101d36;
  --muted: #607089;
  --line: #dfe8f5;
  --primary: #2377ff;
  --primary-strong: #0f5ee8;
  --primary-soft: #eef5ff;
  --ok: #19b765;
  --warn: #c47a28;
  --danger: #e23b3b;
  --shadow: 0 22px 60px rgba(32, 84, 155, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family:
    "Inter",
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    sans-serif;
  background:
    radial-gradient(circle at 0 0, rgba(35, 119, 255, 0.08), transparent 30%),
    linear-gradient(180deg, #f9fcff 0%, #f4f8ff 52%, #ffffff 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 18px;
  color: #233653;
  background: var(--surface);
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

button:hover {
  border-color: rgba(35, 119, 255, 0.48);
  box-shadow: 0 12px 28px rgba(35, 119, 255, 0.08);
  transform: translateY(-1px);
}

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

.primary,
.actions .primary {
  border-color: var(--primary);
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #1168ff);
  box-shadow: 0 14px 30px rgba(35, 119, 255, 0.24);
}

.primary:hover,
.actions .primary:hover {
  background: linear-gradient(135deg, #1468f3, var(--primary-strong));
}

.app-header {
  width: min(1260px, calc(100% - 48px));
  margin: 0 auto;
  padding: 36px 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

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

.brand-shield,
.module-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: linear-gradient(145deg, #2b83ff, #1268f2);
  box-shadow: 0 14px 34px rgba(35, 119, 255, 0.26);
}

.brand-shield {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 22px;
  font-weight: 900;
}

.brand strong {
  display: block;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand span:not(.brand-shield) {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 26px;
  color: #314360;
  font-size: 15px;
  font-weight: 700;
}

.system-ok {
  color: var(--ok);
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 20%, rgba(35, 119, 255, 0.12), transparent 34%),
    linear-gradient(180deg, #f8fbff, #eef6ff);
}

.locked .auth-overlay.open {
  display: flex;
}

.locked .app-header,
.locked .app-shell {
  filter: blur(5px);
  pointer-events: none;
  user-select: none;
}

.auth-card {
  width: min(420px, 100%);
  border: 1px solid rgba(223, 232, 245, 0.96);
  border-radius: 18px;
  padding: 30px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.auth-mark {
  margin-bottom: 18px;
}

.auth-card h1 {
  margin: 0 0 22px;
  font-size: 30px;
}

.auth-card button {
  width: 100%;
  margin-top: 16px;
}

.auth-error {
  min-height: 22px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 14px;
}

.app-shell {
  width: min(1260px, calc(100% - 48px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(440px, 1fr);
  gap: 32px;
  align-items: start;
  padding: 34px 0 46px;
  border-top: 1px solid rgba(223, 232, 245, 0.75);
}

.workspace-card,
.panel-card {
  border: 1px solid rgba(223, 232, 245, 0.96);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.workspace-card {
  min-height: 675px;
  padding: 36px;
}

.workspace-actions {
  grid-column: 1 / -1;
  justify-self: center;
  display: flex;
  gap: 0;
  margin-top: 26px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 40px rgba(32, 84, 155, 0.1);
}

.workspace-actions button {
  min-width: 150px;
  border: 0;
  border-radius: 10px;
  background: transparent;
}

.workspace-actions button + button {
  border-left: 1px solid var(--line);
  border-radius: 0;
}

.card-title-row,
.title-cluster,
.section-title,
.input-row,
.actions,
.compact-actions,
.history-item,
.record-strip {
  display: flex;
  align-items: center;
}

.card-title-row,
.section-title {
  justify-content: space-between;
  gap: 16px;
}

.title-cluster {
  gap: 18px;
}

.module-icon {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  font-size: 26px;
  font-weight: 900;
}

.title-cluster h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

.title-cluster p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h2 {
  font-size: 20px;
  letter-spacing: 0;
}

.state-pill {
  flex: 0 0 auto;
  min-width: 110px;
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--warn);
  text-align: center;
  font-weight: 800;
  background: rgba(245, 153, 66, 0.12);
}

.state-pill.ok {
  color: var(--ok);
  background: rgba(25, 183, 101, 0.12);
}

.state-pill.warn {
  color: var(--warn);
  background: rgba(196, 122, 40, 0.13);
}

.state-pill.error {
  color: var(--danger);
  background: rgba(226, 59, 59, 0.12);
}

.copy-zone {
  text-align: left;
}

.code-display {
  position: relative;
  display: block;
  width: 100%;
  min-height: 196px;
  margin: 40px 0 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(247, 250, 255, 0.92)),
    var(--surface-soft);
}

.code-label {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

#codeValue {
  display: block;
  min-height: 82px;
  margin-top: 22px;
  overflow-wrap: anywhere;
  color: var(--primary);
  font-size: clamp(44px, 8vw, 74px);
  line-height: 1;
  letter-spacing: 0;
}

#messageText {
  display: block;
  min-height: 24px;
  color: var(--muted);
  line-height: 1.5;
}

.copy-hint {
  position: absolute;
  right: 24px;
  top: 50%;
  color: #6a7890;
  font-size: 13px;
  transform: translateY(-50%);
}

.meta-grid,
.card-fields {
  display: grid;
  gap: 18px;
}

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

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

.meta-grid > div,
.record-box,
.data-box {
  min-height: 94px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  background: linear-gradient(180deg, #fff, #fbfdff);
  box-shadow: 0 10px 24px rgba(32, 84, 155, 0.05);
}

.meta-grid span,
.record-box span,
.data-box span,
label {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.meta-grid strong,
.record-box strong {
  display: block;
  margin-top: 12px;
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.35;
}

.actions {
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 34px;
}

.actions button {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-width: 132px;
  font-weight: 800;
}

#autoBtn.active {
  border-color: var(--primary);
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #1168ff);
}

.info-note {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 36px;
  border-radius: 10px;
  padding: 16px 18px;
  color: var(--primary);
  font-weight: 800;
  background: var(--primary-soft);
}

.info-note span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  background: var(--primary);
}

.record-strip {
  gap: 18px;
  margin: 48px 0 18px;
}

.record-box {
  flex: 1 1 0;
  min-width: 0;
}

.data-box {
  margin: 0;
}

.data-box.wide {
  grid-column: 1 / -1;
}

.data-box input,
.data-box textarea {
  min-height: 32px;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  font-size: 18px;
  font-weight: 900;
  resize: none;
  box-shadow: none;
  cursor: pointer;
}

.data-box textarea {
  min-height: 48px;
  line-height: 1.35;
}

.data-box input:focus,
.data-box textarea:focus {
  box-shadow: none;
}

.panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(16, 29, 54, 0.34);
}

.panel-backdrop.open {
  display: flex;
}

.panel-card {
  width: min(640px, 100%);
  max-height: min(720px, calc(100vh - 40px));
  overflow: auto;
  padding: 26px;
}

.compact-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.compact-actions button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--primary);
}

.close-btn {
  min-width: 36px;
  color: var(--muted);
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 92px;
  padding: 10px 12px;
  line-height: 1.45;
}

input {
  min-height: 44px;
  padding: 0 12px;
}

textarea:focus,
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(35, 119, 255, 0.12);
}

label {
  margin-top: 16px;
  margin-bottom: 8px;
}

.input-row {
  gap: 10px;
}

.input-row span {
  color: var(--muted);
}

.history-list {
  display: grid;
  gap: 10px;
  max-height: 430px;
  margin-top: 16px;
  overflow: auto;
  padding-right: 4px;
}

.history-empty {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 22px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-soft);
}

.history-item {
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: var(--surface);
}

.history-type {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.history-code {
  display: block;
  overflow-wrap: anywhere;
  color: var(--primary-strong);
  font-size: 22px;
  font-weight: 900;
}

.history-time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.history-item button {
  min-width: 56px;
  min-height: 38px;
  padding: 0 12px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(360px, calc(100% - 40px));
  border-radius: 10px;
  padding: 12px 14px;
  color: #fff;
  background: rgba(16, 29, 54, 0.94);
  box-shadow: 0 14px 42px rgba(16, 29, 54, 0.28);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

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

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

  .workspace-card {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .app-header {
    width: min(100% - 24px, 1260px);
    align-items: flex-start;
    flex-direction: column;
    padding: 22px 0 18px;
  }

  .header-status {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .app-shell {
    width: min(100% - 20px, 1260px);
    gap: 16px;
    padding: 22px 0 32px;
  }

  .workspace-card {
    padding: 22px;
  }

  .card-title-row,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .meta-grid,
  .card-fields {
    grid-template-columns: 1fr;
  }

  .record-strip {
    flex-direction: column;
  }

  .record-box {
    width: 100%;
  }

  .actions button,
  .compact-actions button,
  .workspace-actions button {
    flex: 1 1 calc(50% - 10px);
    justify-content: center;
    min-width: 132px;
  }

  .workspace-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .workspace-actions button + button {
    border-left: 0;
  }

  #codeValue {
    min-height: 62px;
  }
}
