/* Shared control tokens: keep established colors and existing layout rules. */
/* Dark surfaces need a lighter foreground; retain brand fill on primary actions. */
html[data-theme="dark"] .bottom-nav button.active,
html[data-theme="dark"] .profile-avatar > span,
html[data-theme="dark"] button.outline {
  color: #f3a6c2;
}
html[data-theme="dark"] button.outline {
  border-color: #b86687;
}
:root {
  --control-height: 42px;
  --control-padding: 10px;
  --control-font-size: 13px;
}
:root .crm-filters .crm-select,
:root .maintenance-filters input,
:root .maintenance-filters select,
:root .fmba-course-select,
:root .fmba-search-box input[type="text"],
:root .bus-filter-card input[type="date"],
:root .bus-filter-card select,
:root .document-filter-panel input,
:root .document-filter-panel select {
  height: var(--control-height);
  min-height: var(--control-height);
  min-width: 0;
  max-width: 100%;
  padding: 0 var(--control-padding);
  font-size: var(--control-font-size);
  border-radius: var(--r-chip);
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--panel);
  box-sizing: border-box;
}
:where(button, a, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--accent, #99123f);
  outline-offset: 3px;
}
.portal-changes { margin-top: 20px; min-width: 0; }
dialog > .portal-changes { margin: 0; padding: 24px; }
dialog > .portal-changes > header { position: sticky; top: 0; z-index: 1; padding: 10px 0; background: var(--panel); border-bottom: 1px solid var(--line); }
.portal-changes header, .portal-changes footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.portal-changes h2 { margin: 4px 0; font-size: 18px; }
.portal-changes footer { justify-content: flex-end; margin-top: 14px; }
.portal-state { padding: 16px; border: 1px dashed var(--line); border-radius: var(--r-chip, 12px); line-height: 1.6; font-size: 14px; }
.portal-state.is-error { border-style: solid; }
.portal-change-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.portal-change-row h3 { font-size: 14px; line-height: 1.5; margin: 6px 0; overflow-wrap: anywhere; }
.portal-change-row p, .portal-change-row ul { margin: 6px 0; padding: 0; list-style: none; font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; }
.portal-change-meta { font-size: 12px; line-height: 1.6; color: var(--muted, #64748b); }
.portal-new { display: inline-block; vertical-align: middle; font-size: 11px; font-weight: 600; padding: 2px 7px; border: 1px solid currentColor; border-radius: 20px; color: var(--accent, #99123f); }
.portal-change-row .change-before { text-decoration: line-through; }
.portal-changes button { min-height: var(--control-height); white-space: normal; }
@media (max-width: 720px) {
  :root { --control-height: 44px; --control-font-size: 16px; }
  :root .tasks-list-page .list-toolbar label:not(.task-sort-select) select {
    height: var(--control-height);
    min-height: var(--control-height);
    font-size: var(--control-font-size);
    box-sizing: border-box;
  }
  .portal-change-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .portal-change-row > button { justify-self: start; }
  .portal-changes footer > button { flex: 1 1 150px; }
  .portal-change-meta { font-size: 13px; }
  dialog > .portal-changes { padding: 16px; }
  /* Keep native sorting, but give its visible label a readable touch target. */
  :root .tasks-list-page .task-sort-select {
    display: flex !important;
    align-items: center;
    min-height: 44px;
    padding: 4px 6px;
    border: 1px solid var(--line);
    border-radius: var(--r-chip, 10px);
    box-sizing: border-box;
  }
  :root .tasks-list-page .task-sort-select span {
    font-size: 12px !important;
    line-height: 1.4;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  :root .tasks-list-page .task-sort-select select {
    inset: 0;
    height: 100%;
    min-height: 44px;
    font-size: 16px;
  }
  :root .tasks-list-page .task-sort-select:focus-within {
    outline: 2px solid var(--accent, #99123f);
    outline-offset: 3px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .boot-bar:after { animation: none; width: 100%; }
}

/* Keep past mobile agenda entries subdued without fading their small text. */
@media screen {
  [data-theme="dark"] .cal-agenda-item.is-past { opacity: .85; }
}

/* Calendar grid: keep location colours on the rail, not on small dark text. */
@media screen {
  [data-theme="dark"] .calendar-block.is-past { opacity: .85; }
  [data-theme="dark"] .calendar-block-time,
  [data-theme="dark"] .calendar-block-direction { color: var(--text); opacity: 1; }
  [data-theme="dark"] .calendar-block-location { color: var(--muted); }
}

/* Past entries remain readable in the light agenda/grid and both month views. */
@media screen {
  [data-theme="light"] .calendar-block.is-past,
  [data-theme="light"] .calendar-month-pill.is-past,
  [data-theme="light"] .cal-agenda-item.is-past { opacity: .95; }
  [data-theme="dark"] .calendar-month-pill.is-past { opacity: .85; }
}

/* ---- Поиск участника ФМБА: место под лупу ----
   Иконка лежит абсолютом слева (left:12px), а поле получало симметричный
   отступ из общего правила контролов выше — слово «Поиск» налезало на лупу. */
:root .fmba-desktop-search input[type="text"] { padding-left: 32px; }

/* ---- Тип автобуса на главной ----
   Раньше все выезды красились одним цветом и «Добрый» не отличался от
   «Бонусного». Цвета те же, что у бейджей на странице «Автобусы». */
.home3-event-kind.bus-kind,
.home2-ev .kind.bus-kind { background: #e2f5ef; color: #0a6a5c; }
.home3-event-kind.bus-bonus,
.home2-ev .kind.bus-bonus { background: #fff1d8; color: #9a6500; }
.home3-event-kind.bus-special,
.home2-ev .kind.bus-special { background: #e9edff; color: #3a55b8; }
[data-theme=dark] .home3-event-kind.bus-kind,
[data-theme=dark] .home2-ev .kind.bus-kind { background: rgba(22,139,119,.2); color: #67c9b8; }
[data-theme=dark] .home3-event-kind.bus-bonus,
[data-theme=dark] .home2-ev .kind.bus-bonus { background: rgba(168,109,8,.22); color: #e8c16b; }
[data-theme=dark] .home3-event-kind.bus-special,
[data-theme=dark] .home2-ev .kind.bus-special { background: rgba(58,85,184,.24); color: #9db2ff; }

/* Спецрейс появился позже остальных типов и остался без своего бейджа. */
.bus-type-badge.special { background: #e9edff; color: #3a55b8; }
[data-theme=dark] .bus-type-badge.special { background: rgba(58,85,184,.24); color: #9db2ff; }

/* Поле «Название нового раздела» в форме ссылки появляется под списком. */
.link-edit-form .link-category-new { margin-top: 8px; }
