:root {
  --bg: #0f172a;
  --card: #ffffff;
  --line: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --ok: #059669;
  --warn: #b45309;
  --danger: #dc2626;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: #f3f4f6;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  color: #fff;
  padding: 14px 16px calc(14px + env(safe-area-inset-top, 0px));
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 600;
  letter-spacing: .5px;
}

.topbar .links a {
  color: #cbd5e1;
  text-decoration: none;
  font-size: 14px;
  margin-left: 14px;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 14px 40px;
}

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

.card h2 {
  font-size: 15px;
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 600;
}

label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fafb;
  color: var(--text);
  outline: none;
}

input:focus, select:focus { border-color: var(--brand); background: #fff; }

button, .btn {
  display: inline-block;
  width: 100%;
  min-height: 56px;
  padding: 15px 18px;
  font-size: 17px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: background .15s;
}

button:active { background: var(--brand-dark); }
button.ghost {
  background: #eef2ff;
  color: var(--brand-dark);
  min-height: 48px;
  font-size: 15px;
}
button.danger { background: #fee2e2; color: var(--danger); min-height: 44px; font-size: 14px; padding: 10px 12px; width: auto; }
button.small { width: auto; min-height: 44px; font-size: 14px; padding: 10px 16px; }
button:disabled { opacity: .5; }

.row { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.row > * { flex: 1; }
.row.tight > * { flex: none; }

.price {
  margin: 14px 0 12px;
  font-size: 15px;
  color: var(--warn);
  font-weight: 600;
}

.result {
  margin-top: 14px;
  padding: 14px;
  border: 2px dashed #86efac;
  border-radius: 12px;
  background: #f0fdf4;
  text-align: center;
}

.result .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #065f46;
  word-break: break-all;
  margin-bottom: 10px;
  user-select: all;
}

.hidden { display: none !important; }

.meta { font-size: 12px; color: var(--muted); margin-top: 6px; }

.search-wrap { margin-bottom: 12px; }

.item {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}
.item:last-child { border-bottom: none; }

.item .code-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.item .code-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  word-break: break-all;
}

.tag {
  flex: none;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #dcfce7;
  color: var(--ok);
  white-space: nowrap;
}
.tag.revoked { background: #fee2e2; color: var(--danger); }
.tag.bound { background: #dbeafe; color: var(--brand-dark); }

.item .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  word-break: break-all;
}

.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 24px 0; }

.error {
  background: #fee2e2;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 12px;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.stats span { background: #f3f4f6; padding: 4px 10px; border-radius: 999px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, .92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
  z-index: 99;
}
.toast.show { opacity: 1; }

.filters { display: flex; gap: 8px; margin-bottom: 12px; }
.filters select, .filters input { min-height: 48px; font-size: 15px; }
