:root {
  --bg: #0b1020;
  --card: rgba(255, 255, 255, 0.08);
  --card-strong: rgba(255, 255, 255, 0.12);
  --text: #edf2ff;
  --muted: #96a3bd;
  --line: rgba(255, 255, 255, 0.12);
  --primary: #7c5cff;
  --primary2: #22d3ee;
  --danger: #ff5c7a;
  --success: #34d399;
  --warning: #fbbf24;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, rgba(124, 92, 255, 0.32), transparent 30%),
    radial-gradient(circle at 90% 5%, rgba(34, 211, 238, 0.2), transparent 28%),
    radial-gradient(circle at 60% 90%, rgba(52, 211, 153, 0.13), transparent 28%),
    var(--bg);
}

button, input { font: inherit; }

.app {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255,255,255,.12), rgba(255,255,255,.04));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary2);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(34px, 5vw, 56px); line-height: 1; }
h2 { margin-bottom: 6px; font-size: 20px; }
.subtitle, .card p { color: var(--muted); margin-bottom: 0; }

.status-pill {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--warning);
  background: rgba(255,255,255,.08);
  white-space: nowrap;
}
.status-pill.ok { color: var(--success); }
.status-pill.bad { color: var(--danger); }

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 14px 50px rgba(0,0,0,.22);
  padding: 22px;
  backdrop-filter: blur(18px);
}

.quick-card { grid-column: span 5; }
.form-card { grid-column: span 7; }
.current-card { grid-column: span 6; }
.response-card { grid-column: span 6; }
.log-card { grid-column: span 12; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.actions.split { margin-top: 16px; }

.btn, .icon-btn {
  border: 0;
  color: var(--text);
  background: var(--card-strong);
  border: 1px solid var(--line);
  padding: 11px 15px;
  border-radius: 14px;
  cursor: pointer;
  transition: .16s ease;
}
.btn:hover, .icon-btn:hover { transform: translateY(-1px); background: rgba(255,255,255,.16); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--primary), #4f46e5); border-color: rgba(255,255,255,.22); }
.btn.success { background: rgba(52, 211, 153, .22); border-color: rgba(52, 211, 153, .35); }
.btn.danger { background: rgba(255, 92, 122, .18); border-color: rgba(255, 92, 122, .35); }
.btn.ghost { background: transparent; }
.icon-btn { padding: 10px 12px; white-space: nowrap; }

.form-grid, .order-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.wide-field { grid-column: 1 / -1; }
.order-box { grid-template-columns: 1fr; }

label span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

input {
  width: 100%;
  color: var(--text);
  background: rgba(0,0,0,.22);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  outline: none;
}
input:focus { border-color: rgba(34, 211, 238, .65); box-shadow: 0 0 0 4px rgba(34, 211, 238, .08); }

.copy-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
}
.check-row input { width: auto; }
.check-row span { margin: 0; font-size: 14px; }

.mini-pre {
  min-height: 120px;
  max-height: 220px;
  margin-top: 14px;
}

pre, .logs {
  min-height: 276px;
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 16px;
  color: #dbeafe;
  background: rgba(0,0,0,.28);
  border: 1px solid var(--line);
  border-radius: 18px;
  white-space: pre-wrap;
  word-break: break-word;
}

.logs {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}
.log-line { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.07); }
.log-line:last-child { border-bottom: 0; }
.log-time { color: var(--primary2); margin-right: 8px; }
.log-error { color: #fecdd3; }
.log-ok { color: #bbf7d0; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 6, 23, .72);
  backdrop-filter: blur(10px);
  z-index: 20;
}
.modal-backdrop.show { display: flex; }
.modal-card {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(15, 23, 42, .96);
  box-shadow: var(--shadow);
}
.modal-card p { color: var(--muted); }
.modal-card input { margin: 8px 0 6px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 16px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(15, 23, 42, .92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: .18s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.stat-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(0,0,0,.22);
}
.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}
.stat-card b {
  display: block;
  font-size: 34px;
  line-height: 1;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(0,0,0,.22);
}
.key-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}
.key-table th, .key-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-align: left;
  font-size: 13px;
}
.key-table th { color: var(--muted); font-weight: 600; }
.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
}
.badge.active { color: #bbf7d0; background: rgba(52, 211, 153, .15); }
.badge.used_waiting_code { color: #fde68a; background: rgba(251, 191, 36, .15); }
.badge.consumed { color: #fecdd3; background: rgba(255, 92, 122, .15); }

@media (max-width: 850px) {
  .hero { align-items: flex-start; flex-direction: column; }
  .quick-card, .form-card, .current-card, .response-card, .log-card { grid-column: span 12; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Front customer page redesign */
.front-page {
  background:
    radial-gradient(circle at 15% 10%, rgba(34, 211, 238, .22), transparent 28%),
    radial-gradient(circle at 85% 0%, rgba(124, 92, 255, .28), transparent 30%),
    linear-gradient(180deg, #08111f 0%, #0b1020 55%, #080b14 100%);
}
.front-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 44px;
}
.front-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  box-shadow: 0 12px 36px rgba(34,211,238,.18);
}
.brand strong { display: block; font-size: 18px; }
.brand span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.front-main { display: grid; gap: 18px; }
.front-hero-card, .front-panel {
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(255,255,255,.12), rgba(255,255,255,.055));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.front-hero-card {
  min-height: 310px;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr);
  gap: 28px;
  align-items: center;
  padding: clamp(26px, 5vw, 48px);
  overflow: hidden;
  position: relative;
}
.front-hero-card::after {
  content: '';
  position: absolute;
  width: 260px;
  height: 260px;
  right: -70px;
  top: -80px;
  border-radius: 999px;
  background: rgba(34,211,238,.16);
  filter: blur(2px);
}
.front-hero-text { position: relative; z-index: 1; }
.front-hero-text h1 {
  max-width: 720px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: -0.04em;
  margin-bottom: 16px;
}
.front-desc {
  max-width: 560px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.8;
  margin-bottom: 26px;
}
.front-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.big-btn { padding: 14px 22px; font-size: 16px; border-radius: 16px; }
.btn.ghost { background: rgba(255,255,255,.06); }
.front-steps {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
}
.step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(0,0,0,.22);
}
.step-item b {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(34,211,238,.18);
  color: var(--primary2);
}
.step-item span { font-weight: 700; }
.front-panel { padding: 24px; }
.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.panel-title-row h2 { font-size: 26px; margin: 0; }
.small-row h2 { font-size: 20px; }
.compact-check { margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(0,0,0,.16); }
.order-display-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.display-field {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(0,0,0,.18);
}
.display-field.code-field { grid-column: 1 / -1; }
.display-field span { font-size: 13px; color: var(--muted); }
.display-field input {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .02em;
  background: rgba(255,255,255,.06);
}
.code-field input { font-size: 28px; color: #bbf7d0; }
.highlight-field { border-color: rgba(34,211,238,.28); }
.code-field { border-color: rgba(52,211,153,.28); }
.order-actions { margin-top: 18px; }
.front-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.front-page pre, .front-page .logs { min-height: 210px; max-height: 330px; }
.front-page .status-pill { color: var(--success); }
@media (max-width: 860px) {
  .front-hero-card { grid-template-columns: 1fr; }
  .front-bottom-grid { grid-template-columns: 1fr; }
  .order-display-grid { grid-template-columns: 1fr; }
  .panel-title-row { flex-direction: column; }
  .front-nav { align-items: flex-start; flex-direction: column; }
}
.auto-finish-note {
  padding: 10px 13px;
  border: 1px solid rgba(52,211,153,.28);
  border-radius: 999px;
  color: #bbf7d0;
  background: rgba(52,211,153,.12);
  font-size: 13px;
  white-space: nowrap;
}
@media (max-width: 860px) {
  .auto-finish-note { white-space: normal; }
}
.countdown-pill {
  padding: 10px 13px;
  border: 1px solid rgba(251,191,36,.32);
  border-radius: 999px;
  color: #fde68a;
  background: rgba(251,191,36,.12);
  font-size: 13px;
  white-space: nowrap;
}
.countdown-pill.danger {
  color: #fecdd3;
  border-color: rgba(255,92,122,.38);
  background: rgba(255,92,122,.14);
}
@media (max-width: 860px) {
  .countdown-pill { white-space: normal; }
}
.modal-error {
  min-height: 20px;
  margin: 8px 0 2px;
  color: #fecdd3;
  font-size: 13px;
}
