:root {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0d6efd;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.04);
  --nav-bg: #0f172a;
  --indigo: #6366f1;
}

* {
  box-sizing: border-box;
}

/* ── App Navigation ─────────────────────────────────────── */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--nav-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
}

.app-nav__inner {
  display: flex;
  align-items: center;
  height: 54px;
  padding: 0 16px;
  gap: 8px;
}

.app-nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #f8fafc;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.015em;
  margin-right: 20px;
  flex-shrink: 0;
}

.app-nav__brand:hover { color: #fff; }

.app-nav__logo { color: #818cf8; flex-shrink: 0; }

.app-nav__links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.app-nav__link {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 11px;
  border-radius: 0.45rem;
  color: rgba(248, 250, 252, 0.62);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.app-nav__link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #f8fafc;
}

.app-nav__link.is-active {
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
}

.app-nav__user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.app-nav__username {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(248, 250, 252, 0.5);
  font-size: 0.82rem;
}

.app-nav__logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.4rem;
  background: transparent;
  color: rgba(248, 250, 252, 0.58);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  width: auto;
}

.app-nav__logout-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.18);
  transform: none;
  box-shadow: none;
}

@media (max-width: 560px) {
  .app-nav__username { display: none; }
  .app-nav__brand { margin-right: 10px; }
}

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.page-header__title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.025em;
}

.page-header__sub {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 4px 0 0;
}

/* ── Stat Grid ───────────────────────────────────────────── */
.stat-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 20px;
}

.stat-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08), 0 12px 28px rgba(15, 23, 42, 0.06);
}

.stat-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 0.7rem;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.stat-card__icon--indigo { background: rgba(99, 102, 241, 0.1); color: #6366f1; }
.stat-card__icon--blue   { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.stat-card__icon--amber  { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.stat-card__icon--green  { background: rgba(16, 185, 129, 0.1); color: #10b981; }

.stat-card__value {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  letter-spacing: -0.03em;
}

.stat-card__label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 3px;
}

.stat-card__sub {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 3px;
}

/* ── Activity Grid ───────────────────────────────────────── */
.activity-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.activity-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.activity-card--overflow {
  overflow: visible;
}

.activity-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--panel-border);
  background: #f8fafc;
}

.activity-card__icon { color: var(--indigo); font-size: 0.9rem; }

.activity-card__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.activity-card__body {
  padding: 18px;
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid #f8fafc;
  font-size: 0.875rem;
  color: var(--text);
}

.activity-list__item:last-child { border-bottom: 0; }

.activity-list__empty {
  padding: 24px 18px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.84rem;
}

.activity-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 600;
  white-space: nowrap;
  background: #f1f5f9;
  color: #64748b;
  flex-shrink: 0;
}

.activity-badge--done,
.activity-badge--ok,
.activity-badge--sent   { background: #dcfce7; color: #15803d; }
.activity-badge--failed,
.activity-badge--error  { background: #fee2e2; color: #b91c1c; }
.activity-badge--running { background: #e0e7ff; color: #4338ca; }
.activity-badge--pending { background: #fef9c3; color: #854d0e; }

.task-run-error-badge {
  cursor: pointer;
}

.task-run-error-badge:hover,
.task-run-error-badge:focus {
  filter: brightness(0.96);
}

.task-run-error-modal__text {
  padding: 14px;
  border: 1px solid var(--panel-border);
  border-radius: 0.5rem;
  background: #f8fafc;
  color: #7f1d1d;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ── Auth Card ───────────────────────────────────────────── */
.auth-card {
  width: min(100%, 420px);
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 1.25rem;
  box-shadow: 0 4px 6px rgba(15, 23, 42, 0.05), 0 20px 40px rgba(15, 23, 42, 0.1);
  padding: 36px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

@media (max-width: 480px) {
  .auth-card { padding: 28px 22px; }
}

.auth-card__logo-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-card__logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 0.875rem;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  flex-shrink: 0;
}

.auth-card__logo-icon svg { width: 26px; height: 26px; }

.auth-card__title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.02em;
}

.auth-card__sub {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 3px 0 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.auth-form__field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.auth-form__label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
}

.auth-form__optional {
  font-size: 0.73rem;
  font-weight: 400;
  color: var(--muted);
  background: #f1f5f9;
  padding: 1px 7px;
  border-radius: 999px;
}

.auth-submit-btn {
  min-height: 44px;
  font-weight: 600;
  font-size: 0.92rem;
  margin-top: 4px;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page-shell {
  max-width: 1360px;
}

.hero {
  margin-bottom: 28px;
}

.auth-shell {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
  padding: 24px 0 48px;
}

.auth-shell__panel {
  width: min(100%, 560px);
  border-radius: 1rem;
}

.auth-form .form-label {
  color: var(--text);
  font-weight: 600;
}

.auth-form .form-control-lg {
  min-height: 52px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-size: 0.78rem;
}

h1, h2, p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  margin-bottom: 12px;
}

.lede,
.card p,
.card li,
label {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 0.75rem;
  padding: 20px;
  box-shadow: var(--shadow);
}

form {
  max-width: none;
}

.stack {
  display: grid;
  gap: 12px;
}

input:not([type="checkbox"]):not([type="radio"]):not(.form-control),
select:not(.form-select),
textarea:not(.form-control),
button:not(.btn) {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  border: 1px solid var(--panel-border);
  background: #fff;
  color: var(--text);
}

button:not(.btn) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

button:not(.btn):hover {
  background: #0b5ed7;
  border-color: #0b5ed7;
  box-shadow: 0 0.5rem 1rem rgba(13, 110, 253, 0.2);
  transform: translateY(-1px);
}

button:not(.btn):active {
  transform: translateY(0);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(13, 110, 253, 0.2);
  outline-offset: 2px;
}

.chat-workbench {
  display: grid;
  gap: 16px;
}

.chat-workbench__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.chat-workbench__header p {
  max-width: 72ch;
}

.chat-workbench__header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.chat-workbench__header-actions > button,
.chat-list__empty--panel > button {
  width: auto;
}

.telegram-auth-row {
  --telegram-auth-button-width: 220px;
}

.telegram-auth-row .col-sm {
  min-width: 0;
}

.telegram-auth-row__actions {
  min-width: var(--telegram-auth-button-width);
}

.telegram-auth-row__actions > .btn {
  width: 100%;
}

.manual-task-card {
  min-height: 100%;
}

.manual-task-card__body {
  min-height: 100%;
}

.manual-task-card__footer {
  min-height: 56px;
}

.manual-task-card__button {
  width: min(100%, 240px);
  min-height: 44px;
  align-self: center;
}

[data-manual-task-result] {
  white-space: pre-wrap;
}

.manual-progress {
  display: grid;
  gap: 8px;
  white-space: normal;
}

.manual-progress__topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.manual-progress__message,
.manual-progress__details {
  overflow-wrap: anywhere;
}

.manual-progress__bar {
  height: 10px;
}

.chat-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(13, 110, 253, 0.2);
  background: rgba(13, 110, 253, 0.08);
  color: var(--text);
  font-weight: 600;
}

.chat-workbench__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.chat-pagination-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  width: 100%;
  justify-content: flex-end;
}

.chat-pagination-row__controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
  flex-wrap: nowrap;
}

.chat-pagination-row__size {
  display: inline-flex;
  align-items: center;
  margin: 0;
  flex-shrink: 0;
  flex: 0 0 auto;
}

.chat-pagination-row__size .form-select {
  min-width: 80px;
}

.chat-pagination {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 0.65rem;
}

.chat-pagination__link {
  appearance: none;
  border: 0;
  background: #495057;
  color: #ffffff;
  padding: 0.09rem 0.27rem;
  border-radius: 0.35rem;
  margin: 0;
  font: inherit;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  box-shadow: none;
}

.chat-pagination__link:hover:not(:disabled) {
  color: #000000;
  background: #ffffff;
  box-shadow: none;
  transform: none;
}

.chat-pagination__link:focus-visible {
  outline: 2px solid rgba(13, 110, 253, 0.18);
  outline-offset: 2px;
}

.chat-pagination__link.is-current {
  color: var(--text);
  background: #e9ecef;
  font-weight: 600;
}

.chat-pagination__link:disabled {
  color: #ffffff;
  background: #6c757d;
  cursor: default;
  opacity: 0.78;
}

.chat-pagination__link[aria-disabled="true"] {
  color: #ffffff;
  background: #6c757d;
  cursor: default;
  opacity: 0.78;
  pointer-events: none;
}

.chat-pagination__ellipsis {
  color: #6c757d;
  padding: 0 0.5px;
  user-select: none;
}

@media (max-width: 576px) {
  .chat-pagination-row {
    gap: 8px;
  }

  .chat-pagination-row__label {
    display: none;
  }

  .chat-pagination-row__controls {
    justify-content: flex-start;
  }
}

.status-dot,
.telegram-status {
  position: relative;
  display: inline-flex;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #6c757d;
}

.status-dot::after,
.telegram-status::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  opacity: 0.25;
  animation: telegram-status-pulse 1.6s ease-out infinite;
}

.status-dot.is-online,
.telegram-status.is-online {
  background: #198754;
}

.status-dot.is-online::after,
.telegram-status.is-online::after {
  background: rgba(25, 135, 84, 0.35);
}

.status-dot.is-offline,
.telegram-status.is-offline {
  background: #dc3545;
}

.status-dot.is-offline::after,
.telegram-status.is-offline::after {
  background: rgba(220, 53, 69, 0.35);
}

@keyframes telegram-status-pulse {
  0% {
    transform: scale(0.75);
    opacity: 0.45;
  }
  70% {
    transform: scale(1.4);
    opacity: 0;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

.legend-chip,
.legend-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  color: var(--muted);
  font-size: 0.86rem;
}

.legend-chip strong {
  color: var(--text);
}

.legend-note {
  flex: 1 1 280px;
}

.chat-toolbar {
  display: grid;
  grid-template-columns: 220px minmax(280px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-radius: 0.75rem;
  background: #fff;
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.chat-toolbar__field,
.chat-toolbar__search,
.chat-toolbar__segmented {
  display: grid;
  gap: 8px;
}

.chat-segmented-control {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 38px;
  padding: 3px;
  border-radius: 0.5rem;
  border: 1px solid var(--panel-border);
  background: #f8fafc;
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.chat-segmented-control__item {
  min-width: 0;
  margin: 0;
}

.chat-segmented-control__item > span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 0.35rem;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.chat-segmented-control__item > input:checked + span {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.14);
}

.chat-segmented-control__item > input:focus-visible + span {
  outline: 2px solid rgba(13, 110, 253, 0.35);
  outline-offset: 1px;
}

.overview-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.chat-toolbar__field span,
.chat-toolbar__search span,
.chat-toolbar__segmented > span,
.chat-config__meta span {
  color: var(--muted);
  font-size: 0.85rem;
}

.chat-toolbar select,
.chat-toolbar input {
  width: 100%;
}

.chat-folder-dropdown {
  min-width: 220px;
}

.chat-folder-dropdown__button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  min-height: 38px;
  text-align: left;
  background-color: var(--bs-body-bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: var(--bs-border-radius);
  padding: 0.375rem 0.75rem;
  box-shadow: none;
}

.chat-folder-dropdown__button:hover,
.chat-folder-dropdown__button:focus,
.chat-folder-dropdown__button:focus-visible,
.chat-folder-dropdown__button:active,
.chat-folder-dropdown__button.show {
  background-color: var(--bs-body-bg);
  border-color: var(--panel-border);
  color: var(--text);
  box-shadow: none;
}

.chat-folder-dropdown__button > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.chat-folder-dropdown__chevron {
  flex-shrink: 0;
  font-size: 0.7rem;
  opacity: 0.5;
  transition: transform 0.15s ease;
}

.chat-folder-dropdown__button.show .chat-folder-dropdown__chevron {
  transform: rotate(180deg);
}

.chat-folder-dropdown__menu {
  width: min(360px, calc(100vw - 32px));
  max-height: 340px;
  overflow-y: auto;
  padding: 6px;
}

.chat-folder-dropdown__item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 34px;
  border-radius: 0.35rem;
  color: var(--text);
  white-space: normal;
}

.chat-folder-dropdown__item .form-check-input {
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.chat-toolbar__field--compact {
  max-width: 160px;
}

.chat-workbench__body {
  display: flex;
  gap: 0;
  align-items: start;
  width: 100%;
}

.chat-table {
  flex: 1 1 100%;
  min-width: 0;
  display: grid;
  gap: 10px;
}

.chat-table__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px 40px 40px 40px minmax(114px, auto);
  gap: 8px;
  align-items: center;
  padding: 0 14px;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chat-table__head-sorts {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.chat-table__head-action {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-table__head-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: none;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1;
  text-decoration: none;
  transition: color 0.15s ease, opacity 0.15s ease, text-decoration-color 0.15s ease;
}

.chat-table__head-sort:hover {
  color: var(--text);
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.chat-table__head-sort.is-current {
  color: var(--text);
  font-weight: 600;
}

.chat-table__head-sort:focus-visible {
  outline: none;
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.chat-table__head-sort-label {
  text-decoration: none;
}

.chat-table__head-sort-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0.85rem;
  font-size: 0.88em;
  line-height: 1;
  color: inherit;
}

.chat-table__head-action:hover {
  color: #fff;
  background: linear-gradient(180deg, #4c9bff 0%, #0d6efd 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 0.35rem 0.8rem rgba(13, 110, 253, 0.18);
}

.chat-table__head-action.is-all {
  color: #fff;
  background: linear-gradient(180deg, #198754 0%, #146c43 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 0.35rem 0.8rem rgba(25, 135, 84, 0.24);
}

.chat-table__head-action.is-mixed {
  color: #fff;
  background: linear-gradient(180deg, #fd7e14 0%, #c2410c 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 0.35rem 0.8rem rgba(194, 65, 12, 0.24);
}

.chat-table__head-action.is-none {
  color: #334155;
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  box-shadow: inset 0 0 0 1px rgba(100, 116, 139, 0.18);
}

.chat-table__head-action.is-dirty {
  color: #fff;
  background: linear-gradient(180deg, #3d8bfd 0%, #0d6efd 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14), 0 0.35rem 0.8rem rgba(13, 110, 253, 0.24);
}

.chat-table__head-action:hover,
.chat-table__head-action.is-all:hover,
.chat-table__head-action.is-mixed:hover,
.chat-table__head-action.is-none:hover,
.chat-table__head-action.is-dirty:hover {
  color: #fff;
  background: linear-gradient(180deg, #4c9bff 0%, #0d6efd 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 0.35rem 0.8rem rgba(13, 110, 253, 0.22);
}

.chat-table__head-action:focus-visible {
  outline: 2px solid rgba(13, 110, 253, 0.6);
  outline-offset: 2px;
}

.chat-table__head-action--save {
  justify-content: flex-start;
  padding-left: 8px;
  text-transform: none;
}

.chat-table__rows {
  display: grid;
  gap: 8px;
  max-height: none;
  overflow: visible;
  overflow-anchor: none;
}

.page-shell {
  overflow-anchor: none;
}

.chat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px 40px 40px 40px minmax(114px, auto);
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 0.75rem;
  border: 1px solid var(--panel-border);
  background: #fff;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  cursor: pointer;
}

.chat-row.is-active {
  border-color: rgba(13, 110, 253, 0.35);
  box-shadow: 0 0.35rem 0.9rem rgba(13, 110, 253, 0.08);
  background: rgba(13, 110, 253, 0.03);
}

.chat-row.is-dirty {
  border-color: rgba(255, 193, 7, 0.45);
  background: rgba(255, 193, 7, 0.16);
  box-shadow: 0 0.35rem 0.9rem rgba(255, 193, 7, 0.12);
}

.chat-row.is-dirty.is-active {
  border-color: rgba(255, 193, 7, 0.6);
  background: rgba(255, 193, 7, 0.2);
}

.chat-row:hover {
  border-color: rgba(13, 110, 253, 0.22);
  box-shadow: 0 0.35rem 0.9rem rgba(0, 0, 0, 0.06);
}

.chat-row[hidden] {
  display: none !important;
}

.chat-row__title {
  display: grid;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text) !important;
}

.chat-row__title strong {
  font-size: 0.96rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-row__title span,
.chat-row__folder {
  color: var(--muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-row__title .chat-row__meta {
  display: block;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  line-height: 1.35;
}

.chat-row__folder {
  display: flex;
  align-items: center;
  min-height: 1.5rem;
}

.chat-toggle {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.chat-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chat-toggle__dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: #f1f3f5;
  color: #adb5bd;
  font-size: 0.82rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Monitor — blue */
.chat-toggle--monitor input[type="checkbox"]:checked + .chat-toggle__dot {
  color: #fff;
  background: linear-gradient(180deg, #3d8bfd 0%, #0d6efd 100%);
  border-color: #0d6efd;
  box-shadow: 0 0.25rem 0.65rem rgba(13, 110, 253, 0.28);
}

/* History — indigo */
.chat-toggle--history input[type="checkbox"]:checked + .chat-toggle__dot {
  color: #fff;
  background: linear-gradient(180deg, #7c69ef 0%, #6610f2 100%);
  border-color: #6610f2;
  box-shadow: 0 0.25rem 0.65rem rgba(102, 16, 242, 0.28);
}

/* Summary — amber */
.chat-toggle--summary input[type="checkbox"]:checked + .chat-toggle__dot {
  color: #fff;
  background: linear-gradient(180deg, #ffca2c 0%, #e0a800 100%);
  border-color: #e0a800;
  color: #5c3a00;
  box-shadow: 0 0.25rem 0.65rem rgba(224, 168, 0, 0.32);
}

/* Export — green */
.chat-toggle--export input[type="checkbox"]:checked + .chat-toggle__dot {
  color: #fff;
  background: linear-gradient(180deg, #2dce89 0%, #198754 100%);
  border-color: #198754;
  box-shadow: 0 0.25rem 0.65rem rgba(25, 135, 84, 0.28);
}

.chat-toggle:hover .chat-toggle__dot {
  transform: translateY(-1px);
  border-color: rgba(0, 0, 0, 0.2);
  background: #e9ecef;
}

.chat-row__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.schedule-list__item:first-child {
  border-top: 0 !important;
  padding-top: 0 !important;
}

.schedule-list__item .btn svg {
  display: block;
}

.chat-row__actions button {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-row__save-btn {
  opacity: 0.18;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.chat-row.is-dirty .chat-row__save-btn {
  opacity: 1;
  pointer-events: auto;
}

.chat-detail__tabs {
  margin-bottom: 14px;
}

.chat-detail__tab-content {
  min-height: 360px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(62vh, 680px);
  overflow-y: auto;
  padding: 14px;
  border: 1px solid var(--panel-border);
  border-radius: 0.75rem;
  background:
    linear-gradient(180deg, rgba(13, 110, 253, 0.06), rgba(25, 135, 84, 0.05)),
    #f6f8fb;
}

.chat-messages__state {
  padding: 18px;
  border: 1px dashed rgba(108, 117, 125, 0.35);
  border-radius: 0.75rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
}

.chat-message {
  align-self: flex-start;
  width: min(78%, 760px);
  padding: 9px 11px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 0.7rem;
  border-top-left-radius: 0.2rem;
  background: #fff;
  box-shadow: 0 0.3rem 0.7rem rgba(15, 23, 42, 0.06);
}

.chat-message__sender {
  margin-bottom: 4px;
  color: #0d6efd;
  font-size: 0.82rem;
  font-weight: 700;
}

.chat-message__text {
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1.42;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-message__meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: right;
}

.chat-message__meta a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.chat-detail__grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chat-detail__block {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 0.75rem;
  background: var(--bs-tertiary-bg, #f8f9fa);
}

.chat-detail__item {
  display: grid;
  gap: 2px;
}

.chat-detail__label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chat-detail__value {
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1.35;
  word-break: break-word;
}

.chat-detail__json {
  max-height: 320px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 0.75rem;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 992px) {
  .chat-detail__grid {
    grid-template-columns: 1fr;
  }
}

.chat-list__empty {
  padding: 20px;
  border-radius: 0.75rem;
  border: 1px dashed var(--panel-border);
  color: var(--muted);
}

.chat-config__meta strong {
  display: block;
  margin-top: 4px;
}

.chat-config__footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

.chat-config__footer button,
.chat-list__empty--panel button {
  min-width: 220px;
}

.schedule-editor--compact .card-body {
  padding: 16px;
  gap: 12px;
}

.schedule-editor--compact h3,
.schedule-editor--compact .h5 {
  font-size: 1.02rem;
}

.schedule-editor--compact .form-label {
  margin-bottom: 0.25rem;
  font-size: 0.84rem;
}

.schedule-editor--compact .form-control,
.schedule-editor--compact .form-select {
  min-height: 38px;
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
  font-size: 0.94rem;
}

.schedule-editor--compact .form-text {
  font-size: 0.76rem;
}

.schedule-editor--compact .btn {
  min-height: 38px;
}

.schedule-editor--compact .form-check.form-switch {
  min-height: 38px;
}

.schedule-editor--compact .badge {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

@media (max-width: 1024px) {
  .chat-toolbar,
  .chat-table__head,
  .chat-row {
    grid-template-columns: 1fr;
  }

  .chat-workbench__body {
    display: grid;
    width: auto;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 28px 14px 48px;
  }

  .chat-list {
    max-height: 520px;
  }
}
