/* ============================================================
   ProfitAI UI — Apple Human Interface Guidelines
   font-stack: SF Pro / системный шрифт Apple (явное требование
   пользователя: интерфейс по Apple HIG), поэтому системный стек
   здесь — осознанный выбор бренда, а не дефолт.
   ============================================================ */

:root {
  /* Поверхности */
  --bg: #f2f2f7;                  /* systemGroupedBackground */
  --elev: #ffffff;                /* secondarySystemGroupedBackground */
  --elev2: #f2f2f7;
  --material: rgba(255, 255, 255, 0.78);
  --sidebar-material: rgba(242, 242, 247, 0.78);

  /* Текст */
  --text: #1d1d1f;
  --text-2: rgba(60, 60, 67, 0.60);
  --text-3: rgba(60, 60, 67, 0.33);

  /* Разделители и заливки */
  --sep: rgba(60, 60, 67, 0.29);
  --sep-lite: rgba(60, 60, 67, 0.14);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.16);
  --fill-3: rgba(120, 120, 128, 0.22);

  /* Семантика (iOS system colors) */
  --tint: #007aff;
  --tint-soft: rgba(0, 122, 255, 0.14);
  --btn-filled: #0071e3;
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, 0.15);
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, 0.13);
  --orange: #ff9500;
  --orange-soft: rgba(255, 149, 0, 0.16);

  /* Форма */
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 9px;

  /* Тени и движение */
  --shadow-card: 0 1px 1px rgba(0, 0, 0, 0.03), 0 6px 20px rgba(0, 0, 0, 0.05);
  --shadow-float: 0 12px 40px rgba(0, 0, 0, 0.18);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --elev: #1c1c1e;
    --elev2: #2c2c2e;
    --material: rgba(28, 28, 30, 0.76);
    --sidebar-material: rgba(18, 18, 20, 0.72);
    --text: #f5f5f7;
    --text-2: rgba(235, 235, 245, 0.60);
    --text-3: rgba(235, 235, 245, 0.30);
    --sep: rgba(84, 84, 88, 0.65);
    --sep-lite: rgba(84, 84, 88, 0.42);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-2: rgba(120, 120, 128, 0.32);
    --fill-3: rgba(120, 120, 128, 0.36);
    --tint: #0a84ff;
    --tint-soft: rgba(10, 132, 255, 0.22);
    --btn-filled: #0071e3;
    --green: #30d158;
    --green-soft: rgba(48, 209, 88, 0.20);
    --red: #ff453a;
    --red-soft: rgba(255, 69, 58, 0.20);
    --orange: #ff9f0a;
    --orange-soft: rgba(255, 159, 10, 0.20);
    --shadow-card: 0 1px 1px rgba(0, 0, 0, 0.25), 0 6px 20px rgba(0, 0, 0, 0.35);
    --shadow-float: 0 12px 40px rgba(0, 0, 0, 0.55);
  }
}

/* Ручное переключение темы (дубль тёмных токенов) */
:root[data-theme="dark"] {
  --bg: #000000;
  --elev: #1c1c1e;
  --elev2: #2c2c2e;
  --material: rgba(28, 28, 30, 0.76);
  --sidebar-material: rgba(18, 18, 20, 0.72);
  --text: #f5f5f7;
  --text-2: rgba(235, 235, 245, 0.60);
  --text-3: rgba(235, 235, 245, 0.30);
  --sep: rgba(84, 84, 88, 0.65);
  --sep-lite: rgba(84, 84, 88, 0.42);
  --fill: rgba(120, 120, 128, 0.24);
  --fill-2: rgba(120, 120, 128, 0.32);
  --fill-3: rgba(120, 120, 128, 0.36);
  --tint: #0a84ff;
  --tint-soft: rgba(10, 132, 255, 0.22);
  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.20);
  --red: #ff453a;
  --red-soft: rgba(255, 69, 58, 0.20);
  --orange: #ff9f0a;
  --orange-soft: rgba(255, 159, 10, 0.20);
  --shadow-card: 0 1px 1px rgba(0, 0, 0, 0.25), 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-float: 0 12px 40px rgba(0, 0, 0, 0.55);
}

/* ---------- База ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: color-mix(in srgb, var(--tint) 25%, transparent); }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--fill-3); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }
.muted { color: var(--text-2); font-size: 13px; }

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4.5px color-mix(in srgb, var(--tint) 55%, transparent);
}

/* ---------- Экран входа ---------- */
.auth { position: fixed; inset: 0; z-index: 90; display: none; place-items: center; background: var(--bg); padding: 20px; }
.auth.show { display: grid; }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--elev); border: 1px solid var(--sep-lite);
  border-radius: 20px; box-shadow: var(--shadow-card);
  padding: 34px 30px 26px; text-align: center;
  animation: view-in 0.3s var(--ease);
}
.auth-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; margin: 0 0 4px; }
.auth-sub { margin: 0 0 24px; color: var(--text-2); font-size: 14px; }
.auth-card form { text-align: left; }
.auth-error { color: var(--red); font-size: 13px; margin: -2px 0 12px; }
.auth-foot { margin: 18px 0 0; font-size: 12px; color: var(--text-3); }

.app-mark {
  width: 32px; height: 32px; border-radius: 8.5px;
  background: var(--btn-filled); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 17px; letter-spacing: 0;
  flex-shrink: 0;
}
.app-mark.lg { width: 64px; height: 64px; border-radius: 16px; font-size: 30px; margin: 0 auto 16px; box-shadow: 0 10px 24px color-mix(in srgb, var(--tint) 38%, transparent); }

/* ---------- Каркас: сайдбар + контент ---------- */
.app-shell { display: flex; min-height: 100dvh; align-items: stretch; }

.sidebar {
  width: 250px; flex: 0 0 250px;
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--sidebar-material);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-right: 1px solid var(--sep-lite);
  padding: 16px 10px 12px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 2px 12px 12px; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-section {
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-3); padding: 14px 12px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border-radius: 8px;
  border: none; background: transparent; color: var(--text);
  font-size: 14px; font-weight: 500; font-family: inherit;
  text-align: left; cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.nav-item svg { width: 19px; height: 19px; color: var(--tint); flex-shrink: 0; transition: color 0.15s var(--ease); }
@media (hover: hover) { .nav-item:hover { background: var(--fill); } }
.nav-item.active { background: var(--tint); color: #fff; }
.nav-item.active svg { color: #fff; }

.sidebar-user {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px;
  border: none; border-top: 1px solid var(--sep-lite); border-radius: 0;
  background: transparent; color: var(--text); font-family: inherit;
  cursor: pointer; text-align: left;
  transition: background 0.15s var(--ease);
}
@media (hover: hover) { .sidebar-user:hover { background: var(--fill); } }
.sidebar-user-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-text #userName { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11.5px; color: var(--text-2); }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--fill-2); color: var(--tint);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 600; flex-shrink: 0;
}

/* ---------- Контент ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 30px 12px;
  background: var(--material);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
}
.large-title {
  font-size: clamp(22px, 2.4vw, 28px); font-weight: 700; letter-spacing: -0.5px;
  margin: 0; line-height: 1.15;
}
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

.back-btn {
  display: none; align-items: center; gap: 2px;
  background: none; border: none; color: var(--tint);
  font-size: 16px; font-weight: 500; font-family: inherit;
  cursor: pointer; padding: 4px 8px 4px 2px; border-radius: 8px;
}
.back-btn.show { display: inline-flex; }
.back-btn svg { width: 20px; height: 20px; }

.container { width: 100%; max-width: 880px; margin: 0 auto; padding: 16px 30px 64px; }

.view { display: none; }
.view.active { display: block; animation: view-in 0.22s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }

/* ---------- Карточки (inset grouped) ---------- */
.card {
  background: var(--elev);
  border: 1px solid var(--sep-lite);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-pad { padding: 14px 16px; }

/* Строки сгруппированного списка */
.row-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; position: relative;
  cursor: pointer; background: transparent;
  transition: background 0.12s var(--ease);
}
.row-item + .row-item::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0;
  height: 1px; background: var(--sep-lite);
}
.row-item.lead + .row-item.lead::before { left: 62px; }
@media (hover: hover) { .row-item:hover { background: var(--fill); } }
.row-item:active { background: var(--fill-2); }

.row-icon {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--fill); color: var(--tint);
  display: grid; place-items: center; flex-shrink: 0;
}
.row-icon svg { width: 19px; height: 19px; }
.row-text { flex: 1; min-width: 0; }
.row-title { font-size: 15px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.row-sub {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-2); margin-top: 3px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.chev { width: 16px; height: 16px; color: var(--text-3); flex-shrink: 0; }

/* ---------- Кнопки ---------- */
.btn {
  appearance: none; border: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px;
  border-radius: var(--r-md);
  font-family: inherit; font-size: 14.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: transform 0.12s var(--ease), background 0.15s var(--ease), opacity 0.15s;
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn.primary { background: var(--btn-filled); color: #fff; }
@media (hover: hover) { .btn.primary:hover { background: color-mix(in srgb, var(--btn-filled) 88%, #fff); } }
.btn.tinted { background: var(--tint-soft); color: var(--tint); }
@media (hover: hover) { .btn.tinted:hover { background: color-mix(in srgb, var(--tint-soft) 70%, var(--tint) 10%); } }
.btn.gray { background: var(--fill); color: var(--text); }
@media (hover: hover) { .btn.gray:hover { background: var(--fill-2); } }
.btn.danger-tinted { background: var(--red-soft); color: var(--red); }
@media (hover: hover) { .btn.danger-tinted:hover { background: color-mix(in srgb, var(--red-soft) 70%, var(--red) 10%); } }
.btn.small { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.small svg { width: 14px; height: 14px; }
.btn.block { width: 100%; height: 46px; font-size: 16px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: var(--fill); color: var(--text-2);
  display: grid; place-items: center; cursor: pointer;
  transition: background 0.15s var(--ease);
}
.icon-btn svg { width: 16px; height: 16px; }
@media (hover: hover) { .icon-btn:hover { background: var(--fill-2); } }

/* ---------- Поля ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.field .check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); }
.field .check input { width: 17px; height: 17px; accent-color: var(--tint); }

.input, .select, textarea {
  width: 100%; height: 44px; padding: 0 12px;
  border-radius: 10px; border: 1px solid transparent;
  background: var(--fill); color: var(--text);
  font-size: 16px; font-family: inherit;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
textarea { height: auto; min-height: 110px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input::placeholder, textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, textarea:focus {
  outline: none; background: var(--elev); border-color: var(--tint);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--tint) 18%, transparent);
}
.select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 34px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

.search { display: flex; align-items: center; gap: 8px; background: var(--fill); border-radius: 10px; height: 40px; padding: 0 12px; }
.search svg { width: 16px; height: 16px; color: var(--text-3); flex-shrink: 0; }
.search input { flex: 1; min-width: 0; border: none; background: transparent; outline: none; font-size: 16px; font-family: inherit; color: var(--text); height: 100%; }
.search input::placeholder { color: var(--text-3); }
.search:focus-within { box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--tint) 18%, transparent); }

/* ---------- Бейджи статусов ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2.5px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.1px;
  white-space: nowrap;
}
.badge.queued { background: var(--fill-2); color: var(--text-2); }
.badge.running { background: var(--tint-soft); color: var(--tint); }
.badge.done { background: var(--green-soft); color: var(--green); }
.badge.error { background: var(--red-soft); color: var(--red); }
.badge.trim { background: var(--orange-soft); color: var(--orange); }
.badge.accent { background: var(--tint-soft); color: var(--tint); }

/* ---------- Нижний таб-бар (мобильный) ---------- */
.tabbar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  grid-template-columns: repeat(4, 1fr);
  background: var(--material);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 0.5px solid var(--sep-lite);
  padding: 5px 6px calc(6px + env(safe-area-inset-bottom));
}
.tab-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--text-2);
  font-family: inherit; font-size: 10px; font-weight: 500;
  padding: 4px 0 2px; cursor: pointer;
}
.tab-btn svg { width: 24px; height: 24px; }
.tab-btn.active { color: var(--tint); }

/* ---------- Модальные листы ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.35);
  display: none; align-items: flex-end; justify-content: center;
}
.modal-backdrop.show { display: flex; }
.modal {
  position: relative;
  background: var(--elev);
  width: 100%; max-width: 500px; max-height: 88dvh; overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-float);
  animation: sheet-up 0.34s var(--ease);
}
.modal::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--sep); margin: 4px auto 12px; }
@keyframes sheet-up { from { transform: translateY(100%); } }

.modal h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.2px; margin: 0 44px 16px 0; }
.modal-close { position: absolute; top: 14px; right: 14px; }
.modal .btn-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal .btn-row .block-m { flex: 1; }
.modal pre.full {
  background: var(--fill); padding: 12px; border-radius: 10px;
  overflow: auto; max-height: 56dvh;
  font-size: 12px; line-height: 1.5; margin: 0 0 4px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  white-space: pre-wrap; word-break: break-word;
}
.modal-error { color: var(--red); font-size: 13px; margin: -4px 0 10px; }

/* Модалка на десктопе — центрированная карточка */
@media (min-width: 920px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { border-radius: var(--r-lg); padding: 22px 24px; animation: pop-in 0.22s var(--ease); }
  .modal::before { display: none; }
}
@keyframes pop-in { from { opacity: 0; transform: scale(0.96) translateY(8px); } }

/* ---------- Шапка задачи и контекст ---------- */
.task-head { padding: 14px 16px; }
.task-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.task-head-row h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; margin: 0; line-height: 1.3; overflow-wrap: anywhere; }
.task-head-side { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.task-meta { font-size: 12.5px; color: var(--text-2); margin-top: 4px; font-variant-numeric: tabular-nums; }
.ctx-block { margin-top: 12px; }
.ctx-bar { width: 100%; height: 5px; background: var(--fill-2); border-radius: 3px; overflow: hidden; }
.ctx-fill { height: 100%; width: 0%; border-radius: 3px; background: var(--green); transition: width 0.4s var(--ease), background 0.3s var(--ease); }
.ctx-fill.warn { background: var(--orange); }
.ctx-fill.danger { background: var(--red); }
.ctx-label {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12px; color: var(--text-2); margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.ctx-label + .ctx-bar { margin-top: 0; }
.ctx-block .ctx-label:last-child { margin: 6px 0 0; }

/* ---------- Чат анализа ---------- */
.chat-card { padding: 16px; }
#messages { display: flex; flex-direction: column; }
.msg { display: flex; flex-direction: column; margin-bottom: 12px; }
.msg:last-child { margin-bottom: 2px; }
.msg .role {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-3); margin: 0 6px 4px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.msg .bubble {
  max-width: 80%;
  padding: 9px 13px; border-radius: 17px;
  font-size: 14.5px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
  background: var(--fill); color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 6px;
}
.msg.user .bubble {
  background: var(--btn-filled); color: #fff;
  align-self: flex-end; border-bottom-left-radius: 17px; border-bottom-right-radius: 6px;
}
.msg.assistant .bubble { background: var(--fill); }
.msg.tool .bubble {
  max-width: 88%;
  background: var(--elev2); border: 1px solid var(--sep-lite);
  border-radius: var(--r-md);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.5;
  border-bottom-left-radius: var(--r-md);
}
.msg.tool pre { background: var(--fill); padding: 8px; border-radius: 8px; overflow-x: auto; font-size: 12px; margin: 6px 0; font-family: inherit; white-space: pre-wrap; word-break: break-word; }
.tool-more { margin-top: 8px; display: flex; }
.msg.tool .badge { vertical-align: middle; }

/* ---------- Журнал ---------- */
.logs-tools { padding: 14px 16px 12px; }
.table-wrap { overflow-x: auto; }
.logs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.logs-table th {
  text-align: left; padding: 8px 16px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-3); border-bottom: 1px solid var(--sep-lite);
  white-space: nowrap;
}
.logs-table td { padding: 10px 16px; border-bottom: 1px solid var(--sep-lite); vertical-align: top; font-variant-numeric: tabular-nums; }
.logs-table tr:last-child td { border-bottom: none; }
@media (hover: hover) { .logs-table tbody tr:hover { background: var(--fill); } }

/* ---------- Пустые состояния ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 5px; padding: 38px 20px; }
.empty-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--fill); color: var(--tint);
  display: grid; place-items: center; margin-bottom: 6px;
}
.empty-icon svg { width: 25px; height: 25px; }
.empty-title { font-size: 15px; font-weight: 600; }
.empty-hint { font-size: 13px; color: var(--text-2); max-width: 300px; }
.empty .btn { margin-top: 12px; }

/* ---------- Скелетоны ---------- */
.skel { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.skel-row { height: 13px; border-radius: 6px; background: var(--fill); animation: pulse 1.4s ease-in-out infinite; }
.skel-row:nth-child(2) { width: 70%; }
.skel-row:nth-child(3) { width: 85%; }
.skel-row.w70 { width: 70%; }
.skel-row.w85 { width: 85%; }
@keyframes pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* ---------- Тост ---------- */
.toast {
  position: fixed; top: 14px; left: 50%; z-index: 200;
  transform: translate(-50%, -16px);
  display: flex; align-items: center; gap: 8px;
  max-width: min(92vw, 480px);
  background: var(--material);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--sep-lite); border-radius: 999px;
  padding: 9px 16px; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-float);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.err svg { color: var(--red); }
.toast.ok svg { color: var(--green); }

/* ---------- Профиль ---------- */
.p-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--sep-lite); font-size: 14px; }
.p-row:last-child { border-bottom: none; }
.p-row .p-label { color: var(--text-2); }
.p-row .p-value { font-weight: 500; text-align: right; overflow-wrap: anywhere; }

/* ---------- Спиннер ---------- */
.spin {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--text-3); border-top-color: transparent;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Адаптив ---------- */
@media (max-width: 919.98px) {
  .sidebar { display: none; }
  .tabbar { display: grid; }
  .topbar { padding: 12px 16px 10px; gap: 8px; }
  .container { padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); }
  .topbar-actions .btn { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; }
  .msg .bubble { max-width: 88%; }
  .task-head-row { flex-direction: column; }
  .task-head-side { justify-content: flex-start; }
}

/* Журнал на мобильном — строки превращаются в карточки */
@media (max-width: 640px) {
  .logs-table thead { display: none; }
  .logs-table, .logs-table tbody { display: block; }
  .logs-table tr { display: block; padding: 6px 0; border-bottom: 1px solid var(--sep-lite); }
  .logs-table tr:last-child { border-bottom: none; }
  .logs-table tr:hover { background: transparent; }
  .logs-table td { display: flex; justify-content: space-between; gap: 12px; border: none; padding: 3px 16px; }
  .logs-table td::before { content: attr(data-label); color: var(--text-2); font-size: 12px; flex-shrink: 0; }
  .logs-table td:empty { display: none; }
}

/* ---------- Доступность: уменьшенное движение ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
