/* Оформление задачника: слой поверх Bootstrap 5.3 со своей палитрой и тёмной темой. */

:root {
  --app-radius: 14px;
  --app-radius-sm: 10px;
  --app-sidebar: 248px;

  --app-bg: #f5f6f8;
  --app-surface: #ffffff;
  --app-surface-2: #fafbfc;
  --app-border: #e4e7ec;
  --app-text: #16181d;
  --app-muted: #6b7280;
  --app-accent: #4f46e5;
  --app-accent-soft: rgba(79, 70, 229, .1);
  --app-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .12);

  --tone-red: #d92d20;      --tone-red-bg: rgba(217, 45, 32, .1);
  --tone-amber: #b54708;    --tone-amber-bg: rgba(247, 144, 9, .14);
  --tone-green: #067647;    --tone-green-bg: rgba(6, 118, 71, .1);
  --tone-blue: #175cd3;     --tone-blue-bg: rgba(23, 92, 211, .1);
  --tone-grey: #4a5565;     --tone-grey-bg: rgba(74, 85, 101, .1);
}

[data-bs-theme="dark"] {
  --app-bg: #0e1014;
  --app-surface: #161920;
  --app-surface-2: #1b1f27;
  --app-border: #272c36;
  --app-text: #e7eaf0;
  --app-muted: #98a2b3;
  --app-accent: #818cf8;
  --app-accent-soft: rgba(129, 140, 248, .16);
  --app-shadow: 0 1px 2px rgba(0, 0, 0, .4);

  --tone-red: #fda29b;      --tone-red-bg: rgba(240, 68, 56, .16);
  --tone-amber: #fec84b;    --tone-amber-bg: rgba(247, 144, 9, .16);
  --tone-green: #75e0a7;    --tone-green-bg: rgba(23, 178, 106, .16);
  --tone-blue: #84caff;     --tone-blue-bg: rgba(41, 112, 255, .18);
  --tone-grey: #cdd3de;     --tone-grey-bg: rgba(205, 211, 222, .12);
}

[data-bs-theme] {
  --bs-body-bg: var(--app-bg);
  --bs-body-color: var(--app-text);
  --bs-border-color: var(--app-border);
  --bs-secondary-color: var(--app-muted);
  --bs-primary: var(--app-accent);
  --bs-link-color: var(--app-accent);
  --bs-link-hover-color: var(--app-accent);
  --bs-emphasis-color: var(--app-text);
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--app-bg);
  color: var(--app-text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { letter-spacing: -.015em; }

/* --- каркас: боковая навигация + рабочая область --- */

.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: var(--app-sidebar);
  flex: 0 0 var(--app-sidebar);
  background: var(--app-surface);
  border-right: 1px solid var(--app-border);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: none;
  flex-direction: column;
}

@media (min-width: 992px) { .app-sidebar { display: flex; } }

.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--app-surface) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--app-border);
  position: sticky;
  top: 0;
  z-index: 1020;
}

.app-content { padding: 22px 20px 48px; }
@media (min-width: 992px) { .app-content { padding: 26px 28px 56px; } }

.app-brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 650; font-size: 15px; letter-spacing: -.02em;
  color: var(--app-text); text-decoration: none; padding: 4px 8px 16px;
}

.app-brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--app-accent), color-mix(in srgb, var(--app-accent) 55%, #ec4899));
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700;
}

.nav-side { display: flex; flex-direction: column; gap: 2px; }

.nav-side a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--app-radius-sm);
  color: var(--app-muted); text-decoration: none; font-weight: 500;
  transition: background .12s ease, color .12s ease;
}

.nav-side a:hover { background: var(--app-surface-2); color: var(--app-text); }
.nav-side a.active { background: var(--app-accent-soft); color: var(--app-accent); }
.nav-side a svg { flex: 0 0 16px; opacity: .9; }
.nav-side .nav-count {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--app-accent); color: #fff;
  border-radius: 999px; padding: 1px 7px; line-height: 18px;
}

.nav-section {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--app-muted); padding: 16px 10px 6px; font-weight: 600;
}

/* --- поверхности --- */

.surface {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
}

.surface-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--app-border);
  font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

.page-title { font-size: 22px; font-weight: 650; margin: 0; }
.page-sub { color: var(--app-muted); margin: 2px 0 0; }

/* --- пилюли статусов и приоритетов --- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 18px; white-space: nowrap;
}

.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pill-danger    { color: var(--tone-red);   background: var(--tone-red-bg); }
.pill-warning   { color: var(--tone-amber); background: var(--tone-amber-bg); }
.pill-success   { color: var(--tone-green); background: var(--tone-green-bg); }
.pill-primary   { color: var(--tone-blue);  background: var(--tone-blue-bg); }
.pill-secondary { color: var(--tone-grey);  background: var(--tone-grey-bg); }

/* --- таблица задач --- */

.table-tasks { margin: 0; color: var(--app-text); }
.table-tasks > thead th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--app-muted); font-weight: 600;
  background: var(--app-surface-2); border-bottom: 1px solid var(--app-border);
  padding: 10px 16px; white-space: nowrap;
}
.table-tasks > tbody td { padding: 12px 16px; border-bottom: 1px solid var(--app-border); vertical-align: middle; }
.table-tasks > tbody tr:last-child td { border-bottom: 0; }
.table-tasks > tbody tr:hover td { background: var(--app-surface-2); }

.task-title { color: var(--app-text); text-decoration: none; font-weight: 550; }
.task-title:hover { color: var(--app-accent); }

/* --- аватар-инициалы --- */

.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-grid; place-items: center; flex: 0 0 26px;
  font-size: 11px; font-weight: 650; color: #fff;
  background: var(--app-accent);
}
.avatar-lg { width: 34px; height: 34px; flex-basis: 34px; font-size: 13px; }
.avatar-muted { background: var(--tone-grey-bg); color: var(--tone-grey); }

.who { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }

/* --- формы --- */

.form-control, .form-select {
  background: var(--app-surface);
  border-color: var(--app-border);
  color: var(--app-text);
  border-radius: var(--app-radius-sm);
  padding: 7px 11px;
}
.form-control:focus, .form-select:focus {
  background: var(--app-surface);
  color: var(--app-text);
  border-color: var(--app-accent);
  box-shadow: 0 0 0 3px var(--app-accent-soft);
}
.form-control::placeholder { color: color-mix(in srgb, var(--app-muted) 75%, transparent); }
.form-label { font-size: 12px; font-weight: 600; color: var(--app-muted); margin-bottom: 4px; }

.btn { border-radius: var(--app-radius-sm); font-weight: 550; }
.btn-primary {
  --bs-btn-bg: var(--app-accent); --bs-btn-border-color: var(--app-accent);
  --bs-btn-hover-bg: color-mix(in srgb, var(--app-accent) 85%, #000);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--app-accent) 85%, #000);
  --bs-btn-color: #fff; --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: color-mix(in srgb, var(--app-accent) 78%, #000);
}
.btn-soft {
  background: var(--app-surface); border: 1px solid var(--app-border); color: var(--app-text);
}
.btn-soft:hover { background: var(--app-surface-2); color: var(--app-text); }

.filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }

/* --- лента «История работы» --- */

.feed-day { display: flex; align-items: center; gap: 12px; margin: 22px 0 12px; }
.feed-day::after { content: ""; flex: 1; height: 1px; background: var(--app-border); }
.feed-day span {
  font-size: 12px; font-weight: 600; color: var(--app-muted);
  text-transform: capitalize; white-space: nowrap;
}

.feed-item { display: flex; gap: 12px; padding: 12px 16px; border-radius: var(--app-radius); }
.feed-item + .feed-item { margin-top: 2px; }
.feed-note { background: var(--app-surface); border: 1px solid var(--app-border); box-shadow: var(--app-shadow); }
.feed-event { padding-top: 6px; padding-bottom: 6px; }
.feed-event .feed-body { color: var(--app-muted); font-size: 13px; }
.feed-item.is-new { box-shadow: inset 3px 0 0 var(--app-accent), var(--app-shadow); }

.feed-body { min-width: 0; flex: 1; }
.feed-meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--app-muted); }
.feed-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 3px; }

.new-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--app-accent); font-size: 12px; font-weight: 600; }
.new-divider::before, .new-divider::after { content: ""; flex: 1; height: 1px; background: var(--app-accent); opacity: .35; }

/* --- прочее --- */

.modal-content { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--app-radius); }
.dropdown-menu {
  --bs-dropdown-bg: var(--app-surface);
  --bs-dropdown-border-color: var(--app-border);
  --bs-dropdown-link-color: var(--app-text);
  --bs-dropdown-link-hover-bg: var(--app-surface-2);
  --bs-dropdown-link-hover-color: var(--app-text);
  border-radius: var(--app-radius-sm);
  box-shadow: var(--app-shadow);
}
.offcanvas { background: var(--app-surface); color: var(--app-text); }
.text-muted-app { color: var(--app-muted) !important; }
.empty-state { padding: 48px 20px; text-align: center; color: var(--app-muted); }
.accordion {
  --bs-accordion-bg: var(--app-surface);
  --bs-accordion-color: var(--app-text);
  --bs-accordion-border-color: var(--app-border);
  --bs-accordion-btn-color: var(--app-text);
  --bs-accordion-active-bg: var(--app-surface-2);
  --bs-accordion-active-color: var(--app-text);
  --bs-accordion-btn-focus-box-shadow: 0 0 0 3px var(--app-accent-soft);
  border-radius: var(--app-radius);
  overflow: hidden;
}
.alert { border-radius: var(--app-radius-sm); }

/* --- мобильная версия --- */

/* Карточки задач вместо таблицы: таблица прячется на узких экранах и наоборот. */
.task-cards { display: none; flex-direction: column; gap: 10px; }

.task-card {
  position: relative;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
  padding: 14px;
}

.task-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.task-card .task-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  margin: 9px 0 8px;
}

.task-card-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 12px; color: var(--app-muted);
}

.task-card-people {
  display: flex; align-items: center; gap: 10px;
  margin-top: 12px; padding-top: 11px;
  border-top: 1px solid var(--app-border);
  font-size: 12px;
}

/* Ряд проектов в «Истории работы»: на широком экране переносится,
   на телефоне прокручивается вбок вместо стены кнопок. */
.chip-row { flex-wrap: wrap; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }

@media (max-width: 767.98px) {
  .app-content { padding: 16px 14px 40px; }
  .page-title { font-size: 19px; }
  .page-sub { font-size: 13px; }

  .table-wrap { display: none; }
  .task-cards { display: flex; }

  /* 16px не даёт iOS зумить страницу при фокусе в поле. */
  .form-control, .form-select { font-size: 16px; padding: 9px 12px; }
  .btn { padding: 9px 14px; }
  .btn-sm { padding: 6px 10px; }

  .filters { grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); }
  .filters > div:last-child { grid-column: 1 / -1; }

  .chip-row { flex-wrap: nowrap; overflow-x: auto; margin-inline: -14px; padding-inline: 14px; }
  .chip-row > * { flex: 0 0 auto; }
  .chip-row .ms-auto { margin-left: 0 !important; }

  .feed-item { padding: 12px; }
  .feed-meta { font-size: 11px; row-gap: 2px; }

  .surface-head { padding: 12px 14px; }
  .accordion-button { padding: 12px 14px; }

  /* В архиве карточки уже лежат в теле аккордеона — лишние отступы убираем. */
  .accordion-body .task-cards { gap: 8px; }
  .accordion-body .task-card { box-shadow: none; }
}
