:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Roboto", sans-serif;
  --color-bg: #f4f6fb;
  --color-surface: #ffffff;
  --color-text: #111827;
  --color-text-muted: #4b5563;
  --color-primary: #2563eb;
  --color-border: #e5e7eb;
  --shadow-elevated: 0 10px 30px rgba(15, 23, 42, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.08), rgba(99, 102, 241, 0.05));
  color: var(--color-text);
}

a {
  color: inherit;
}

.app-header,
.app-footer {
  backdrop-filter: blur(16px);
  background: rgba(15, 23, 42, 0.85);
  color: #f9fafb;
}

.app-header__inner,
.app-footer__inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.app-header__logo {
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.app-header__nav {
  display: flex;
  gap: 0.75rem;
  margin-left: auto;
}

.app-header__profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: 1rem;
  color: rgba(249, 250, 251, 0.85);
  font-size: 0.95rem;
}

.app-header__logout {
  margin: 0;
}

.app-header__logout button {
  font-size: 0.9rem;
}

.app-header__user-login {
  white-space: nowrap;
}

.app-header__link {
  padding: 0.4rem 0.8rem;
  border-radius: 0.75rem;
  text-decoration: none;
  color: rgba(249, 250, 251, 0.8);
  transition: color 0.2s ease, background 0.2s ease;
}

.app-header__link:hover,
.app-header__link:focus-visible {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.app-header__link--active {
  color: #111827;
  background: #ffffff;
}

.page {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.section {
  background: var(--color-surface);
  border-radius: 1.25rem;
  padding: 2.5rem;
  box-shadow: var(--shadow-elevated);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.section__title {
  margin: 0 0 1.5rem;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.section__subtitle {
  margin: -1rem 0 2rem;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.section--split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
  gap: 2.5rem;
}

.section__col {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.section__col--preview {
  background: rgba(248, 250, 252, 0.75);
  border-radius: 1.25rem;
  padding: 1.75rem;
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.section p {
  margin: 0;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.section--narrow {
  max-width: 420px;
  margin: 0 auto;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form--inline {
  margin-top: 2.5rem;
  flex-direction: column;
  gap: 1rem;
}

.form__group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form__group--inline {
  flex-direction: row;
  align-items: center;
  gap: 1rem;
}

.form__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.form__actions {
  display: flex;
  gap: 0.75rem;
}

.form__actions--compact {
  justify-content: flex-start;
}

.form__label {
  font-weight: 500;
  color: var(--color-text);
}

.form__control {
  border: 1px solid var(--color-border);
  border-radius: 0.9rem;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  background: #f9fafb;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form__control:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.7);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.form__control--textarea {
  min-height: 200px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.6;
}

.multiselect {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(255, 255, 255, 0.7);
}

.multiselect__option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  color: var(--color-text);
}

.multiselect__option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #2563eb;
}

.form__hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.vk-integration {
  margin-top: 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.vk-integration .button {
  align-self: flex-start;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: 0.9rem;
  padding: 0.85rem 1.4rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

.button--primary {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.3);
}

.button--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(37, 99, 235, 0.35);
}

.button--ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #262626;
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.button--ghost:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.18);
}

.form__feedback {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  font-size: 0.95rem;
}

.form__feedback--success {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
  color: #047857;
}

.form__feedback--error {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.2);
  color: #b91c1c;
}

.groups-list {
  margin-top: 2.5rem;
}

.groups-list__items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.groups-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

.groups-list__main {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.groups-list__item .button {
  white-space: nowrap;
}

.groups-list__link {
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
  word-break: break-word;
}

.groups-list__link:hover {
  text-decoration: underline;
}

.groups-list__meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.groups-list__empty {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.preview-placeholder {
  border: 1px dashed rgba(148, 163, 184, 0.5);
  border-radius: 1rem;
  padding: 2rem;
  text-align: center;
  color: var(--color-text-muted);
}

.preview {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: #ffffff;
  border-radius: 1.25rem;
  padding: 1.75rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

.preview__cover img {
  max-width: 100%;
  border-radius: 1rem;
  display: block;
}

.preview__content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 1rem;
  color: var(--color-text);
  line-height: 1.7;
}

.preview__content br {
  content: "";
}

.preview__cta {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.2rem;
  border-radius: 0.9rem;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #ffffff;
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.25);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.preview__cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(37, 99, 235, 0.35);
}

.alert {
  padding: 1rem 1.25rem;
  border-radius: 0.9rem;
  border: 1px solid transparent;
  background: rgba(37, 99, 235, 0.05);
  color: var(--color-text);
  margin-bottom: 1.5rem;
}

.alert--error {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.2);
  color: #b91c1c;
}

.history-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.5rem;
}

.users-table,
.history-table {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 1rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.85);
}

.history-table__empty {
  margin: 0;
  padding: 2rem;
  text-align: center;
  color: var(--color-text-muted);
}

.history-table table {
  width: 100%;
  border-collapse: collapse;
}

.users-table table {
  width: 100%;
  border-collapse: collapse;
}

.history-table thead {
  background: rgba(37, 99, 235, 0.08);
}

.users-table thead {
  background: rgba(37, 99, 235, 0.08);
}

.history-table th,
.history-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  font-size: 0.95rem;
}

.users-table th,
.users-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  font-size: 0.95rem;
}

.history-table tr:last-child td {
  border-bottom: none;
}

.users-table tr:last-child td {
  border-bottom: none;
}

.users-table__empty {
  margin: 0;
  padding: 2rem;
  text-align: center;
  color: var(--color-text-muted);
}

.users-table__actions {
  display: flex;
  gap: 0.5rem;
}

.users-table__actions .button {
  font-size: 0.85rem;
  padding: 0.5rem 0.8rem;
}

.users-table input,
.users-table select {
  width: 100%;
}

.history-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.history-status--ok {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.history-status--error {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

.history-pagination {
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}

.history-pagination button {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 0.8rem;
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.history-pagination button[disabled],
.history-pagination button.is-active {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #ffffff;
  border-color: transparent;
  cursor: default;
}

.app-footer__inner {
  justify-content: center;
  font-size: 0.85rem;
  opacity: 0.85;
}

@media (max-width: 768px) {
  .app-header__inner,
  .app-footer__inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .app-header__nav {
    margin-left: 0;
    flex-wrap: wrap;
  }

  .app-header__profile {
    margin-left: 0;
  }

  .page {
    padding: 2rem 1rem;
  }

  .section {
    padding: 1.75rem;
  }

  .section__title {
    font-size: 1.4rem;
  }

  .section--narrow {
    max-width: 100%;
  }

  .groups-list__item {
    flex-direction: column;
    align-items: flex-start;
  }

  .section--split {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .section__col--preview {
    padding: 1.25rem;
  }

  .form__grid {
    grid-template-columns: 1fr;
  }

  .form__group--inline {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .form__actions {
    width: 100%;
  }

  .form__actions .button {
    width: 100%;
  }

  .history-controls {
    justify-content: flex-start;
  }
}

/* History grouped by date styles */
.history-grouped {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.history-date-header {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
  padding: 0.5rem 0;
  border-bottom: 2px solid var(--color-border);
  text-transform: capitalize;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.history-table thead {
  background: #f9fafb;
  border-bottom: 2px solid var(--color-border);
}

.history-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9375rem;
}

.history-table tbody tr:last-child td {
  border-bottom: none;
}

.history-table tbody tr:hover {
  background: #f9fafb;
}

.history-table a {
  color: var(--color-primary);
  text-decoration: none;
  word-break: break-word;
}

.history-table a:hover {
  text-decoration: underline;
}

.history-status {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 0.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.25px;
}

.history-status--ok {
  background: #d1fae5;
  color: #065f46;
}

.history-status--error {
  background: #fee2e2;
  color: #991b1b;
}

.history-table__empty {
  padding: 2rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 1rem;
}

/* Кликабельные строки таблицы кампаний */
.history-table__row--clickable {
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.history-table__row--clickable:hover {
  background: rgba(37, 99, 235, 0.04);
  transform: translateX(2px);
}

.history-table__row--clickable:active {
  background: rgba(37, 99, 235, 0.08);
}

/* Стили для таблицы кампаний */
.history-table--campaigns {
  margin-top: 1.5rem;
}

/* Стили для детального просмотра */
.history-detail__title {
  margin: 1.5rem 0 1rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
}

.history-table--detail {
  margin-top: 1rem;
}

/* Маленькие кнопки */
.button--small {
  padding: 0.5rem 0.9rem;
  font-size: 0.875rem;
}
