:root {
  --bg: #f6f8f7;
  --card: #ffffff;
  --ink: #1d2a2b;
  --muted: #5f6f70;
  --line: #dfe6e4;
  --brand: #1f7a6d;
  --brand-ink: #ffffff;
  --brand-soft: #e3f1ee;
  --warn: #b7791f;
  --warn-soft: #fbf1df;
  --bad: #b23a48;
  --bad-soft: #f9e4e7;
  --ok: #2f855a;
  --ok-soft: #e2f3e9;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.container { max-width: 1100px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 720px; }

/* header */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar .container { display: flex; align-items: center; gap: 16px; padding-block: 10px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--brand); text-decoration: none; letter-spacing: .02em; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a { text-decoration: none; color: var(--ink); padding: 6px 10px; border-radius: 8px; }
.nav a.active, .nav a:hover { background: var(--brand-soft); color: var(--brand); }

/* cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card h2 { margin-bottom: .75rem; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); padding: 10px 16px; border-radius: 10px; font-size: 1rem; cursor: pointer; text-decoration: none; min-height: 44px; }
.btn:hover { filter: brightness(.95); }
.btn.secondary { background: var(--card); color: var(--brand); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 6px 10px; min-height: 34px; font-size: .9rem; }
.btn.block { width: 100%; }
button.linklike { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }

/* forms */
label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=tel], select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; min-height: 44px; }
textarea { min-height: 120px; resize: vertical; }
.field { margin-bottom: 14px; }
.help { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.errorlist { color: var(--bad); margin: 4px 0 0; padding-left: 18px; font-size: .9rem; }
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; background: var(--brand-soft); color: var(--brand); }
.messages li.error { background: var(--bad-soft); color: var(--bad); }
.messages li.info { background: var(--warn-soft); color: var(--warn); }
.messages li.success { background: var(--ok-soft); color: var(--ok); }

/* badges & levels */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--line); color: var(--ink); white-space: nowrap; }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.lvl-low { background: var(--ok-soft); color: var(--ok); }
.lvl-mid { background: var(--warn-soft); color: var(--warn); }
.lvl-high { background: var(--bad-soft); color: var(--bad); }
.lvl-none { background: var(--line); color: var(--muted); }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.table-wrap { overflow-x: auto; }
.num { text-align: right; white-space: nowrap; }

/* board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.column { background: #eef2f1; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.column h3 { font-size: .9rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; display: flex; justify-content: space-between; }
.ticket { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; display: block; text-decoration: none; color: var(--ink); }
.ticket:hover { border-color: var(--brand); }
.ticket .name { font-weight: 600; }
.ticket .action { color: var(--warn); font-size: .85rem; margin-top: 4px; }

/* progress */
.progress { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .3s; }

/* questionnaire */
.q-chapters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.q-chapters a { font-size: .8rem; padding: 4px 8px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.q-chapters a.done { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.q-chapters a.current { background: var(--brand); color: #fff; border-color: var(--brand); }
.q-section { margin-bottom: 20px; }
.q-section h3 { padding: 8px 0; border-bottom: 2px solid var(--brand-soft); margin-bottom: 8px; }
.q-group { font-weight: 600; color: var(--muted); margin: 14px 0 6px; font-size: .9rem; }
.q { padding: 12px 0; border-bottom: 1px solid var(--line); }
.q .text { margin-bottom: 8px; }
.q .num { color: var(--muted); font-size: .85rem; margin-right: 6px; text-align: left; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opts label { flex: 1 1 auto; margin: 0; font-weight: 500; }
.opts input { position: absolute; opacity: 0; width: 0; height: 0; }
.opts span { display: block; text-align: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); cursor: pointer; min-height: 44px; }
.opts input:checked + span { background: var(--brand); color: #fff; border-color: var(--brand); }
.opts input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.opts.vertical { flex-direction: column; }
.opts.grid2 label { flex: 1 1 calc(50% - 3px); }
.opts.vertical span { text-align: left; }
.q.unanswered .text::after { content: " •"; color: var(--warn); }
.savebar { position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding: 10px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 16px -16px -16px; border-radius: 0 0 var(--radius) var(--radius); }
.savestatus { font-size: .85rem; color: var(--muted); }
.savestatus.err { color: var(--bad); }

/* legal texts */
.legal { white-space: pre-wrap; font-size: .92rem; background: #fbfcfb; border: 1px solid var(--line); border-radius: 10px; padding: 12px; max-height: 260px; overflow: auto; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; }

.copybox { display: flex; gap: 8px; align-items: center; }
.copybox input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }
.timeline li { margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 6px; } }
footer { color: var(--muted); font-size: .8rem; text-align: center; padding: 24px 0; }

/* verification */
.verify-grid { display: grid; grid-template-columns: minmax(260px, 36%) 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .verify-grid { grid-template-columns: 1fr; } }
.pages { max-height: 80vh; overflow: auto; padding: 8px; }
.pages img { width: 100%; border: 1px solid var(--line); margin-bottom: 8px; }
#results input, #results select { min-height: 34px; padding: 4px 8px; font-size: .9rem; }
#results td:nth-child(1) input { min-width: 170px; }
#results select { min-width: 150px; }
#results td { padding: 4px 6px; }
tr.unmatched-row td:first-child input { border-color: var(--warn); }

/* ai report */
.ai-item { padding: 8px 0; border-bottom: 1px solid var(--line); }
.ai-item.rejected > label > span { text-decoration: line-through; color: var(--muted); }
.ai-item .check input { margin-top: 4px; }
.md h2 { font-size: 1.05rem; margin-top: 16px; border-bottom: 2px solid var(--brand-soft); padding-bottom: 4px; }
.md ul { padding-left: 20px; }
