/* ============================================================================
   Раскладка кабинета (фаза 6) поверх дизайн-системы theme.css.
   Только layout/утилиты страниц — токены и компоненты живут в theme.css.
   ========================================================================== */

/* --------------------------------- общее --------------------------------- */
/* Атрибут hidden обязан скрывать элемент даже при заданном display
   (напр. .field { display:flex } из theme.css перебивал UA-стиль [hidden]) —
   иначе переключатель источника мастера не прячет блоки формы. */
[hidden] { display: none !important; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; margin-bottom: 22px;
}
.page-title { font-size: 26px; margin-top: 6px; }
.section { margin-top: 24px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 26px; }
.actions-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline-row input { flex: 1; min-width: 160px; }
/* строка «поле с label + кнопка»: кнопка выравнивается по НИЗУ поля,
   а не по центру (иначе поле с подписью и кнопка пляшут по высоте) */
.form-row-end { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.form-row-end .field { flex: 1; min-width: 180px; margin-bottom: 0; }
.form-row-end .btn { margin-bottom: 1px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* сообщения форм (JS: note()) */
.form-note { font-size: 13.5px; margin: 10px 0; }
.form-note.ok { color: var(--ok); }
.form-note.error { color: var(--err); }

/* --------------------------------- auth ---------------------------------- */
.auth-wrap { max-width: 420px; margin: 7vh auto 0; }

/* -------------------------------- лендинг -------------------------------- */
.landing-hero { text-align: center; padding: 44px 12px 36px; max-width: 760px; margin: 0 auto; }
.landing-hero h1 { font-size: clamp(28px, 4.6vw, 42px); line-height: 1.18; margin: 14px 0 16px; }
.landing-lead { font-size: 16.5px; line-height: 1.65; color: var(--muted); margin: 0 auto 24px; max-width: 640px; }
.landing-hero .actions-row { justify-content: center; }
.landing-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px; margin: 8px 0 26px;
}
.landing-ico { font-size: 26px; margin-bottom: 10px; }
.landing-grid h3 { margin-bottom: 8px; font-size: 16.5px; }
.landing-why { margin-bottom: 26px; }
.landing-why h2, .landing-contact h2 { font-size: 21px; margin-bottom: 12px; }
.landing-list { margin: 0; padding-left: 20px; }
.landing-list li { margin: 10px 0; line-height: 1.6; }
.landing-contact { max-width: 720px; margin: 0 auto; }
.landing-captcha label { font-weight: 600; }
.landing-footer { text-align: center; margin-top: 34px; font-size: 13px; }

/* -------------------------------- таблицы -------------------------------- */
.table-card { padding: 6px 0; overflow-x: auto; }
.table-scroll { overflow-x: auto; }
.cell-progress { min-width: 170px; }
.cell-progress progress { width: 110px; vertical-align: middle; margin-right: 8px; }
.cell-actions { text-align: right; white-space: nowrap; }
/* компактные кнопки-иконки в строке таблицы вместо текстовых (экономят ширину) */
.cell-actions .row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; }
.icon-btn-sm { width: 32px; height: 32px; border-radius: 9px; font-size: 15px; }
.icon-btn-sm svg { width: 16px; height: 16px; display: block; }
.icon-btn[disabled] { opacity: .5; pointer-events: none; }
.empty-card { text-align: center; padding: 44px 22px; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; }

/* --------------------------- мастер новой задачи --------------------------- */
.media-map { border: 1px solid var(--hair); border-radius: var(--r-md); padding: 14px 16px; margin: 0 0 16px; }
.media-map legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 6px; }
.media-map-row {
  display: grid; grid-template-columns: minmax(120px, 1fr) minmax(140px, 1fr) minmax(120px, 1fr);
  gap: 10px; align-items: end; padding: 8px 0; border-bottom: 1px solid var(--hair);
}
.media-map-row:last-child { border-bottom: none; }
.media-map-row .file-name { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); word-break: break-all; align-self: center; }
.media-map-row .field { margin-bottom: 0; }

.upload-block { display: flex; align-items: center; gap: 12px; margin: 14px 0 4px; }
.upload-block progress { flex: 1; }

/* чекбокс-строка в .field (режим транскрибации мастера) */
.check-line { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.check-line input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }

/* «Другие параметры» мастера: summary-ссылка + шкалы range */
details.other-params > summary {
  cursor: pointer; font-size: 14px; font-weight: 600; color: var(--accent);
  margin: 2px 0 12px; width: fit-content;
}
details.other-params > summary:hover { text-decoration: underline; }
.field input[type="range"] {
  accent-color: var(--accent); background: transparent; border: none;
  padding: 8px 0; cursor: pointer;
}
.field input[type="range"]:focus { border: none; }
.field label output { font-family: var(--font-mono); color: var(--accent); font-size: 13px; }

/* тумблер-выключатель (шапка мастера: «Готовые транскрипты») */
.switch-line {
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--muted); user-select: none;
  padding: 8px 0; align-self: center;
}
.switch-line input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-line .switch {
  flex: none; width: 36px; height: 20px; border-radius: 100px;
  background: var(--chip); border: 1px solid var(--line);
  position: relative; transition: background .15s ease, border-color .15s ease;
}
.switch-line .switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--muted); transition: transform .15s ease, background .15s ease;
}
.switch-line input:checked + .switch { background: var(--accent); border-color: var(--accent); }
.switch-line input:checked + .switch::after { transform: translateX(16px); background: #fff; }
.switch-line input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-line:hover { color: var(--text); }

/* ----------------------------- детальная задачи ---------------------------- */
.progress-line { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.progress-line progress { flex: 1; min-width: 160px; }
.log-title { margin-top: 18px; font-size: 14px; color: var(--muted); }

/* сворачиваемый лог задачи (details, открытие переживает HTMX-свапы) */
.job-log { margin-top: 16px; }
.job-log > summary {
  cursor: pointer; width: fit-content; list-style: none;
  font-size: 13.5px; font-weight: 600; color: var(--accent);
}
.job-log > summary::-webkit-details-marker { display: none; }
.job-log > summary::after { content: " ▾"; font-size: 12px; }
.job-log[open] > summary::after { content: " ▴"; }
.job-log > summary:hover { text-decoration: underline; }
.log-lines {
  list-style: none; margin: 10px 0 0; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--hair); border-radius: var(--r-md);
  max-height: 420px; overflow-y: auto;
  font-size: 13px; line-height: 1.7;
}
.log-ts { color: var(--faint); margin-right: 10px; font-size: 12px; }
.log-msg.log-warn { color: var(--warn); }
.log-msg.log-error { color: var(--err); }
.log-msg.log-debug { color: var(--faint); }

/* ---------------------------- просмотрщик отчёта -------------------------- */
.report-frame {
  width: 100%; height: 78vh; border: 1px solid var(--hair);
  border-radius: var(--r-md); background: var(--surface);
}
.code-editor { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; min-height: 260px; resize: vertical; }
details.section > summary { cursor: pointer; font-weight: 600; }

/* -------------------------------- проекты -------------------------------- */
.project-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.project-head h3 { display: flex; align-items: center; gap: 10px; }

/* ------------------------------- настройки -------------------------------- */
.secret-box {
  margin-top: 14px; padding: 14px 16px; border-radius: var(--r-md);
  border: 1px dashed var(--accent); background: var(--accent-soft);
}
.secret-box label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.secret-box input { width: auto; flex: 1; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 9px 12px; }
.events-row { border: 1px solid var(--hair); border-radius: var(--r-md); padding: 10px 14px; margin: 0 0 14px; display: flex; gap: 20px; flex-wrap: wrap; }
.events-row legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 6px; }
.events-row label { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; }

/* --------------------------------- квоты ---------------------------------- */
.usage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.usage-row { margin-top: 14px; }
.usage-row-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-bottom: 6px; }
.meter {
  height: 8px; border-radius: 100px; background: var(--chip);
  border: 1px solid var(--hair); overflow: hidden;
}
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 100px; transition: width .3s ease; }
.meter > i.meter-hot { background: var(--err); }

/* ------------------------------- адаптивность ----------------------------- */
@media (max-width: 760px) {
  .main-nav { display: none; }
  .page-head { flex-direction: column; }
  .media-map-row { grid-template-columns: 1fr; }
  .report-frame { height: 64vh; }
}

/* --- Тултип графиков статистики (admin/_charts.html + admin.js) --- */
.chart-tip {
  position: fixed; z-index: 999; pointer-events: none;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 6px 11px; font-size: 12.5px; font-weight: 600;
  box-shadow: var(--shadow-soft); white-space: nowrap;
}
svg.chart g.bar:hover .bar-fill { opacity: .8; }
svg.chart g.pt:hover .pt-dot { r: 5; }

/* --- Инструкция по API (/cabinet/api-docs) --- */
.sec-head-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.api-docs { max-width: 900px; }
.api-docs h1 { margin-top: 6px; }
.api-toc { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 22px 0; padding: 14px 18px; }
.api-toc a { font-size: 13.5px; font-weight: 600; color: var(--muted); text-decoration: none; padding: 4px 0; }
.api-toc a:hover { color: var(--accent); }
.api-sec { margin-bottom: 18px; }
.api-sec h2 { font-size: 19px; margin-bottom: 10px; }
.api-sec p { margin: 8px 0; color: var(--text); font-size: 14.5px; }
.api-sec p.muted { color: var(--muted); }
.api-sec a { color: var(--accent); }
.api-list { margin: 8px 0 0; padding-left: 20px; font-size: 14.5px; }
.api-list li { margin: 6px 0; }
pre.codeblock {
  background: var(--bg-2); border: 1px solid var(--hair); border-radius: var(--r-md);
  padding: 14px 16px; margin: 10px 0; overflow-x: auto;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.65;
  color: var(--text); white-space: pre;
}
.api-sec .table-wrap { overflow-x: auto; }

/* вкладки полных примеров (§13): Python / PHP / Windows .bat */
.api-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.api-tab-panel[hidden] { display: none; }

/* --- Подсветка кода highlight.js в .codeblock (обе темы через палитру) --- */
.codeblock code.hljs { display: block; background: transparent; padding: 0; color: var(--text); }
.codeblock .hljs-keyword,
.codeblock .hljs-built_in,
.codeblock .hljs-type { color: var(--accent); }
.codeblock .hljs-string { color: var(--ok); }
.codeblock .hljs-number,
.codeblock .hljs-literal,
.codeblock .hljs-symbol { color: var(--violet); }
.codeblock .hljs-comment { color: var(--faint); font-style: italic; }
.codeblock .hljs-title,
.codeblock .hljs-function,
.codeblock .hljs-section { color: var(--info); }
.codeblock .hljs-attr,
.codeblock .hljs-attribute,
.codeblock .hljs-variable,
.codeblock .hljs-meta { color: var(--warn); }
/* светлая тема: те же цвета более тёмными оттенками — иначе не хватает контраста на светлом фоне */
html[data-theme="light"] .codeblock .hljs-keyword,
html[data-theme="light"] .codeblock .hljs-built_in,
html[data-theme="light"] .codeblock .hljs-type { color: var(--accent-deep); }
html[data-theme="light"] .codeblock .hljs-string { color: #1d8a55; }
html[data-theme="light"] .codeblock .hljs-number,
html[data-theme="light"] .codeblock .hljs-literal,
html[data-theme="light"] .codeblock .hljs-symbol { color: #6a58e0; }
html[data-theme="light"] .codeblock .hljs-title,
html[data-theme="light"] .codeblock .hljs-function,
html[data-theme="light"] .codeblock .hljs-section { color: #1273c4; }
html[data-theme="light"] .codeblock .hljs-attr,
html[data-theme="light"] .codeblock .hljs-attribute,
html[data-theme="light"] .codeblock .hljs-variable,
html[data-theme="light"] .codeblock .hljs-meta { color: #9c6a06; }
