:root {
  --brand: #0A6EB1;
  --brand-dark: #085a92;
  --ink: #1b2733;
  --muted: #667788;
  --line: #dfe5ec;
  --bg: #f5f7fa;
  --err: #c0392b;
  --ok: #1e874b;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  font-size: 15px;
}

.wrap { max-width: 940px; margin: 0 auto; padding: 0 20px; }

.topbar {
  background: var(--brand);
  color: #fff;
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .wrap { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.save-state { font-size: 13px; opacity: .9; }
.save-state.ok { color: #cdeedd; }
.save-state.err { color: #ffd9d4; }

main { padding: 24px 0 60px; }

section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}
section > h2 {
  margin: 0 0 4px;
  font-size: 17px;
  color: var(--brand);
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}
.sec-hint { margin: 8px 0 14px; color: var(--muted); font-size: 13px; }

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px 4px;
  margin: 14px 0;
}
legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 6px; }

.row { display: flex; flex-wrap: wrap; gap: 0 16px; }
.row > .field { flex: 1 1 200px; }
.row.inline { align-items: flex-end; }

.field { margin: 12px 0; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
}
.req { color: var(--err); margin-left: 3px; }
.opt { color: var(--muted); font-weight: 400; margin-left: 5px; font-size: 12px; }

input[type=text], input[type=email], input[type=date], input[type=password], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10, 110, 177, .12);
}
input:disabled, select:disabled, textarea:disabled { background: #f2f4f7; color: var(--muted); }

.hint { margin: 5px 0 0; font-size: 12px; color: var(--muted); }
.hint.err { color: var(--err); }
.err-msg { margin: 5px 0 0; font-size: 12px; color: var(--err); }
.has-err input, .has-err select, .has-err textarea { border-color: var(--err); }
.has-err > label { color: var(--err); }

.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 4px 0; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 400; font-size: 14px; margin: 0; }
.check input { width: auto; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 16px 14px;
  margin: 14px 0;
  background: #fbfcfd;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0 6px;
  border-bottom: 1px dashed var(--line);
}

button { font: inherit; cursor: pointer; }
.add {
  background: none;
  border: 1px dashed var(--brand);
  color: var(--brand);
  border-radius: 6px;
  padding: 8px 14px;
  margin: 6px 0 2px;
}
.link { background: none; border: none; color: var(--brand); padding: 4px 6px; font-size: 13px; }
.link.danger { color: var(--err); }

.primary {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 12px 30px;
  font-size: 16px;
  font-weight: 600;
}
.primary:hover { background: #085a92; }
.primary:disabled { background: var(--muted); cursor: not-allowed; }

.submit-bar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  text-align: center;
}

.upload {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  margin: 10px 0;
  background: #fbfcfd;
}
.upload-label { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.upload input[type=file] { font-size: 13px; }
.file-ok { display: flex; align-items: center; gap: 10px; color: var(--ok); font-size: 14px; }
.has-err.upload { border-color: var(--err); background: #fff7f6; }

.notice {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 18px;
}
.notice.error { border-left-color: var(--err); }
.notice.ok { border-left-color: var(--ok); }
.notice h1 { font-size: 18px; margin: 0 0 6px; }

.foot { color: var(--muted); font-size: 12px; padding-bottom: 30px; }

/* ── 後台 ─────────────────────────────── */
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 14px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #eef2f6; font-size: 13px; }
tr:hover td { background: #fafbfc; }
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 12px;
  background: #eef2f6;
  color: var(--muted);
  white-space: nowrap;
}
.badge.pending { background: #fff3d6; color: #8a6100; }
.badge.sent    { background: #e3f0fb; color: #0a5486; }
.badge.pass    { background: #ddf3e6; color: var(--ok); }
.badge.fail    { background: #fde5e2; color: var(--err); }

.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

pre.json {
  background: #1b2733;
  color: #d6e2ef;
  padding: 14px;
  border-radius: 6px;
  overflow: auto;
  font-size: 12px;
  max-height: 460px;
}

.toolbar { display: flex; gap: 10px; align-items: center; margin: 16px 0; flex-wrap: wrap; }
.copy-url {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  background: #eef2f6;
  padding: 6px 10px;
  border-radius: 5px;
  word-break: break-all;
}

@media (max-width: 640px) {
  .row > .field { flex: 1 1 100%; }
  .kv { grid-template-columns: 1fr; }
  section { padding: 16px; }
}
