:root {
  --bg: #f0f4f8;
  --card: #ffffff;
  --primary: #1677ff;
  --primary-dark: #0958d9;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --success: #059669;
  --danger: #dc2626;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.top-bar {
  background: linear-gradient(135deg, #1677ff, #0958d9);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.top-bar h1 {
  margin: 0;
  font-size: 1.15rem;
}

.top-bar nav a {
  color: #fff;
  margin-left: 12px;
  text-decoration: none;
  font-size: 0.9rem;
  opacity: 0.95;
}

.container {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.92rem;
}

input,
select,
button {
  font-size: 16px;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
}

.part-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.part-row select {
  width: 100px;
  flex-shrink: 0;
}

.part-row input {
  flex: 1;
}

.prefix-hint {
  color: var(--muted);
  font-weight: 600;
}

.hint {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.btn-primary,
.btn-secondary,
.btn-scan {
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
  margin-top: 4px;
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #e5e7eb;
  color: var(--text);
  width: 100%;
  margin-top: 10px;
}

.btn-scan {
  background: #e0f2fe;
  color: #0369a1;
  white-space: nowrap;
  flex-shrink: 0;
}

.message {
  min-height: 1.2em;
  margin-top: 10px;
  font-size: 0.9rem;
}

.message.ok {
  color: var(--success);
}

.message.err {
  color: var(--danger);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  width: 100%;
  max-width: 400px;
}

#qrReader {
  width: 100%;
  min-height: 260px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.toolbar label {
  flex: 1;
  min-width: 140px;
}

.toolbar .btn-primary,
.toolbar .btn-secondary {
  width: auto;
  flex: 1;
  min-width: 100px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 8px 6px;
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f9fafb;
  position: sticky;
  top: 0;
}

.option-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}

.option-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.option-list button {
  background: #fee2e2;
  color: var(--danger);
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
}

.hidden {
  display: none !important;
}

section.card h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}
