/* ===== Токены ===== */
:root {
  color-scheme: light;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;

  --text: #050038;
  --text-2: #5c5a7a;
  --text-3: #8f8da8;
  --line: #e7e6ef;
  --line-2: #d6d5e2;
  --bg: #ffffff;
  --bg-soft: #f6f6f9;
  --bg-muted: #eeeef3;
  --hover: rgba(5, 0, 56, 0.06);
  --press: rgba(5, 0, 56, 0.1);

  --blue: #4262ff;
  --blue-600: #3651e6;
  --blue-700: #2a43c8;
  --blue-50: #eef1ff;
  --blue-100: #dfe4ff;
  --red: #e5484d;
  --red-600: #cd2b31;
  --red-50: #fdeded;
  --green: #18a058;
  --yellow: #ffc53d;

  --canvas-bg: #f7f7f9;
  --grid-dot: #d3d3dc;

  --shadow-sm: 0 1px 2px rgba(5, 0, 56, 0.08);
  --shadow: 0 0 0 1px rgba(5, 0, 56, 0.05), 0 2px 8px rgba(5, 0, 56, 0.12);
  --shadow-lg: 0 0 0 1px rgba(5, 0, 56, 0.05), 0 12px 32px rgba(5, 0, 56, 0.18);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
}

/* ===== Сброс ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}
button:disabled {
  cursor: default;
}
a {
  color: var(--blue);
  text-decoration: none;
}
h1,
h2,
h3,
p {
  margin: 0;
}
[hidden] {
  display: none !important;
}
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.icon {
  flex: none;
  display: block;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.muted {
  color: var(--text-2);
}

/* ===== Логотип ===== */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 32px;
  height: 32px;
  flex: none;
  display: block;
}

/* ===== Кнопки ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius);
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.12s, box-shadow 0.12s, color 0.12s;
}
.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}
.btn-lg {
  height: 48px;
  font-size: 15px;
}
.btn-block {
  width: 100%;
}
.btn-primary {
  background: var(--blue);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--blue-600);
}
.btn-primary:active:not(:disabled) {
  background: var(--blue-700);
}
.btn-secondary {
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-soft);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--hover);
}
.btn-danger {
  background: var(--red);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background: var(--red-600);
}
.btn:disabled {
  opacity: 0.55;
}
.btn.is-loading {
  color: transparent !important;
  position: relative;
  pointer-events: none;
}
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
.btn-secondary.is-loading::after {
  border-color: var(--line-2);
  border-top-color: var(--blue);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: background-color 0.12s;
}
.icon-btn:hover:not(:disabled),
.icon-btn.is-open {
  background: var(--hover);
}
.icon-btn:disabled {
  color: var(--text-3);
}

.link-btn {
  color: var(--blue);
  font-weight: 600;
}
.link-btn:hover {
  text-decoration: underline;
}
.link-btn:disabled {
  color: var(--text-3);
  text-decoration: none;
}

/* ===== Поля ввода ===== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.input {
  height: 44px;
  width: 100%;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: #fff;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input::placeholder {
  color: var(--text-3);
}
.input:hover {
  border-color: #b9b7cc;
}
.input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-100);
}
.input.has-error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-50);
}
.form-error {
  color: var(--red-600);
  font-size: 13px;
}

/* ===== Аватар ===== */
.avatar {
  --size: 32px;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  color: #fff;
  font-weight: 600;
  font-size: calc(var(--size) * 0.4);
  line-height: 1;
  user-select: none;
}

/* ===== Модальные окна ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5, 0, 56, 0.32);
  opacity: 0;
  transition: opacity 0.18s;
}
.modal-backdrop.open {
  opacity: 1;
}
.modal {
  max-width: 100%;
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.18s;
}
.modal-backdrop.open .modal {
  transform: none;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 0 24px;
}
.modal-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.modal-body {
  padding: 16px 24px 24px;
  overflow: auto;
}
.modal-text {
  color: var(--text-2);
  font-size: 15px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 24px 24px;
}

/* ===== Меню ===== */
.menu {
  position: fixed;
  z-index: 200;
  min-width: 220px;
  padding: 6px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.12s ease-out;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  text-align: left;
  white-space: nowrap;
}
.menu-item:hover:not(:disabled) {
  background: var(--hover);
}
.menu-item:disabled {
  color: var(--text-3);
}
.menu-item.danger {
  color: var(--red-600);
}
.menu-item.checked::after {
  content: '✓';
  margin-left: auto;
  padding-left: 16px;
  color: var(--blue);
  font-weight: 700;
}
.menu-divider {
  height: 1px;
  margin: 6px 4px;
  background: var(--line);
}
.menu-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 10px;
}
.menu-header-text {
  min-width: 0;
}
.menu-header-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-header-email {
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Подсказки ===== */
.tooltip {
  position: fixed;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
}
.tooltip.show {
  opacity: 1;
}
.tooltip kbd {
  font-family: inherit;
  font-size: 11px;
  color: #b8b6d1;
}

/* ===== Уведомления ===== */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  max-width: min(90vw, 420px);
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: #fff;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show {
  opacity: 1;
  transform: none;
}
.toast-error {
  background: var(--red-600);
}
.toast-success::before {
  content: '✓  ';
  color: #7ee2a8;
}

/* ===== Разное ===== */
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}
