:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #677382;
  --border: #dde1e6;
  --primary: #1d3a5f;
  --primary-hover: #152b47;
  --ok-bg: #e6f4ea; --ok-text: #1e6b34;
  --err-bg: #fdecea; --err-text: #a4251c;
  --info-bg: #e8f0fb; --info-text: #1d3a5f;
  --warn-bg: #fff4e0; --warn-text: #8a5300;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .25rem; }
.muted, .meta, .hint { color: var(--muted); }
.meta { font-size: .9rem; }
.hint { font-size: .85rem; margin: .25rem 0 .75rem; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }

.topbar {
  display: flex; align-items: center; gap: 2rem; flex-wrap: wrap;
  background: var(--primary); color: #fff; padding: .75rem 1.5rem;
}
.topbar a { color: #fff; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.1rem; }
.topbar nav { display: flex; gap: 1.25rem; flex: 1; }
.topbar nav a { opacity: .8; padding-bottom: 2px; }
.topbar nav a.active, .topbar nav a:hover { opacity: 1; border-bottom: 2px solid #fff; }
.who { font-size: .9rem; opacity: .9; }

.container { max-width: 1050px; margin: 1.5rem auto; padding: 0 1rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.count { display: inline-block; background: var(--primary); color: #fff; border-radius: 999px; font-size: .85rem; padding: 0 .6rem; vertical-align: middle; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem; }

.doc-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.doc-head h2 a { text-decoration: none; }
.doc-head h2 a:hover { text-decoration: underline; }
.summary {
  white-space: pre-wrap; margin: 1rem 0; padding: 1rem; background: #fafbfc;
  border-left: 3px solid var(--primary); border-radius: 4px;
}
.summary.pending { color: var(--muted); border-left-color: var(--border); }
.summary.error { background: var(--warn-bg); color: var(--warn-text); border-left-color: var(--warn-text); }
.summary.error form { margin-top: .5rem; }

.actions { display: flex; gap: .75rem; align-items: flex-start; flex-wrap: wrap; }
details.validate { flex: 1; }
details.validate > summary { list-style: none; display: inline-block; }
details.validate > summary::-webkit-details-marker { display: none; }
details.validate[open] > summary { margin-bottom: .75rem; }
.validate-form { background: #fafbfc; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; max-width: 560px; }

label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: .75rem; }
label.check { font-weight: normal; display: flex; gap: .5rem; align-items: center; }
input:not([type=checkbox]) {
  display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem;
  border: 1px solid var(--border); border-radius: 6px; font: inherit;
}
input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
form.inline { display: inline-flex; gap: .5rem; align-items: center; margin: 0; }
form.inline input { margin-top: 0; width: 190px; }

.btn {
  display: inline-block; cursor: pointer; font: inherit; font-weight: 600; text-decoration: none;
  padding: .5rem 1rem; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--text); white-space: nowrap;
}
.btn:hover { background: #f0f2f5; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--err-text); border-color: #e8b4b0; }
.btn-danger:hover { background: var(--err-bg); }
.btn-small { padding: .3rem .7rem; font-size: .85rem; }

.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); }
.flash-error { background: var(--err-bg); color: var(--err-text); }
.flash-info { background: var(--info-bg); color: var(--info-text); }

.table { width: 100%; border-collapse: collapse; padding: 0; overflow: hidden; }
.table th, .table td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: #fafbfc; font-size: .85rem; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.tag { display: inline-block; font-size: .8rem; font-weight: 600; padding: .1rem .5rem; border-radius: 4px; background: #eceff3; }
.tag-ok { background: var(--ok-bg); color: var(--ok-text); }
.tag-warn { background: var(--warn-bg); color: var(--warn-text); }

.form-narrow { max-width: 460px; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login { width: 100%; max-width: 360px; }
.login h1 { margin-bottom: 0; }
.login .muted { margin-top: 0; margin-bottom: 1.25rem; }
.login .btn { width: 100%; }

.spinner {
  display: inline-block; width: 12px; height: 12px; margin-right: .4rem; vertical-align: -1px;
  border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 700px) {
  .doc-head { flex-direction: column; }
  .table { display: block; overflow-x: auto; }
}
