:root {
  --ink: #16211c; --muted: #5d6b64; --paper: #f4f2ec; --card: #fffefb; --line: #dcd8cc;
  --brand: #0f5c46; --brand-ink: #fff; --ok: #0f6b3f; --bad: #a3271f; --warn: #7a5200;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--brand); }
h1 { font-size: 1.55rem; line-height: 1.25; margin: 0 0 .6rem; letter-spacing: -.01em; overflow-wrap: anywhere; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .5rem; }
.card h2:first-child { margin-top: 0; }
main { max-width: 920px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1.5rem;
  padding: .7rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.mark { width: 22px; height: 22px; border-radius: 6px 6px 6px 0; background: var(--brand);
  box-shadow: inset 0 -7px 0 -4px #d9b45a; }
.top nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.1rem; }
.top form { margin: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin: 0 0 1rem; }
.narrow { max-width: 440px; margin: 2rem auto; }
.center { text-align: center; }
.muted { color: var(--muted); font-size: .92rem; }
.mono, code { font-family: ui-monospace, Consolas, "DejaVu Sans Mono", monospace; font-size: .85rem; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.ok { color: var(--ok); } .bad { color: var(--bad); font-weight: 600; }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; margin-bottom: .8rem; }
.bar h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.actions form { margin: 0; }

label { display: block; margin: 0 0 .85rem; font-weight: 600; font-size: .93rem; }
label .muted { font-weight: 400; }
input, select { display: block; width: 100%; margin-top: .3rem; padding: .6rem .7rem; font: inherit; color: inherit;
  background: #fff; border: 1px solid #b9b4a4; border-radius: 8px; }
input[type=file] { padding: .45rem; }
input[type=checkbox] { display: inline-block; width: 1.25rem; height: 1.25rem; margin: .15rem 0 0; flex: none; accent-color: var(--brand); }
:focus-visible { outline: 3px solid #d9b45a; outline-offset: 2px; }
.btn { display: inline-block; padding: .62rem 1.05rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  color: var(--brand-ink); background: var(--brand); border: 1px solid var(--brand); border-radius: 8px; }
.btn:hover { background: #0b4a38; }
.btn.ghost { color: var(--brand); background: transparent; }
.btn.ghost:hover { background: #e8efe9; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: #f8e9e7; }
.btn[disabled] { opacity: .55; cursor: progress; }
.link { padding: 0; font: inherit; color: var(--brand); background: none; border: 0; cursor: pointer; text-decoration: underline; }
.alert { padding: .65rem .85rem; border-radius: 8px; background: #f8e9e7; color: var(--bad); border: 1px solid #e6bdb8; }
.alert.warn { background: #fbf3df; color: var(--warn); border-color: #ead9a8; }
.alert.ok { background: #e6f2ea; color: var(--ok); border-color: #b9d8c4; }
[hidden] { display: none !important; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filters input { flex: 1 1 220px; margin: 0; } .filters select { flex: 0 1 190px; margin: 0; }
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th, td { padding: .6rem .8rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
table.log td { font-size: .86rem; }
table.log td:nth-child(4) { overflow-wrap: anywhere; min-width: 14rem; }
.pill { display: inline-block; padding: .12rem .6rem; border-radius: 99px; font-size: .82rem; font-weight: 600; white-space: nowrap;
  background: #fbf3df; color: var(--warn); }
.pill.signed { background: #e6f2ea; color: var(--ok); }
.pill.cancelled { background: #ecebe6; color: var(--muted); }
.who { display: inline-block; margin: 0 .5rem .1rem 0; }
.who.signed::before { content: "✓ "; color: var(--ok); }
.who.pending::before { content: "○ "; color: var(--muted); }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 1rem 0 0; }
.meta dt { color: var(--muted); font-size: .9rem; } .meta dd { margin: 0; }
.plain { list-style: none; padding: 0; margin: 0; } .plain li { padding: .35rem 0; }
.keybox { padding: .7rem; background: #fff; border: 1px dashed var(--brand); border-radius: 8px; user-select: all; }

.signer { display: grid; grid-template-columns: 2fr 1.4fr 1.2fr auto; gap: 0 .7rem; align-items: end; }
.signer .remove { margin-bottom: 1.45rem; }
.linkrow { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; align-items: center; }
.linkrow input { flex: 1 1 260px; margin: 0; font-size: .85rem; } .linkrow form { margin: 0; }

.signhead { text-align: center; margin: .5rem 0 1rem; }
.signhead p { margin: .2rem 0; }
.pages { display: grid; gap: .8rem; }
.pages img { display: block; width: 100%; height: auto; background: #fff; border: 1px solid var(--line); box-shadow: 0 1px 6px rgba(22, 33, 28, .08); }
.signbox { margin-top: 1.2rem; border: 2px solid var(--brand); }
.check { display: flex; gap: .7rem; font-weight: 400; font-size: 1rem; }
.done { border: 2px solid var(--ok); }
.eds { margin-top: 1rem; }
.or { text-align: center; color: var(--muted); margin: .4rem 0 .8rem; }
#code { max-width: 12rem; font-size: 1.5rem; letter-spacing: .3em; text-align: center; }

@media (max-width: 640px) {
  .signer { grid-template-columns: 1fr; padding-bottom: .6rem; margin-bottom: .9rem; border-bottom: 1px solid var(--line); }
  .signer .remove { margin: 0; justify-self: start; }
  .meta { grid-template-columns: 1fr; gap: 0; } .meta dd { margin-bottom: .5rem; }
  .signbox .btn { width: 100%; text-align: center; }
}

.usage { margin: 0 0 1rem; font-size: .92rem; color: var(--muted); }
.usage.full { color: var(--bad); font-weight: 600; }
.grid3 { display: grid; grid-template-columns: 2fr 1.4fr 1.2fr; gap: 0 .7rem; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.plan { margin: 0; } .plan h3 { margin: 0 0 .3rem; font-size: 1.05rem; }
.plan.current { border: 2px solid var(--brand); }
.price { font-size: 1.35rem; font-weight: 700; margin: 0 0 .3rem; }
.price .muted { font-size: .85rem; font-weight: 400; }
progress { width: 100%; height: .8rem; accent-color: var(--brand); }
.pre { white-space: pre-line; }
td input, td select { margin: 0; min-width: 6rem; }
td input[type=checkbox] { min-width: 0; }
td .actions { flex-wrap: nowrap; }
#egov-box { margin-top: 1rem; text-align: center; }
#egov-box img { max-width: 100%; height: auto; border: 1px solid var(--line); background: #fff; }
#egov-box .actions { justify-content: center; margin: .8rem 0; }
@media (max-width: 640px) { .grid3 { grid-template-columns: 1fr; } td .actions { flex-wrap: wrap; } }
