/* Дизайн системата на платформата (docs/DESIGN_SYSTEM.md).
   Един файл за цялата платформа. Цветове, размери и компоненти само оттук. */
:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #1C1C1E;
  --surface-hover: #242426;
  --surface-2: #2C2C2E;
  --line: rgba(255, 255, 255, 0.07);   /* тънък ръб на плочките, за да се отделят от черното */
  --text: #FFFFFF;
  --text-2: #8E8E93;
  --accent: #1571A8;
  --accent-hover: #1A82C0;
  --link: #4DA3E0;
  --danger: #FF6961;
  --danger-bg: #2A1212;
  --danger-line: rgba(255, 105, 97, 0.18);

  /* Размери на текста: само тези пет */
  --t-xs: 13px;
  --t-sm: 15px;
  --t-md: 17px;
  --t-lg: 22px;
  --t-xl: 34px;

  --r-group: 16px;
  --r-tile: 20px;
  --ease: 140ms ease;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body {
  color: var(--text);
  font-family: Onest, system-ui, sans-serif;
  font-size: var(--t-md);
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--link); text-decoration: none; transition: color var(--ease); }
a:hover { color: #7DBBE8; }
::selection { background: rgba(21, 113, 168, 0.55); }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------------------------------------------------------------- Разположение */
.page { min-height: 100vh; padding: 48px 24px 72px; display: flex; justify-content: center; }
.page--step { padding-top: 24px; }
.col { width: 100%; max-width: 760px; display: flex; flex-direction: column; gap: 32px; }
.col--step { max-width: 640px; gap: 24px; }
.col--wide { max-width: 1200px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 40px; align-items: start; }
.cols__main, .cols__side { display: flex; flex-direction: column; gap: 36px; min-width: 0; }
@media (min-width: 961px) { .cols__side { position: sticky; top: 24px; } }
@media (max-width: 960px) { .cols { grid-template-columns: minmax(0, 1fr); gap: 36px; } }

/* ---------------------------------------------------------------- Заглавия */
.screen-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.screen-head__text { display: flex; flex-direction: column; gap: 2px; }
.title { margin: 0; font-size: var(--t-xl); font-weight: 700; letter-spacing: -0.025em; line-height: 1.12;
  text-wrap: balance; }
.sub { font-size: var(--t-sm); color: var(--text-2); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: var(--t-sm); font-weight: 600;
  color: var(--text-2); }

.section { display: flex; flex-direction: column; gap: 12px; }
.section__head { padding: 0 4px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 32px; }
.section__title { font-size: var(--t-lg); font-weight: 700; letter-spacing: -0.015em; }
.section__title .sub { font-weight: 400; letter-spacing: 0; margin-left: 8px; }
.pill { height: 32px; padding: 0 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line);
  display: inline-flex; align-items: center; font-size: var(--t-sm); font-weight: 500; color: var(--link);
  transition: background var(--ease); }
.pill:hover { background: var(--surface-hover); color: var(--link); }

/* ---------------------------------------------------------------- Проблеми (един блок, по ред на проблем) */
.alerts { background: var(--danger-bg); border: 1px solid var(--danger-line); border-radius: var(--r-group);
  display: flex; flex-direction: column; overflow: hidden; }
.problem { padding: 14px 16px; display: flex; align-items: center; gap: 12px; color: var(--text);
  transition: background var(--ease); }
.problem + .problem { border-top: 1px solid var(--danger-line); }
.problem:hover { color: var(--text); background: rgba(255, 105, 97, 0.06); }
.problem__icon { flex-shrink: 0; display: flex; color: var(--danger); }
.problem__text { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.problem__title { font-size: var(--t-sm); font-weight: 600; color: var(--danger); }
.problem__action { font-size: var(--t-xs); color: #C9A3A0; }
.problem__arrow { font-size: 20px; line-height: 1; color: var(--danger); opacity: 0.7; }

/* ---------------------------------------------------------------- Плочки с цели */
.pillars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.pillar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-group); padding: 16px 18px 18px;
  display: flex; flex-direction: column; gap: 14px; min-height: 132px; }
.pillar__label { font-size: var(--t-sm); color: var(--text-2); flex-grow: 1; }
.pillar__figure { display: flex; align-items: baseline; gap: 6px; }
.pillar__num { font-size: 40px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.pillar__goal { font-size: var(--t-md); font-weight: 500; color: var(--text-2); }
.pillar__hint { font-size: var(--t-xs); color: var(--text-2); }
.pillar--bad .pillar__num { color: var(--danger); }
@media (max-width: 720px) { .pillars { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------------------------------------------------------------- Път от етапи (SOP) */
.path { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-group); overflow: hidden; }
.path__step { background: var(--surface); padding: 14px 14px 16px; display: flex; flex-direction: column; gap: 8px;
  color: var(--text); transition: background var(--ease); }
.path__step:hover { background: var(--surface-hover); color: var(--text); }
.path__title { font-size: var(--t-xs); font-weight: 600; min-height: 34px; }
.path__num { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.path__meta { font-size: var(--t-xs); color: var(--text-2); line-height: 1.3; }
@media (max-width: 1100px) { .path { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 480px) { .path { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------------------------------------------------------------- Бутони workflow */
.flows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.flow { min-height: 136px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-tile);
  padding: 20px; display: flex; flex-direction: column; justify-content: space-between; gap: 16px; color: var(--text);
  transition: background var(--ease), transform var(--ease); }
.flow:hover { color: var(--text); background: var(--surface-hover); }
.flow:active { transform: scale(0.985); }
.flow__icon { width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); display: flex;
  align-items: center; justify-content: center; }
.flow--main .flow__icon { background: var(--accent); }
.flow__text { display: flex; flex-direction: column; gap: 4px; }
.flow__title { font-size: var(--t-md); font-weight: 600; letter-spacing: -0.01em; }
.flow__desc { font-size: var(--t-sm); color: var(--text-2); line-height: 1.3; }

/* ---------------------------------------------------------------- Група и редове */
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-group); display: flex;
  flex-direction: column; overflow: hidden; }
.row { min-height: 60px; padding: 0 16px; display: flex; align-items: center; gap: 14px; color: var(--text);
  transition: background var(--ease); }
label.row, a.row { cursor: pointer; }
label.row:hover, a.row:hover { background: var(--surface-hover); color: var(--text); }
.row__body { flex-grow: 1; min-width: 0; align-self: stretch; display: flex; flex-direction: column; justify-content: center;
  gap: 2px; padding: 11px 0; border-bottom: 1px solid var(--surface-2); }
.row:last-child .row__body { border-bottom-color: transparent; }
.row__title { font-size: var(--t-md); overflow-wrap: anywhere; }
.row__meta { font-size: var(--t-xs); color: var(--text-2); }
.row__meta--danger { color: var(--danger); }
.row__action { font-size: var(--t-sm); font-weight: 500; color: var(--link); background: none; border: none; padding: 10px 0;
  font-family: inherit; cursor: pointer; flex-shrink: 0; transition: color var(--ease); }
.row__action:hover { color: #7DBBE8; }
.row__code { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Ред с число вдясно */
.row__body--split { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.row__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row__value { font-size: var(--t-md); font-weight: 600; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.row__value--danger { color: var(--danger); }
.row__chevron { color: var(--text-2); font-weight: 400; opacity: 0.7; }

/* Отметки и радио: кръг като в Напомняния */
.row input[type=checkbox], .row input[type=radio] {
  appearance: none; -webkit-appearance: none; width: 24px; height: 24px; margin: 0; flex-shrink: 0; cursor: pointer;
  border: 1.5px solid #5A5A5F; border-radius: 50%; background: transparent center / 14px no-repeat;
  transition: background-color var(--ease), border-color var(--ease);
}
.row input[type=checkbox]:hover, .row input[type=radio]:hover { border-color: var(--link); }
.row input[type=checkbox]:checked, .row input[type=radio]:checked {
  background-color: var(--accent); border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7.5l2.6 2.6L11 4.6'/%3E%3C/svg%3E");
}

/* Задача */
.task .row__title { font-size: var(--t-sm); font-weight: 500; }
.task--done .row__title { color: var(--text-2); font-weight: 400; text-decoration: line-through;
  text-decoration-color: rgba(142, 142, 147, 0.5); }

/* Първи кадър 9:16 в ред */
.frame { width: 34px; height: 60px; border-radius: 6px; background: var(--surface-2); flex-shrink: 0; display: block; }

/* Поле за писане в група */
.row:focus-within { background: var(--surface-hover); }
.field { width: 100%; background: transparent; border: none; color: var(--text); font-family: inherit;
  font-size: var(--t-md); line-height: 1.4; padding: 4px 0; outline: none; resize: vertical; caret-color: var(--link); }
.field::placeholder { color: #636366; }
textarea.field { min-height: 120px; }

/* ---------------------------------------------------------------- Сегменти и търсене */
.segmented { display: flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented__item { flex: 1 0 auto; min-height: 36px; padding: 0 14px; display: flex; align-items: center;
  justify-content: center; border-radius: 9px; font-size: var(--t-sm); color: var(--text-2); white-space: nowrap;
  transition: background var(--ease), color var(--ease); }
.segmented__item:hover { color: var(--text); }
.segmented__item--on, .segmented__item--on:hover { background: var(--surface-2); color: var(--text); font-weight: 600; }

.search { margin: 0; }
.search__input { width: 100%; height: 48px; border: 1px solid var(--line); border-radius: 12px; color: var(--text);
  font-family: inherit; font-size: var(--t-md); padding: 0 16px 0 44px; outline: none;
  background: var(--surface) 14px center / 18px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  transition: border-color var(--ease); }
.search__input:focus { border-color: var(--link); }
.search__input::placeholder { color: #636366; }

/* ---------------------------------------------------------------- Мрежа с реклами 9:16 */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 28px 16px; }
.card { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.card__frame { aspect-ratio: 9 / 16; border-radius: 14px; border: 1px solid var(--line); margin-bottom: 4px;
  background: var(--surface) center / 36px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%233A3A3C'%3E%3Cpath d='M8 5.5v13l11-6.5z'/%3E%3C/svg%3E"); }
.card__title { font-size: var(--t-sm); font-weight: 600; line-height: 1.3; }
.card__number { font-size: var(--t-sm); color: var(--text); }
.card__line { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: var(--t-xs);
  color: var(--text-2); }
.card__code { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.card .row__action { font-size: var(--t-xs); padding: 2px 0; }
@media (max-width: 480px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 12px; } }

/* ---------------------------------------------------------------- Стъпка на workflow */
.step-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; min-height: 44px; }
.step-bar__back { min-height: 44px; display: inline-flex; align-items: center; font-size: var(--t-md); justify-self: start; }
.step-bar__name { font-size: var(--t-sm); font-weight: 600; }
.step-bar__count { font-size: var(--t-sm); color: var(--text-2); justify-self: end; }
.segments { display: grid; gap: 6px; }
.segment { height: 4px; border-radius: 2px; background: var(--surface-2); }
.segment--on { background: var(--accent); }
.question { display: flex; flex-direction: column; gap: 8px; padding-top: 16px; }

/* Главен бутон: само един на екран */
.actions { display: flex; flex-direction: column; gap: 12px; padding-top: 8px; }
.main-btn { height: 56px; width: 100%; border: none; border-radius: 16px; background: var(--accent); color: var(--text);
  font-family: inherit; font-size: var(--t-md); font-weight: 600; display: flex; align-items: center;
  justify-content: center; cursor: pointer; transition: background var(--ease), transform var(--ease); }
.main-btn:hover { color: var(--text); background: var(--accent-hover); }
.main-btn:active { transform: scale(0.985); }
.actions__next { text-align: center; font-size: var(--t-xs); color: var(--text-2); text-wrap: balance; }
a.actions__next { color: var(--link); font-size: var(--t-sm); min-height: 44px; display: flex; align-items: center;
  justify-content: center; }

/* Текст от монтажа и готовото видео */
.cut .row__title { color: var(--text-2); text-decoration: line-through; }
.video { aspect-ratio: 9 / 16; width: 100%; max-width: 280px; border-radius: var(--r-group); border: 1px solid var(--line);
  background: var(--surface); margin: 0 auto; display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; color: var(--text-2); font-size: var(--t-xs); text-align: center; }

/* ---------------------------------------------------------------- Телефон */
@media (max-width: 600px) {
  .page { padding: 28px 16px 40px; }
  .page--step { padding-top: 12px; }
  .col, .cols__main, .cols__side { gap: 28px; }
  .title { font-size: 30px; }
  .flows { gap: 10px; }
  .flow { padding: 16px; min-height: 128px; }
  .pillar { min-height: 116px; padding: 14px 16px 16px; }
  .pillar__num { font-size: 34px; }
  /* Главният бутон стои долу, под палеца */
  .col--step .actions { position: sticky; bottom: 0; margin: 0 -16px; padding: 12px 16px 16px;
    background: var(--bg); border-top: 1px solid var(--line); }
}

/* ---------------------------------------------------------------- Вход, действия в ред, бутони-линкове */
.col--auth { max-width: 440px; gap: 24px; }
.head-actions { display: flex; align-items: center; gap: 8px; margin: 0; }
.pill { font-family: inherit; cursor: pointer; }
.section__note { padding: 0 4px; }
.row__actions { display: flex; gap: 14px; margin: 0; flex-shrink: 0; }
.row__action--quiet { color: var(--text-2); }
.row__clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-btn { background: none; border: none; font-family: inherit; cursor: pointer; width: 100%; }
form.row { margin: 0; }
[data-busy][aria-busy="true"] .main-btn { opacity: 0.6; pointer-events: none; }

/* Падащ списък и бутони като ред (счетоводството) */
select.field { appearance: none; -webkit-appearance: none; cursor: pointer; }
select.field option { background: var(--surface-2); color: var(--text); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-quiet { height: 48px; width: 100%; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  color: var(--link); font-family: inherit; font-size: var(--t-sm); font-weight: 600; display: flex; align-items: center;
  justify-content: center; cursor: pointer; transition: background var(--ease); }
.btn-quiet:hover { background: var(--surface-hover); }
.btn-quiet--danger { color: #FF6961; }
.sum-row { display: flex; justify-content: space-between; gap: 12px; }
