/* YaDirectPanel — стили визуального языка Apple/macOS.
   Все цвета, тени и радиусы — только из дизайн-токенов (ТЗ §2–§4). */

:root {
  /* Палитра (ТЗ §3) */
  --bg: #F5F5F7;
  --text: #1D1D1F;
  --text-secondary: #6E6E73;
  --border: #E2E2E7;
  --surface-secondary: #F0F0F2;
  --surface: #FFFFFF;
  --accent: #0071E3;
  --accent-hover: #0077ED;
  --success: #2E9B4F;
  --table-bg: #FAFAFA;
  --input-border: #D7D7DC;
  --row-border: #EDEDEF;
  --icon-muted: #8E8E93;

  /* Тени и радиусы (ТЗ §8, §10) */
  --shadow-card: 0 5px 22px rgba(0, 0, 0, .045);
  --shadow-block: 0 5px 24px rgba(0, 0, 0, .045);
  --shadow-segment: 0 1px 3px rgba(0, 0, 0, .10);
  --radius-card: 19px;
  --radius-input: 10px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", Arial, sans-serif;
  --transition: .15s ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Контейнер страницы (ТЗ §6) */
.container {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding-top: 34px;
  padding-bottom: 48px;
}

svg.icon {
  width: 16px;
  height: 16px;
  flex: none;
  vertical-align: -3px;
}

/* ---------- Шапка (ТЗ §7, §23) ---------- */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
}

.brand {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 6px;
}

.page-title {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin: 0;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 8px 0 0;
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-input);
  border: 1px solid var(--input-border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
    opacity var(--transition);
}

.button:hover {
  background: var(--table-bg);
}

/* «Загрузить» — главная кнопка интерфейса (ТЗ §14) */
.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  border-radius: 999px;
  color: #FFFFFF;
  font-weight: 600;
}

.button--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.button--primary:disabled {
  opacity: .6;
  cursor: default;
}

.button--small {
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
}

.spin {
  animation: rotate 1s linear infinite;
}

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

/* ---------- Карточки показателей (ТЗ §8–§9) ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px 22px;
  min-height: 118px;
  display: flex;
  flex-direction: column;
}

.card__label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 10px;
}

.card__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.card__value {
  font-size: 31px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: 0;
}

.card__meta {
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  margin: auto 0 0;
  padding-top: 8px;
}

/* Акцент карточки «Сегодня» — только тонкая синяя граница + точка (ТЗ §9) */
.card--today {
  border-color: rgba(0, 113, 227, .18);
}

/* ---------- Блок «Статистика по аккаунтам» (ТЗ §10–§11) ---------- */

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

.panel__header {
  padding: 22px 24px 0;
}

.panel__title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 16px;
}

/* Панель управления (ТЗ §12–§15) */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.toolbar .button--primary {
  margin-left: auto;
}

.field {
  position: relative;
}

.field .icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--icon-muted);
  pointer-events: none;
}

.input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-input);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  transition: border-color var(--transition);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
}

.input--search {
  width: 210px;
  padding-left: 34px;
}

.input--date {
  padding-left: 34px;
  color: var(--text);
}

/* Фильтры — segmented control (ТЗ §16–§17) */
.filters {
  display: inline-flex;
  gap: 2px;
  background: var(--surface-secondary);
  border-radius: var(--radius-input);
  padding: 3px;
  margin: 20px 24px;
}

.filters__button {
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), opacity var(--transition);
}

.filters__button--active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-segment);
}

/* ---------- Таблица (ТЗ §18–§22) ---------- */

.table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--row-border);
}

.table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
  background: var(--table-bg);
  text-align: left;
  padding: 10px 16px;
  white-space: nowrap;
}

.table th:first-child { padding-left: 24px; }
.table th:last-child { padding-right: 24px; }

.table th.sortable {
  cursor: pointer;
  user-select: none;
}

.table th.sortable:hover {
  color: var(--text);
}

.sort-mark {
  display: inline-block;
  margin-left: 4px;
  color: var(--accent);
}

.sort-mark .icon {
  width: 12px;
  height: 12px;
  vertical-align: -2px;
}

.table td {
  padding: 0 16px;
  height: 62px;
  border-top: 1px solid var(--row-border);
  font-size: 14px;
  vertical-align: middle;
}

.table td:first-child { padding-left: 24px; }
.table td:last-child { padding-right: 24px; }

.table tbody tr {
  transition: background var(--transition);
}

.table tbody tr:hover {
  background: var(--table-bg);
}

.cell-login {
  font-weight: 600;
}

.cell-number {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-secondary {
  color: var(--text-secondary);
}

/* Статус (ТЗ §21) */
.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 13px;
}

.status--active {
  color: var(--success);
}

.status--error {
  color: var(--text-secondary);
}

.status__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex: none;
}

/* Кнопка удаления (ТЗ §22) */
.row-delete {
  border: none;
  background: none;
  padding: 4px;
  font-size: 20px;
  line-height: 1;
  color: var(--icon-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition);
}

.table tbody tr:hover .row-delete,
.row-delete:focus-visible {
  opacity: 1;
}

.row-delete:hover {
  color: var(--text);
}

.table-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-secondary);
}

/* ---------- Модальное окно «Добавить аккаунт» ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .32);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-block);
  width: min(420px, 100%);
  padding: 26px 28px;
}

.modal__title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 18px;
}

.modal .field-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 6px;
}

.modal .input {
  width: 100%;
}

.modal__label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 5px;
}

.modal__hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 5px 0 0;
}

.modal__error {
  min-height: 18px;
  font-size: 13px;
  color: var(--text-secondary);
  margin: 8px 0 10px;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

[hidden] {
  display: none !important;
}

/* ---------- Страница входа (ТЗ §29) ---------- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-card);
  width: min(380px, 100%);
  padding: 34px 32px;
}

.login-card__title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
}

.login-card__subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 22px;
}

.login-card .input {
  width: 100%;
  margin-bottom: 14px;
}

.login-card .button--primary {
  width: 100%;
}

.login-card__error {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 12px 0 0;
  text-align: center;
}

/* ---------- Адаптивность (ТЗ §25) ---------- */

@media (max-width: 850px) {
  .container {
    width: calc(100% - 24px);
    padding-top: 24px;
    padding-bottom: 32px;
  }

  .page-title {
    font-size: 32px;
  }

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

  .toolbar .button--primary {
    margin-left: 0;
  }

  .input--search {
    width: 100%;
  }

  .toolbar .field,
  .toolbar .button {
    flex: 1 1 auto;
  }

  .filters {
    display: flex;
  }

  .filters__button {
    flex: 1;
  }
}
