/* Базові стилі проєкту КСК 2026 — адаптовано з МСРЗ 2026 для єдиного фірмового стилю */
* {
  box-sizing: border-box;
}
html,
body {
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

@media (max-width: 768px) {
  html,
  body {
    overflow-x: auto;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1f2937;
  line-height: 1.5;
  text-align: center;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 420px at 50% -160px, #eaf0f7 0%, #f4f7fb 45%, #f7f9fc 70%, #f8fafc 100%);
}

main {
  flex: 1 0 auto;
  width: min(100%, 55.2rem);
  max-width: 55.2rem;
  margin: 0 auto;
  padding: clamp(12px, 2vw, 28px);
}

main > * {
  width: 100%;
}

.ksk-formula-selector {
  margin: 0 auto 1rem;
  text-align: left;
}

.ksk-formula-intro {
  margin: 0 0 0.45rem;
  color: #475569;
  font-size: 1rem;
  text-align: center;
}

.ksk-formula-carousel {
  overflow: hidden;
  border: 1px solid #d8e1ec;
  border-radius: 8px;
  background: #ffffff;
}

.ksk-formula-slide:not(.is-selected) {
  display: none;
}

.ksk-formula-slide {
  padding: 1rem 1.15rem 0.8rem;
}

.ksk-formula-slide h2 {
  margin: 0;
  color: #1e293b;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

.ksk-formula-expression {
  display: grid;
  gap: 0.25rem;
  margin: 0.7rem 0 0.45rem;
  color: #0f172a;
  font-family: Cambria, "Times New Roman", serif;
  font-size: 1.15rem;
  text-align: center;
}

.ksk-fraction {
  display: inline-grid;
  grid-template-rows: auto auto;
  margin: 0 0.15rem;
  text-align: center;
  vertical-align: middle;
}

.ksk-fraction > span:first-child {
  border-bottom: 1px solid currentColor;
  padding: 0 0.18rem 0.08rem;
}

.ksk-fraction > span:last-child {
  padding: 0.08rem 0.18rem 0;
}

.ksk-formula-note {
  margin: 0;
  color: #475569;
  font-size: 0.95rem;
  text-align: center;
}

.ksk-carousel-status {
  color: #64748b;
  font-size: 0.85rem;
  padding: 0.4rem 0;
  text-align: center;
}

.ksk-carousel-controls {
  display: grid;
  grid-template-columns: 2.4rem 1fr 2.4rem;
  align-items: center;
  border-top: 1px solid #e2e8f0;
}

.ksk-carousel-button {
  height: 2.2rem;
  border: 0;
  background: transparent;
  color: #36516d;
  cursor: pointer;
  font-size: 1.15rem;
}

.ksk-carousel-button:hover,
.ksk-carousel-button:focus-visible {
  background: #eef4f8;
}

.ksk-currency-perspective {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  margin: 0.5rem 0 0.3rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid #d8e1ec;
  border-radius: 6px;
  color: #334155;
  font-size: 0.92rem;
}

.ksk-currency-perspective legend {
  padding: 0 0.25rem;
  font-weight: 600;
}

.ksk-currency-perspective label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.ksk-currency-operation {
  width: fit-content;
  max-width: calc(100% - 1.5rem);
  margin: -0.45rem auto 1rem;
}

#ksk-indicator-block {
  width: 100%;
  border: 1px solid #d8e1ec;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  padding: clamp(12px, 1.5vw, 20px);
}

:root {
  --primary-color: #2d3e50;
  --secondary-color: #34495e;
  --bg-color: #ffffff;
  --text-color: #222222;
  --border-color: #cccccc;
  --error-color: #dc2626;
  --success-color: #16a34a;
  --warning-color: #ca8a04;
  --light-bg: #f8fafc;
  --shadow-light: rgba(0, 0, 0, 0.1);
}

@media (min-width: 769px) {
  main {
    width: min(100%, 68rem) !important;
    max-width: 68rem !important;
    padding: 2rem 2.5rem 2.5rem;
  }

  main > h1 {
    font-size: 2rem !important;
    margin-bottom: 0.75rem;
  }

  .ksk-formula-selector,
  #ksk-indicator-block {
    font-size: 1.08rem;
  }

  #ksk-indicator-block {
    padding: 1.75rem;
  }

  #ksk-indicator-block .app-input,
  #ksk-indicator-block select {
    font-size: 1rem;
    min-height: 2.4rem;
  }

  #kskDataTable,
  #kskResults table {
    font-size: 1rem;
  }

  .app-btn {
    min-height: 3.25rem;
    font-size: 1.05rem;
  }
}

@media (max-width: 768px) {
  main {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0.75rem !important;
  }

  #ksk-indicator-block {
    padding: 0.85rem;
  }

  .overflow-x-auto {
    max-width: 100vw !important;
    overflow-x: scroll !important;
    -webkit-overflow-scrolling: touch;
  }

  .footer-details {
    font-size: 0.86rem;
    padding: 8px;
  }

  .footer-details > summary {
    font-size: 0.9rem;
  }

  button {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 44px;
  }

  table {
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  main {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0.6rem !important;
  }

  #ksk-indicator-block {
    padding: 0.6rem;
  }
}

/* Меню (header/nav) */
header {
  background: #2d3e50;
  color: #fff;
  margin-bottom: 20px;
  position: static;
}
.main-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 0 clamp(12px, 2.2vw, 30px);
  height: 56px;
  position: relative;
}
.logo {
  font-weight: bold;
  font-size: 20px;
  color: #fff;
  text-decoration: none;
}
.nav-links {
  display: flex;
  gap: 18px;
}
.nav-links a {
  color: #fff;
  text-decoration: none;
  font-size: 16px;
  padding: 8px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}
.nav-links a:hover {
  background: #1a2533;
}

.nav-links a:focus-visible,
.menu-toggle:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
  border-radius: 6px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
}

@media (max-width: 768px) {
  .main-nav {
    flex-wrap: wrap;
    height: auto;
    padding: 0 8px;
  }
  .nav-links {
    flex-direction: column;
    width: 100%;
    display: none;
    background: #2d3e50;
    position: absolute;
    top: 56px;
    left: 0;
    z-index: 10;
  }
  .nav-links.active {
    display: flex;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
  }
  .menu-toggle {
    display: block;
  }
}

/* Підвал (footer) */
footer {
  padding: 16px;
  background: #f2f2f2;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}

footer section p {
  line-height: 1.55;
}

footer section p:first-child {
  font-weight: 700;
  letter-spacing: 0.01em;
}

footer section p:nth-child(2) {
  color: #334155;
}

footer a {
  margin-left: 10px;
  color: #2d3e50;
  text-decoration: underline;
}

.app-input {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.app-input:focus {
  border-color: #2d3e50;
  box-shadow: 0 0 0 3px rgba(45, 62, 80, 0.14);
}

.ksk-row-type--stimulator {
  border-color: #a9c6b0;
  background-color: #f3f8f3;
  color: #356b43;
}

.ksk-row-type--destimulator {
  border-color: #d6be9b;
  background-color: #faf6ed;
  color: #765632;
}

.ksk-row-type option[value="stimulator"] {
  background-color: #f3f8f3;
  color: #356b43;
}

.ksk-row-type option[value="destimulator"] {
  background-color: #faf6ed;
  color: #765632;
}

.ksk-row-type:focus-visible {
  outline: 2px solid #36516d;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(54, 81, 109, 0.12);
}

.app-btn {
  min-height: 44px;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 22px rgba(26, 37, 51, 0.12);
}

.app-btn:hover {
  box-shadow: 0 14px 30px rgba(26, 37, 51, 0.18);
}

.footer-details {
  text-align: left;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  padding: 8px 10px;
  background: inherit;
}

.footer-details > summary {
  cursor: pointer;
  font-weight: 500;
  color: #1e293b;
  list-style: none;
}

.footer-details > summary::-webkit-details-marker {
  display: none;
}

.footer-details > summary::marker {
  content: "";
}

.footer-details > summary::after {
  content: "▸";
  font-weight: 700;
  margin-left: 8px;
  color: #475569;
}

.footer-details[open] > summary::after {
  content: "▾";
}

.footer-authors {
  margin-top: 8px;
}

.footer-authors p {
  margin: 0 0 6px;
}

.footer-authors p:last-child {
  margin-bottom: 0;
}

.footer-label {
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 700;
}

.footer-authors-list {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.footer-authors-list li {
  position: relative;
  margin: 0 0 8px;
  padding-left: 1.25rem;
}

.footer-authors-list li::before {
  content: "▸";
  position: absolute;
  left: 0;
  top: 0;
  color: #334155;
  font-size: 0.9em;
}

.footer-authors-note {
  display: block;
  margin-top: 2px;
  color: #475569;
}

.footer-name-emphasis {
  font-weight: 400;
  color: #0f172a;
  letter-spacing: 0.01em;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 9999;
  background: #0f172a;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 10px;
}

.sum-row {
  background-color: #f1f5f9;
  font-weight: bold;
}
.sum-row td {
  font-family: inherit !important;
  letter-spacing: normal !important;
  color: #222 !important;
}

/* Прибираємо синій фон autofill у всіх сучасних браузерах */
input:-webkit-autofill,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
input:-webkit-autofill:hover {
  background: none !important;
  box-shadow: 0 0 0 1000px white inset !important;
  -webkit-box-shadow: 0 0 0 1000px white inset !important;
  -webkit-text-fill-color: #222 !important;
  transition: background-color 5000s ease-in-out 0s;
}

.input-table-scroll {
  width: 100%;
  max-width: 100%;
  max-height: 420px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.ksk-table-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.35rem;
}

.ksk-transpose-btn {
  width: 36px;
  height: 32px;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  background: #f8fafc;
  color: #1e3a5f;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.ksk-transpose-btn:hover,
.ksk-transpose-btn:focus-visible {
  border-color: #2d3e50;
  background: #eaf0f7;
}

#kskDataTable th:first-child,
#kskDataTable td:first-child {
  width: 1%;
  white-space: nowrap;
}

#kskDataTable .ksk-row-type {
  width: max-content !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

input:focus,
button:focus {
  outline: 2px solid #2d3e50;
  outline-offset: 2px;
}

* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.overflow-x-auto {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
