/* ═══════════════════════════════════════════════
   components.css — кнопки, инпуты, карточки,
   модалы, тосты, бейджи, таблицы
═══════════════════════════════════════════════ */

/* ══════════════════════════════════════════════
   КНОПКИ
══════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--f-ui);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-base);
  border: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.btn:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* Primary */
.btn-primary {
  background: var(--c-accent);
  color: #f8f8f8;
}
.btn-primary:hover { filter: brightness(0.9); }

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--c-text);
  border: 1px solid var(--c-stroke);
}
.btn-ghost:hover {
  background: var(--c-raised);
  border-color: rgba(229,56,59,0.3);
}

/* Subtle */
.btn-subtle {
  background: var(--c-accent-s);
  color: var(--c-accent);
  border: 1px solid rgba(229,56,59,0.2);
}
.btn-subtle:hover { background: rgba(229,56,59,0.18); }

/* Danger */
.btn-danger {
  background: var(--c-accent);
  color: #f8f8f8;
}
.btn-danger:hover { filter: brightness(0.85); }

/* OK */
.btn-ok {
  background: var(--c-ok);
  color: #131315;
}
.btn-ok:hover { filter: brightness(0.9); }

/* Mono */
.btn-mono {
  font-family: var(--f-mono);
  font-size: 11px;
  padding: 6px 14px;
  background: var(--c-raised);
  color: var(--c-muted);
  border: 1px solid var(--c-stroke);
}
.btn-mono:hover { color: var(--c-text); border-color: rgba(229,56,59,0.3); }

/* Sizes */
.btn-sm { font-size: 12px; padding: 5px 12px; border-radius: var(--r-sm); }
.btn-lg { font-size: 15px; padding: 11px 24px; border-radius: var(--r-lg); }
.btn-full { width: 100%; }

/* Spinner в кнопке */
.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ══════════════════════════════════════════════
   ИНПУТЫ И ФОРМЫ
══════════════════════════════════════════════ */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  font-size: 13px;
  font-weight: 500;
  color: var(--c-text);
}
.label-hint {
  font-size: 12px;
  color: var(--c-muted);
  margin-left: 6px;
  font-weight: 400;
}

.input,
.select,
.textarea {
  font-family: var(--f-ui);
  font-size: 14px;
  color: var(--c-text);
  background: var(--c-bg);
  border: 1px solid var(--c-stroke);
  border-radius: var(--r-md);
  padding: 9px 12px;
  outline: none;
  transition: border-color var(--t-base), box-shadow var(--t-base);
  width: 100%;
  line-height: 1.5;
}
.input::placeholder,
.textarea::placeholder { color: var(--c-muted); }

.input:hover,
.select:hover,
.textarea:hover { border-color: rgba(229,56,59,0.25); }

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-s);
}

.input.input-error,
.select.input-error { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-s); }
.input.input-ok,
.select.input-ok    { border-color: var(--c-ok);     box-shadow: 0 0 0 3px var(--c-ok-s); }

.input:disabled,
.select:disabled,
.textarea:disabled { opacity: 0.45; cursor: not-allowed; }

.textarea { resize: vertical; min-height: 80px; }

/* Select */
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23858589'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}
.select option { background: var(--c-raised); color: var(--c-text); }

/* Input с иконкой */
.input-wrap { position: relative; display: flex; align-items: center; }
.input-icon { position: absolute; left: 10px; color: var(--c-muted); font-size: 13px; pointer-events: none; }
.input-wrap .input { padding-left: 32px; }
.input-suffix { position: absolute; right: 10px; font-family: var(--f-mono); font-size: 11px; color: var(--c-muted); pointer-events: none; }
.input-wrap .input.has-suffix { padding-right: 40px; }

/* Number input без стрелок */
.input-number-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
  background: var(--c-bg);
  border: 1px solid var(--c-stroke);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.input-number-wrap:focus-within {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-s);
}
.input-number-wrap .input {
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  flex: 1;
  min-width: 0;
  padding-right: 4px;
}
.input-number-wrap .input:focus { border: none; box-shadow: none; }
.input[type=number]::-webkit-inner-spin-button,
.input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.number-btns {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--c-stroke);
  flex-shrink: 0;
}
.number-btn {
  width: 22px;
  flex: 1;
  border: none;
  background: none;
  color: var(--c-muted);
  cursor: pointer;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  padding: 0;
  font-family: var(--f-mono);
  line-height: 1;
}
.number-btn:hover { background: var(--c-raised); color: var(--c-accent); }
.number-btn:active { background: var(--c-accent-s); }
.number-btn + .number-btn { border-top: 1px solid var(--c-stroke); }

/* Checkbox / Radio */
.check-row { display: flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-size: 13px; color: var(--c-text); }
.check {
  width: 16px; height: 16px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--c-stroke);
  background: var(--c-bg);
  appearance: none;
  cursor: pointer;
  transition: all var(--t-base);
  flex-shrink: 0;
  position: relative;
}
.check:checked { background: var(--c-accent); border-color: var(--c-accent); }
.check:checked::after {
  content: '';
  position: absolute;
  left: 4px; top: 1.5px;
  width: 5px; height: 9px;
  border: 2px solid #f8f8f8;
  border-top: none; border-left: none;
  transform: rotate(45deg);
}
.check.radio { border-radius: var(--r-pill); }
.check.radio:checked::after {
  left: 3px; top: 3px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #f8f8f8;
  border: none; transform: none;
}

/* Toggle */
.toggle-wrap { display: flex; align-items: center; gap: var(--sp-2); cursor: pointer; }
.toggle {
  width: 36px; height: 20px;
  background: var(--c-stroke);
  border-radius: var(--r-pill);
  position: relative;
  transition: background var(--t-base);
  cursor: pointer;
  border: none;
  flex-shrink: 0;
}
.toggle.on { background: var(--c-accent); }
.toggle::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  background: var(--c-text);
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform var(--t-base);
}
.toggle.on::after { transform: translateX(16px); }

/* Helper text */
.field-helper     { font-size: 12px; color: var(--c-muted); margin-top: 4px; }
.field-error-msg  { font-size: 12px; color: var(--c-accent); margin-top: 4px; }
.field-ok-msg     { font-size: 12px; color: var(--c-ok);     margin-top: 4px; }

/* Form grid */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-4); }

@media (max-width: 640px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════
   КАРТОЧКИ
══════════════════════════════════════════════ */

.card {
  background: var(--c-raised);
  border: 1px solid var(--c-stroke);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
}

.card-sm { border-radius: var(--r-lg); padding: var(--sp-4); }
.card-lg { border-radius: var(--r-2xl); padding: var(--sp-6); }

.card-interactive {
  cursor: pointer;
  transition: all var(--t-base);
}
.card-interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(229,56,59,0.15);
}

/* Инфо-карточка (метрика) */
.info-card {
  background: var(--c-bg);
  border: 1px solid var(--c-stroke);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.info-card-label {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-muted);
}
.info-card-value {
  font-size: 22px;
  font-weight: 600;
  font-family: var(--f-mono);
  color: var(--c-text);
  line-height: 1.2;
}
.info-card-value.accent { color: var(--c-accent); }
.info-card-value.ok     { color: var(--c-ok); }
.info-card-value.warn   { color: var(--c-warn); }

/* ══════════════════════════════════════════════
   БЕЙДЖИ
══════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-ok       { background: var(--c-ok-s);     color: var(--c-ok); }
.badge-warn     { background: var(--c-warn-s);   color: var(--c-warn); }
.badge-critical { background: var(--c-accent-s); color: var(--c-accent); }
.badge-muted    { background: var(--c-raised);   color: var(--c-muted); border: 1px solid var(--c-stroke); }

/* ══════════════════════════════════════════════
   ТАБЛИЦЫ
══════════════════════════════════════════════ */

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-muted);
  padding: 0 var(--sp-3) var(--sp-3);
  border-bottom: 1px solid var(--c-stroke);
  white-space: nowrap;
}
.table td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--c-stroke);
  vertical-align: middle;
  color: var(--c-text);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--c-raised); }

/* ══════════════════════════════════════════════
   ТОСТ
══════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  bottom: var(--sp-6);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  align-items: center;
  z-index: 999;
  pointer-events: none;
  width: min(90vw, 420px);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--c-raised);
  border: 1px solid var(--c-stroke);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--c-text);
  pointer-events: all;
  width: 100%;

  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--t-base), transform var(--t-base);
}
.toast.toast-visible { opacity: 1; transform: none; }
.toast.toast-hiding  { opacity: 0; transform: translateY(8px); }

.toast-ok       { border-color: rgba(74,222,128,0.25); }
.toast-warn     { border-color: rgba(251,191,36,0.25); }
.toast-error    { border-color: rgba(229,56,59,0.3); }

.toast-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.toast-ok    .toast-icon { color: var(--c-ok); }
.toast-warn  .toast-icon { color: var(--c-warn); }
.toast-error .toast-icon { color: var(--c-accent); }
.toast-note  .toast-icon { color: var(--c-muted); }

.toast-msg  { flex: 1; line-height: 1.4; }
.toast-close {
  background: none;
  border: none;
  color: var(--c-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  transition: color var(--t-fast);
}
.toast-close:hover { color: var(--c-text); }

/* ══════════════════════════════════════════════
   МОДАЛЬНЫЕ ОКНА
══════════════════════════════════════════════ */

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 200;
  backdrop-filter: blur(3px);
}
.modal-backdrop.modal-backdrop-visible { display: block; }

.modal-container {
  position: fixed;
  inset: 0;
  z-index: 201;
  display: grid;
  grid-template: 1fr / 1fr;   /* single cell */
  place-items: center;
  padding: var(--sp-4);
  pointer-events: none;
}
/* Все модалы в одну ячейку — накладываются, не стекируются вертикально */
.modal-container > .modal { grid-area: 1 / 1; }

.modal {
  background: var(--c-base);
  border: 1px solid var(--c-stroke);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  pointer-events: all;
  position: relative;

  opacity: 0;
  transform: translateY(-12px) scale(0.98);
  transition: opacity var(--t-base), transform var(--t-base);
}
.modal.modal-visible { opacity: 1; transform: none; }
.modal.modal-hiding  { opacity: 0; transform: translateY(-12px) scale(0.98); }
/* Схлопывание родительского модала при открытии дочернего */
.modal.modal-collapsed {
  transform: scaleY(0);
  transform-origin: center center;
  opacity: 0.25;
  pointer-events: none;
  overflow: hidden;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.5s ease;
}
/* Раскрытие обратно */
.modal.modal-expanding {
  transform: scaleY(1) !important;
  opacity: 1 !important;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.5s ease !important;
}
/* Медленное появление дочернего модала (0.5s вместо дефолтных 0.18s) */
.modal.modal-slow-appear {
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}



.modal-sm { max-width: 360px; }
.modal-md { max-width: 520px; }
.modal-lg { max-width: 720px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6) var(--sp-4);
  border-bottom: 1px solid var(--c-stroke);
  position: sticky;
  top: 0;
  background: var(--c-base);
  z-index: 1;
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--c-text);
}
.modal-close {
  background: none;
  border: none;
  color: var(--c-muted);
  cursor: pointer;
  font-size: 16px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  transition: all var(--t-fast);
}
.modal-close:hover { background: var(--c-raised); color: var(--c-accent); }

.modal-body {
  padding: var(--sp-5) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6) var(--sp-5);
  border-top: 1px solid var(--c-stroke);
}

/* Текст подтверждения */
.confirm-text { font-size: 14px; color: var(--c-text); line-height: 1.6; }

/* ══════════════════════════════════════════════
   ПУСТОЕ СОСТОЯНИЕ
══════════════════════════════════════════════ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
  gap: var(--sp-3);
}
.empty-icon { font-size: 36px; opacity: 0.3; }
.empty-msg  { font-size: 14px; color: var(--c-muted); max-width: 300px; line-height: 1.6; }

/* ══════════════════════════════════════════════
   УВЕДОМЛЕНИЯ-БАННЕРЫ
══════════════════════════════════════════════ */

.alert {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  font-size: 13px;
  line-height: 1.5;
}
.alert-tag {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  opacity: 0.7;
  flex-shrink: 0;
}
.alert-ok       { background: var(--c-ok-s);     border: 1px solid rgba(74,222,128,0.18);   color: var(--c-ok); }
.alert-warn     { background: var(--c-warn-s);   border: 1px solid rgba(251,191,36,0.18);   color: var(--c-warn); }
.alert-critical { background: var(--c-accent-s); border: 1px solid rgba(229,56,59,0.2);    color: var(--c-accent); }
.alert-note     { background: var(--c-raised);   border: 1px solid var(--c-stroke);         color: var(--c-muted); }

/* ══════════════════════════════════════════════
   РАЗДЕЛИТЕЛИ И СЕКЦИИ
══════════════════════════════════════════════ */

.divider { height: 1px; background: var(--c-stroke); margin: var(--sp-5) 0; }

.section-label {
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-muted);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--c-stroke);
}

/* ══════════════════════════════════════════════
   ФОТО-АВАТАР
══════════════════════════════════════════════ */

.avatar {
  border-radius: var(--r-lg);
  object-fit: cover;
  background: var(--c-bg);
  border: 1px solid var(--c-stroke);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--c-muted);
  flex-shrink: 0;
}
.avatar-sm { width: 40px;  height: 40px;  font-size: 18px; }
.avatar-md { width: 64px;  height: 64px;  font-size: 28px; }
.avatar-lg { width: 96px;  height: 96px;  font-size: 40px; }

/* ══════════════════════════════════════════════
   ИНДИКАТОР ЦВЕТА КАТУШКИ
══════════════════════════════════════════════ */

.color-dot {
  border-radius: var(--r-sm);
  border: 1px solid var(--c-stroke);
  flex-shrink: 0;
}
.color-dot-sm { width: 20px; height: 20px; }
.color-dot-md { width: 32px; height: 32px; }
.color-dot-lg { width: 48px; height: 48px; border-radius: var(--r-md); }

/* ── Карусель заказов на дашборде ───────────── */

/* Обёртка: стрелки по бокам, карточки по центру */
.orders-carousel-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

/* Сетка карточек — колонки задаются из JS через inline style */
.orders-cards-grid {
  flex: 1;
  display: grid;
  gap: var(--sp-2);
  min-width: 0;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

/* Карточки не должны вылезать за сетку */
.orders-cards-grid .order-card-mini {
  min-width: 0;
  width: 100%;
}

/* Стрелки — только символ, без фона и рамки */
.carousel-arrow {
  flex-shrink: 0;
  width: 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: var(--c-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--t-fast);
  user-select: none;
  padding: 0;
}
.carousel-arrow:hover {
  color: var(--c-accent);
}
.carousel-arrow-hidden {
  visibility: hidden;
  pointer-events: none;
}

/* Точки пагинации */
.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: var(--sp-1) 0 0;
}
.carousel-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-stroke);
  cursor: pointer;
  transition: all var(--t-fast);
}
.carousel-dot.active {
  background: var(--c-accent);
  width: 16px;
  border-radius: 3px;
}

/* Пустая иконка заказа */
.order-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--c-muted);
  background: var(--c-raised);
}

/* ── info-card кликабельный ─────────────────── */
.info-card-link {
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.info-card-link:hover {
  border-color: rgba(229,56,59,.25);
  box-shadow: 0 0 0 2px var(--c-accent-s);
}

/* ── Milestones ──────────────────────────────── */
.milestone-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-bg);
  border: 1px solid var(--c-stroke);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-2);
  transition: all var(--t-fast);
}
.milestone-row:hover { border-color: var(--c-stroke); }
.milestone-done { opacity: 0.6; }
.milestone-done .milestone-title { text-decoration: line-through; }

.milestone-check {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border: 2px solid var(--c-stroke);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--c-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  margin-top: 1px;
}
.milestone-check:hover {
  border-color: var(--c-ok);
  color: var(--c-ok);
}
.milestone-done .milestone-check {
  background: var(--c-ok);
  border-color: var(--c-ok);
  color: #fff;
}

.milestone-body    { flex: 1; min-width: 0; }
.milestone-title   { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.milestone-note    { font-size: 12px; color: var(--c-muted); line-height: 1.5; margin-top: 2px; white-space: pre-wrap; }
.milestone-done-at { font-size: 11px; color: var(--c-ok); margin-top: 4px; font-family: var(--f-mono); }

.milestone-del {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--c-muted);
  cursor: pointer;
  font-size: 12px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all var(--t-fast);
}
.milestone-row:hover .milestone-del { opacity: 1; }
.milestone-del:hover { background: var(--c-accent-s); color: var(--c-accent); }

/* ══════════════════════════════════════════════
   МОБИЛЬНАЯ АДАПТАЦИЯ КОМПОНЕНТОВ
══════════════════════════════════════════════ */

/* ── iOS zoom fix: инпуты ≥ 16px — браузер не зумит ────── */
@media (max-width: 768px) {
  .input,
  .select,
  .textarea {
    font-size: 16px !important;
  }
}

/* ── Кнопки: минимальная тач-зона 44px ─────────────────── */
@media (max-width: 768px) {
  .btn {
    min-height: 44px;
  }
  /* Маленькие кнопки — чуть меньше, но всё равно удобно */
  .btn-sm {
    min-height: 36px;
  }
  /* Кнопка закрытия модала */
  .modal-close {
    width: 36px;
    height: 36px;
  }
  /* Кнопки-тоглы в топбаре */
  .btn-topbar-toggle {
    min-height: 36px;
    display: flex;
    align-items: center;
  }
}

/* ── Модальные окна → bottom sheet на мобиле ───────────── */
@media (max-width: 768px) {
  /* Прижимаем контейнер к низу */
  .modal-container {
    align-items: flex-end;
    padding: 0;
  }

  /* Все модалы — full-width, округление только сверху */
  .modal {
    border-radius: var(--r-2xl) var(--r-2xl) 0 0 !important;
    max-width: 100% !important;
    width: 100%;
    /* dvh корректно учитывает адресную строку мобила */
    max-height: 92dvh;
    /* Переопределяем анимацию: снизу вверх */
    transform: translateY(40px);
    opacity: 0;
  }

  .modal.modal-visible {
    transform: translateY(0);
    opacity: 1;
  }

  .modal.modal-hiding {
    transform: translateY(40px);
    opacity: 0;
  }

  .modal.modal-collapsed {
    transform: translateY(100%);
    opacity: 0;
  }

  /* Шапка модала */
  .modal-header {
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    /* Место под drag-handle */
    padding-top: calc(var(--sp-5) + 10px);
    position: relative;
  }

  /* Drag-handle — полоска-индикатор */
  .modal-header::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: var(--c-stroke);
    border-radius: var(--r-pill);
  }

  /* Подложка модала — тёмная, но можно закрыть тапом */
  .modal-backdrop.modal-backdrop-visible {
    cursor: pointer;
  }

  /* Футер: кнопки стопкой (основное действие наверху стека = визуально внизу) */
  .modal-footer {
    flex-direction: column-reverse;
    padding: var(--sp-3) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom, 0px));
  }

  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }

  /* Тело модала — чуть компактнее */
  .modal-body {
    padding: var(--sp-4) var(--sp-4);
  }
}

/* ── Таблицы: горизонтальный скролл ────────────────────── */
@media (max-width: 768px) {
  .table-wrap {
    -webkit-overflow-scrolling: touch;
    /* Тень-подсказка что можно скроллить */
    background:
      linear-gradient(to right, var(--c-base) 0%, transparent 40px) left,
      linear-gradient(to left,  var(--c-base) 0%, transparent 40px) right;
    background-color: var(--c-base);
    background-attachment: local, local;
  }

  /* Минимальная ширина чтобы таблица не сжималась некрасиво */
  .table { min-width: 480px; }
}

/* ── Тосты: ширина на мобиле ────────────────────────────── */
@media (max-width: 480px) {
  .toast-container {
    width: calc(100vw - 2 * var(--sp-3));
    left: var(--sp-3);
    transform: none;
    bottom: calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
  }
}

/* ── Гостевой режим: приглашение войти вместо формы ─────── */
.guest-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-3);
  border: 1px dashed var(--c-stroke);
  border-radius: var(--r-md);
  background: var(--c-raised);
  color: var(--c-muted);
  font-size: 13px;
}

/* Кнопка входа в топбаре — на мобиле подписи прячутся, эта нужна всегда */
#topbarLoginBtn { white-space: nowrap; }

/* ── Запертые разделы у гостя ───────────────────────────── */
/* Показываем, но глушим: гость должен видеть, что ещё умеет платформа.
   Клик работает — открывает модалку входа, поэтому не pointer-events:none. */
.nav-item--locked { opacity: .45; }
.nav-item--locked:hover { opacity: .7; }

.nav-item--locked .nav-lock {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.nav-item--locked .nav-lock .lucide-icon {
  width: 13px;
  height: 13px;
  opacity: .8;
}
/* Бейдж и счётчик рядом с замком гостю не нужны — данных за ними нет */
.nav-item--locked .nav-badge,
.nav-item--locked .nav-count { display: none; }

/* Вкладка «Мои профили» у гостя — заперта так же, как пункты меню */
.period-tab--locked { opacity: .45; }
.period-tab--locked:hover { opacity: .7; }
.period-tab--locked .lucide-icon {
  width: 12px;
  height: 12px;
  vertical-align: -1px;
}

/* ── Приглашение зарегистрироваться ─────────────────────── */
.guest-panel {
  margin: var(--sp-4) var(--sp-3) var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--c-stroke);
  border-radius: var(--r-md);
  background: var(--c-raised);
}

.guest-panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 6px;
}
.guest-panel-title .lucide-icon { width: 14px; height: 14px; }

.guest-panel-body {
  margin: 0 0 var(--sp-3);
  font-size: 12px;
  line-height: 1.5;
  color: var(--c-muted);
}

/* ── Отчёт о частично загруженном наборе ────────────────── */
.bundle-fail-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--c-stroke);
  border: 1px solid var(--c-stroke);
  border-radius: var(--r-md);
  overflow: hidden;
  max-height: 300px;
  overflow-y: auto;
}

.bundle-fail-row {
  padding: var(--sp-2) var(--sp-3);
  background: var(--c-raised);
}

.bundle-fail-file {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--c-text);
  word-break: break-all;
}

.bundle-fail-why {
  font-size: 12px;
  color: var(--c-accent);
  margin-top: 2px;
}
