/* ==========================================================================
   РКН.Чек — design system (single stylesheet shared by all modules)
   Modules may add assets/css/<module>.css and include it via $extra_css.
   ========================================================================== */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --text: #1b1f2a;
  --text-2: #4a5263;
  --muted: #7b8496;
  --line: #e3e7ef;
  --line-2: #d3d9e4;
  --primary: #2453d6;
  --primary-600: #1c43b3;
  --primary-50: #edf2ff;
  --red: #d63b3b;
  --red-50: #fdeeee;
  --yellow: #c98a0b;
  --yellow-50: #fff6e0;
  --green: #18995a;
  --green-50: #e7f6ee;
  --violet: #6b4ce6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --container: 1160px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.55; color: var(--text); background: var(--bg); }
img, svg { max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .6em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.02rem; }
p { margin: 0 0 1em; }
small, .small { font-size: .875rem; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
code, pre, kbd { font-family: var(--mono); font-size: .88em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
pre { background: #0f172a; color: #e2e8f0; padding: 14px 16px; border-radius: var(--radius-sm); overflow: auto; line-height: 1.45; margin: 0 0 1em; white-space: pre-wrap; word-break: break-word; }
pre code { background: none; padding: 0; color: inherit; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.icon { width: 18px; height: 18px; vertical-align: -3px; flex-shrink: 0; }
.icon-lg { width: 28px; height: 28px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
:focus-visible { outline: 3px solid rgba(36, 83, 214, .4); outline-offset: 2px; }

/* ----- Layout ----- */
.container { max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.container-sm { max-width: 760px; margin: 0 auto; padding: 0 20px; }
.section { padding: 56px 0; }
.section-sm { padding: 32px 0; }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.stack-lg > * + * { margin-top: 28px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid { display: grid; gap: 20px; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 20px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } h1 { font-size: 1.65rem; } .section { padding: 36px 0; } }
.mt-0 { margin-top: 0 !important; } .mb-0 { margin-bottom: 0 !important; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 40px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.w-100 { width: 100%; }
.hidden { display: none !important; }

/* ----- Header / footer ----- */
.site-header { background: rgba(255, 255, 255, .92); backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.site-header .container { display: flex; align-items: center; gap: 24px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; color: var(--text); letter-spacing: -.02em; }
.logo:hover { text-decoration: none; }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--primary), var(--violet)); display: grid; place-items: center; color: #fff; }
.logo-mark svg { width: 18px; height: 18px; }
.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav a { color: var(--text-2); padding: 8px 12px; border-radius: 8px; font-weight: 500; font-size: .95rem; }
.nav a:hover, .nav a.active { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.btn-primary, .nav a.btn-primary:hover { color: #fff; background: var(--primary); }
.nav a.btn-primary:hover { background: var(--primary-600); }
.nav a.btn-secondary { color: var(--text); background: var(--surface); }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; padding: 8px; cursor: pointer; color: var(--text); }
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; top: 64px; left: 0; right: 0; background: var(--surface); flex-direction: column; align-items: stretch; padding: 12px 20px 20px; border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
  .nav.open { display: flex; }
}
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 36px 0 28px; margin-top: 56px; color: var(--text-2); font-size: .9rem; }
.site-footer a { color: var(--text-2); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 28px; }
.footer-grid h4 { font-size: .9rem; color: var(--text); }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin: 6px 0; }
.disclaimer { font-size: .82rem; color: var(--muted); margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } }

/* ----- Buttons ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none !important; line-height: 1.2; transition: background .15s, border-color .15s, box-shadow .15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }
.btn-success { background: var(--green); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .85rem; border-radius: 8px; }
.btn-lg { padding: 14px 24px; font-size: 1.05rem; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }

/* ----- Forms ----- */
.field { display: block; margin-bottom: 16px; }
.field > label, .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field .hint, .hint { font-size: .83rem; color: var(--muted); margin-top: 4px; }
.input, input[type=text], input[type=email], input[type=url], input[type=tel], input[type=number], input[type=password], input[type=search], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; font: inherit; background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36, 83, 214, .15); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; margin: 8px 0; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; flex-shrink: 0; }
.field-error { color: var(--red); font-size: .85rem; margin-top: 4px; }
.input-group { display: flex; gap: 8px; }
.input-group > input { flex: 1; }
@media (max-width: 560px) { .input-group { flex-direction: column; } }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 16px; }
legend { font-weight: 700; padding: 0 6px; }

/* ----- Cards ----- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card-flat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.card-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; margin-bottom: 14px; }
.card-header h2, .card-header h3 { margin: 0; }
.card-muted { background: var(--surface-2); border-radius: var(--radius); padding: 18px; }
.card-link { display: block; color: inherit; }
.card-link:hover { text-decoration: none; border-color: var(--line-2); box-shadow: var(--shadow-lg); }

/* ----- Badges / levels ----- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; line-height: 1.6; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge-p0, .badge-red { background: var(--red-50); color: var(--red); }
.badge-p1, .badge-yellow, .badge-warn { background: var(--yellow-50); color: #9a6a05; }
.badge-p2, .badge-blue, .badge-info { background: var(--primary-50); color: var(--primary); }
.badge-ok, .badge-green { background: var(--green-50); color: var(--green); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-violet { background: #f0ecff; color: var(--violet); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot-red { background: var(--red); } .dot-yellow { background: #e8a90f; } .dot-green { background: var(--green); }
.level { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.level-red { color: var(--red); } .level-yellow { color: #9a6a05; } .level-green { color: var(--green); }

/* ----- Alerts ----- */
.alert { padding: 12px 16px; border-radius: 10px; border: 1px solid; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; }
.alert .icon { margin-top: 2px; }
.alert-info { background: var(--primary-50); border-color: #cfdcff; color: #1c3b8f; }
.alert-warn { background: var(--yellow-50); border-color: #f5dea2; color: #7a5304; }
.alert-danger, .alert-error { background: var(--red-50); border-color: #f6c8c8; color: #9b2222; }
.alert-ok, .alert-success { background: var(--green-50); border-color: #bfe6d0; color: #0f6b3e; }

/* ----- Tables ----- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: var(--surface-2); font-weight: 600; color: var(--text-2); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table-compact th, .table-compact td { padding: 7px 10px; }

/* ----- Progress ----- */
.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--violet)); border-radius: 999px; transition: width .4s; }
.progress-sm { height: 6px; }
.meter { display: flex; flex-direction: column; gap: 4px; }
.meter-label { display: flex; justify-content: space-between; font-size: .85rem; color: var(--text-2); }

/* ----- Score ring ----- */
.score { --val: 0; --c: var(--muted); width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--val) * 1%), var(--surface-2) 0); position: relative; flex-shrink: 0; }
.score::before { content: ""; position: absolute; inset: 10px; background: var(--surface); border-radius: 50%; }
.score span { position: relative; font-size: 1.9rem; font-weight: 800; }
.score small { position: relative; display: block; font-size: .7rem; color: var(--muted); text-align: center; margin-top: -6px; }
.score-red { --c: var(--red); } .score-yellow { --c: #e8a90f; } .score-green { --c: var(--green); }
.score-sm { width: 56px; height: 56px; } .score-sm::before { inset: 6px; } .score-sm span { font-size: 1rem; }

/* ----- KPI tiles ----- */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi-label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.kpi-sub { font-size: .82rem; color: var(--text-2); }

/* ----- App shell (account/admin) ----- */
.app-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; padding: 28px 0 0; }
.sidebar { position: sticky; top: 84px; align-self: start; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--text-2); font-weight: 500; font-size: .95rem; }
.sidebar nav a:hover { background: var(--surface); text-decoration: none; color: var(--text); }
.sidebar nav a.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.sidebar .sidebar-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 18px 12px 6px; }
.sidebar .plan-box { margin-top: 18px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: .88rem; }
.main-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.main-head h1 { font-size: 1.6rem; margin: 0; }
.breadcrumbs { font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.breadcrumbs a { color: var(--muted); }
@media (max-width: 900px) { .app-shell { grid-template-columns: minmax(0, 1fr); } .sidebar { position: static; } .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; } .sidebar .sidebar-title, .sidebar .plan-box { display: none; } }

/* ----- Tabs ----- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a, .tabs button { padding: 10px 14px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--text-2); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs a.active, .tabs button.active { color: var(--primary); border-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* ----- Details (findings) ----- */
details.item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
details.item > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; }
details.item > summary::-webkit-details-marker { display: none; }
details.item > summary::after { content: ""; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-top: 6px; flex-shrink: 0; transition: transform .15s; }
details.item[open] > summary::after { transform: rotate(-135deg); margin-top: 10px; }
details.item .item-body { padding: 0 16px 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.copy-wrap { position: relative; }
.copy-wrap .copy-btn { position: absolute; top: 8px; right: 8px; }

/* ----- Hero (landing) ----- */
.hero { padding: 72px 0 56px; background: radial-gradient(1200px 400px at 50% -10%, #e6ecff 0%, rgba(246, 247, 251, 0) 70%); }
.hero h1 { font-size: 2.7rem; max-width: 820px; margin: 0 auto 16px; text-align: center; }
.hero .lead { font-size: 1.18rem; color: var(--text-2); max-width: 720px; margin: 0 auto 28px; text-align: center; }
.scan-form { max-width: 720px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px; box-shadow: var(--shadow-lg); }
.scan-form .input-group input { border: 0; font-size: 1.1rem; padding: 14px 14px; box-shadow: none; }
.scan-form .consent { padding: 4px 8px 2px; }
@media (max-width: 640px) { .hero h1 { font-size: 1.9rem; } .hero { padding: 40px 0 32px; } }
.feature-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; margin-bottom: 12px; }
.feature-icon .icon { width: 22px; height: 22px; }

/* ----- Pricing ----- */
.price-card { display: flex; flex-direction: column; }
.price-card.featured { border: 2px solid var(--primary); box-shadow: var(--shadow-lg); }
.price { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.price small { font-size: .9rem; color: var(--muted); font-weight: 600; }
.price-card ul { list-style: none; padding: 0; margin: 14px 0 20px; flex: 1; }
.price-card li { display: flex; gap: 8px; margin: 7px 0; font-size: .93rem; }
.price-card li .icon { color: var(--green); margin-top: 3px; }

/* ----- Empty state ----- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty .icon { width: 40px; height: 40px; color: var(--muted); margin-bottom: 10px; }

/* ----- Paywall ----- */
.paywall { border: 1px dashed var(--line-2); background: linear-gradient(180deg, #fbfcff, #f3f6ff); border-radius: var(--radius); padding: 22px; text-align: center; }

/* ----- Misc ----- */
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-check { list-style: none; padding: 0; }
.list-check li { position: relative; padding-left: 26px; margin: 8px 0; }
.list-check li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 10px; height: 6px; border-left: 2px solid var(--green); border-bottom: 2px solid var(--green); transform: rotate(-45deg); }
.kv { display: grid; grid-template-columns: 200px 1fr; gap: 8px 16px; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; } }
.spinner { width: 20px; height: 20px; border: 3px solid var(--surface-2); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.sparkline { display: block; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem; z-index: 1000; box-shadow: var(--shadow-lg); }
.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: .9rem; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }
.steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.steps .step { flex: 1; min-width: 110px; font-size: .82rem; font-weight: 600; color: var(--muted); border-top: 3px solid var(--line); padding-top: 8px; }
.steps .step.done { color: var(--green); border-color: var(--green); }
.steps .step.current { color: var(--primary); border-color: var(--primary); }
.prose { max-width: 820px; }
.prose h2 { margin-top: 1.6em; }
.prose h3 { margin-top: 1.3em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .3em 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: .93rem; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); }
.doc-paper { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 40px 48px; box-shadow: var(--shadow); }
@media (max-width: 640px) { .doc-paper { padding: 22px 18px; } }
@media print {
  .site-header, .site-footer, .sidebar, .no-print { display: none !important; }
  body { background: #fff; }
  .card, .doc-paper { box-shadow: none; border: 0; }
  .app-shell { display: block; }
}

/* QA: long button labels must wrap on phones instead of causing horizontal scroll */
@media (max-width: 480px) { .btn { white-space: normal; text-align: center; max-width: 100%; } }
