/* Дизайн-система TSB: тёмная тема, крупные карточки, сайдбар слева. Палитра и геометрия — по референсу. */

:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --card-top: #111113;
  --card-bottom: #0d0d0f;
  --field: #131315;
  --row: #0f0f11;
  --border: #1e1e22;
  --border-strong: #2a2a2f;
  --text: #f5f5f6;
  --muted: #8d8d95;
  --dim: #5d5d65;
  --green: #35d38f;
  --green-soft: rgba(53, 211, 143, 0.12);
  --red: #f26d78;
  --red-soft: rgba(242, 109, 120, 0.12);
  --amber: #f3b64c;
  --amber-soft: rgba(243, 182, 76, 0.12);
  --blue: #6cb2ff;
  --blue-soft: rgba(108, 178, 255, 0.12);
  --radius-card: 22px;
  --radius-row: 16px;
  --radius-field: 14px;
  --sidebar-w: 248px;
}

.hidden,
[hidden] {
  display: none !important;
}

body.tsb-body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Каркас: сайдбар + контент ---------- */

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

.tsb-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  padding: 0 14px 16px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.tsb-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 74px;
  margin: 0 -14px 18px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.tsb-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0;
}

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

.tsb-nav a,
.tsb-nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.tsb-nav a:hover,
.tsb-nav-btn:hover {
  color: var(--text);
}

.tsb-nav a.is-active {
  background: #161618;
  border-color: var(--border-strong);
  color: var(--text);
}

.tsb-nav svg,
.tsb-nav-btn svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.tsb-sidebar-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tsb-promo {
  padding: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: linear-gradient(180deg, #141416, #0e0e10);
}

.tsb-promo-label {
  font-size: 12px;
  color: var(--muted);
}

.tsb-promo-value {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tsb-promo-hint {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--dim);
}

.tsb-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tsb-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 74px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 11, 0.86);
  backdrop-filter: blur(12px);
}

.tsb-crumb {
  font-size: 11px;
  color: var(--muted);
}

.tsb-title {
  margin: 2px 0 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.tsb-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tsb-search {
  position: relative;
  display: block;
  width: 250px;
}

.tsb-search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.tsb-search input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 42px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-field);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
}

.tsb-search input::placeholder {
  color: var(--dim);
}

.tsb-search input:focus {
  border-color: #4a4a52;
}

.tsb-main {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 28px 48px;
  box-sizing: border-box;
}

.tsb-bottom-nav {
  display: none;
}

/* ---------- Сетка и карточки ---------- */

.tsb-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.tsb-span-2 {
  grid-column: span 2;
}

.tsb-span-3 {
  grid-column: 1 / -1;
}

.tsb-card {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: linear-gradient(180deg, var(--card-top), var(--card-bottom));
  min-width: 0;
}

.tsb-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.tsb-card-title {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tsb-label {
  font-size: 14px;
  color: var(--muted);
}

.tsb-big {
  font-size: 46px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.tsb-link {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.tsb-link:hover {
  color: var(--text);
}

.tsb-muted {
  color: var(--muted);
}

.tsb-dim {
  color: var(--dim);
}

.tsb-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 26px;
}

.tsb-stat {
  padding: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--row);
}

.tsb-stat-value {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tsb-stat-value.is-text {
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: 0;
}

.tsb-stat-hint {
  margin-top: 2px;
  font-size: 12px;
  color: var(--dim);
}

.tsb-upcoming {
  margin-top: 26px;
}

.tsb-upcoming-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.015);
  font-size: 14px;
}

.tsb-upcoming-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.tsb-upcoming-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.tsb-upcoming.is-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 0;
  text-align: center;
}

.tsb-upcoming-empty {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.tsb-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
}

.tsb-chip-green {
  color: var(--green);
}

.tsb-chip-red {
  color: var(--red);
}

.tsb-chip-muted {
  color: var(--muted);
}

/* ---------- Кнопки ---------- */

.tsb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-field);
  background: #141416;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.tsb-btn:hover {
  background: #1a1a1d;
  border-color: #38383e;
}

.tsb-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tsb-btn-primary {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.tsb-btn-primary:hover {
  background: #ffffff;
  border-color: #ffffff;
}

.tsb-btn-block {
  width: 100%;
}

.tsb-btn-sm {
  height: 34px;
  padding: 0 13px;
  border-radius: 11px;
  font-size: 13px;
}

.tsb-btn-danger {
  color: var(--red);
}

.tsb-btn-danger:hover {
  background: var(--red-soft);
  border-color: rgba(242, 109, 120, 0.35);
}

.tsb-btn-danger-fill {
  background: var(--red);
  border-color: var(--red);
  color: #1b0609;
}

.tsb-btn-danger-fill:hover {
  background: #ff8791;
  border-color: #ff8791;
}

.tsb-btn-warn {
  color: var(--amber);
}

.tsb-btn-warn:hover {
  background: var(--amber-soft);
  border-color: rgba(243, 182, 76, 0.35);
}

.tsb-btn-ok {
  color: var(--green);
}

.tsb-btn-ok:hover {
  background: var(--green-soft);
  border-color: rgba(53, 211, 143, 0.35);
}

/* ---------- Бейджи ---------- */

.tsb-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: #18181b;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.tsb-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.tsb-pill-green {
  color: var(--green);
  background: var(--green-soft);
  border-color: rgba(53, 211, 143, 0.25);
}

.tsb-pill-red {
  color: var(--red);
  background: var(--red-soft);
  border-color: rgba(242, 109, 120, 0.25);
}

.tsb-pill-amber {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: rgba(243, 182, 76, 0.25);
}

.tsb-pill-blue {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: rgba(108, 178, 255, 0.25);
}

/* ---------- Списки в виде строк-«таблиц» ---------- */

.tsb-list-head,
.tsb-row {
  display: grid;
  grid-template-columns: var(--cols);
  align-items: center;
  gap: 14px;
  padding-left: 18px;
  padding-right: 18px;
}

.tsb-list-head {
  padding-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
}

.tsb-row {
  margin-bottom: 10px;
  padding-top: 12px;
  padding-bottom: 12px;
  min-height: 60px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-row);
  background: var(--row);
  transition: border-color 0.15s;
}

.tsb-row:last-child {
  margin-bottom: 0;
}

.tsb-row:hover {
  border-color: #3a3a40;
}

.tsb-cell {
  min-width: 0;
  font-size: 14px;
}

.tsb-cell-meta {
  white-space: nowrap;
}

.tsb-cell-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.tsb-cell-title > div {
  min-width: 0;
}

.tsb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.tsb-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.tsb-avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: #17171a;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.tsb-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tsb-noresults {
  padding: 22px 0 6px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.tsb-more {
  padding: 14px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--dim);
}

/* ---------- Пустые состояния, ошибки, скелетоны ---------- */

/* Без собственной рамки: карточка вокруг и есть рамка, "рамка в рамке" на пустых экранах выглядит как недорисованный интерфейс. */
.tsb-empty {
  padding: 36px 16px 30px;
  text-align: center;
}

.tsb-empty-inline {
  padding: 4px 0 2px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

/* Онбординг вместо сетки пустых карточек */
.tsb-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.tsb-step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-row);
  background: var(--row);
}

.tsb-step-num {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: #17171a;
  font-size: 14px;
  font-weight: 700;
}

.tsb-step-text {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.tsb-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: #151517;
  color: var(--muted);
}

.tsb-empty-icon svg {
  width: 24px;
  height: 24px;
}

.tsb-empty-title {
  font-size: 17px;
  font-weight: 600;
}

.tsb-empty-text {
  margin: 6px auto 18px;
  max-width: 340px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.tsb-alert {
  margin-bottom: 20px;
  padding: 14px 16px;
  border: 1px solid rgba(242, 109, 120, 0.35);
  border-radius: 14px;
  background: var(--red-soft);
  color: #ffb4bb;
  font-size: 14px;
}

.tsb-skeleton {
  height: 60px;
  margin-bottom: 10px;
  border-radius: var(--radius-row);
  background: linear-gradient(90deg, #111113 0%, #18181b 50%, #111113 100%);
  background-size: 200% 100%;
  animation: tsb-shimmer 1.4s ease-in-out infinite;
}

@keyframes tsb-shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

/* ---------- Формы ---------- */

.tsb-field {
  margin-bottom: 14px;
}

.tsb-field > label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

.tsb-input,
.tsb-select,
.tsb-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-field);
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tsb-input::placeholder,
.tsb-textarea::placeholder {
  color: var(--dim);
}

.tsb-input:focus,
.tsb-select:focus,
.tsb-textarea:focus {
  border-color: #4a4a52;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

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

/* Нативные стрелочки числового поля и крестик поиска выбиваются из дизайна и мешают на телефоне. */
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button,
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  margin: 0;
}

.tsb-select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238d8d95' stroke-width='2' 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;
}

.tsb-select option {
  background: #131315;
  color: var(--text);
}

.tsb-form-hint {
  margin: 4px 0 16px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--dim);
}

/* ---------- Модалки ---------- */

.tsb-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.tsb-modal {
  width: 100%;
  max-width: 30rem;
  max-height: 92vh;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  background: #0f0f11;
}

/* Диалог подтверждения — по центру на любой ширине (в отличие от форм, которые на телефоне выезжают снизу). */
.tsb-modal-backdrop.tsb-modal-backdrop-center {
  align-items: center;
  padding: 16px;
}

.tsb-modal-backdrop.tsb-modal-backdrop-center .tsb-modal {
  max-width: 26rem;
  border-radius: 24px;
}

.tsb-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.tsb-modal-title {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
}

.tsb-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.tsb-close:hover {
  color: var(--text);
  background: #17171a;
}

/* ---------- Тосты ---------- */

#tsb-toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.tsb-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 340px;
  padding: 12px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: #141416;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  font-size: 14px;
  animation: tsb-toast-in 0.18s ease-out;
}

.tsb-toast::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.tsb-toast-success::before {
  background: var(--green);
}

.tsb-toast-error {
  border-color: rgba(242, 109, 120, 0.4);
}

.tsb-toast-error::before {
  background: var(--red);
}

.tsb-toast-out {
  animation: tsb-toast-out 0.2s ease-in forwards;
}

@keyframes tsb-toast-in {
  from {
    opacity: 0;
    transform: translateX(1rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes tsb-toast-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translateX(1rem);
  }
}

/* ---------- Профиль в шапке ---------- */

.tsb-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tsb-profile-avatar {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: #1c1c20;
  font-size: 14px;
  font-weight: 700;
}

.tsb-profile-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tsb-profile-name {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}

@media (max-width: 900px) {
  .tsb-profile-name {
    display: none;
  }
}

/* ---------- Экран входа ---------- */

.tsb-widget-slot {
  display: flex;
  justify-content: center;
  min-height: 44px;
  margin-top: 22px;
}

.tsb-widget-slot:empty {
  display: none;
}

.tsb-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  box-sizing: border-box;
}

.tsb-auth-card {
  width: 100%;
  max-width: 400px;
  padding: 34px 28px;
  text-align: center;
}

/* ---------- Адаптив ---------- */

@media (max-width: 1100px) {
  .tsb-grid {
    grid-template-columns: 1fr;
  }

  .tsb-span-2 {
    grid-column: auto;
  }
}

@media (max-width: 900px) {
  .tsb-sidebar {
    display: none;
  }

  .tsb-header {
    height: 64px;
    padding: 0 16px;
  }

  .tsb-title {
    font-size: 20px;
  }

  .tsb-search {
    display: none;
  }

  .tsb-main {
    padding: 16px 16px 96px;
  }

  .tsb-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    justify-content: space-around;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: rgba(10, 10, 11, 0.92);
    backdrop-filter: blur(12px);
  }

  .tsb-bottom-nav a,
  .tsb-bottom-nav button {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
  }

  .tsb-bottom-nav a.is-active {
    color: var(--text);
    background: #161618;
  }

  .tsb-bottom-nav svg {
    width: 22px;
    height: 22px;
  }
}

@media (max-width: 760px) {
  .tsb-card {
    padding: 18px;
  }

  .tsb-big {
    font-size: 38px;
  }

  .tsb-stats {
    grid-template-columns: 1fr 1fr;
  }

  .tsb-stats > .tsb-stat:last-child {
    grid-column: 1 / -1;
  }

  .tsb-list-head {
    display: none;
  }

  .tsb-row {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 10px;
  }

  .tsb-row > .tsb-cell-meta {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    color: var(--muted);
  }

  .tsb-row > .tsb-cell-meta::before {
    content: attr(data-label);
    color: var(--dim);
  }

  .tsb-row > .tsb-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .tsb-modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .tsb-modal {
    max-width: none;
    border-radius: 24px 24px 0 0;
  }

  #tsb-toast-container {
    left: 16px;
    right: 16px;
    align-items: stretch;
  }

  .tsb-toast {
    max-width: none;
  }
}

/* ======================================================================
   Собственный выпадающий список (js/select.js)
   ====================================================================== */

.tsb-select-wrap {
  position: relative;
}

.tsb-select-wrap > select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.tsb-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-field);
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tsb-select-trigger:hover {
  border-color: #3a3a40;
}

.tsb-select-trigger:focus-visible,
.tsb-select-trigger[aria-expanded="true"] {
  border-color: #4a4a52;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
  outline: none;
}

.tsb-select-trigger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tsb-select-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tsb-select-value.is-placeholder {
  color: var(--dim);
}

.tsb-select-trigger svg {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: transform 0.15s;
}

.tsb-select-trigger[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.tsb-select-sm .tsb-select-trigger {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
}

.tsb-dropdown {
  position: fixed;
  z-index: 140;
  box-sizing: border-box;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: #131315;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
}

.tsb-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

.tsb-dropdown-item.is-active {
  background: #1c1c1f;
}

.tsb-dropdown-item[aria-selected="true"] {
  font-weight: 600;
}

.tsb-dropdown-item svg {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--green);
}

.tsb-dropdown-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tsb-dropdown-empty {
  padding: 12px;
  font-size: 13px;
  color: var(--muted);
}

/* ======================================================================
   Чекбокс, фильтры, панель инструментов, иконки-кнопки
   ====================================================================== */

.tsb-check {
  -webkit-appearance: none;
  appearance: none;
  display: inline-grid;
  place-content: center;
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1.5px solid #3a3a41;
  border-radius: 7px;
  background: var(--field);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.tsb-check:hover {
  border-color: #55555d;
}

.tsb-check:checked {
  background: var(--text);
  border-color: var(--text);
}

.tsb-check:checked::after {
  content: "";
  width: 5px;
  height: 10px;
  margin-top: -2px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.tsb-check:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tsb-check:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.14);
}

.tsb-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.tsb-toolbar-spacer {
  flex: 1;
}

.tsb-inline-search {
  position: relative;
  flex: 1 1 220px;
  min-width: 0;
  max-width: 360px;
}

.tsb-inline-search svg {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.tsb-inline-search input {
  width: 100%;
  height: 40px;
  box-sizing: border-box;
  padding: 0 14px 0 40px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
}

.tsb-inline-search input::placeholder {
  color: var(--dim);
}

.tsb-inline-search input:focus {
  border-color: #4a4a52;
}

.tsb-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tsb-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}

.tsb-filter:hover {
  color: var(--text);
  border-color: #3a3a40;
}

.tsb-filter.is-active {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.tsb-filter .count {
  font-weight: 600;
  opacity: 0.55;
}

.tsb-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: #141416;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}

.tsb-icon-btn svg {
  width: 16px;
  height: 16px;
}

.tsb-icon-btn:hover {
  background: #1a1a1d;
  color: var(--text);
}

.tsb-icon-btn.is-ok:hover {
  color: var(--green);
  border-color: rgba(53, 211, 143, 0.4);
}

.tsb-icon-btn.is-warn:hover {
  color: var(--amber);
  border-color: rgba(243, 182, 76, 0.4);
}

.tsb-icon-btn.is-danger:hover {
  color: var(--red);
  border-color: rgba(242, 109, 120, 0.4);
}

/* ======================================================================
   Компактный список задач: одна строка на задачу, пагинация
   ====================================================================== */

.tsb-row.tsb-row-compact {
  min-height: 0;
  margin-bottom: 6px;
  padding-top: 9px;
  padding-bottom: 9px;
  border-radius: 14px;
}

.tsb-row-compact .tsb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 13px;
}

.tsb-row-compact .tsb-actions {
  flex-wrap: nowrap;
  gap: 6px;
}

.tsb-sm-only {
  display: none;
}

.tsb-row-detail {
  display: none;
}

.tsb-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  font-size: 13px;
  color: var(--muted);
}

.tsb-pager-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tsb-page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tsb-page-btn:hover:not(:disabled) {
  background: #17171a;
  color: var(--text);
}

.tsb-page-btn.is-active {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.tsb-page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tsb-page-gap {
  align-self: center;
  padding: 0 4px;
  color: var(--dim);
}

.tsb-link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.tsb-link-btn:hover {
  color: var(--text);
}

/* ======================================================================
   Создание задач: выбор чатов + параметры сообщения
   ====================================================================== */

.tsb-composer {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr);
  gap: 20px;
  align-items: start;
}

.tsb-sticky {
  position: sticky;
  top: 94px;
}

.tsb-chatlist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tsb-chatrow {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--row);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.tsb-chatrow:hover {
  border-color: #3a3a40;
}

.tsb-chatrow.is-selected {
  border-color: rgba(245, 245, 246, 0.5);
  background: #141416;
}

.tsb-chatrow.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tsb-chatrow .tsb-cell-title {
  flex: 1;
}

.tsb-selectall {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 12px;
  margin: 4px 0 12px;
  font-size: 13px;
  color: var(--muted);
}

.tsb-selectall label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

/* «Шаблон для всех задач»: строка с чекбоксом+счётчиком и строка кнопок — как два элемента одного flex-ряда, чтобы на
   узком экране кнопки аккуратно переносились на вторую строку целиком, а не расползались посимвольно. */
.tsb-selectall-row,
.tsb-selectall-actions {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
}

.tsb-inline-row {
  display: flex;
  gap: 10px;
}

.tsb-inline-row > :first-child {
  flex: 1;
  min-width: 0;
}

.tsb-inline-row > .tsb-select-wrap {
  width: 130px;
  flex: none;
}

.tsb-counter {
  margin-top: 6px;
  text-align: right;
  font-size: 12px;
  color: var(--dim);
}

.tsb-counter.is-over {
  color: var(--red);
}

.tsb-check-line {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 4px 0 16px;
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
}

.tsb-check-line small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--dim);
}

.tsb-summary {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--row);
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.tsb-summary b {
  color: var(--text);
}

/* ======================================================================
   Шаблоны
   ====================================================================== */

.tsb-tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.tsb-tpl {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--row);
  min-width: 0;
}

.tsb-tpl-grid .tsb-noresults {
  grid-column: 1 / -1;
}

.tsb-tpl-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 600;
}

.tsb-tpl-text {
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.tsb-tpl-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--dim);
}

/* ======================================================================
   Адаптив новых компонентов
   ====================================================================== */

@media (max-width: 1100px) {
  .tsb-composer {
    grid-template-columns: 1fr;
  }

  .tsb-sticky {
    position: static;
  }
}

@media (max-width: 760px) {
  .tsb-lg-only {
    display: none !important;
  }

  .tsb-sm-only {
    display: block;
  }

  .tsb-row.tsb-row-compact {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 4px;
    padding: 11px 12px;
    cursor: pointer;
  }

  .tsb-row-compact .tsb-avatar {
    display: none;
  }

  .tsb-row-compact .tsb-summary-line {
    grid-column: 1 / -1;
    font-size: 12px;
    color: var(--muted);
  }

  .tsb-row-compact.is-open .tsb-row-detail {
    display: block;
    grid-column: 1 / -1;
    font-size: 12px;
    line-height: 1.5;
    color: var(--dim);
  }

  .tsb-row-compact > .tsb-actions {
    display: none;
  }

  .tsb-row-compact.is-open > .tsb-actions {
    display: flex;
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding-top: 6px;
  }

  .tsb-inline-search {
    flex-basis: 100%;
    max-width: none;
  }

  .tsb-pager {
    justify-content: center;
  }
}

/* ======================================================================
   Мастер подключения аккаунта: переключатель способа, шаги, ожидание
   ====================================================================== */

.tsb-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-field);
  background: var(--field);
}

.tsb-mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 46px;
  padding: 6px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tsb-mode-btn small {
  font-size: 11px;
  font-weight: 500;
  color: var(--dim);
}

.tsb-mode-btn[data-mode="auto"] small {
  color: var(--green);
}

.tsb-mode-btn:hover {
  color: var(--text);
}

.tsb-mode-btn.is-active {
  background: var(--text);
  color: var(--bg);
}

.tsb-mode-btn.is-active small,
.tsb-mode-btn.is-active[data-mode="auto"] small {
  color: #4b4b52;
}

.tsb-steps {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--muted);
}

.tsb-steps b {
  color: var(--text);
  font-weight: 600;
}

.tsb-steps-dots {
  display: flex;
  flex: none;
  gap: 5px;
}

.tsb-steps-dot {
  width: 22px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
}

.tsb-steps-dot.is-done {
  background: var(--muted);
}

.tsb-steps-dot.is-current {
  background: var(--text);
}

.tsb-form-hint-lead {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

.tsb-form-hint-lead b {
  color: var(--text);
  font-weight: 600;
}

.tsb-wizard-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}

.tsb-linkbtn {
  padding: 6px 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.tsb-linkbtn:hover:not(:disabled) {
  color: var(--text);
  text-decoration: underline;
}

.tsb-linkbtn:disabled {
  color: var(--dim);
  cursor: default;
}

.tsb-alert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tsb-working {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 30px 8px 22px;
  text-align: center;
}

.tsb-working-title {
  font-size: 16px;
  font-weight: 600;
}

.tsb-working-text {
  max-width: 22rem;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.tsb-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: tsb-spin 0.8s linear infinite;
}

@keyframes tsb-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tsb-spinner {
    animation-duration: 2.4s;
  }
}

/* ======================================================================
   Режим работы: циферблат (один на все чаты аккаунта), расписание, диалог длительности
   ====================================================================== */

:root {
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, 0.14);
}

/* Слот карточки в сетке «Обзора»: растягивается на высоту соседней карточки (KPI), сама карточка занимает всё место */
.tsb-work-slot {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tsb-work-slot > .tsb-timer {
  flex: 1;
}

.tsb-timer {
  /* Цифры подстраиваются под ширину карточки, а не экрана: в узкой колонке десктопа они должны влезать так же, как на телефоне */
  --seg-h: clamp(44px, 15vw, 80px);
  --on: #f5f5f6;
  --off: rgba(255, 255, 255, 0.07);
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-sizing: border-box;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: linear-gradient(180deg, var(--card-top), var(--card-bottom));
}

@supports (width: 1cqw) {
  .tsb-timer-face {
    --seg-h: clamp(44px, 30cqw, 80px);
  }
}

/* Свободное место в растянутой карточке достаётся циферблату: он с подписью остаётся по центру между шапкой и кнопками */
.tsb-timer > .tsb-timer-face {
  margin-top: auto;
}

.tsb-timer > .tsb-timer-caption {
  margin-bottom: auto;
}

/* Напоминание на странице «Задачи»: аккаунт спит, а настраивается это в «Обзоре» */
.tsb-work-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 14px;
  background: var(--violet-soft);
  color: var(--violet);
  font-size: 14px;
  font-weight: 600;
}

.tsb-work-note .tsb-link {
  color: var(--violet);
  white-space: nowrap;
}

.tsb-timer[data-state="asleep"] {
  --on: rgba(167, 139, 250, 0.62);
  --off: rgba(167, 139, 250, 0.08);
}

.tsb-timer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tsb-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.tsb-state i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.tsb-state svg {
  width: 14px;
  height: 14px;
  flex: none;
}

.tsb-timer[data-state="awake"] .tsb-state {
  color: var(--green);
  background: var(--green-soft);
  border-color: rgba(53, 211, 143, 0.28);
}

.tsb-timer[data-state="awake"] .tsb-state i {
  animation: tsb-pulse 1.8s ease-out infinite;
}

.tsb-timer[data-state="asleep"] .tsb-state {
  color: var(--violet);
  background: var(--violet-soft);
  border-color: rgba(167, 139, 250, 0.3);
}

@keyframes tsb-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(53, 211, 143, 0.55);
  }
  100% {
    box-shadow: 0 0 0 9px rgba(53, 211, 143, 0);
  }
}

.tsb-timer-until {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--dim);
  text-align: right;
}

/* Циферблат ЧЧ:ММ без секунд; вместо цифр при работе без ограничений — знак бесконечности */
.tsb-timer-face {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--seg-h) * 0.09);
  height: var(--seg-h);
  padding: 6px 0 2px;
  user-select: none;
}

.seg {
  display: block;
  width: auto;
  height: 100%;
  overflow: visible;
}

.seg polygon {
  fill: var(--off);
  transition: fill 0.25s;
}

.seg polygon.on {
  fill: var(--on);
}

.tsb-timer[data-state="awake"] .seg polygon.on {
  filter: drop-shadow(0 0 7px rgba(255, 255, 255, 0.16));
}

.seg-colon {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: calc(var(--seg-h) * 0.2);
  width: calc(var(--seg-h) * 0.2);
  height: 100%;
}

.seg-colon i {
  display: block;
  width: calc(var(--seg-h) * 0.11);
  height: calc(var(--seg-h) * 0.11);
  margin: 0 auto;
  background: var(--on);
}

.tsb-timer[data-state="awake"] .seg-colon i {
  animation: tsb-colon 2s steps(1, end) infinite;
}

@keyframes tsb-colon {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.18;
  }
}

.seg-inf {
  display: block;
  width: auto;
  height: 100%;
}

.seg-inf path {
  fill: none;
  stroke: var(--on);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 7px rgba(255, 255, 255, 0.16));
}

.tsb-timer-caption {
  min-height: 20px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

.tsb-timer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* Кнопки делят ширину поровну, но в широкой карточке (одна колонка на планшете) не растягиваются без меры */
.tsb-timer-actions .tsb-btn {
  flex: 1 1 auto;
  max-width: 240px;
}

/* Пока аккаунт спит, строки задач приглушены: они не потеряны, а ждут пробуждения */
body[data-work="asleep"] .tsb-row-compact {
  opacity: 0.62;
}

@media (prefers-reduced-motion: reduce) {
  .tsb-timer[data-state="awake"] .tsb-state i,
  .tsb-timer[data-state="awake"] .seg-colon i {
    animation: none;
  }
}

/* ---------- Настройка режима ---------- */

.tsb-wp-pane {
  display: none;
}

.tsb-wp-pane.is-open {
  display: block;
}

.tsb-wp-label {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.tsb-wp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tsb-wp-chip {
  max-width: 100%;
  min-height: 40px;
  padding: 0 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--field);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tsb-wp-chip:hover {
  color: var(--text);
  border-color: #3a3a41;
}

.tsb-wp-chip.is-active {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.tsb-wp-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 16px;
}

.tsb-wp-day {
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--field);
  color: var(--dim);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tsb-wp-day:hover {
  color: var(--text);
  border-color: #3a3a41;
}

.tsb-wp-day.is-on {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.tsb-wp-hours {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.tsb-wp-hours > div {
  min-width: 0;
}

/* Время можно ввести руками (09:30) или подвинуть кнопками ± на полчаса */
.tsb-wp-time {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-field);
  background: var(--field);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tsb-wp-time:focus-within {
  border-color: #4a4a52;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.tsb-wp-time.is-invalid {
  border-color: var(--red);
}

.tsb-wp-time button {
  flex: none;
  width: 34px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: #1b1b1f;
  color: var(--text);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.tsb-wp-time button:hover {
  background: #26262b;
}

.tsb-wp-time input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-align: center;
  outline: none;
}

.tsb-wp-summary {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--row);
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.tsb-wp-summary b {
  color: var(--text);
}

.tsb-wp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.tsb-wp-actions .tsb-btn-primary {
  flex: 1 1 auto;
}

/* ---------- Диалог «на сколько разбудить / продлить» ---------- */

.tsb-wp-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tsb-wp-custom {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.tsb-wp-custom .tsb-input {
  width: 84px;
  text-align: center;
}

.tsb-wp-custom span {
  font-size: 14px;
  color: var(--muted);
}

/* Переключатель режима: «Без ограничений» / «По расписанию» */
.tsb-wp-mode,
.tsb-seg {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-field);
  background: var(--field);
}

.tsb-wp-mode button,
.tsb-seg button {
  min-height: 42px;
  padding: 0 8px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tsb-wp-mode button:hover,
.tsb-seg button:hover {
  color: var(--text);
}

.tsb-wp-mode button.is-active,
.tsb-seg button.is-active {
  background: var(--text);
  color: var(--bg);
}

.tsb-wp-chip.is-add {
  border-style: dashed;
  color: var(--dim);
}

.tsb-wp-hint {
  margin: -6px 0 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--red);
}

.tsb-wp-custom + .tsb-wp-hint {
  margin: 8px 0 0;
}

.tsb-wp-editor-foot {
  margin-top: 14px;
}

.tsb-pill-violet {
  color: var(--violet);
  background: var(--violet-soft);
  border-color: rgba(167, 139, 250, 0.3);
}

/* ======================================================================
   Задачи: кнопки в шапке карточки, изменение задачи, «Шаблон для всех»
   ====================================================================== */

.tsb-head-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

/* Число с подписью-единицей справа («60 мин») */
.tsb-suffix-field {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tsb-suffix-field .tsb-input {
  flex: 1;
  min-width: 0;
}

.tsb-suffix-field > span {
  flex: none;
  font-size: 14px;
  color: var(--muted);
}

/* Задачи «по времени суток»: список времён отправки */
.tsb-times {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.tsb-times-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.tsb-time-input {
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.tsb-time-input.is-invalid {
  border-color: var(--red);
}

/* Интервал: два поля рядом — часы и минуты */
.tsb-time-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* Название чата под заголовком окна */
.tsb-modal-sub {
  margin: -8px 0 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  color: var(--muted);
}

/* Предпросмотр текста шаблона (только чтение) */
.tsb-preview {
  max-height: 160px;
  margin: -4px 0 16px;
  padding: 12px 14px;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--row);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 760px) {
  .tsb-head-actions {
    width: 100%;
    justify-content: stretch;
  }

  .tsb-head-actions > .tsb-btn {
    flex: 1 1 auto;
  }
}

@media (max-width: 760px) {
  .tsb-card-head {
    flex-wrap: wrap;
  }
}

/* ======================================================================
   Фото в сообщениях: выбор, миниатюры в шаблонах и предпросмотр
   ====================================================================== */

.tsb-photo-empty {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.tsb-photo-hint {
  flex: 1 1 200px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--dim);
}

.tsb-photo-has {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tsb-photo-thumb,
.tsb-tpl-thumb,
.tsb-preview-thumb {
  display: block;
  object-fit: cover;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--field);
}

.tsb-photo-thumb {
  flex: none;
  width: 84px;
  height: 84px;
}

.tsb-photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tsb-tpl-thumb {
  width: 100%;
  height: 120px;
  margin-bottom: 10px;
}

.tsb-preview-thumb {
  width: 100%;
  max-height: 150px;
  margin-bottom: 10px;
}

img.is-pending {
  opacity: 0.35;
}

/* Значок «с фото» рядом с названием чата в списке задач */
.tsb-photo-mark {
  display: inline-flex;
  margin-left: 8px;
  vertical-align: -2px;
  color: var(--dim);
}

.tsb-photo-mark svg {
  width: 15px;
  height: 15px;
}

/* ---------- Несколько текстов у одной задачи («＋ Добавить ещё текст») ---------- */

.tsb-variants {
  margin-top: 12px;
}

.tsb-variant {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-field);
  background: rgba(255, 255, 255, 0.02);
}

.tsb-variant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tsb-variant-label {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.tsb-variants-add {
  margin-top: 2px;
}

.tsb-variants-order {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.tsb-variants-order .tsb-seg {
  margin: 0;
  min-width: 220px;
}

.tsb-variants-order .tsb-seg button {
  min-height: 34px;
  font-size: 13px;
}

.tsb-variants-hint {
  margin: 8px 0 0;
}

/* Значок «×3» у названия задачи, у которой несколько текстов */
.tsb-variants-mark {
  display: inline-block;
  margin-left: 8px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  color: var(--dim);
  vertical-align: 1px;
}

/* ---------- Расписание «по дням»: у каждого дня своё время ---------- */

.tsb-wp-adv-switch {
  margin-bottom: 16px;
}

.tsb-wp-dayrow {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.tsb-wp-dayrow .tsb-wp-day {
  min-height: 40px;
}

.tsb-wp-dayrow .tsb-wp-time {
  padding: 2px;
}

.tsb-wp-dayrow .tsb-wp-time button {
  width: 26px;
  height: 34px;
  font-size: 16px;
}

.tsb-wp-dayrow .tsb-wp-time input {
  font-size: 15px;
}

.tsb-wp-dayrow.is-off .tsb-wp-time {
  opacity: 0.35;
}
