:root {
  color-scheme: dark;
  --bg: #070b12;
  --bg-2: #0d1522;
  --surface: rgba(13, 24, 37, 0.78);
  --surface-strong: rgba(15, 27, 42, 0.92);
  --surface-soft: rgba(18, 33, 51, 0.62);
  --ink: #f4f8fb;
  --muted: #8fa3b8;
  --line: rgba(148, 163, 184, 0.2);
  --line-strong: rgba(125, 211, 252, 0.3);
  --primary: #22d3ee;
  --primary-strong: #67e8f9;
  --primary-soft: rgba(34, 211, 238, 0.12);
  --accent: #34d399;
  --accent-soft: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --danger: #fb7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --radius: 8px;
  --mono: "Fira Code", "SFMono-Regular", Consolas, monospace;
  --sans: "Fira Sans", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--sans);
  background:
    linear-gradient(rgba(125, 211, 252, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 211, 252, 0.035) 1px, transparent 1px),
    linear-gradient(145deg, #070b12 0%, #0c1420 46%, #07100f 100%);
  background-size: 42px 42px, 42px 42px, auto;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(34, 211, 238, 0.06), transparent 26%, transparent 74%, rgba(52, 211, 153, 0.045)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 24%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.32;
  background-image: linear-gradient(transparent 50%, rgba(255, 255, 255, 0.025) 50%);
  background-size: 100% 4px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 16px;
  color: #dbeafe;
  background: rgba(15, 23, 42, 0.68);
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

button:hover {
  border-color: var(--line-strong);
  color: #ffffff;
  background: rgba(15, 33, 52, 0.9);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.24);
  transform: translateY(-1px);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(103, 232, 249, 0.92);
  outline-offset: 3px;
}

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

button.loading {
  opacity: 1;
  cursor: wait;
}

button.loading span {
  display: inline-block;
  margin-right: 9px;
  animation: spin 760ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.primary,
.actions .primary {
  border-color: rgba(34, 211, 238, 0.72);
  color: #031014;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow:
    0 16px 34px rgba(34, 211, 238, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.38);
}

.primary:hover,
.actions .primary:hover {
  color: #001014;
  background: linear-gradient(135deg, #67e8f9, #6ee7b7);
}

i[data-lucide],
svg.lucide {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke-width: 2;
}

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

.brand,
.header-status,
.system-ok,
.session-chip {
  display: flex;
  align-items: center;
}

.brand {
  gap: 14px;
}

.brand-shield,
.module-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(103, 232, 249, 0.32);
  color: var(--primary-strong);
  background:
    linear-gradient(145deg, rgba(34, 211, 238, 0.16), rgba(52, 211, 153, 0.1)),
    rgba(15, 23, 42, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 12px 32px rgba(0, 0, 0, 0.3);
}

.brand-shield {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
}

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

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

.header-status {
  gap: 12px;
  color: #b7c8da;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}

.system-ok,
.session-chip,
#headerClock {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(18px);
}

.system-ok,
.session-chip {
  gap: 8px;
}

.system-ok {
  border-color: rgba(52, 211, 153, 0.32);
  color: #86efac;
}

.session-chip {
  color: #bae6fd;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    linear-gradient(rgba(125, 211, 252, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 211, 252, 0.04) 1px, transparent 1px),
    linear-gradient(145deg, rgba(2, 6, 23, 0.98), rgba(8, 18, 31, 0.98));
  background-size: 44px 44px, 44px 44px, auto;
}

.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(430px, 100%);
  border: 1px solid rgba(125, 211, 252, 0.24);
  border-radius: var(--radius);
  padding: 30px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.88), rgba(9, 18, 31, 0.84)),
    rgba(15, 23, 42, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

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

.auth-card h1 {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.2;
}

.auth-subtitle {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.6;
}

.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(1280px, calc(100% - 48px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 22px;
  align-items: stretch;
  padding: 22px 0 42px;
}

.workspace-card,
.panel-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 34%),
    var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.workspace-card {
  display: flex;
  flex-direction: column;
  min-height: 668px;
  padding: 26px;
}

.workspace-actions {
  grid-column: 1 / -1;
  justify-self: center;
  display: flex;
  gap: 6px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  background: rgba(10, 18, 30, 0.72);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(18px);
}

.workspace-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 146px;
  border-color: transparent;
  background: transparent;
}

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

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

.card-title-row {
  min-height: 70px;
}

.title-cluster {
  min-width: 0;
  gap: 16px;
}

.module-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
}

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

.title-cluster p:not(.card-kicker) {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.eyebrow,
.card-kicker {
  margin: 0 0 8px;
  color: var(--primary-strong);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

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

.state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 96px;
  min-height: 36px;
  border: 1px solid rgba(251, 191, 36, 0.34);
  border-radius: 999px;
  padding: 0 13px;
  color: #fde68a;
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  background: rgba(251, 191, 36, 0.1);
}

.state-pill.ok {
  border-color: rgba(52, 211, 153, 0.42);
  color: #86efac;
  background: rgba(52, 211, 153, 0.12);
}

.state-pill.warn {
  border-color: rgba(251, 191, 36, 0.34);
  color: #fde68a;
  background: rgba(251, 191, 36, 0.1);
}

.state-pill.error {
  border-color: rgba(251, 113, 133, 0.42);
  color: #fda4af;
  background: rgba(251, 113, 133, 0.12);
}

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

.code-display {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 218px;
  margin: 32px 0 20px;
  overflow: hidden;
  border: 1px solid rgba(34, 211, 238, 0.26);
  border-radius: var(--radius);
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(34, 211, 238, 0.12), transparent 42%),
    linear-gradient(180deg, rgba(8, 47, 73, 0.5), rgba(15, 23, 42, 0.76));
}

.code-display::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(103, 232, 249, 0.16);
  border-radius: 6px;
  pointer-events: none;
}

.code-display::after {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), var(--accent), transparent);
  opacity: 0.75;
}

.code-label {
  display: block;
  color: #bae6fd;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
}

#codeValue {
  display: block;
  min-height: 80px;
  margin-top: 22px;
  overflow-wrap: anywhere;
  color: #ecfeff;
  font-family: var(--mono);
  font-size: clamp(44px, 5vw, 66px);
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(34, 211, 238, 0.28);
}

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

.copy-hint {
  position: absolute;
  right: 24px;
  top: 22px;
  gap: 7px;
  color: #a7f3d0;
  font-family: var(--mono);
  font-size: 12px;
}

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

.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: 88px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: rgba(8, 17, 29, 0.58);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

.record-box,
.data-box {
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.record-box:hover,
.data-box:hover {
  border-color: rgba(103, 232, 249, 0.42);
  background:
    linear-gradient(120deg, rgba(34, 211, 238, 0.08), transparent 46%),
    rgba(8, 24, 38, 0.76);
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transform: translateY(-1px);
}

.record-box:hover span,
.data-box:hover span {
  color: #bae6fd;
}

.record-box:hover strong,
.data-box:hover input,
.data-box:hover textarea {
  color: #ecfeff;
}

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

.meta-grid strong,
.record-box strong {
  display: block;
  margin-top: 11px;
  overflow-wrap: anywhere;
  color: #e0f2fe;
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.35;
}

.actions {
  flex-wrap: wrap;
  gap: 12px;
  margin-top: auto;
  padding-top: 24px;
}

.actions button,
.compact-actions button,
.field-head button,
.auth-card button {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  justify-content: center;
}

.actions button {
  min-width: 132px;
  font-weight: 800;
}

.info-note {
  gap: 12px;
  margin-top: 22px;
  border: 1px solid rgba(34, 211, 238, 0.18);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: #c8e6f5;
  line-height: 1.55;
  background: var(--primary-soft);
}

.info-note span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #031014;
  background: var(--primary-strong);
}

.record-strip {
  gap: 14px;
  margin: 32px 0 14px;
}

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

.data-box {
  margin: 0;
}

.data-box.wide {
  grid-column: 1 / -1;
  min-height: 110px;
}

.field-head {
  justify-content: space-between;
  gap: 12px;
}

.field-head button {
  min-height: 32px;
  border-color: rgba(52, 211, 153, 0.22);
  border-radius: var(--radius);
  padding: 0 10px;
  color: #bbf7d0;
  font-size: 12px;
  font-weight: 800;
  background: var(--accent-soft);
}

.address-box textarea {
  margin-top: 10px;
}

.data-box input,
.data-box textarea {
  min-height: 32px;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: #f8fafc;
  background: transparent;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  resize: none;
  box-shadow: none;
  cursor: pointer;
}

.data-box textarea {
  min-height: 50px;
  line-height: 1.38;
}

.data-box input::placeholder,
.data-box textarea::placeholder {
  color: rgba(148, 163, 184, 0.72);
}

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

.data-box:focus-within {
  border-color: rgba(103, 232, 249, 0.52);
  background:
    linear-gradient(120deg, rgba(34, 211, 238, 0.1), transparent 46%),
    rgba(8, 24, 38, 0.78);
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

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

.data-box:has(input:focus-visible),
.data-box:has(textarea:focus-visible) {
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.22),
    0 0 0 2px rgba(103, 232, 249, 0.68),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(10px);
}

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

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

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

.compact-actions button {
  min-height: 36px;
  padding: 0 12px;
  color: #bae6fd;
}

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

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: rgba(8, 17, 29, 0.72);
  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: rgba(103, 232, 249, 0.72);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 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: 18px;
  overflow: auto;
  padding-right: 4px;
}

.history-empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--muted);
  text-align: center;
  background: rgba(8, 17, 29, 0.52);
}

.history-item {
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(8, 17, 29, 0.62);
}

.card-history-item {
  align-items: flex-start;
}

.history-main {
  min-width: 0;
  flex: 1 1 auto;
}

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

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

.history-detail-grid > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.58);
}

.history-detail-grid > .wide {
  grid-column: 1 / -1;
}

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

.history-detail-grid strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  color: #e0f2fe;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.35;
}

.history-type {
  display: block;
  color: #bae6fd;
  font-size: 12px;
  font-weight: 800;
}

.history-code {
  display: block;
  overflow-wrap: anywhere;
  color: var(--primary-strong);
  font-family: var(--mono);
  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;
}

.card-history-item button {
  flex: 0 0 auto;
  min-width: 82px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(360px, calc(100% - 40px));
  border: 1px solid rgba(103, 232, 249, 0.22);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: #e0f2fe;
  background: rgba(8, 17, 29, 0.94);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.38);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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

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

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

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

  .system-ok,
  .session-chip,
  #headerClock {
    justify-content: flex-start;
    width: 100%;
  }

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

  .workspace-card {
    padding: 18px;
  }

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

  .title-cluster {
    align-items: flex-start;
  }

  .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%;
  }

  .card-history-item {
    flex-direction: column;
  }

  .history-detail-grid {
    grid-template-columns: 1fr;
  }

  .code-display {
    min-height: 194px;
    padding: 20px;
  }

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