:root {
  --bg: #e8eef2;
  --bg2: #f7fafb;
  --ink: #1a2b33;
  --muted: #5b6b73;
  --line: #c5d0d6;
  --brand: #0b5f6b;
  --brand-dark: #084851;
  --accent: #b45309;
  --ok: #166534;
  --err: #991b1b;
  --panel: #ffffff;
  --shadow: 0 10px 30px rgba(26, 43, 51, 0.08);
  --font: "Source Sans 3", "Segoe UI", "Helvetica Neue", sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
}

@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Source+Sans+3:wght@400;600;700&display=swap");

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #cfe8e6 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #f3e0c7 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
}
a { color: var(--brand); }
.shell {
  width: min(1120px, calc(100% - 2rem));
  margin: 1.5rem auto 2.5rem;
}
.shell.narrow { width: min(480px, calc(100% - 2rem)); }
.top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}
.brand {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand);
}
h1 {
  margin: 0.2rem 0;
  font-family: var(--display);
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  line-height: 1.15;
}
.sub, .hint, .muted { color: var(--muted); }
.sub { margin: 0.35rem 0 0; max-width: 42rem; }
.userbox { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
  padding: 0;
  margin: 0 0 1.25rem;
}
.steps li {
  background: rgba(255,255,255,0.55);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.6rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
}
.steps li.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}
.grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.panel h2 {
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
}
.filelist { list-style: none; padding: 0; margin: 0.75rem 0 0; }
.filelist li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}
.filelist li.active { background: #f0f7f7; margin: 0 -0.5rem; padding-left: 0.5rem; padding-right: 0.5rem; border-radius: 8px; }
.meta { display: block; font-size: 0.82rem; color: var(--muted); margin-top: 0.15rem; }
.kv { display: grid; grid-template-columns: 9rem 1fr; gap: 0.35rem 0.75rem; margin: 0.5rem 0 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.badge {
  display: inline-block;
  background: #e6f3f4;
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.actions { display: flex; flex-direction: column; gap: 0.55rem; align-items: stretch; }
.sign-form { display: flex; flex-direction: column; gap: 0.45rem; }
.inline input {
  width: 100%;
  margin-top: 0.25rem;
}
.btn, button.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.card-form { display: flex; flex-direction: column; gap: 0.75rem; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem; box-shadow: var(--shadow); }
.card-form label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.92rem; }
.card-form input, .sign-form input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font: inherit;
}
.flash {
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid;
}
.flash.ok { background: #ecfdf3; border-color: #86efac; color: var(--ok); }
.flash.error { background: #fef2f2; border-color: #fecaca; color: var(--err); }
.verify-panel.verify-ok { border-color: #86efac; background: linear-gradient(180deg, #ecfdf3, #fff); }
.verify-panel.verify-bad { border-color: #fecaca; background: linear-gradient(180deg, #fef2f2, #fff); }
.verify-flags { list-style: none; padding: 0; margin: 0.75rem 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.verify-flags li {
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid var(--line);
}
.verify-flags li.yes { background: #166534; color: #fff; border-color: #166534; }
.verify-flags li.no { background: #991b1b; color: #fff; border-color: #991b1b; }
pre.raw {
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  overflow: auto;
  font-size: 0.8rem;
}
.pdf-frame {
  width: 100%;
  height: min(72vh, 820px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f3f4f6;
}
.preview-head { display: flex; justify-content: space-between; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.6rem; }
.preview-links { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { border-top: 1px solid var(--line); padding: 0.45rem 0.35rem; text-align: left; vertical-align: top; }
.table .detail { word-break: break-word; color: var(--muted); }
.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}
.link { font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }

@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 1fr; }
}
