/* ============================================================
   ROOT VARIABLES
============================================================ */
:root {
  --header-h: 66px; /* высота header */
  --menu-w: 230px;  /* ширина мобильного меню */
  --icon-size: 20px; /* размер иконок */
  --icon-gap: 8px;   /* отступ между иконкой и текстом */
}


/* ============================================================
   RADIO BUTTONS — GRAPHITE ACCENT
============================================================ */
input[type="radio"] {
  accent-color: #1f2933;
}

/* ============================================================
   GLOBAL RESET
============================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
}


/* ============================================================
   BODY BACKGROUND (GRID — softer version)
============================================================ */
body {
  background-color: #f8f8f8;

  background-image:
    /* 1 мм — тонкие */
    linear-gradient(to right, rgba(0,0,0,0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0,0,0,0.03) 1px, transparent 1px),

    /* 5 мм — средние */
    linear-gradient(to right, rgba(0,0,0,0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0,0,0,0.06) 1px, transparent 1px),

    /* 10 мм — основные */
    linear-gradient(to right, rgba(0,0,0,0.09) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0,0,0,0.09) 1px, transparent 1px);

  background-size:
    3.78px 3.78px, 3.78px 3.78px,
    18.9px 18.9px, 18.9px 18.9px,
    37.8px 37.8px, 37.8px 37.8px;

  background-attachment: fixed;
}


/* ============================================================
   UNIFIED BUTTON STYLE — 42px
============================================================ */
.cv-link,
.access-btn,
.password-entry button[type="submit"],
.carousel-controls button {
  display: flex;               /* flex для вертикального центрирования текста */
  align-items: center;         /* центр по вертикали */
  justify-content: center;     /* центр по горизонтали */
  height: 42px;                /* фиксированная высота */
  padding: 0 20px;             /* только горизонтальный padding */
  font-size: 16px;             /* размер текста */
  border-radius: 6px;          /* общий радиус */
  background: #1f2933;         /* основной фон */
  color: #fff;
  border: none;
  cursor: pointer;
  text-align: center;
  transition: background 0.25s ease;
}

.cv-link:hover,
.access-btn:hover,
.password-entry button[type="submit"]:hover,
.carousel-controls button:hover {
  background: #11171a;         /* hover фон */
}

/* ---------------- Show All / Show Filtered — disabled ----------------- */

button#showAllProjectsBtn:disabled {
    background: #cccccc;   /* светло-серый фон */
    color: #fff;           /* белый текст */
    cursor: default;       /* не кликабельная */
    opacity: 1;            /* полностью видимая */
    border: none;
}

/* Hover на disabled не меняет фон */
button#showAllProjectsBtn:disabled:hover {
    background: #cccccc;
}


/* ============================================================
   HEADER (FIXED)
============================================================ */
header {
  background: #1f2933;
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-h);
  z-index: 1000;
}

.header-inner {
  max-width: 1200px;
  margin: auto;
  padding: 15px 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}


/* ---------------- LOGO ---------------- */
.logo {
  font-weight: bold;
  font-size: 18px;
  cursor: pointer;
}

.logo:hover {
  text-decoration: underline;
}


/* ---------------- DESKTOP MENU ---------------- */
nav ul {
  list-style: none;
  display: flex;
  gap: 25px;
}

nav a {
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  display: flex;
  align-items: center;
}

nav a:hover {
  text-decoration: underline;
}


/* ---------------- HEROICONS ---------------- */
.icon {
  width: var(--icon-size);
  height: var(--icon-size);
  margin-right: var(--icon-gap);
  vertical-align: middle;
  stroke: #fff;
  flex-shrink: 0;
  display: none;
}


/* ---------------- BURGER ICON ---------------- */
.burger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  z-index: 1100;
}

.burger div {
  width: 25px;
  height: 3px;
  background: #fff;
  transition: 0.3s;
}

.burger.active div:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.burger.active div:nth-child(2) {
  opacity: 0;
}

.burger.active div:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}


/* ============================================================
   MOBILE MENU
============================================================ */
@media (max-width: 768px) {

  #menu {
    position: fixed;
    top: var(--header-h);
    right: calc(-1 * var(--menu-w));
    width: var(--menu-w);
    padding: 16px;
    background: #1f2933;

    display: flex;
    flex-direction: column;
    gap: 14px;

    opacity: 0;
    pointer-events: none;
    transition: right 0.45s ease, opacity 0.45s ease;

    box-shadow: -3px 6px 14px rgba(0,0,0,0.28);
    z-index: 1050;
  }

  #menu.active {
    right: 0;
    opacity: 1;
    pointer-events: auto;
  }

  .burger {
    display: flex;
  }

  .icon {
    display: inline-block;
  }

  nav ul:not(#menu) {
    display: none;
  }
}


/* ============================================================
   HERO SECTION WITH PHOTO LEFT & TEXT RIGHT
============================================================ */

/* --- Переменные для десктопа --- */
:root {
  --hero-height: 300px;            /* высота блока HERO */
  --hero-photo-gap-top: 70px;      /* верхний отступ фото */
  --hero-photo-gap-bottom: 20px;   /* нижний отступ фото */
}

.hero {
  position: relative;
  overflow: hidden;
  min-height: var(--hero-height);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: url("hero.jpg") center center no-repeat;
  background-size: cover;
  transform: scale(1);
  animation: heroZoom 8s ease-in-out infinite alternate;
  will-change: transform;
  z-index: -1;
}

.hero-overlay{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,0.35);

  display:flex;
  justify-content:center;
}

.hero-inner {
  max-width: 1100px;
  margin: auto;

  padding-top: 50px;
  padding-bottom: 50px;
  padding-left: 20px;
  padding-right: 20px;

  display: flex;
  gap: 40px;
  color: #fff;
  align-items: flex-start;
}

/* Фото */
.hero-photo {
  flex:0 0 200px;
  width:200px;
  height:200px;
  object-fit:cover;
  border:2px solid rgba(255,255,255,0.6);
  border-radius:4px;
  background:#ccc;
  margin-top:var(--hero-photo-gap-top);
  margin-bottom:var(--hero-photo-gap-bottom);
}

/* Текст справа от фото */
.hero-text {
  margin-top: var(--hero-photo-gap-top); /* выравнивание по верхнему краю фото */
  flex: 1; /* занимает всё свободное место до правой границы */
}

.hero h1 {
  font-size: 28px;
  margin-bottom: 10px;
  white-space: nowrap;
  letter-spacing: -0.5px;
}

.hero p {
  max-width: none;
}

/* ---------------- TEXT ALIGNMENT ---------------- */

.hero-text p {
  text-align: justify;
  hyphens: auto;
}

.card p {
  text-align: justify;
  hyphens: auto;
}



/* Анимация фона */
@keyframes heroZoom {
  from { transform: scale(1) translate(0,0); }
  to { transform: scale(1.22) translate(-4%,-4%); }
}

/* ---------------- HERO MOBILE ---------------- */
@media (max-width: 768px) {
  .hero {
    min-height: 100vh;
    margin-top: 0;
  }

  .hero-overlay {
    flex-direction: column;
    padding: 40px 20px;
  }

  .hero-inner {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }

  .hero::before {
    animation: heroZoom 10s ease-in-out infinite alternate;
  }

  .hero-photo,
  .hero-text {
    margin-top: initial;
    margin-bottom: initial;
  }
}

/* ---------------- REDUCED MOTION ---------------- */
@media (prefers-reduced-motion: reduce) {
  .hero::before {
    animation: none;
    transform: scale(1.08);
  }
}


/* ============================================================
   GLOBAL CONTAINER
============================================================ */

.container{
  max-width:1100px;
  margin:auto;
  padding:0 20px;
}


/* ============================================================
   SECTIONS (GENERAL)
============================================================ */
section {
  max-width: 1100px;
  margin: auto;
  padding: 50px 20px;
}

section h2 {
  margin-bottom: 20px;
}

section h3 {
  margin: 20px 0 10px;
}

.card {
  background: #fff;
  padding: 25px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}


/* ============================================================
   ABOUT SECTION (TEXT READABILITY)
============================================================ */

#about p {
  line-height: 1.55;
}

#about p + p {
  margin-top: 0.65em;
}


/* ============================================================
   HERO LINK STYLE
============================================================ */

/* языковые отступы */
html[lang="en"] {
  --hero-cv-gap: 60px;
}

html[lang="et"] {
  --hero-cv-gap: 60px;
}

html[lang="ru"] {
  --hero-cv-gap: 60px;
}

.hero-cv {
  display: inline-block;
  margin-top: var(--hero-cv-gap, 43px); /* регулируемый зазор */

  font: inherit;
  font-weight: bold;
  font-size: 18px;
  color: #fff;
  text-decoration: none;
}

/* общий hover как у логотипа */
.logo:hover,
.hero-cv:hover {
  text-decoration: underline;
}


/* ============================================================
   COMPANY WEBSITE BUTTON — только иконка и disabled
============================================================ */

/* disabled — как все .cv-link */
#companySiteBtn:disabled,
#companySiteBtn.disabled {
  background: #999;
  cursor: not-allowed;
  opacity: 0.5;
  pointer-events: none;
}

/* иконка глобуса слева от текста */
#companySiteBtn svg.icon-heroicon {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  vertical-align: middle;
  stroke: currentColor;
}


/* ============================================================
   FILTER ROW (COMPANY + WEBSITE BUTTON)
============================================================ */

.company-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.company-row .combo-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* обе кнопки сайтов */
.company-row .cv-link {
  flex-shrink: 0;
  margin-left: 6px;
}


/* ============================================================
   DESKTOP FILTER ALIGNMENT
============================================================ */

@media (min-width: 769px) {

  .company-row .cv-link {
    flex: 0 0 200px;
    justify-content: center;
  }

}


/* ============================================================
   MOBILE ADAPTATION (FILTERS)
============================================================ */
@media (max-width: 768px) {

  /* фильтр года растягиваем по ширине контейнера */
  .filter-item:first-child .combo-row {
    width: 100%;
  }

  .company-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .company-row .combo-row {
    width: 100%;
  }

  .company-row #companySiteBtn,
  .company-row #profileSiteBtn {
    width: 100%;
    text-align: center;
    margin-left: 0;
    margin-top: 6px;
  }

}


/* ============================================================
   FILTER ALIGNMENT
============================================================ */
.filter-item .combo-row,
.company-row {
  justify-content: flex-start;
}


/* ============================================================
   COMPANY WEBSITE DROPDOWN
============================================================ */

.company-dropdown {
  position: relative;
  flex-shrink: 0;
}

.company-arrow {
  margin-left: 8px;
  font-size: 10px;
  transition: transform 0.22s ease;
}

.company-dropdown.open .company-arrow {
  transform: rotate(180deg);
}

.company-menu {
  position: absolute;

  top: calc(100% + 8px);
  left: 0;

  min-width: 240px;

  background: rgba(31,41,51,0.96);

  backdrop-filter: blur(10px);

  border-radius: 10px;

  overflow: hidden;

  opacity: 0;
  visibility: hidden;

  transform: translateY(-6px);

  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    visibility 0.22s ease;

  z-index: 5000;

  box-shadow:
    0 12px 30px rgba(0,0,0,0.22);
}

.company-dropdown.open .company-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.company-menu-item {
  display: block;

  width: 100%;

  padding: 14px 18px;

  border: 0;

  background: transparent;

  color: white;

  text-align: left;

  text-decoration: none;

  cursor: pointer;

  border-bottom:
    1px solid rgba(255,255,255,0.08);

  transition:
    background 0.18s ease;
}

.company-menu-item:last-child {
  border-bottom: none;
}

.company-menu-item:hover {
  background: rgba(255,255,255,0.08);
}



/* ============================================================
   SKILLS CATEGORY HEADERS
============================================================ */

#skills h3{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:14px;

  margin:40px 0 20px;

  font-size:18px;
  font-weight:600;
  letter-spacing:.05em;
  text-transform:uppercase;
}

#skills h3::before,
#skills h3::after{
  content:"";
  flex:1;
  max-width:120px;   /* ограничивает длину линии */
  height:1px;
  background:#dcdcdc;
}


/* ============================================================
   SKILLS SECTION
============================================================ */

/* строка навыка */
.skill{
  display:flex;
  align-items:center;
  gap:15px;
  margin-bottom:14px;
}


/* Название программы: перенос длинных названий без сжатия прогресс-бара */
.skill-name{
  flex:0 0 200px;
  min-width:0;
  white-space:normal;
  overflow-wrap:anywhere;
  line-height:1.25;
}


/* контейнер бара */
.skill-bar{
  flex:1 1 auto;
  height:12px;
  background:#e5e5e5;
  border-radius:6px;
  overflow:hidden;
}


/* заполнение бара */
.skill-progress{
  height:100%;
  width:0;
  background:#2c3640;
  border-radius:6px;
  transition:width 1.2s ease;
}


/* процент */
.skill-percent{
  flex:0 0 40px;
  text-align:right;
}

/* ============================================================
      SKILLS MOBILE
============================================================ */

@media (max-width:768px){

  .skill{
    display:grid;
    grid-template-columns:1fr auto;
    grid-template-rows:auto auto;
    gap:6px 10px;
  }

  .skill-name{
    grid-column:1;
    grid-row:1;
  }

  .skill-percent{
    grid-column:2;
    grid-row:1;
    text-align:right;
  }

  .skill-bar{
    grid-column:1 / span 2;
    grid-row:2;
    width:100%;
    height:10px;
  }

}


/* ============================================================
   PUBLICATIONS
============================================================ */
.publications-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.publications-list li {
  margin-bottom: 12px;
}

.publications-list li:last-child {
  margin-bottom: 0;
}

.publications-list a {
  display: inline-block;
  box-sizing: border-box;
  width: 215px;
  max-width: 100%;
  padding: 10px 15px;
  background: #1f2933;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-size: 16px;
  text-align: center;
  transition: background 0.3s;
}

.publications-list a:hover {
  background: #11171a;
}

/* ---------------- PUBLICATIONS MOBILE ---------------- */
@media (max-width: 480px) {
  .publications-list a {
    display: block;
    width: 100%;
    text-align: center;
    margin-bottom: 10px;
  }

  .publications-list a:last-child {
    margin-bottom: 0;
  }
}


/* ============================================================
   FOOTER
============================================================ */
footer {
  background: #1f2933;
  color: #fff;
  text-align: center;
  padding: 25px;
  font-size: 14px;

  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 900;
  margin-top: 0;
}

/* ---------------- FOOTER MOBILE ---------------- */
@media (max-width: 768px) {

  footer {
    position: static;
    width: 100%;
    margin-top: 40px;
  }
}


/* ============================================================
   LANGUAGE MENU
============================================================ */
.lang {
  font-size: 13px;
  color: #ccc;
}

.lang a {
  text-decoration: none;
  color: #ccc;
}

.lang a:hover {
  color: #fff;
}

.lang strong {
  color: #fff;
  font-weight: normal;
}


/* ============================================================
   PROJECTS — SHOW CARDS
============================================================ */

.project-cards-toggle {
  margin: 4px 0 18px;
  padding: 8px 12px;

  border: 1px solid #ddd;
  border-radius: 6px;

  background: #f7f7f7;
}

.project-cards-toggle label {
  display: flex;
  align-items: center;
  gap: 8px;

  width: fit-content;

  font-size: 14px;
  color: #444;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}

.project-cards-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;

  accent-color: #1f2933;
  cursor: pointer;
}

/* ============================================================
   PROJECT FILTER COMBO — UNIFIED & RESPONSIVE
============================================================ */

/* ================== Контейнеры фильтров ================== */
.project-filter,
.filter-item {
  display: flex;
  flex-direction: column;
  gap: 12pt;
  margin-bottom: 0;
}

.filter-item {
  gap: 6px;
}

/* ================== Комбо + кнопка сброса ================== */
.combo-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.company-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Селекты внутри фильтров — светлый стиль Market Monitor */
.project-filter select.combo,
.company-row select.combo {
  flex: 0 0 auto;
  width: 220px;
  min-width: 140px;
  height: 42px;
  padding: 10px 20px;
  font-size: 16px;
  border-radius: 6px;
  border: 1px solid #c9cdd1;
  background-color: #fff;
  color: #1f2933;
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: none;
  text-shadow: none;
  transition: border-color 0.18s ease;
}

.project-filter select.combo:hover,
.company-row select.combo:hover {
  background-color: #fff;
  border-color: #8b9299;
}

.project-filter select.combo:focus,
.company-row select.combo:focus {
  background-color: #fff;
  color: #1f2933;
  border-color: #1f2933;
  outline: none;
  box-shadow: none;
}

/* ================== Кнопка сброса ================== */
.combo-reset {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  border-radius: 6px;
  background: #fff;
  color: #5f6670;
  border: 1px solid #c9cdd1;
  box-shadow: none;
  text-shadow: none;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease;
}

.combo-reset:hover {
  background: #fff;
  color: #1f2933;
  border-color: #8b9299;
}

.combo-reset:focus,
.combo-reset:active,
.combo-reset:focus-visible {
  background: #fff;
  color: #1f2933;
  border-color: #1f2933;
  outline: none;
  box-shadow: none;
}

.combo-reset svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

/* ================== Кнопка Company website / CV ================== */
.cv-link {
  height: 42px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: #1f2933;
  color: #fff;
  cursor: pointer;
  transition: background 0.25s ease;
}

.cv-link:disabled,
.cv-link.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  background: #999;
}

.cv-link:hover:not(:disabled):not(.disabled) {
  background: #11171a;
}

/* ================== Мобильные экраны (телефоны) ================== */
@media(max-width: 768px) {

  .project-filter {
    gap: 10pt;
  }

  /* строка select + reset */
  .combo-row{
    width:100%;
  }

  /* селект растягивается */
  .project-filter select.combo,
  .company-row select.combo {
    flex:1;
    width:100%;
    min-width:0;
    max-width:none;
    font-size:14px;
  }

  /* reset кнопка фиксированная */
  .combo-reset{
    flex:0 0 42px;
  }

  /* company filter */
  .company-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .company-row .combo-row {
    width: 100%;
  }

  /* кнопки сайтов */
  #profileSiteBtn,
  #companySiteBtn {
    width:100%;
    text-align:center;
    margin-top:6px;
  }

}

/* ================== Планшеты ================== */
@media(min-width: 769px) and (max-width: 1024px) {
  .project-filter select.combo,
  .company-row select.combo {
    flex: 1;
    min-width: 140px;
    max-width: none;
    font-size: 15px;
  }
}

/* ================== Десктоп ================== */
@media(min-width: 1025px) {
  .project-filter select.combo,
  .company-row select.combo {
    max-width: 400px;
    font-size: 16px;
  }
}


/* ============================================================
   GALLERY (HORIZONTAL SCROLL)
============================================================ */
.gallery-wrapper {
  overflow-x: auto;
  padding-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}

.gallery {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
}

.gallery a {
  flex: 0 0 auto;
  display: block;
}

.gallery img {
  display: block;
  height: 180px;
  width: auto;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.3s;
}

.gallery img:hover {
  transform: scale(1.05);
}


/* ---------------- GALLERY SCROLLBAR ---------------- */
.gallery-wrapper::-webkit-scrollbar {
  height: 8px;
}

.gallery-wrapper::-webkit-scrollbar-thumb {
  background-color: #aaa;
  border-radius: 4px;
}


/* ---------------- GALLERY MOBILE ---------------- */
@media (max-width:768px) {
  .gallery img {
    height: 140px;
  }
}

@media (max-width:480px) {
  .gallery img {
    height: 120px;
  }
}



/* ============================================================
   CV BUTTON
============================================================ */
#cv .cv-link {
  display: inline-block;
  width: 215px;
  box-sizing: border-box;
  padding: 10px 20px;
  background: #1f2933;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-size: 16px;
  transition: background 0.3s;
  text-align: center;
  margin-top: 12px;
}

#cv .cv-link:hover {
  background: #11171a;
}

#cv .cv-link.disabled,
#cv .cv-link:disabled {
  background: #999;
  cursor: not-allowed;
  opacity: 0.5;
  pointer-events: none;
}

#cv .cv-link.history::after {
  content: " ↗";
  font-size: 14px;
  margin-left: 6px;
  opacity: 0.85;
}

/* ---------------- CV MOBILE ---------------- */
@media (max-width: 480px) {
  #cv .cv-link {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 10px;
  }
}



/* ============================================================
   DRAWINGS SECTION
============================================================ */
#drawings .card {
  padding: 25px 25px 5px 25px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* ---------------- DRAWINGS LINKS ---------------- */
.drawing-links {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.drawing-links .cv-link {
  flex: 1;
  text-align: center;
  min-width: 150px;
  display: inline-block;
  padding: 10px 20px;
  background: #1f2933;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.25s;
  font-size: 16px;
}

/* ---------------- REQUEST ACCESS BUTTON ---------------- */
#drawings .access-btn {
  display: block;
  width: 215px;
  max-width: 100%;
  box-sizing: border-box;
  flex: none;
  text-align: center;
  padding: 10px 20px;
  background: #1f2933;
  color: #fff;
  text-decoration: none;
  border: none;
  border-radius: 6px;
  transition: background 0.25s;
  font-size: 16px;
  margin-bottom: 4px;
}

.drawing-links .cv-link:hover,
#drawings .access-btn:hover {
  background: #11171a;
}

/* Отступ после текста перед кнопкой Request Access */
#drawings p + .access-btn {
  margin-top: 12px;
}

/* ---------------- DRAWINGS MOBILE ---------------- */
@media (max-width: 768px) {
  .drawing-links {
    flex-direction: column;
  }

  .drawing-links .cv-link {
    width: 100%;
    box-sizing: border-box;
  }

  #drawings .card {
    padding-bottom: 5px;
  }
}

/* Request Access растягивается только на узких экранах */
@media (max-width: 480px) {
  #drawings .access-btn {
    width: 100%;
  }
}

/* ---------------- ADJUST BUTTON MARGINS ---------------- */
#drawings .password-entry {
  margin-top: 0;
}


/* ============================================================
   PASSWORD ENTRY
============================================================ */
.password-entry {
  margin-top: 10px;
  display: none; /* скрыто по умолчанию */
  gap: 10px;
  flex-direction: column; /* вертикально по умолчанию */
}

/* ---------------- INPUT WRAPPER ---------------- */
.input-wrapper {
  display: flex;
  align-items: stretch; /* выравнивание по высоте */
  width: 100%;
}

.password-entry input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 6px 0 0 6px; /* скругление слева */
  border: 1px solid #ccc;
  font-size: 14px;
  border-right: none; /* объединяем с кнопкой глаза */
}

.password-entry button#togglePassword {
  padding: 0 12px;
  border: 1px solid #ccc;
  border-left: none; /* объединяем с полем */
  background: #1f2933;
  color: #fff;
  border-radius: 0 6px 6px 0; /* скругление справа */
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s;
}

.password-entry button#togglePassword:hover {
  background: #11171a;
}

.password-entry button#passwordSubmitBtn {
  padding: 10px 16px;
  border: none;
  background: #1f2933;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.25s;
}

/* ---------------- DESKTOP LAYOUT ---------------- */
@media (min-width: 769px) {
  .password-entry {
    flex-direction: row;
    align-items: center;
  }

  .password-entry button#passwordSubmitBtn {
    margin-left: 10px;
  }
}

/* ---------------- MOBILE LAYOUT ---------------- */
@media (max-width: 768px) {
  .password-entry {
    flex-direction: column;
    align-items: stretch;
  }

  .password-entry button#passwordSubmitBtn {
    width: 100%;
    margin-left: 0;
  }
}

/* ============================================================
   PASSWORD MESSAGE
============================================================ */
.password-msg {
  margin-top: 6px;
  min-height: 18px;
  font-size: 14px;
}

/* ============================================================
   MODAL
============================================================ */
.modal {
  display: none; /* скрыта по умолчанию */
  position: fixed;
  inset: 0;
  z-index: 9999;
  justify-content: center;
  align-items: center;
}

/* затемнение фона */
.modal::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75); /* почти непрозрачный черный */
  z-index: 1;
}

/* модальное окно поверх затемнения */
.modal-content {
  position: relative;
  z-index: 2; /* поверх затемнения */
  background: #fff;
  padding: 24px;
  border-radius: 8px;
  width: 360px;
  max-width: 90%;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.modal-content h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.modal-content input,
.modal-content textarea {
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 10px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 14px;
}

.modal-content textarea {
  resize: vertical;
  min-height: 70px;
}

.modal-content button[type="submit"] {
  width: 100%;
  padding: 10px 0;
  background: #1f2933;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.25s;
}

.modal-content button[type="submit"]:hover {
  background: #11171a;
}

.close {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  color: #333;
}

.success {
  margin-top: 12px;
  color: green;
  text-align: center;
  font-size: 14px;
}

/* ---------------- RESPONSIVE MODAL ---------------- */
@media (max-width: 480px) {
  .modal-content {
    padding: 16px;
  }

  .modal-content h2 {
    font-size: 18px;
  }

  .modal-content button[type="submit"] {
    font-size: 14px;
  }
}


/* ============================================================
   PROJECT SYSTEM LOGOS
============================================================ */

.project-systems{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:10px;

  min-height:36px;
  margin-bottom:8px;

  border-bottom:1px solid #e5e5e5;
  padding-bottom:6px;
}

.project-systems img{
  height:28px;
  width:auto;
  max-width:90px;
  object-fit:contain;

  opacity:0.9;
}

/* ======================================================
   PROJECT PARAGRAPH MARKERS
====================================================== */

/* выравнивание текста начиная с первого маркированного абзаца */

.project p.marker-start,
.project p.marker-start ~ p{
  padding-left:14px;
  margin-top:6px;
}

/* кружок только у нужных абзацев */

.project-marker{
  position:relative;
}

.project-marker::before{
  content:"";
  position:absolute;
  left:0;
  top:0.6em;

  width:4px;
  height:4px;

  background:#444;
  border-radius:50%;
}


/* ============================================================ */
/* UNIFIED HOVER EFFECTS — PROJECTS & 3D CAROUSEL */
/* ============================================================ */


/* ------------------------------- */
/* PROJECT CARDS */

.projects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.project {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.project:hover,
.project:focus,
.project:active {
  transform: scale(1.03);
  box-shadow: 0 12px 24px rgba(0,0,0,0.15);
  outline: none;
}

.project > img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  margin-bottom: 12px;
  background: #ddd;
  transition: transform 0.3s ease, filter 0.3s ease;
}

.project:hover img,
.project:focus img,
.project:active img {
  transform: scale(1.02);
  filter: brightness(0.95);
}

.project h3 {
  margin-bottom: 5px;
  color: inherit;
}

.project p {
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}


/* overlay */

.project .overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.05);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.project:hover .overlay,
.project:focus .overlay,
.project:active .overlay {
  opacity: 1;
}


/* links */

.project a,
.project a:visited,
.project a:hover,
.project a:active,
.project a:focus {
  color: inherit;
  text-decoration: none;
}

.project:hover a,
.project:focus a,
.project:active a {
  text-decoration: underline;
}


/* icons & media buttons */

.project .icon,
.project .media-button {
  transition: transform 0.25s ease;
}

.project:hover .icon,
.project:focus .icon,
.project:active .icon,
.project:hover .media-button,
.project:focus .media-button,
.project:active .media-button {
  transform: scale(1.2);
}


/* active project */

.project-active {
  box-shadow: 0 0 0 2px #000;
}

.project-active:hover,
.project-active:focus,
.project-active:active {
  box-shadow:
    0 0 0 2px #000,
    0 12px 24px rgba(0,0,0,0.15);
}


/* ------------------------------- */
/* 3D CERTIFICATE CAROUSEL */

.carousel-container {
  width: 100%;
  height: 360px;
  margin: 32px 0;
  position: relative;
  perspective: 1200px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.carousel {
  position: relative;
  width: 226px;
  height: 320px;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  transition: transform 0.9s ease;
}

.carousel img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  cursor: pointer;
  transition: filter 0.3s ease, box-shadow 0.3s ease;
}

.carousel img:hover,
.carousel img:focus,
.carousel img:active {
  filter: brightness(0.95);
  box-shadow: 0 12px 24px rgba(0,0,0,0.15);
}


/* captions */

.carousel img + h3,
.carousel img + p {
  color: inherit;
}


/* ------------------------------- */
/* CAROUSEL CONTROLS */

.carousel-controls {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 16px;
}

.carousel-controls button {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  width: 84px;
  font-size: 20px;
  border-radius: 6px;
  background: #1f2933;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.25s ease;
}

.carousel-controls button:hover {
  background: #11171a;
}


/* ------------------------------- */
/* MOBILE */

@media (max-width: 768px) {
  .carousel-container {
    height: 280px;
    perspective: 800px;
    align-items: center;
  }

  .carousel {
    width: 155px;
    height: 219px;
  }

  .carousel-controls {
    gap: 12px;
  }

  .carousel-controls button {
    padding: 8px 14px;
    font-size: 14px;
  }
}

/* ------------------------------- */
/* CURRENT CERTIFICATE TITLE */

#certificates .certificate-current-title {
  margin: 0 0 12px;
  color: #1f2933;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

@media (max-width: 768px) {
  #certificates .certificate-current-title {
    margin-bottom: 8px;
    font-size: 15px;
  }
}

/* ------------------------------- */
/* CERTIFICATE POSITION DOTS */

#certificates .certificate-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px auto 8px;
}

#certificates .certificate-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #c7cdd2;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

#certificates .certificate-dot[aria-current="true"] {
  background: #1f2933;
  transform: scale(1.4);
}

#certificates .certificate-dot:focus-visible {
  outline: 2px solid #647789;
  outline-offset: 3px;
}

@media (max-width: 768px) {
  #certificates .certificate-dots {
    gap: 9px;
    margin: 14px auto 8px;
  }
}


/* ============================================================
   PROJECT HISTORY INDICATOR
============================================================ */
.project {
  position: relative;
}

.project.has-history .project-systems::after {
  content: "";
  margin-left: auto;

  width: 28px;
  height: 28px;

  background: url("LinksLogo/book.png") center no-repeat;
  background-size: contain;

  flex-shrink: 0;
}


.project .history-label {
  position: absolute;
  top: 28px;
  right: 10px;
  font-size: 12px;
  background: #1f2933;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s;
}

.project.has-history:hover .history-label {
  opacity: 1;
  transform: translateY(0);
}

/* ---------------- HISTORY BUTTON DISABLED ---------------- */
.cv-link.disabled,
.cv-link:disabled {
  background: #999;
  cursor: not-allowed;
  opacity: 0.5;
  pointer-events: none;
}

.cv-link.disabled:hover,
.cv-link:disabled:hover {
  background: #999;
}



/* ============================================================
   SHOW ALL / HISTORY BUTTONS (плоские, как CV)
============================================================ */
.show-all-card {
  margin-top: 12px;        /* текст → первая кнопка */
  margin-bottom: 12px;     /* после кнопок (desktop) */
}

.show-all-card p {
  margin: 0 0 12px 0;      /* текст → кнопка */
}

.show-all-card .cv-link {
  display: flex;
  padding: 10px 20px;
  margin-bottom: 10px;    /* расстояние между кнопками */
  background: #1f2933;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-size: 16px;
  transition: background 0.3s;
  text-align: center;
}

.show-all-card .cv-link:last-child {
  margin-bottom: 0;       /* убираем лишний зазор внутри */
}

.show-all-card .cv-link:hover:not(.disabled) {
  background: #11171a;
}

.show-all-card .cv-link.disabled {
  background: #999;
  cursor: not-allowed;
  opacity: 0.5;
  pointer-events: none;
}


/* ---------------- MOBILE ---------------- */
@media (max-width: 480px) {
  .show-all-card {
    margin-top: 10px;     /* текст → кнопка */
    margin-bottom: 10px;  /* после кнопок */
  }

  .show-all-card p {
    margin-bottom: 10px;
  }

  .show-all-card .cv-link {
    display: block;      /* на всю ширину */
    width: 100%;
    margin-bottom: 10px;
  }

  .show-all-card .cv-link:last-child {
    margin-bottom: 0;
  }
}


/* ============================================================
   SPACING BETWEEN HEADER CARD AND PROJECT CARDS
============================================================ */
#projects > .card:first-child {
  margin-bottom: 20px;
}

/* ============================================================
   LIGHTBOX
============================================================ */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  animation: fadeIn 0.25s forwards;
}

/* убрать рамку фокуса */
.lightbox-overlay:focus {
  outline: none;
}

.lightbox-img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
  transform: scale(1);
  touch-action: none;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 2rem;
  color: #fff;
  background: none;
  border: none;
  cursor: pointer;
}

/* ---------------- LIGHTBOX ANIMATION ---------------- */
@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

/* ============================================================
   LIGHTBOX ARROWS
============================================================ */

.lightbox-prev,
.lightbox-next{
position:absolute;
top:50%;
transform:translateY(-50%);
font-size:40px;
color:white;
background:none;
border:none;
cursor:pointer;
padding:20px;
}

.lightbox-prev{
left:30px;
}

.lightbox-next{
right:30px;
}


/* ============================================================
   YANDEX TELEMOST FLOAT BUTTON
============================================================ */

.floating-yandex {
    position: fixed;

    right: 22px;
    bottom: 170px;      /* выше Telegram */

    width: 64px;
    height: 64px;

    border-radius: 50%;

    background: #FF0000;

    display: flex;
    align-items: center;
    justify-content: center;

    z-index: 99997;

    box-shadow:
        0 10px 25px rgba(0,0,0,0.25),
        0 0 0 0 rgba(255,0,0,0.5);

    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease;

    animation: yandexPulse 2s infinite;

    text-decoration: none;

    color: white;

    font-family: Arial, sans-serif;
    font-size: 38px;
    font-weight: 700;
}

.floating-yandex:hover {
    transform: scale(1.08);

    box-shadow:
        0 14px 35px rgba(0,0,0,0.35),
        0 0 0 14px rgba(255,0,0,0);
}

.yandex-tooltip {
    position: absolute;

    right: 78px;

    background: #111827;
    color: white;

    padding: 8px 12px;

    border-radius: 10px;

    font-size: 14px;
    font-weight: 500;

    opacity: 0;

    transform: translateX(10px);

    transition: all 0.25s ease;

    pointer-events: none;

    white-space: nowrap;
}

.floating-yandex:hover .yandex-tooltip {
    opacity: 1;
    transform: translateX(0);
}

@keyframes yandexPulse {

    0% {
        box-shadow:
            0 10px 25px rgba(0,0,0,0.25),
            0 0 0 0 rgba(255,0,0,0.5);
    }

    70% {
        box-shadow:
            0 10px 25px rgba(0,0,0,0.25),
            0 0 0 18px rgba(255,0,0,0);
    }

    100% {
        box-shadow:
            0 10px 25px rgba(0,0,0,0.25),
            0 0 0 0 rgba(255,0,0,0);
    }
}

@media (max-width: 768px) {

    .floating-yandex {
        width: 58px;
        height: 58px;

        right: 16px;
        bottom: 160px;

        opacity: 0.65;
    }

    .yandex-tooltip {
        display: none;
    }
}


/* ============================================================
   YANDEX TELEMOST MODAL
============================================================ */

.telemost-modal {
    position: fixed;

    inset: 0;

    background: rgba(0, 0, 0, 0.55);

    display: flex;
    align-items: center;
    justify-content: center;

    z-index: 100000;

    opacity: 0;
    visibility: hidden;

    transition: all 0.25s ease;

    padding: 20px;
}

.telemost-modal.active {
    opacity: 1;
    visibility: visible;
}


/* WINDOW */

.telemost-window {

    position: relative;

    width: 100%;
    max-width: 380px;

    background: #ffffff;

    border-radius: 20px;

    padding: 30px;

    box-shadow:
        0 20px 60px rgba(0,0,0,0.35);

    transform: translateY(15px) scale(0.96);

    transition: all 0.25s ease;

    box-sizing: border-box;
}

.telemost-modal.active .telemost-window {

    transform: translateY(0) scale(1);

}


/* CLOSE */

.telemost-close {

    position: absolute;

    top: 12px;
    right: 16px;

    width: 32px;
    height: 32px;

    border: none;

    background: transparent;

    font-size: 28px;

    line-height: 1;

    color: #6b7280;

    cursor: pointer;
}

.telemost-close:hover {
    color: #111827;
}


/* TITLE */

.telemost-title {

    font-size: 22px;

    font-weight: 700;

    color: #111827;

    margin-bottom: 8px;

    text-align: center;
}


/* SUBTITLE */

.telemost-subtitle {

    font-size: 15px;

    color: #6b7280;

    text-align: center;

    margin-bottom: 20px;
}


/* INPUT */

.telemost-input {

    width: 100%;

    height: 52px;

    box-sizing: border-box;

    border: 1px solid #d1d5db;

    border-radius: 12px;

    padding: 0 15px;

    font-size: 16px;

    outline: none;

    text-align: center;

    transition: border-color 0.2s,
                box-shadow 0.2s;
}

.telemost-input:focus {

    border-color: #ff0000;

    box-shadow:
        0 0 0 3px rgba(255,0,0,0.12);
}


/* BUTTON */

.telemost-enter {

    width: 100%;

    height: 52px;

    margin-top: 14px;

    border: none;

    border-radius: 12px;

    background: #ff0000;

    color: #ffffff;

    font-size: 16px;

    font-weight: 600;

    cursor: pointer;

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.telemost-enter:hover {

    transform: translateY(-1px);

    box-shadow:
        0 8px 20px rgba(255,0,0,0.25);
}


/* MOBILE */

@media (max-width: 768px) {

    .telemost-window {

        max-width: 340px;

        padding: 26px 20px;

        border-radius: 18px;
    }

    .telemost-title {
        font-size: 20px;
    }

}


/* ============================================================
   TELEMOST ERROR
============================================================ */

.telemost-input.telemost-error {
    border-color: #ff0000;
    box-shadow:
        0 0 0 3px rgba(255, 0, 0, 0.15);
    animation: telemostShake 0.25s ease;
}

@keyframes telemostShake {

    0%   { transform: translateX(0); }
    25%  { transform: translateX(-6px); }
    50%  { transform: translateX(6px); }
    75%  { transform: translateX(-4px); }
    100% { transform: translateX(0); }

}


/* ============================================================
   TELEGRAM FLOAT BUTTON
============================================================ */

.tg-button {
    position: fixed;

    right: 22px;
    bottom: 96px;      /* выше WhatsApp */

    width: 64px;
    height: 64px;

    border-radius: 50%;

    background: #229ED9;

    display: flex;
    align-items: center;
    justify-content: center;

    z-index: 99998;

    box-shadow:
        0 10px 25px rgba(0,0,0,0.25),
        0 0 0 0 rgba(34,158,217,.60);

    transition:
        transform .25s ease,
        box-shadow .25s ease;

    animation: tgPulse 2s infinite;

    text-decoration: none;
}

.tg-button:hover {

    transform: scale(1.08);

    box-shadow:
        0 14px 35px rgba(0,0,0,.35),
        0 0 0 14px rgba(34,158,217,0);
}

.tg-icon{
    width:34px;
    height:34px;
}

.tg-tooltip{

    position:absolute;

    right:78px;

    background:#111827;
    color:#fff;

    padding:8px 12px;

    border-radius:10px;

    font-size:14px;
    font-weight:500;

    white-space:nowrap;

    opacity:0;

    transform:translateX(10px);

    transition:.25s;

    pointer-events:none;
}

.tg-button:hover .tg-tooltip{

    opacity:1;
    transform:translateX(0);
}

@keyframes tgPulse{

    0%{
        box-shadow:
            0 10px 25px rgba(0,0,0,.25),
            0 0 0 0 rgba(34,158,217,.60);
    }

    70%{
        box-shadow:
            0 10px 25px rgba(0,0,0,.25),
            0 0 0 18px rgba(34,158,217,0);
    }

    100%{
        box-shadow:
            0 10px 25px rgba(0,0,0,.25),
            0 0 0 0 rgba(34,158,217,0);
    }
}

@media (max-width:768px){

    .tg-button{

        width:58px;
        height:58px;

        right:16px;
        bottom:88px;

        opacity: 0.65;
    }

    .tg-icon{

        width:30px;
        height:30px;
    }

    .tg-tooltip{
        display:none;
    }

}


/* ============================================================
   WHATSAPP FLOAT BUTTON
============================================================ */

.wa-button {
    position: fixed;

    right: 22px;
    bottom: 22px;

    width: 64px;
    height: 64px;

    border-radius: 50%;

    background: #25D366;

    display: flex;
    align-items: center;
    justify-content: center;

    z-index: 99999;

    box-shadow:
        0 10px 25px rgba(0,0,0,0.25),
        0 0 0 0 rgba(37,211,102,0.6);

    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease;

    animation: waPulse 2s infinite;

    text-decoration: none;

    pointer-events: auto;
}

.wa-button:hover {
    transform: scale(1.08);

    box-shadow:
        0 14px 35px rgba(0,0,0,0.35),
        0 0 0 14px rgba(37,211,102,0);
}

.wa-icon {
    width: 34px;
    height: 34px;
}

.wa-tooltip {
    position: absolute;

    right: 78px;

    background: #111827;
    color: white;

    padding: 8px 12px;

    border-radius: 10px;

    font-size: 14px;
    font-weight: 500;

    opacity: 0;

    transform: translateX(10px);

    transition: all 0.25s ease;

    pointer-events: none;

    white-space: nowrap;
}

.wa-button:hover .wa-tooltip {
    opacity: 1;
    transform: translateX(0);
}

@keyframes waPulse {

    0% {
        box-shadow:
            0 10px 25px rgba(0,0,0,0.25),
            0 0 0 0 rgba(37,211,102,0.6);
    }

    70% {
        box-shadow:
            0 10px 25px rgba(0,0,0,0.25),
            0 0 0 18px rgba(37,211,102,0);
    }

    100% {
        box-shadow:
            0 10px 25px rgba(0,0,0,0.25),
            0 0 0 0 rgba(37,211,102,0);
    }
}

@media (max-width: 768px) {

    .wa-button {
        width: 58px;
        height: 58px;

        right: 16px;
        bottom: 16px;

        opacity: 0.65;
    }

    .wa-icon {
        width: 30px;
        height: 30px;
    }

    .wa-tooltip {
        display: none;
    }
}


/* ============================================================
   VIDEO DROPDOWN
============================================================ */

.video-dropdown{
    position:relative;
    display:inline-block;
}

/* стрелка */

.video-arrow{
    display:inline-block;

    margin-left:8px;

    font-size:10px;

    transition:
        transform 0.22s ease;
}

/* rotate */

.video-dropdown.open .video-arrow{
    transform:rotate(180deg);
}

/* menu */

.video-menu{

    position:absolute;

    top:calc(100% + 8px);
    left:0;

    min-width:240px;

    background:rgba(31,41,51,0.96);

    backdrop-filter:blur(10px);

    border-radius:10px;

    overflow:hidden;

    opacity:0;
    visibility:hidden;

    transform:translateY(-6px);

    transition:
        opacity 0.22s ease,
        transform 0.22s ease,
        visibility 0.22s ease;

    z-index:5000;

    box-shadow:
        0 12px 30px rgba(0,0,0,0.22);
}

/* opened */

.video-dropdown.open .video-menu{

    opacity:1;
    visibility:visible;

    transform:translateY(0);
}

/* links */

.video-menu a{

    display:block;

    padding:14px 18px;

    color:#fff;
    text-decoration:none;

    font-size:15px;
    font-weight:500;

    border-bottom:
        1px solid rgba(255,255,255,0.08);

    transition:
        background 0.2s ease,
        padding-left 0.2s ease;
}

.video-menu a:last-child{
    border-bottom:none;
}

.video-menu a:hover{

    background:
        rgba(255,255,255,0.08);

    padding-left:24px;
}


/* ============================================================
   VIDEO DROPDOWN — RESPONSIVE FIX
============================================================ */

.video-dropdown {

    position: relative;

    display: flex;

    flex: 1 1 220px;
}

#videoBtn {

    width: 100%;
}


/* ============================================================
   VIDEO MENU BUTTONS
============================================================ */

.video-menu-item {

    display: block;

    width: 100%;

    padding: 14px 18px;

    border: 0;

    background: transparent;

    color: white;

    text-align: left;

    text-decoration: none;

    cursor: pointer;

    border-bottom:
        1px solid rgba(255,255,255,0.08);

    transition:
        background 0.18s ease;
}

.video-menu-item:last-child {

    border-bottom: none;
}

.video-menu-item:hover {

    background:
        rgba(255,255,255,0.08);
}

/* ============================================================
   АНИМАЦИЯ СТАТУСА ПРОЕКТА (ИДЕТ ПРОЕКТИРОВАНИЕ)
============================================================ */

    .project-status-animated {

        display: inline-flex;
        align-items: center;
        gap: 8px;

        margin-top: -2px;
        margin-bottom: 4px;

        padding: 5px 10px;

        border-radius: 999px;

        background:
            linear-gradient(
                135deg,
                #8a0000,
                #c40000,
                #ff3d3d
            );

        background-size: 200% 200%;

        color: #ffffff;

        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.13em;
        text-transform: uppercase;
        line-height: 1;

        box-shadow:
            0 0 6px rgba(180,0,0,0.14);

        animation:
            projectStatusGradient 10s ease infinite,
            projectStatusFloat 5s ease-in-out infinite;
    }

    .status-dot {

        width: 7px;
        height: 7px;

        flex-shrink: 0;

        border-radius: 50%;

        background: #ffffff;

        box-shadow:
            0 0 4px rgba(255,255,255,0.55);

        animation:
            statusDotPulse 2.8s ease-in-out infinite;
    }

    @keyframes projectStatusGradient {

        0% {
            background-position: 0% 50%;
        }

        50% {
            background-position: 100% 50%;
        }

        100% {
            background-position: 0% 50%;
        }

    }

    @keyframes projectStatusFloat {

        0%,100% {
            transform: translateY(0px);
        }

        50% {
            transform: translateY(-1px);
        }

    }

    @keyframes statusDotPulse {

        0%,100% {
            opacity: 0.9;
            transform: scale(1);
        }

        50% {
            opacity: 0.55;
            transform: scale(1.18);
        }

    }


/* ============================================================
   АДАПТАЦИЯ ТАБЛИЦЫ ССЫЛОК К ШИРИНЕ ЭКРАНА
============================================================ */

.links-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

.links-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.links-list img {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
}

.links-list a {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* планшет */
@media (max-width: 1100px) {
    .links-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* телефон */
@media (max-width: 600px) {
    .links-list {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}


    /* ============================================================
       COMPANY WARNING MODAL
    ============================================================ */

    .company-warning-modal {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 10000;

        align-items: center;
        justify-content: center;

        background: rgba(0, 0, 0, 0.65);
    }

    .company-warning-modal.open {
        display: flex;
    }

    .company-warning-box {
        position: relative;

        width: min(560px, calc(100% - 40px));
        padding: 30px 35px;

        background: #ffffff;
        border-radius: 10px;

        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);

        text-align: center;
        box-sizing: border-box;
    }

    .company-warning-box h2 {
        margin: 0 0 20px 0;

        font-size: 22px;
        line-height: 1.3;
        font-weight: 700;

        color: #c00000;
    }

    .company-warning-box p {
        margin: 0 auto 25px auto;

        max-width: 480px;

        font-size: 16px;
        line-height: 1.5;
    }

    .company-warning-box button {
        min-width: 90px;
        padding: 10px 25px;

        border: none;
        border-radius: 5px;

        background: #000000;
        color: #ffffff;

        font-size: 16px;
        font-weight: 600;

        cursor: pointer;
    }

    .company-warning-box button:hover {
        background: #333333;
        color: #ffffff;
    }


    /* ============================================================
       COMPANY WARNING MODAL — MOBILE
    ============================================================ */

    @media (max-width: 600px) {

        .company-warning-box {
            width: calc(100% - 30px);
            padding: 25px 20px;
        }

        .company-warning-box h2 {
            font-size: 19px;
        }

        .company-warning-box p {
            font-size: 15px;
        }

        .company-warning-box button {
            width: 100%;
        }

    }

/* ============================================================
   MARKET MONITOR
============================================================ */

/* ---------- Основной блок ---------- */

#market-monitor {
    width: 100%;
}

#market-monitor .market-monitor-description {
    margin: 0 0 8px;
}

#market-monitor #status {
    margin: 10px 0 16px;
    color: #666;
    font-size: 13px;
}


/* ---------- Панель управления ---------- */

#market-monitor .controls {
    display: flex;
    gap: 12px;
    flex-wrap: nowrap;
    margin: 20px 0;
    align-items: center;
}

#market-monitor .controls label {
    display: flex;
    align-items: center;
    gap: 6px;

    /* Все 4 группы могут сжиматься */
    flex: 1 1 0;
    min-width: 0;

    /* Текст "Год:", "Сортировка:" и т.д. не переносим */
    white-space: nowrap;
}

#market-monitor .controls select,
#market-monitor .controls input {
    flex: 1 1 0;

    width: auto;
    min-width: 0;
    max-width: 100%;

    padding: 8px 10px;
    font-size: 14px;
    box-sizing: border-box;
}

#market-monitor .controls input {
    min-width: 0;
}


/* ---------- Таблица ---------- */

#market-monitor .table-wrap {
    width: 100%;
    overflow-x: auto;
}

#market-monitor table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    table-layout: fixed;
}

#market-monitor th,
#market-monitor td {
    padding: 9px 8px;
    border-bottom: 1px solid #ddd;
    text-align: right;
    vertical-align: middle;
}

#market-monitor th {
    background: #f3f3f3;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: break-word;
}

#market-monitor td {
    font-size: 14px;
    white-space: nowrap;
}


/* Ширины колонок */

#market-monitor th:nth-child(1),
#market-monitor td:nth-child(1) {
    width: 20%;
    text-align: left;
}

#market-monitor th:nth-child(2),
#market-monitor td:nth-child(2) {
    width: 6%;
}

#market-monitor th:nth-child(3),
#market-monitor td:nth-child(3) {
    width: 11%;
}

#market-monitor th:nth-child(4),
#market-monitor td:nth-child(4) {
    width: 18%;
}

#market-monitor th:nth-child(5),
#market-monitor td:nth-child(5) {
    width: 11%;
}

#market-monitor th:nth-child(6),
#market-monitor td:nth-child(6) {
    width: 12%;
}

#market-monitor th:nth-child(7),
#market-monitor td:nth-child(7) {
    width: 8%;
}

#market-monitor th:nth-child(8),
#market-monitor td:nth-child(8) {
    width: 14%;
}

#market-monitor th:first-child,
#market-monitor td:first-child {
    text-align: left;
}

#market-monitor td.company {
    white-space: normal;
}

#market-monitor td.company .company-cell {
    max-width: none;
}


/* ---------- Компания ---------- */

#market-monitor .company-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}

#market-monitor .company-name,
#market-monitor .company-name:visited {
    color: #222;
    text-decoration: none;
}

#market-monitor .company-name:hover {
    color: #222;
    text-decoration: underline;
}


/* ---------- Значок Teatmik ---------- */

#market-monitor .teatmik-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 20px;
    height: 20px;

    border: 1px solid #d5d5d5;
    border-radius: 50%;

    background: #fafafa;

    text-decoration: none;
    flex-shrink: 0;
}

#market-monitor .teatmik-icon {
    color: #73b82a;
    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
}

#market-monitor .teatmik-link:hover {
    border-color: #73b82a;
    background: #f5f5f5;
}


/* ---------- Значения ---------- */

#market-monitor .positive {
    color: #16803c;
}

#market-monitor .negative {
    color: #b42318;
}

#market-monitor .muted {
    color: #888;
}


/* ============================================================
   MARKET MONITOR — MOBILE
============================================================ */

@media (max-width: 700px) {

    #market-monitor {
        width: 100%;
    }

    #market-monitor .controls {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    #market-monitor .controls label {
        display: grid;
        grid-template-columns: 120px 1fr;
        align-items: center;
        gap: 8px;
    }

    #market-monitor .controls input,
    #market-monitor .controls select {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    #market-monitor .table-wrap {
        overflow: visible;
    }

    #market-monitor table {
        min-width: 0;
        width: 100%;
        border-collapse: separate;
        border-spacing: 0 10px;
    }

   /* Все ячейки карточки занимают всю ширину */
#market-monitor tbody td {
    width: 100% !important;
    max-width: none;
}

    #market-monitor thead {
        display: none;
    }

    #market-monitor tbody,
    #market-monitor tr,
    #market-monitor td {
        display: block;
    }

    #market-monitor tbody tr {
        background: #f7f7f7;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 10px;
    }

    #market-monitor tbody td {
        border: 0;
        padding: 5px 0;
        text-align: right;
        white-space: normal;
    }


    /* ---------- Название компании ---------- */

    #market-monitor tbody td.company {
        text-align: left;
        font-weight: 600;
        font-size: 16px;
        padding-bottom: 9px;
        border-bottom: 1px solid #ddd;
        margin-bottom: 5px;
    }

    #market-monitor .company-cell {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        width: 100%;
    }

    #market-monitor .company-name {
        overflow-wrap: normal;
        word-break: normal;
        white-space: normal;
        flex: 1 1 auto;
        min-width: 0;
    }

    #market-monitor .teatmik-link {
        flex-shrink: 0;
    }


    /* ---------- Подписи перед значениями ---------- */

#market-monitor tbody td:not(.company)::before {
    content: attr(data-label);
    float: left;
    font-weight: 400;
    color: #777;
}


    #market-monitor #status {
        font-size: 13px;
    }
}

/* ============================================================
   MARKET MONITOR — REPORT TABS
============================================================ */

#market-monitor .market-monitor-tabs {
    display: flex;
    gap: 8px;
    margin: 0 0 20px;
    border-bottom: 1px solid #ddd;
}

#market-monitor .market-monitor-tab {
    appearance: none;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    background: #f3f3f3;
    color: #222;
    padding: 9px 16px;
    font-size: 14px;
    cursor: pointer;
}

#market-monitor .market-monitor-tab:hover {
    background: #eaeaea;
}

#market-monitor .market-monitor-tab.active {
    background: #1f2933;
    color: #fff;
    border-color: #1f2933;
}

#market-monitor .market-monitor-report[hidden] {
    display: none;
}


/* ============================================================
   MARKET MONITOR — QUARTERLY
============================================================ */

#market-monitor .quarterly-note {
    margin: 0 0 16px;
    color: #888;
    font-size: 13px;
}

#market-monitor .market-monitor-quarterly-status {
    margin: 10px 0 16px;
    color: #666;
    font-size: 13px;
}

#market-monitor .quarterly-controls {
    display: flex;
    gap: 12px;
    flex-wrap: nowrap;
    align-items: center;
    margin: 20px 0;
}

#market-monitor .quarterly-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 0;
    min-width: 0;
    white-space: nowrap;
}

#market-monitor .quarterly-controls select,
#market-monitor .quarterly-controls input {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    max-width: 100%;
    padding: 8px 10px;
    font-size: 14px;
    box-sizing: border-box;
}

#market-monitor .quarterly-table-wrap {
    width: 100%;
    overflow-x: auto;
}

#market-monitor .quarterly-table {
    width: 100%;
    min-width: 1250px;
    border-collapse: collapse;
    table-layout: auto;
}

/* ---------- Чередование строк ---------- */

#market-monitor tbody tr:nth-child(even) {
    background: #f7f7f7;
}

/* ---------- Фиксированный первый столбец ---------- */

#market-monitor .quarterly-table th:first-child,
#market-monitor .quarterly-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
}

#market-monitor .quarterly-table th:first-child {
    background: #f3f3f3;
    z-index: 3;
}

#market-monitor .quarterly-table tbody tr:nth-child(odd) td:first-child {
    background: #fff;
}

#market-monitor .quarterly-table tbody tr:nth-child(even) td:first-child {
    background: #f7f7f7;
}


#market-monitor .annual-table th,
#market-monitor .quarterly-table th {
    text-align: center;
    vertical-align: middle;
}

#market-monitor .quarterly-table th,
#market-monitor .quarterly-table td {
    padding: 9px 8px;
    border-bottom: 1px solid #ddd;
    vertical-align: middle;
}

#market-monitor .quarterly-table th {
    text-align: center;
}

#market-monitor .quarterly-table td {
    text-align: right;
}

#market-monitor .quarterly-table th {
    background: #f3f3f3;
    font-weight: 600;
    font-size: 13px;
    line-height: 1.2;
    white-space: normal;
    overflow-wrap: break-word;
}

#market-monitor .quarterly-table td {
    font-size: 14px;
    white-space: nowrap;
}

#market-monitor .quarterly-table th:nth-child(1),
#market-monitor .quarterly-table td:nth-child(1) {
    width: 14%;
    text-align: left;
}

#market-monitor .quarterly-table th:nth-child(2),
#market-monitor .quarterly-table td:nth-child(2) {
    width: 6%;
}

#market-monitor .quarterly-table th:nth-child(3),
#market-monitor .quarterly-table td:nth-child(3) {
    width: 9%;
}

#market-monitor .quarterly-table th:nth-child(4),
#market-monitor .quarterly-table td:nth-child(4) {
    width: 10%;
}

#market-monitor .quarterly-table th:nth-child(5),
#market-monitor .quarterly-table td:nth-child(5) {
    width: 8%;
}

#market-monitor .quarterly-table th:nth-child(6),
#market-monitor .quarterly-table td:nth-child(6) {
    width: 8%;
}

#market-monitor .quarterly-table th:nth-child(7),
#market-monitor .quarterly-table td:nth-child(7) {
    width: 6%;
}

#market-monitor .quarterly-table th:nth-child(8),
#market-monitor .quarterly-table td:nth-child(8) {
    width: 9%;
}

#market-monitor .quarterly-table th:nth-child(9),
#market-monitor .quarterly-table td:nth-child(9) {
    width: 9%;
}

#market-monitor .quarterly-table th:nth-child(10),
#market-monitor .quarterly-table td:nth-child(10) {
    width: 8%;
}

#market-monitor .quarterly-table th:nth-child(11),
#market-monitor .quarterly-table td:nth-child(11) {
    width: 7%;
}

#market-monitor .quarterly-table th:nth-child(12),
#market-monitor .quarterly-table td:nth-child(12) {
    width: 6%;
}

#market-monitor .quarterly-company-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}

#market-monitor .quarterly-company-name {
    flex: 1 1 auto;
    min-width: 0;
    display: block;
    color: inherit;
    text-decoration: none;
    overflow-wrap: normal;
    word-break: normal;
    white-space: normal;
    hyphens: none;
}

#market-monitor .quarterly-company-name:hover {
    text-decoration: underline;
}

#market-monitor .quarterly-teatmik {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    border: 1px solid #d5d5d5;
    border-radius: 50%;
    background: #fafafa;
    color: #73b82a;
    text-decoration: none;
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
}

#market-monitor .quarterly-teatmik:hover {
    border-color: #73b82a;
    background: #f5f5f5;
}

#market-monitor .quarterly-positive {
    color: #16803c;
}

#market-monitor .quarterly-negative {
    color: #b42318;
}

#market-monitor .quarterly-muted {
    color: #888;
}

#market-monitor .quarterly-error {
    text-align: left !important;
    color: #b42318;
    white-space: normal !important;
}


/* ============================================================
   MARKET MONITOR — QUARTERLY MOBILE / CARDS
============================================================ */

@media (max-width: 768px) {

    #market-monitor .market-monitor-tabs {
        gap: 6px;
        margin-bottom: 16px;
    }

    #market-monitor .market-monitor-tab {
        flex: 1 1 0;
        padding: 9px 8px;
        font-size: 14px;
    }

    #market-monitor .quarterly-controls {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    #market-monitor .quarterly-controls label {
        display: grid;
        grid-template-columns: 120px 1fr;
        align-items: center;
        gap: 8px;
        white-space: normal;
    }

    #market-monitor .quarterly-controls input,
    #market-monitor .quarterly-controls select {
        width: 100%;
        min-width: 0;
    }

    #market-monitor .quarterly-table-wrap {
        overflow: visible;
    }

    #market-monitor .quarterly-table {
        min-width: 0;
        width: 100%;
        border-collapse: separate;
        border-spacing: 0 10px;
        table-layout: auto;
    }

    #market-monitor .annual-table th,
    #market-monitor .quarterly-table th {
        text-align: center;
        vertical-align: middle;
    }

    #market-monitor .quarterly-table thead {
        display: none;
    }

    #market-monitor .quarterly-table tbody,
    #market-monitor .quarterly-table tr,
    #market-monitor .quarterly-table td {
        display: block !important;
    }

    #market-monitor .quarterly-table tbody tr {
        background: #f7f7f7;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 10px;
    }

    #market-monitor .quarterly-table tbody td {
        width: 100% !important;
        max-width: none;
        border: 0;
        padding: 5px 0;
        text-align: right;
        white-space: normal;
    }

    #market-monitor .quarterly-table tbody td:nth-child(1) {
        text-align: left;
        font-weight: 600;
        font-size: 16px;
        padding-bottom: 9px;
        border-bottom: 1px solid #ddd;
        margin-bottom: 5px;
    }

    #market-monitor .quarterly-company-cell {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        width: 100%;
    }

    #market-monitor .quarterly-company-name {
        overflow-wrap: normal;
        word-break: normal;
        white-space: normal;
        flex: 1 1 auto;
        min-width: 0;
    }

    #market-monitor .quarterly-teatmik {
        flex-shrink: 0;
    }

#market-monitor .quarterly-table tbody td:not(:first-child)::before {
    content: attr(data-label);
    float: left;
    font-weight: 400;
    color: #777;
}

    #market-monitor .market-monitor-quarterly-status {
        font-size: 13px;
    }
}

/* ============================================================
   MARKET MONITOR — COMPANY SELECTION
   ============================================================ */

#market-monitor .market-selection-action {
    margin: 4px 0 18px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f7f7f7;
}

#market-monitor .market-selection-label {
    display: flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    font-size: 14px;
    color: #444;
    cursor: pointer;
    user-select: none;
    font-weight: 500;
}

#market-monitor .market-selection-label input,
#market-monitor .market-company-checkbox {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #1f2933;
    cursor: pointer;
}

#market-monitor .company-selection {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

#market-monitor .company-selection .company-rank {
    flex: 0 0 auto;
}

@media (max-width: 700px) {
    #market-monitor .market-selection-action {
        margin-bottom: 10px;
    }

    #market-monitor .market-selection-label {
        font-size: 14px;
    }
}

/* ============================================================
   MARKET MONITOR — SELECTION FILE BUTTONS
============================================================ */

#market-monitor .market-summary-action,
#market-monitor .market-selection-file-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
}

#market-monitor .market-summary-action {
    margin: 8px 0 0;
}

#market-monitor .market-selection-file-actions {
    margin: 0 0 6px;
}

#market-monitor .market-summary-action .cv-link,
#market-monitor .market-selection-file-actions .cv-link {
    display: block;
    box-sizing: border-box;
    width: 215px;
    margin: 0 0 8px;
    padding: 10px 20px;
    text-align: center;
    border-radius: 4px;
    font-size: 16px;
    transition: background 0.3s;
}

#market-monitor .market-summary-action .cv-link:last-child {
    margin-bottom: 18px;
}

#market-monitor .market-selection-file-actions .cv-link:last-child {
    margin-bottom: 0;
}

#market-monitor .market-summary-action .cv-link:last-child {
    margin-bottom: 8px;
}

#market-monitor .market-summary-action .cv-link:hover:not(.disabled),
#market-monitor .market-selection-file-actions .cv-link:hover:not(.disabled) {
    background: #11171a;
}

@media (max-width: 480px) {
    #market-monitor .market-summary-action {
        margin-top: 10px;
    }

    #market-monitor .market-selection-file-actions {
        margin-bottom: 10px;
    }

    #market-monitor .market-summary-action .cv-link,
    #market-monitor .market-selection-file-actions .cv-link {
        width: 100%;
        margin-bottom: 8px;
    }
}

/* ============================================================
   MARKET SUMMARY MODAL
============================================================ */

.market-summary-modal {
  position: fixed;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 20px;

  background: rgba(0, 0, 0, 0.45);

  z-index: 9999;
}

/* hidden должен действительно скрывать модальное окно */
.market-summary-modal[hidden] {
  display: none;
}


.market-summary-window {
  position: relative;

  width: min(520px, 100%);
  max-height: 80vh;

  overflow: auto;

  background: #fff;
  color: #1f2933;

  border-radius: 8px;

  padding: 24px;

  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}


.market-summary-window h3 {
  margin: 0 0 8px;
  padding-right: 35px;

  font-size: 22px;
}


.market-summary-subtitle {
  margin-bottom: 18px;

  color: #666;

  font-size: 14px;
}


.market-summary-close {
  position: absolute;

  top: 10px;
  right: 12px;

  width: 32px;
  height: 32px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;

  border: none;
  border-radius: 50%;

  background: transparent;
  color: #555;

  font-size: 24px;
  line-height: 1;

  cursor: pointer;
}


.market-summary-close:hover {
  background: #eee;
  color: #111;
}


.market-summary-table-wrap {
  width: 100%;
  overflow-x: auto;
}


.market-summary-table {
  width: 100%;

  border-collapse: collapse;

  font-size: 14px;
}


.market-summary-table th,
.market-summary-table td {
  padding: 10px 8px;

  border-bottom: 1px solid #ddd;

  text-align: left;
}


.market-summary-table th {
  background: #f5f5f5;

  font-weight: 600;
}


.market-summary-table td:last-child,
.market-summary-table th:last-child {
  text-align: right;
}


.market-summary-positive {
  color: #187a3d;
  font-weight: 600;
}


.market-summary-negative {
  color: #b42318;
  font-weight: 600;
}


/* ---------------- MARKET SUMMARY MOBILE ---------------- */

@media (max-width: 768px) {

  .market-summary-modal {
    padding: 12px;
  }

  .market-summary-window {
    width: 100%;
    max-height: 85vh;

    padding: 20px 16px;
  }

  .market-summary-window h3 {
    font-size: 20px;
  }

  .market-summary-table {
    font-size: 13px;
  }

  .market-summary-table th,
  .market-summary-table td {
    padding: 8px 6px;
  }

}

/* ============================================================
   GALLERY — DESKTOP ONLY
   Mobile / tablet layout is intentionally untouched.
============================================================ */

@media (min-width: 1025px) {

  #gallery > .card {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    column-gap: 24px;
    align-items: start;
  }

  #gallery > .card > h2 {
    grid-column: 1 / -1;
    margin-bottom: 20px;
  }

  #gallery .show-all-card {
    grid-column: 1;
    grid-row: 2;

    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 10px;

    width: 100%;
    margin: 0;
  }

  #gallery .show-all-card .cv-link {
    display: flex;
    flex: none;
    width: 100%;
    min-width: 0;
    margin: 0;

    justify-content: center;
    align-items: center;
    text-align: center;
  }

  #gallery .show-all-card .video-dropdown {
    position: relative;
    display: flex;
    flex: none;
    width: 100%;
  }

  #gallery .show-all-card .video-dropdown .cv-link {
    width: 100%;
  }

  #gallery .gallery-wrapper {
    grid-column: 2;
    grid-row: 2;

    min-width: 0;
    width: 100%;
    margin: 0;
  }

}

/* ============================================================
   GALLERY PHOTO WINDOW — DESKTOP
   The photo area follows the height of the control column.
   Adding another button automatically increases the photo area.
============================================================ */

@media (min-width: 1025px) {

  /* The second grid row is determined by the controls.
     Gallery wrapper stretches to the full row height. */
  #gallery > .card {
    grid-template-rows: auto auto;
  }

  #gallery .gallery-wrapper {
    align-self: stretch;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
  }

  #gallery .gallery {
    height: 100%;
    min-height: 0;
    align-items: flex-start;
    box-sizing: border-box;
  }

}

/* ============================================================
   GALLERY PHOTOS — DESKTOP SIZE
   Photos fill the available gallery window height.
   Mobile sizes remain unchanged.
============================================================ */

@media (min-width: 1025px) {

  #gallery .gallery img {
    height: calc(100% - 10px);
    width: auto;
    object-fit: cover;
  }

  #gallery .gallery a {
    height: 100%;
    flex: 0 0 auto;
  }

}


/* ============================================================
   GALLERY — DESKTOP HEIGHT FIX
   Photo height follows the control column without percentage
   height feedback. Adding/removing a control changes the row
   height naturally.
============================================================ */

@media (min-width: 1025px) {

  #gallery .gallery-wrapper {
    align-self: stretch;
    height: auto;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
  }

  #gallery .gallery {
    height: auto;
    min-height: 0;
    align-items: stretch;
  }

  #gallery .gallery a {
    height: auto;
    align-self: stretch;
    flex: 0 0 auto;
    display: flex;
  }

  #gallery .gallery img {
    height: 100%;
    width: auto;
    max-height: 100%;
    object-fit: cover;
  }

}


/* ============================================================
   GALLERY — DESKTOP DYNAMIC HEIGHT
   The photo area matches the control column height.
   Adding a control automatically increases the photo height.
============================================================ */

@media (min-width: 1025px) {

  #gallery > .card {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    column-gap: 24px;
  }

  #gallery > .card > h2 {
    flex: 0 0 100%;
    margin-bottom: 20px;
  }

  #gallery .show-all-card {
    flex: 0 0 220px;
    width: 220px;
    height: auto;
    align-self: stretch;
    box-sizing: border-box;
  }

  #gallery .gallery-wrapper {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    height: auto;
    align-self: stretch;
    overflow-x: auto;
    overflow-y: hidden;
    box-sizing: border-box;
  }

  #gallery .gallery {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
  }

  #gallery .gallery a {
    display: flex;
    flex: 0 0 auto;
    height: 100%;
    align-items: stretch;
  }

  #gallery .gallery img {
    height: 100%;
    width: auto;
    max-height: 100%;
    object-fit: cover;
  }

}

/* ============================================================
   GALLERY — DESKTOP FINAL
   Control column defines photo height.
   Mobile/tablet remain untouched.
============================================================ */

@media (min-width: 1025px) {

  /* The controls are the reference height. */
  #gallery .show-all-card {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 10px;
    align-self: start;
    height: max-content;
    margin: 0;
    width: 220px;
    flex: 0 0 220px;
  }

  #gallery .show-all-card > .cv-link,
  #gallery .show-all-card > .video-dropdown {
    flex: 0 0 42px;
    height: 42px;
    min-height: 42px;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
  }

  #gallery .show-all-card > .video-dropdown {
    position: relative;
  }

  #gallery .show-all-card > .video-dropdown > .cv-link {
    width: 100%;
    height: 42px;
    min-height: 42px;
    margin: 0;
  }

  /*
     The photo area gets the same height as the five controls.
     :has() increases it automatically when another control is added.
  */
  #gallery .gallery-wrapper {
    flex: 1 1 0;
    min-width: 0;
    align-self: flex-start;
    height: 250px;
    min-height: 250px;
    overflow-x: auto;
    overflow-y: hidden;
    box-sizing: border-box;
  }

  #gallery .gallery {
    height: 100%;
    min-height: 0;
    align-items: stretch;
  }

  #gallery .gallery a {
    height: 100%;
    display: flex;
    flex: 0 0 auto;
    align-items: stretch;
  }

  #gallery .gallery img {
    height: 100%;
    width: auto;
    max-height: none;
    object-fit: cover;
  }

  /* 6 controls */
  #gallery .show-all-card:has(> :nth-child(6)) ~ .gallery-wrapper {
    height: 302px;
    min-height: 302px;
  }

  /* 7 controls */
  #gallery .show-all-card:has(> :nth-child(7)) ~ .gallery-wrapper {
    height: 354px;
    min-height: 354px;
  }

  /* 8 controls */
  #gallery .show-all-card:has(> :nth-child(8)) ~ .gallery-wrapper {
    height: 406px;
    min-height: 406px;
  }

  /* 9 controls */
  #gallery .show-all-card:has(> :nth-child(9)) ~ .gallery-wrapper {
    height: 458px;
    min-height: 458px;
  }

}

/* ============================================================
   GALLERY — INTERMEDIATE MODE
   481–1024px

   481–768px  — phone / desktop-mode
   769–1024px — tablet / desktop-mode

   480px and below remain TRUE MOBILE.
============================================================ */

@media (min-width: 481px) and (max-width: 1024px) {

  /* ==========================================================
     GALLERY LAYOUT
     Controls left / photos right
  ========================================================== */

  #gallery > .card {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    column-gap: 24px;
  }

  #gallery > .card > h2 {
    flex: 0 0 100%;
    margin-bottom: 20px;
  }


  /* ==========================================================
     CONTROL COLUMN
     Fixed 220px — must NOT stretch with viewport
  ========================================================== */

  #gallery .show-all-card {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;

    gap: 10px;

    width: 220px;
    min-width: 220px;
    max-width: 220px;

    flex: 0 0 220px;

    height: max-content;

    margin: 0;

    box-sizing: border-box;
  }

  #gallery .show-all-card .cv-link {
    display: flex;

    flex: 0 0 42px;

    width: 220px;
    min-width: 220px;
    max-width: 220px;

    height: 42px;
    min-height: 42px;

    margin: 0;

    justify-content: center;
    align-items: center;
    text-align: center;

    box-sizing: border-box;
  }

  #gallery .show-all-card .video-dropdown {
    position: relative;

    display: flex;

    flex: 0 0 42px;

    width: 220px;
    min-width: 220px;
    max-width: 220px;

    height: 42px;
    min-height: 42px;

    box-sizing: border-box;
  }

  #gallery .show-all-card .video-dropdown .cv-link {
    width: 220px;
    min-width: 220px;
    max-width: 220px;

    height: 42px;
    min-height: 42px;

    margin: 0;
  }


  /* ==========================================================
     PHOTO WINDOW
     Remaining width
     Height follows control column
  ========================================================== */

  #gallery .gallery-wrapper {
    flex: 1 1 0;

    min-width: 0;
    width: auto;

    align-self: flex-start;

    height: 250px;
    min-height: 250px;

    overflow-x: auto;
    overflow-y: hidden;

    box-sizing: border-box;
  }

  #gallery .gallery {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;

    height: 100%;
    min-height: 0;

    box-sizing: border-box;
  }

  #gallery .gallery a {
    display: flex;
    flex: 0 0 auto;

    height: 100%;

    align-items: stretch;
  }

  #gallery .gallery img {
    display: block;

    height: 100%;
    width: auto;

    max-height: none;

    object-fit: cover;
  }


  /* ==========================================================
     DYNAMIC PHOTO HEIGHT
     Same values as working desktop Gallery
  ========================================================== */

  /* 6 controls */
  #gallery .show-all-card:has(> :nth-child(6))
    ~ .gallery-wrapper {
    height: 302px;
    min-height: 302px;
  }

  /* 7 controls */
  #gallery .show-all-card:has(> :nth-child(7))
    ~ .gallery-wrapper {
    height: 354px;
    min-height: 354px;
  }

  /* 8 controls */
  #gallery .show-all-card:has(> :nth-child(8))
    ~ .gallery-wrapper {
    height: 406px;
    min-height: 406px;
  }

  /* 9 controls */
  #gallery .show-all-card:has(> :nth-child(9))
    ~ .gallery-wrapper {
    height: 458px;
    min-height: 458px;
  }

}

.market-summary-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.market-csv-options {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.market-csv-options[hidden],
.market-csv-years[hidden] {
  display: none;
}

.market-csv-choice {
  display: flex;
  align-items: center;
  gap: 8px;
}

.market-csv-years {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.market-csv-years label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.market-csv-years select {
  max-width: 100%;
  padding: 8px;
}

.market-csv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}


/* ============================================================
   MARKET MONITOR — Al / Fe PRESET BUTTONS
============================================================ */

.market-selection-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.market-selection-presets {
  display: flex;
  align-items: center;
  gap: 6px;
}

.market-selection-preset {
  min-width: 38px;
  padding: 4px 9px;
  border: 1px solid #aeb6bf;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.market-selection-preset.active {
  border: 2px solid #1f2933;
  padding: 3px 8px;
  background: transparent;
}

.market-selection-preset:disabled {
  opacity: 0.55;
  cursor: wait;
}
