/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s var(--ease), border-color 0.12s var(--ease),
    color 0.12s var(--ease), opacity 0.12s var(--ease);
  user-select: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  background: var(--accent-active);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

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

.btn-ghost:hover {
  background: var(--surface-active);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  height: 26px;
  padding: 0 9px;
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

/* A minimal, low-emphasis action rendered as text rather than a boxed
   button -- e.g. "Отвязать" next to a settings row. Overrides .btn-sm's
   fixed box so it reads as a link, not another button. */
.btn-link {
  height: auto;
  padding: 3px 6px;
  background: transparent;
  color: var(--accent);
  font-weight: 500;
}
.btn-link:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.btn-icon {
  width: 30px;
  padding: 0;
  flex: none;
}

.btn-block {
  width: 100%;
}

/* Inputs */

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

.field-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.input,
.textarea {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 8px 11px;
  font-size: var(--text-sm);
  color: var(--text);
  transition: border-color 0.12s var(--ease), box-shadow 0.12s var(--ease);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-tertiary);
}

.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.textarea {
  resize: none;
  font-family: inherit;
}

.field-error {
  font-size: var(--text-xs);
  color: var(--danger);
  min-height: 1em;
}

/* Badge / pill */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge-neutral {
  background: var(--neutral-soft);
  color: var(--text-secondary);
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--text-on-accent-soft);
}

/* Avatar */

.avatar {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--text-on-accent-soft);
  font-weight: 600;
  letter-spacing: 0.01em;
  overflow: hidden;
}

.avatar-sizes {
  width: var(--avatar-size, 36px);
  height: var(--avatar-size, 36px);
  font-size: calc(var(--avatar-size, 36px) * 0.4);
}

.avatar-palette-0 { background: #eef1fd; color: #3d55c9; }
.avatar-palette-1 { background: #eafaf1; color: #1c8a52; }
.avatar-palette-2 { background: #fdf1e7; color: #b4671f; }
.avatar-palette-3 { background: #fdecec; color: #c2464a; }
.avatar-palette-4 { background: #f1edfb; color: #6d4fc4; }
.avatar-palette-5 { background: #e8f6f8; color: #1c8296; }

/* Modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 23, 33, 0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fade-in 0.14s var(--ease);
}

.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  position: relative;
  animation: modal-in 0.16s var(--ease);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: 4px;
}

.modal-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 18px;
}

/* Toasts */

#toast-root {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  align-items: center;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1f2230;
  color: #fff;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-md);
  animation: toast-in 0.18s var(--ease);
}

.toast-danger {
  background: #4a2323;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Empty / loading states */

.state-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 24px;
  color: var(--text-tertiary);
  text-align: center;
  flex: 1;
}

.state-pane-icon {
  width: 40px;
  height: 40px;
  color: var(--text-tertiary);
  opacity: 0.7;
}

.state-pane-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.state-pane-hint {
  font-size: var(--text-xs);
  max-width: 260px;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
  flex: none;
}

.spinner-lg {
  width: 26px;
  height: 26px;
  border-width: 3px;
}

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

.banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.banner-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.banner-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  display: inline-block;
}

/* Confirm-in-place */

.confirm-swap {
  display: inline-flex;
  gap: 6px;
}

/* Skeleton */

.skeleton {
  background: linear-gradient(90deg, var(--neutral-soft) 25%, #e6e8ee 37%, var(--neutral-soft) 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* Dropdown menu */

.menu {
  position: absolute;
  min-width: 168px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 60;
  animation: modal-in 0.12s var(--ease);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  font-size: var(--text-sm);
  color: var(--text);
  cursor: pointer;
}

.menu-item:hover {
  background: var(--surface-hover);
}

.menu-item-danger {
  color: var(--danger);
}

.menu-separator {
  height: 1px;
  background: var(--border);
  margin: 5px 3px;
}

/* Toggle switch */

.switch {
  position: relative;
  display: inline-flex;
  width: 40px;
  height: 24px;
  flex: none;
  cursor: pointer;
  vertical-align: middle;
}

.switch-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  transition: background-color 0.18s var(--ease);
  pointer-events: none;
}

.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(20, 24, 38, 0.25);
  transition: transform 0.18s var(--ease);
  pointer-events: none;
}

.switch-input:checked ~ .switch-track {
  background: var(--success);
}

.switch-input:checked ~ .switch-knob {
  transform: translateX(16px);
}

.switch-input:focus-visible ~ .switch-track {
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.switch-input:disabled {
  cursor: default;
}

.switch-input:disabled ~ .switch-track {
  opacity: 0.5;
}

/* Brand / provider logos (self-contained SVG marks) */

.logo {
  display: block;
  flex: none;
}
