.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn--icon-label {
  padding: 8px 12px;
  gap: 6px;
}

.btn--icon-label svg {
  width: 16px;
  height: 16px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--compact {
  padding: 7px 12px;
  font-size: 0.8rem;
  gap: 6px;
}

.btn--compact svg {
  width: 16px;
  height: 16px;
}

.btn--icon-only {
  width: 32px;
  height: 32px;
  padding: 0;
}

.btn--icon-only svg {
  width: 16px;
  height: 16px;
}

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

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

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn--danger {
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.35);
}

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

.btn--warning {
  background: transparent;
  color: var(--warning);
  border: 1px solid rgba(217, 119, 6, 0.35);
}

.btn--warning:hover {
  background: rgba(217, 119, 6, 0.1);
  color: var(--warning);
}

.btn--icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}

.btn--icon:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

.icon-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.user-chip__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-chip__name {
  font-size: 0.82rem;
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .user-chip__name {
    display: none;
  }
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

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

.field span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  transition: border-color var(--transition), box-shadow var(--transition);
}

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

.search-field {
  position: relative;
  flex: 1 1 200px;
  min-width: 0;
  max-width: none;
}

.search-field svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  padding: 10px 12px 10px 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

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

.toast {
  display: none;
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  bottom: auto;
  left: 50%;
  z-index: 100;
  max-width: min(90vw, 360px);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: var(--text-primary);
  color: var(--bg-elevated);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  transform: translateX(-50%);
}

.toast.is-visible {
  display: block;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(2, 6, 23, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: min(90dvh, calc(100dvh - env(safe-area-inset-top, 0px) - 12px));
  background: var(--bg-elevated);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.modal-overlay.is-open .modal {
  transform: translateY(0);
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
    padding: 24px;
  }

  .modal {
    border-radius: var(--radius-xl);
    max-height: 85vh;
    transform: scale(0.96);
    opacity: 0;
  }

  .modal-overlay.is-open .modal {
    transform: scale(1);
    opacity: 1;
  }

  .modal--server {
    max-width: min(640px, 100%);
    max-height: min(85vh, 720px);
  }
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 0;
}

.modal__title {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal__subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.modal__body {
  flex: 1;
  min-height: 0;
  padding: 16px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.modal__footer--detail {
  justify-content: stretch;
}

.modal__form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  width: 100%;
}

.modal__footer--detail .detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

.modal__footer--detail .detail-actions .btn {
  flex: 1 1 auto;
  min-width: min(140px, 100%);
}

body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid .field--full {
  grid-column: 1 / -1;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill--success {
  background: rgba(5, 150, 105, 0.12);
  color: var(--success);
}

.pill--muted {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.link-btn {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  padding: 4px 0;
}

.link-btn:hover {
  text-decoration: underline;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  opacity: 0.4;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
