:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #65727f;
  --line: #d9e0e7;
  --soft: #f5f7f9;
  --brand: #0f6b61;
  --brand-dark: #0a4d46;
  --danger: #b42318;
  --ok: #087443;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  background: #eef2f4;
  color: var(--ink);
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.topbar strong { display: block; font-size: 18px; }
.topbar span { color: var(--muted); font-size: 13px; }
.topbar nav { display: flex; gap: 10px; align-items: center; }
.topbar nav form { margin: 0; }
.topbar a { color: var(--brand-dark); text-decoration: none; font-weight: 700; }

main {
  width: min(1120px, calc(100vw - 32px));
  margin: 28px auto 60px;
}

h1, h2 { margin: 0 0 16px; letter-spacing: 0; }
h1 { font-size: 28px; }
h2 { font-size: 18px; margin-top: 18px; }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 8px 22px rgba(22, 34, 44, .06);
}

.narrow { max-width: 460px; margin: 8vh auto; }
.stack, .grid-form { display: grid; gap: 16px; }
.grid-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wide { grid-column: 1 / -1; }

label, .label {
  display: grid;
  gap: 7px;
  font-weight: 700;
  color: #27313a;
}

input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  padding: 11px 12px;
  font: inherit;
  background: #fff;
}

textarea { min-height: 96px; resize: vertical; }
button, .button {
  appearance: none;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 11px 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
}

.ghost {
  color: var(--brand-dark);
  background: #e5f2ef;
}

.pagehead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.record {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(320px, .9fr);
  gap: 16px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.record:last-child { border-bottom: 0; }
.record b { display: block; font-size: 17px; }
.record span, .muted { color: var(--muted); }
.actions { display: flex; gap: 10px; }
.copylink { font-size: 13px; }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.compact { align-items: start; margin-bottom: 18px; }
.summary { width: 100%; border-collapse: collapse; }
.summary th, .summary td { border-bottom: 1px solid var(--line); padding: 11px 8px; text-align: left; }
.summary th { color: var(--muted); font-weight: 700; width: 52%; }
.summary td { text-align: right; }

.details {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px 14px;
}
.details dt { color: var(--muted); font-weight: 700; }
.details dd { margin: 0; overflow-wrap: anywhere; }

.notice {
  background: #edf7f5;
  border: 1px solid #c7e4de;
  border-radius: 8px;
  padding: 13px 14px;
  margin-bottom: 18px;
  color: #164c45;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}
.check input { width: 18px; height: 18px; }

#signaturePad {
  width: 100%;
  height: 220px;
  border: 1px solid #b8c4cf;
  border-radius: 8px;
  background: #fff;
  touch-action: none;
  display: block;
}

.row-actions { display: flex; gap: 12px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.status { background: #eef7f1; color: var(--ok); border-radius: 99px; padding: 6px 10px; font-weight: 800; }
.error { color: var(--danger); font-weight: 700; }
.success h1 { color: var(--ok); }
.files a { color: var(--brand-dark); font-weight: 700; }
.review { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 18px; }
input[type=checkbox] { flex-shrink: 0; }
.check { align-items: flex-start; }
img { max-width: 100%; }
.panel { box-shadow: none; }

@media (max-width: 760px) {
  .topbar, .pagehead, .actions { align-items: stretch; flex-direction: column; }
  .grid-form, .split, .record { grid-template-columns: 1fr; }
  main { width: min(100vw - 20px, 1120px); margin-top: 16px; }
  .panel { padding: 18px; }
}
