* { box-sizing: border-box; }
body {
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  margin: 0; background: #f4f5f7; color: #1f2330; line-height: 1.45;
}
.wrap { max-width: 980px; margin: 0 auto; padding: 20px; }
.wrap.narrow { max-width: 420px; }
.topbar { display: flex; align-items: center; justify-content: space-between; }
h1 { font-size: 22px; margin: 10px 0; }
h2 { font-size: 17px; margin: 18px 0 10px; }
.muted { color: #6b7280; }
.small { font-size: 13px; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 18px; margin: 14px 0; }
.card.ok   { border-color: #16a34a; background: #f0fdf4; }
.card.warn { border-color: #dc2626; background: #fef2f2; }

.nav { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 4px; }
.nav a { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 7px 12px; color: #1f2330; }
.nav a:hover { background: #eef2ff; text-decoration: none; }

.btn { display: inline-block; background: #fff; border: 1px solid #cbd2dc; border-radius: 8px;
       padding: 9px 16px; cursor: pointer; color: #1f2330; font-size: 15px; }
.btn:hover { background: #f0f2f5; text-decoration: none; }
.btn.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }

label { display: block; margin: 10px 0; font-size: 14px; color: #374151; }
input[type=text], input[type=password], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cbd2dc; border-radius: 8px;
  font-size: 15px; margin-top: 4px; background: #fff;
}
textarea { resize: vertical; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: auto; margin: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tpl { border: 2px solid #e5e7eb; border-radius: 10px; padding: 8px; text-align: center; cursor: pointer; background: #fff; display: block; }
.tpl img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 6px; display: block; }
.tpl span { display: block; font-size: 13px; margin-top: 6px; }
.tpl input[type=radio] { margin-bottom: 6px; }
.tpl.off { opacity: .45; }

.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 12px 0; }
.result-grid img { width: 100%; border-radius: 8px; border: 1px solid #e5e7eb; }
.cap { font-size: 13px; color: #6b7280; margin-bottom: 4px; }

.srcrow { display: flex; gap: 12px; margin: 8px 0 14px; }
.srcrow img { width: 220px; max-width: 42%; border-radius: 8px; border: 1px solid #e5e7eb; }
.cmp { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 8px; }
.cmp-item img { width: 100%; border-radius: 8px; border: 1px solid #e5e7eb; }

table.kv { border-collapse: collapse; width: 100%; }
table.kv td { padding: 6px 8px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
table.kv td:first-child { color: #6b7280; width: 38%; }

table.hist { border-collapse: collapse; width: 100%; font-size: 13px; }
table.hist th, table.hist td { padding: 6px 8px; border-bottom: 1px solid #eef0f3; text-align: left; }
.thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 6px; }
.nowrap { white-space: nowrap; }
.badge { padding: 2px 8px; border-radius: 20px; font-size: 12px; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.err { background: #fee2e2; color: #991b1b; }
