
/* ============================================
   Engineering Helper Platform — industrial CSS
   Cross-browser tested: Chrome, Firefox, Safari, Edge
   ============================================ */

/* Reset + defaults */
*, *::before, *::after { box-sizing: border-box; }

/* Skip link — accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 8px;
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  z-index: 1000;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: top .15s;
}
.skip-link:focus {
  top: 8px;
  color: #fff;
  text-decoration: none;
}
address { font-style: normal; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -moz-tab-size: 4; tab-size: 4; }
body {
  margin: 0;
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #0f172a;
  background: #ffffff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; display: block; }
a { color: #1e40af; text-decoration: none; transition: color .12s ease; }
a:hover { color: #1d4ed8; text-decoration: underline; }
a:focus-visible { outline: 2px solid #1e40af; outline-offset: 2px; border-radius: 2px; }

/* Color tokens */
:root {
  --ink: #0f172a;
  --ink-2: #1e293b;
  --muted: #475569;
  --muted-2: #64748b;
  --faint: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --bg: #ffffff;
  --bg-2: #f8fafc;
  --bg-3: #f1f5f9;
  --accent: #1e40af;
  --accent-soft: #dbeafe;
  --signal: #b91c1c;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ============================================
   HEADER
   ============================================ */
.site-header {
  background: #0f172a;
  color: #e2e8f0;
  border-bottom: 3px solid #1e40af;
}
.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 14px 28px;
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  gap: 24px;
  -ms-flex-wrap: wrap; flex-wrap: wrap;
}
.site-brand {
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}
.site-brand:hover { text-decoration: none; color: #fff; }
.brand-mark {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .04em;
  padding: 7px 10px;
  border: 1.5px solid #60a5fa;
  color: #93c5fd;
  line-height: 1;
  background: rgba(30, 64, 175, .15);
}
.brand-text { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column; gap: 1px; }
.brand-title { font-size: 16px; font-weight: 600; color: #fff; line-height: 1.2; letter-spacing: .01em; }
.brand-tag { font-size: 11px; color: #94a3b8; letter-spacing: .05em; text-transform: uppercase; font-weight: 500; }

.lang-switcher {
  display: -webkit-box; display: -ms-flexbox; display: inline-flex;
  gap: 0;
  border: 1px solid rgba(148,163,184,.3);
  background: rgba(255,255,255,.04);
  padding: 2px;
}
.lang-btn {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  color: #cbd5e1;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  padding: 6px 10px;
  cursor: pointer;
  transition: all .12s;
  text-decoration: none;
  display: inline-block;
}
.lang-btn:hover { color: #fff; background: rgba(30,64,175,.2); text-decoration: none; }
.lang-btn[aria-pressed="true"] { background: #1e40af; color: #fff; }
.translation-notice {
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  padding: 10px 14px;
  margin: 0 0 18px 0;
  font-size: 13px;
  color: #78350f;
}

.contacts {
  margin-left: auto;
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  gap: 8px;
  -ms-flex-wrap: wrap; flex-wrap: wrap;
  font-size: 13px;
}
.contacts .phone, .contacts .msg {
  display: -webkit-box; display: -ms-flexbox; display: inline-flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  gap: 7px;
  padding: 6px 10px;
  color: #e2e8f0;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(148,163,184,.25);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  transition: all .12s ease;
}
.contacts .phone { font-family: var(--mono); font-size: 12.5px; letter-spacing: .01em; }
.contacts .phone:hover, .contacts .msg:hover { border-color: #60a5fa; color: #fff; background: rgba(30,64,175,.25); text-decoration: none; }
.contacts .ico {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  color: #60a5fa;
  letter-spacing: .05em;
  padding: 2px 4px;
  background: rgba(30,64,175,.25);
  line-height: 1;
}

/* ============================================
   LAYOUT
   ============================================ */
.layout {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  padding: 28px;
  -webkit-box-align: start; -ms-flex-align: start; align-items: start;
}

/* ============================================
   SIDEBAR NAV
   ============================================ */
.sidebar {
  position: -webkit-sticky; position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  font-size: 15px;
  padding-right: 4px;
  border-right: 1px solid var(--border);
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.sidebar a {
  display: block;
  padding: 7px 12px;
  color: var(--muted);
  border-left: 2px solid transparent;
  transition: all .1s ease;
}
.sidebar a:hover { background: var(--bg-3); color: var(--ink); text-decoration: none; }
.sidebar a.active,
.sidebar a.nav-top.active,
.sidebar a.nav-sub.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}
.nav-top { font-weight: 600; color: var(--ink); margin-top: 2px; }
.nav-section { margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.nav-section:last-child { border-bottom: none; }
.nav-group { margin: 4px 0 4px 6px; }
.nav-group summary {
  list-style: none;
  cursor: pointer;
  padding: 6px 10px;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--muted-2);
  font-family: var(--mono);
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  gap: 6px;
}
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::marker { display: none; content: ""; }
.nav-group summary::before {
  content: "+";
  color: var(--faint);
  font-family: var(--mono);
  font-weight: 700;
  width: 10px;
  text-align: center;
}
.nav-group[open] summary::before { content: "−"; color: var(--accent); }
.nav-group summary a { display: inline; padding: 0; border: none; color: inherit; }
.nav-group summary a:hover { background: transparent; }
.nav-group ul {
  list-style: none;
  margin: 2px 0 4px 14px;
  padding: 0;
  border-left: 1px solid var(--border);
}
.nav-group li { margin: 0; }
.nav-group li a { padding-left: 14px; font-size: 14px; }

/* ============================================
   CONTENT
   ============================================ */
.content { min-width: 0; }
.content::after { content: ""; display: block; clear: both; }
/* Cap text-readable elements (paragraphs, lists, headings) for line length;
   tables and embeds use full content width. */
.content > p, .content > h1, .content > h2, .content > h3, .content > h4,
.content > ul, .content > ol, .content > blockquote { max-width: 920px; }
.content > .breadcrumbs { max-width: none; }

.breadcrumbs {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent); text-decoration: none; }
.breadcrumbs .bc-sep { margin: 0 8px; color: var(--faint); }
.breadcrumbs .bc-current { color: var(--ink); font-weight: 600; }

/* Only direct children of .content — never reach inside embeds (.ehp-embed) */
.content > h1 {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 22px;
  color: var(--ink);
  letter-spacing: -.01em;
}
.content > h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 36px 0 14px;
  padding: 0 0 8px 14px;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  line-height: 1.3;
}
.content > h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 24px 0 10px;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: .02em;
  font-family: var(--mono);
}
.content > p { margin: 12px 0; color: var(--ink-2); }
.content > ul, .content > ol { padding-left: 22px; }
.content > ul > li, .content > ol > li { margin: 4px 0; }
.content > img { margin: 14px 0; border: 1px solid var(--border); }
.content > blockquote {
  border-left: 3px solid var(--accent);
  margin: 16px 0;
  padding: 10px 16px;
  color: var(--muted);
  background: var(--bg-2);
  font-style: normal;
}
.content > p strong, .content > h1 strong, .content > h2 strong, .content > h3 strong { color: var(--ink); font-weight: 600; }

/* ============================================
   TABLES
   ============================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 13.5px;
  border: 1px solid var(--border-strong);
  background: #fff;
}
.data-table caption {
  caption-side: top;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 8px;
  padding: 8px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-bottom: none;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-family: var(--mono);
}
.data-table th, .data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: top;
}
.data-table th:last-child, .data-table td:last-child { border-right: none; }
.data-table tr:last-child td { border-bottom: none; }
.data-table thead th {
  background: #0f172a;
  color: #e2e8f0;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 2px solid var(--accent);
  border-right-color: #1e293b;
}
.data-table tbody tr:nth-child(even) { background: var(--bg-2); }
.data-table tbody tr:hover { background: var(--accent-soft); }
.data-table td:first-child { font-weight: 600; color: var(--ink); }
/* Monospace for numeric columns */
.data-table td { font-variant-numeric: tabular-nums; }
.data-table td:not(:first-child) { font-family: var(--mono); font-size: 13px; }

/* ============================================
   EMBEDS (calculators) — inline, scoped per-embed
   ============================================ */
.ehp-embed { margin: 20px 0; }
.embed-inline-block { width: 100%; }
.embed-inline-float {
  float: right;
  clear: right;
  width: 50%;
  min-width: 380px;
  margin: 4px 0 20px 28px;
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  margin-top: 60px;
  padding: 24px 28px;
}
.footer-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: -webkit-box; display: -ms-flexbox; display: flex;
  -webkit-box-pack: justify; -ms-flex-pack: justify; justify-content: space-between;
  -webkit-box-align: center; -ms-flex-align: center; align-items: center;
  -ms-flex-wrap: wrap; flex-wrap: wrap;
  gap: 14px;
  font-size: 12.5px;
  color: var(--muted-2);
  font-family: var(--mono);
  letter-spacing: .02em;
}
.footer-right a { color: var(--muted); margin: 0 4px; }
.footer-right a:hover { color: var(--accent); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; gap: 20px; padding: 20px; }
  .sidebar { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--border); padding-bottom: 12px; padding-right: 0; }
  .contacts { margin-left: 0; width: 100%; }
  .header-inner { padding: 12px 16px; }
}
@media (max-width: 780px) {
  .embed-float { float: none; width: 100%; min-width: 0; margin: 20px 0; }
  .content h1 { font-size: 24px; }
  .content h2 { font-size: 18px; }
  .data-table { font-size: 12.5px; }
  .data-table th, .data-table td { padding: 7px 9px; }
  .footer-inner { -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column; -webkit-box-align: start; -ms-flex-align: start; align-items: flex-start; }
}

/* Fix card label overflow in /dopuski.html cards — source embed hardcodes
   .io-lbl { width: 32px } which fits only short Russian labels ("Ввод", "Итог").
   Longer labels in other languages ("Введення", "Підсумок", "Bottom line")
   overflow and visually overlap the adjacent .io-val column.
   Use !important to override scoped embed CSS (.ehp-embed-N .io-lbl). */
[class*="ehp-embed-"] .io-lbl {
  width: auto !important;
  min-width: 44px;
  white-space: nowrap;
}
[class*="ehp-embed-"] .io-row {
  align-items: flex-start;
}

/* Print */
@media print {
  .site-header, .sidebar, .site-footer { display: none; }
  .layout { grid-template-columns: 1fr; padding: 0; }
  .embed-wrap { border: 1px solid #999; page-break-inside: avoid; }
  a { color: #000; text-decoration: underline; }
}
