/* Sticky footer без зайвої прокрутки */
* {
  box-sizing: border-box;
}
html,
body {
  min-height: 100vh;
  margin: 0;
  padding: 0;
}
body {
  font-family: Arial, sans-serif;
  text-align: center;
  display: flex;
  flex-direction: column;
}
main {
  flex: 1 0 auto;
  padding: 20px; /* Додаємо відступи тільки для контенту */
}

/* CSS змінні для кращої кастомізації */
: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 (max-width: 768px) {
  main {
    padding: 0.75rem !important;
  }
  
  .overflow-x-auto {
    max-width: 100vw !important;
    overflow-x: scroll !important;
    -webkit-overflow-scrolling: touch;
  }
  
  #dataTable {
    min-width: 400px !important;
    font-size: 0.875rem;
  }
  
  #dataTable input {
    min-width: 80px !important;
    padding: 0.25rem !important;
    font-size: 0.875rem;
  }
  
  .table-title {
    font-size: 0.875rem !important;
    margin-bottom: 0.5rem !important;
  }
  
  button {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 44px;
  }
  
  .tab-btn {
    padding: 0.375rem 0.75rem !important;
    font-size: 0.75rem !important;
    min-height: 40px;
  }
  
  table {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  #dataTable {
    min-width: 350px !important;
  }
  
  #dataTable input {
    min-width: 60px !important;
    padding: 0.125rem !important;
  }
  
  main {
    padding: 0.5rem !important;
  }
}

/* Меню (header/nav) */
header {
  background: #2d3e50;
  color: #fff;
  margin-bottom: 20px;
}
.main-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 16px;
  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;
}
.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;
  }
  .menu-toggle {
    display: block;
  }
}

/* Підвал (footer) */
footer {
  padding: 16px;
  background: #f2f2f2;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}
footer a {
  margin-left: 10px;
  color: #2d3e50;
  text-decoration: underline;
}

.mode-toggle-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}
.mode-label {
  font-size: 16px;
  color: #222;
  min-width: 180px;
  text-align: center;
}
.switch {
  position: relative;
  display: inline-block;
  width: 54px;
  height: 28px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}
.switch input:checked + .slider {
  background-color: #2d3e50; /* основний колір сайту */
}
.switch input:checked + .slider:before {
  transform: translateX(26px);
}

/* Якщо потрібно повернути фокус для input (не обов'язково, але якщо буде) */
input:focus {
  outline: 2px solid #2d3e50; /* основний колір сайту */
  outline-offset: 2px;
}

.sum-row {
  background-color: #f1f5f9;
  font-weight: bold;
}
.sum-row td {
  font-family: inherit !important;
  letter-spacing: normal !important;
  color: #222 !important;
}

/* Перевірте, чи немає такого або подібного коду: */
input[type="number"]:focus,
input[type="number"]:active,
input[type="number"]:autofill,
input:autofill,
input:-webkit-autofill {
  background: none !important;
  box-shadow: none !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[type="number"]:autofill,
input:autofill {
  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;
}

/* Виділення активної вкладки мульти-режиму */
.single-tab-btn[data-active="1"],
.multi-tab-btn[data-active="1"] {
  background-color: #e5e7eb !important;
  color: #222 !important;
  border-color: #e5e7eb !important;
  font-weight: 600;
}

/* Для сінгл-режиму: прибрати відступи між формулою та таблицею */
#singleTabContents .math-formula,
#singleTabContents .formula-block,
#singleTabContents .formula,
#singleTabContents .math,
#singleTabContents .katex,
#singleTabContents .mjx-container {
  margin-bottom: 0 !important;
  padding-bottom: 0 !important;
}
#singleTabContents .single-calc-table-block {
  margin-top: 0 !important;
  padding-top: 0 !important;
}
#singleTabContents .single-formula-block {
  margin-bottom: 0 !important;
  padding-bottom: 0 !important;
}

/* Accessibility improvements */
.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;
}

/* Focus improvements for accessibility */
input:focus,
button:focus {
  outline: 2px solid #2d3e50;
  outline-offset: 2px;
}

/* Touch improvements for mobile */
@media (hover: none) and (pointer: coarse) {
  button {
    min-height: 44px;
    min-width: 44px;
  }
  
  input[type="number"],
  input[type="text"] {
    min-height: 44px;
  }
}

/* Правильний порядок CSS префіксів */
.rounded {
  -webkit-border-radius: 0.375rem;
  border-radius: 0.375rem;
}

.rounded-md {
  -webkit-border-radius: 0.375rem;
  border-radius: 0.375rem;
}

.shadow {
  -webkit-box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.shadow-md {
  -webkit-box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Видаляємо застарілі властивості */
/* -webkit-text-size-adjust: 100%; */ /* застаріле */

/* Performance improvements - видалено застарілі властивості */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Оптимізація перерисовки */
.overflow-x-auto {
  will-change: scroll-position;
  -webkit-overflow-scrolling: touch;
}

/* GPU acceleration для анімацій */
.transition {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Покращення для жестів та touch-інтерфейсу */
@media (hover: none) and (pointer: coarse) {
  /* Збільшуємо область натискання для touch-пристроїв */
  .tab-btn {
    min-height: 48px;
    min-width: 48px;
    padding: 0.75rem 1rem;
  }
  
  /* Покращення для input-полів на touch-пристроях */
  input[type="number"],
  input[type="text"] {
    font-size: 16px; /* Запобігає zoom на iOS */
    min-height: 48px;
  }
  
  /* Покращення для кнопок */
  button {
    min-height: 48px;
    min-width: 48px;
    padding: 0.75rem 1rem;
  }
  
  /* Покращення hover-ефектів для touch */
  button:active,
  .tab-btn:active {
    background-color: #e5e7eb;
    transform: scale(0.98);
  }
}

/* Покращення доступності для скрін-рідерів */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Підтримка темної теми */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #1a1a1a;
    --text-color: #e5e5e5;
    --border-color: #333;
  }
  
  /* Цей код можна розкоментувати, коли буде потреба у темній темі
  body {
    background-color: var(--bg-color);
    color: var(--text-color);
  }
  
  table {
    border-color: var(--border-color);
  }
  */
}

/* Стилі для заголовка таблиці */
.text-xl {
    font-size: 1rem;
    line-height: 1.5;
    font-weight: bold;
    margin: 1rem 0 0.25rem 0;
    padding: 0;
    text-align: center;
    color: var(--text-color);
}

.font-bold {
    font-weight: bold;
}

.text-gray-800 {
    color: var(--text-color);
}

.mb-4 {
    margin-bottom: 0.25rem;
}

.input-table-scroll {
  max-height: 420px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

/* Стилі для заголовка вхідної таблиці */
.input-table-title {
    font-size: 1rem;
    line-height: 1.5;
    font-weight: 600;
    margin: 1rem 0 0.25rem 0;
    padding: 0;
    text-align: center;
    color: var(--text-color);
}

#singleTabs {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
}

#singleTabs.hidden {
  display: none;
}

#singleTabs:not(.hidden) {
  display: block;
}

/* Стили для текста с коэффициентом K */
.coefficient-value {
  font-weight: 600;
  color: #2d3e50;
}

/* Стилі для вашого інпутбокса з класом norm-input */
.norm-input {
  border: 1px solid #4a4a4a; /* Тонка рамка 1px, графітовий колір */
  border-radius: 4px;      /* Трохи заокруглені кути для м'якшого вигляду */
}

/* Стилі для помилок валідації input-error */
input.input-error {
  background-color: #ffc0cb !important;
  color: #333;
}

input.input-error::placeholder {
  color: #ff69b4;
}